mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
#51 preg_match()를 substr_compare() 또는 strncmp()로 대체
This commit is contained in:
parent
681a9b2d07
commit
63e0fd6f3b
20 changed files with 68 additions and 61 deletions
|
|
@ -2256,11 +2256,11 @@ class Context
|
|||
{
|
||||
$filename = substr($filename, 2);
|
||||
}
|
||||
if(preg_match('/\.js$/i', $filename))
|
||||
if(substr_compare($filename, '.js', -3) === 0)
|
||||
{
|
||||
$self->loadFile(array($plugin_path . $filename, 'body', '', 0), TRUE);
|
||||
}
|
||||
elseif(preg_match('/\.css$/i', $filename))
|
||||
if(substr_compare($filename, '.css', -4) === 0)
|
||||
{
|
||||
$self->loadFile(array($plugin_path . $filename, 'all', '', 0), TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -859,7 +859,7 @@ class ModuleHandler extends Handler
|
|||
{
|
||||
if($val->type == 'image')
|
||||
{
|
||||
if(preg_match('/^\.\/files\/attach\/images\/(.+)/i', $val->value))
|
||||
if(strncmp('./files/attach/images/', $val->value, 22) === 0)
|
||||
{
|
||||
$val->value = Context::getRequestUri() . substr($val->value, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,10 +113,11 @@ class Security
|
|||
{
|
||||
if(is_string($var))
|
||||
{
|
||||
if(!preg_match('/^\$user_lang->/', $var))
|
||||
if(strncmp('$user_lang->', $var, 12) !== 0)
|
||||
{
|
||||
$var = htmlspecialchars($var, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ class documentItem extends Object
|
|||
$url = trim($this->get('homepage'));
|
||||
if(!$url) return;
|
||||
|
||||
if(!preg_match("/^http:\/\//i",$url)) $url = "http://".$url;
|
||||
if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ class emoticon extends EditorHandler
|
|||
{
|
||||
$attr_output[] = "alt=\"".$alt."\"";
|
||||
}
|
||||
if(preg_match("/\.png$/i",$src)) $attr_output[] = "class=\"iePngFix\"";
|
||||
|
||||
$code = sprintf("<img %s style=\"border:0px\" />", implode(" ",$attr_output));
|
||||
|
||||
|
|
|
|||
|
|
@ -85,9 +85,6 @@ class image_link extends EditorHandler
|
|||
$style .= ' margin:'.$margin.'px;';
|
||||
}
|
||||
if($align) $attr_output[] = "align=\"".$align."\"";
|
||||
|
||||
if(preg_match("/\.png$/i",$src)) $attr_output[] = "class=\"iePngFix\"";
|
||||
|
||||
if($width) $attr_output[] = 'width="'.$width.'"';
|
||||
if($height) $attr_output[] = 'height="'.$height.'"';
|
||||
if($border)
|
||||
|
|
|
|||
|
|
@ -159,16 +159,23 @@ class editorController extends editor
|
|||
$content_style = $editor_config->content_style;
|
||||
if($content_style)
|
||||
{
|
||||
$path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/';
|
||||
if(is_dir($path) && file_exists($path.'style.ini'))
|
||||
$path = _XE_PATH_ . 'modules/editor/styles/'.$content_style.'/';
|
||||
if(is_dir($path) && file_exists($path . 'style.ini'))
|
||||
{
|
||||
$ini = file($path.'style.ini');
|
||||
for($i=0,$c=count($ini);$i<$c;$i++)
|
||||
for($i = 0, $c = count($ini); $i < $c; $i++)
|
||||
{
|
||||
$file = trim($ini[$i]);
|
||||
if(!$file) continue;
|
||||
if(preg_match('/\.css$/i',$file)) Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
elseif(preg_match('/\.js/i',$file)) Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
|
||||
if(substr_compare($file, '.css', -4) === 0)
|
||||
{
|
||||
Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
}
|
||||
elseif(substr_compare($file, '.js', -3) === 0)
|
||||
{
|
||||
Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class extract
|
|||
FileHandler::removeFile($this->cache_index_file);
|
||||
$this->index_fd = fopen($this->cache_index_file,"a");
|
||||
// If local file
|
||||
if(!preg_match('/^http:/i',$this->filename))
|
||||
if(strncasecmp('http://', $this->filename, 7) !== 0)
|
||||
{
|
||||
if(!file_exists($this->filename)) return new Object(-1,'msg_no_xml_file');
|
||||
$this->fd = fopen($this->filename,"r");
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class importerAdminController extends importer
|
|||
$filename = Context::get('filename');
|
||||
$isExists = 'false';
|
||||
|
||||
if(preg_match('/^http/i', $filename))
|
||||
if(strncasecmp('http://', $filename, 7) === 0)
|
||||
{
|
||||
if(ini_get('allow_url_fopen'))
|
||||
{
|
||||
|
|
@ -397,8 +397,7 @@ class importerAdminController extends importer
|
|||
}
|
||||
}
|
||||
// Create url for homepage and blog
|
||||
if($obj->homepage && !preg_match("/^http:\/\//i",$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage;
|
||||
if($obj->blog && !preg_match("/^http:\/\//i",$obj->blog)) $obj->blog = 'http://'.$obj->blog;
|
||||
if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
|
||||
// email address column
|
||||
$obj->email_address = $obj->email;
|
||||
list($obj->email_id, $obj->email_host) = explode('@', $obj->email);
|
||||
|
|
@ -736,7 +735,7 @@ class importerAdminController extends importer
|
|||
$obj->user_id = base64_decode($xmlDoc->post->user_id->body);
|
||||
$obj->email_address = base64_decode($xmlDoc->post->email->body);
|
||||
$obj->homepage = base64_decode($xmlDoc->post->homepage->body);
|
||||
if($obj->homepage && !preg_match('/^http:\/\//i',$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage;
|
||||
if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
|
||||
$obj->tags = base64_decode($xmlDoc->post->tags->body);
|
||||
$obj->regdate = base64_decode($xmlDoc->post->regdate->body);
|
||||
$obj->last_update = base64_decode($xmlDoc->post->update->body);
|
||||
|
|
@ -1084,8 +1083,15 @@ class importerAdminController extends importer
|
|||
// Create a directory
|
||||
if(!FileHandler::makeDir($path)) continue;
|
||||
|
||||
if(preg_match('/^\.\/files\/cache\/importer/i',$file_obj->file)) FileHandler::rename($file_obj->file, $filename);
|
||||
else @copy($file_obj->file, $filename);
|
||||
if(strncmp('./files/cache/importer/', $file_obj->file, 23) === 0)
|
||||
{
|
||||
FileHandler::rename($file_obj->file, $filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy($file_obj->file, $filename);
|
||||
}
|
||||
|
||||
// Insert the file to the DB
|
||||
unset($file_obj->file);
|
||||
if(file_exists($filename))
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class installAdminController extends install
|
|||
}
|
||||
|
||||
$default_url = Context::get('default_url');
|
||||
if($default_url && !preg_match('/^(http|https):\/\//i', $default_url)) $default_url = 'http://'.$default_url;
|
||||
if($default_url && strncasecmp('http://', $default_url, 7) !== 0 && strncasecmp('https://', $default_url, 8) !== 0) $default_url = 'http://'.$default_url;
|
||||
|
||||
$use_ssl = Context::get('use_ssl');
|
||||
if(!$use_ssl) $use_ssl = 'none';
|
||||
|
|
|
|||
|
|
@ -676,13 +676,14 @@ class installController extends install
|
|||
|
||||
$header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body);
|
||||
$fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5);
|
||||
|
||||
if($fp)
|
||||
{
|
||||
fputs($fp, $header);
|
||||
while(!feof($fp))
|
||||
{
|
||||
$line = trim(fgets($fp, 4096));
|
||||
if(preg_match("/^<error>/i",$line))
|
||||
if(strncmp('<error>', $line, 7) === 0)
|
||||
{
|
||||
fclose($fp);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -697,7 +697,7 @@ class layoutAdminController extends layout
|
|||
if(!Context::isUploaded()) exit();
|
||||
$file = Context::get('file');
|
||||
if(!is_uploaded_file($file['tmp_name']) || !checkUploadedFile($file['tmp_name'])) exit();
|
||||
if(!preg_match('/\.(tar)$/i', $file['name'])) exit();
|
||||
if(substr_compare($file['name'], '.tar', -4) !== 0) exit();
|
||||
|
||||
$layout_srl = Context::get('layout_srl');
|
||||
if(!$layout_srl) exit();
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class layoutView extends layout
|
|||
{
|
||||
if($val->type == 'image')
|
||||
{
|
||||
if(preg_match('/^\.\/files\/attach\/images\/(.+)/i', $val->value))
|
||||
if(strncmp('./files/attach/images/', $val->value, 22) === 0)
|
||||
{
|
||||
$val->value = Context::getRequestUri() . substr($val->value, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1761,11 +1761,9 @@ class menuAdminController extends menu
|
|||
|
||||
if($normal_btn)
|
||||
{
|
||||
if(preg_match('/\.png$/',$normal_btn)) $classname = 'class="iePngFix"';
|
||||
else $classname = '';
|
||||
if($hover_btn) $hover_str = sprintf('onmouseover="this.src=\'%s\'"', $hover_btn); else $hover_str = '';
|
||||
if($active_btn) $active_str = sprintf('onmousedown="this.src=\'%s\'"', $active_btn); else $active_str = '';
|
||||
$link = sprintf('<img src="%s" onmouseout="this.src=\'%s\'" alt="<?php print htmlspecialchars($_names[$lang_type], ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" %s %s %s />', $normal_btn, $normal_btn, $hover_str, $active_str, $classname);
|
||||
$link = sprintf('<img src="%s" onmouseout="this.src=\'%s\'" alt="<?php print htmlspecialchars($_names[$lang_type], ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" %s %s />', $normal_btn, $normal_btn, $hover_str, $active_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1880,12 +1878,10 @@ class menuAdminController extends menu
|
|||
|
||||
if($normal_btn)
|
||||
{
|
||||
if(preg_match('/\.png$/',$normal_btn)) $classname = 'class=\"iePngFix\"';
|
||||
else $classname = '';
|
||||
if($hover_btn) $hover_str = sprintf('onmouseover=\"this.src=\'%s\'\"', $hover_btn); else $hover_str = '';
|
||||
if($active_btn) $active_str = sprintf('onmousedown=\"this.src=\'%s\'\"', $active_btn); else $active_str = '';
|
||||
$link = sprintf('"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s %s %s />"', $normal_btn, $normal_btn, $node->menu_item_srl, $hover_str, $active_str, $classname);
|
||||
if($active_btn) $link_active = sprintf('"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s %s />"', $active_btn, $active_btn, $node->menu_item_srl, $hover_str, $classname);
|
||||
$link = sprintf('"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s %s />"', $normal_btn, $normal_btn, $node->menu_item_srl, $hover_str, $active_str);
|
||||
if($active_btn) $link_active = sprintf('"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s />"', $active_btn, $active_btn, $node->menu_item_srl, $hover_str);
|
||||
else $link_active = $link;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class messageMobile extends messageView
|
|||
$ssl_mode = false;
|
||||
if($member_config->enable_ssl == 'Y')
|
||||
{
|
||||
if(preg_match('/^https:\/\//i',Context::getRequestUri())) $ssl_mode = true;
|
||||
if(strncasecmp('https://', Context::getRequestUri(), 8) === 0) $ssl_mode = true;
|
||||
}
|
||||
Context::set('ssl_mode',$ssl_mode);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class messageView extends message
|
|||
$ssl_mode = false;
|
||||
if($member_config->enable_ssl == 'Y')
|
||||
{
|
||||
if(preg_match('/^https:\/\//i',Context::getRequestUri())) $ssl_mode = true;
|
||||
if(strncasecmp('https://', Context::getRequestUri(), 8) === 0) $ssl_mode = true;
|
||||
}
|
||||
Context::set('ssl_mode',$ssl_mode);
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ class moduleController extends module
|
|||
}
|
||||
|
||||
$args->site_srl = getNextSequence();
|
||||
$args->domain = preg_replace('/\/$/','',$domain);
|
||||
$args->domain = (substr_compare($domain, '/', -1) === 0) ? substr($domain, 0, -1) : $domain;
|
||||
$args->index_module_srl = $index_module_srl;
|
||||
$args->default_language = Context::getLangType();
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ class moduleController extends module
|
|||
|
||||
if($args->domain && !isSiteID($args->domain))
|
||||
{
|
||||
$args->domain = preg_replace('/\/$/','',$args->domain);
|
||||
$args->domain = (substr_compare($domain, '/', -1) === 0) ? substr($domain, 0, -1) : $domain;
|
||||
}
|
||||
}
|
||||
$output = executeQuery('module.updateSite', $args);
|
||||
|
|
|
|||
|
|
@ -81,8 +81,12 @@ class moduleModel extends module
|
|||
*/
|
||||
function getDefaultMid()
|
||||
{
|
||||
$default_url = preg_replace('/\/$/','',Context::getDefaultUrl());
|
||||
$request_url = preg_replace('/\/$/','',Context::getRequestUri());
|
||||
$default_url = Context::getDefaultUrl();
|
||||
if(substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1);
|
||||
|
||||
$request_url = Context::getRequestUri();
|
||||
if(substr_compare($request_url, '/', -1) === 0) $request_url = substr($request_url, 0, -1);
|
||||
|
||||
$default_url_parse = parse_url($default_url);
|
||||
$request_url_parse = parse_url($request_url);
|
||||
$vid = Context::get('vid');
|
||||
|
|
@ -95,7 +99,9 @@ class moduleModel extends module
|
|||
{
|
||||
$url_info = parse_url($request_url);
|
||||
$hostname = $url_info['host'];
|
||||
$path = preg_replace('/\/$/','',$url_info['path']);
|
||||
$path = $url_info['path'];
|
||||
if(substr_compare($path, '/', -1) === 0) $path = substr($path, 0, -1);
|
||||
|
||||
$domain = sprintf('%s%s%s', $hostname, $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$path);
|
||||
}
|
||||
// xe.com/blog
|
||||
|
|
|
|||
|
|
@ -607,20 +607,17 @@ class content extends WidgetHandler
|
|||
$content_item->setTitle($item->title);
|
||||
$content_item->setNickName(max($item->author,$item->{'dc:creator'}));
|
||||
$content_item->setAuthorSite($value->author->uri->body);
|
||||
|
||||
//$content_item->setCategory($item->category);
|
||||
$item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->content);
|
||||
if($item->description)
|
||||
$item->description = ($item->content) ? $item->content : $item->description = $item->summary;
|
||||
$item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->description);
|
||||
|
||||
if(($item->content && stripos($value->content->attrs->type, "html") === FALSE) || (!$item->content && stripos($value->summary->attrs->type, "html") === FALSE))
|
||||
{
|
||||
if(!preg_match("/html/i", $value->content->attrs->type)) $item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
}
|
||||
if(!$item->description)
|
||||
{
|
||||
$item->description = $item->summary;
|
||||
if($item->description)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->summary->attrs->type)) $item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
}
|
||||
$item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
|
||||
}
|
||||
|
||||
$content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
|
||||
$content_item->setThumbnail($this->_getRssThumbnail($item->description));
|
||||
$content_item->setLink($item->link);
|
||||
|
|
|
|||
|
|
@ -553,20 +553,17 @@ class mcontent extends WidgetHandler
|
|||
$content_item->setTitle($item->title);
|
||||
$content_item->setNickName(max($item->author,$item->{'dc:creator'}));
|
||||
$content_item->setAuthorSite($value->author->uri->body);
|
||||
|
||||
//$content_item->setCategory($item->category);
|
||||
$item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->content);
|
||||
if($item->description)
|
||||
$item->description = ($item->content) ? $item->content : $item->description = $item->summary;
|
||||
$item->description = preg_replace('!<a href=!is','<a onclick="window.open(this.href);return false" href=', $item->description);
|
||||
|
||||
if(($item->content && stripos($value->content->attrs->type, "html") === FALSE) || (!$item->content && stripos($value->summary->attrs->type, "html") === FALSE))
|
||||
{
|
||||
if(!preg_match("/html/i", $value->content->attrs->type)) $item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
}
|
||||
if(!$item->description)
|
||||
{
|
||||
$item->description = $item->summary;
|
||||
if($item->description)
|
||||
{
|
||||
if(!preg_match("/html/i", $value->summary->attrs->type)) $item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
}
|
||||
$item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
|
||||
}
|
||||
|
||||
$content_item->setContent($this->_getSummary($item->description, $args->content_cut_size));
|
||||
$content_item->setLink($item->link);
|
||||
$date = date('YmdHis', strtotime(max($item->published,$item->updated,$item->{'dc:date'})));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue