From 601df26d5176328bebc76e020cb76e34428d8d06 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 20 Dec 2020 11:50:10 -0800 Subject: [PATCH] Code optimization for speed and reduced memory usage. --- class2.php | 4 +- e107_admin/admin_log.php | 2 +- e107_admin/boot.php | 2 +- e107_admin/emoticon.php | 24 +-- e107_admin/frontpage.php | 4 +- e107_admin/lancheck.php | 2 +- e107_admin/language.php | 4 +- e107_admin/newspost.php | 4 +- e107_admin/theme.php | 2 +- e107_admin/update_routines.php | 2 +- e107_core/bbcodes/bb_block.php | 6 +- e107_core/bbcodes/bb_h.php | 6 +- e107_core/bbcodes/link.bb | 2 +- e107_core/controllers/index/index.php | 2 +- .../shortcodes/batch/admin_shortcodes.php | 10 +- .../shortcodes/batch/comment_shortcodes.php | 4 +- .../shortcodes/batch/page_shortcodes.php | 4 +- .../shortcodes/batch/user_shortcodes.php | 2 +- e107_core/shortcodes/single/imageselector.php | 4 +- e107_core/shortcodes/single/nextprev.php | 2 +- e107_core/templates/header_default.php | 4 +- e107_handlers/admin_ui.php | 20 +-- e107_handlers/application.php | 14 +- e107_handlers/bbcode_handler.php | 8 +- e107_handlers/bounce_handler.php | 70 ++++---- e107_handlers/cli_class.php | 2 +- e107_handlers/comment_class.php | 6 +- e107_handlers/cron_class.php | 6 +- e107_handlers/date_handler.php | 2 +- e107_handlers/db_table_admin_class.php | 8 +- e107_handlers/db_verify_class.php | 4 +- e107_handlers/debug_handler.php | 2 +- e107_handlers/e_db_pdo_class.php | 14 +- e107_handlers/e_parse_class.php | 20 +-- e107_handlers/file_class.php | 56 +++--- e107_handlers/form_handler.php | 107 ++++++------ e107_handlers/iphandler_class.php | 12 +- e107_handlers/js_manager.php | 6 +- e107_handlers/jslib_handler.php | 2 +- e107_handlers/language_class.php | 2 +- e107_handlers/magpie_rss.php | 4 +- e107_handlers/mail_validation_class.php | 8 +- e107_handlers/media_class.php | 2 +- e107_handlers/menu_class.php | 4 +- e107_handlers/menumanager_class.php | 32 ++-- e107_handlers/message_handler.php | 2 +- e107_handlers/mysql_class.php | 10 +- e107_handlers/pcltar.lib.php | 14 +- e107_handlers/pcltrace.lib.php | 2 +- e107_handlers/pclzip.lib.php | 20 +-- e107_handlers/plugin_class.php | 16 +- e107_handlers/rate_class.php | 2 +- e107_handlers/search_class.php | 2 +- e107_handlers/shortcode_handler.php | 5 +- e107_handlers/sitelinks_class.php | 16 +- e107_handlers/theme_handler.php | 18 +- e107_handlers/upload_handler.php | 2 +- e107_handlers/user_handler.php | 4 +- e107_handlers/user_model.php | 6 +- e107_handlers/validator_class.php | 6 +- e107_plugins/blogcalendar_menu/archive.php | 2 +- .../blogcalendar_menu/blogcalendar_menu.php | 4 +- e107_plugins/chatbox_menu/chat.php | 2 +- e107_plugins/download/download_shortcodes.php | 2 +- e107_plugins/download/includes/admin.php | 2 +- e107_plugins/download/request.php | 8 +- e107_plugins/forum/forum_post.php | 2 +- e107_plugins/import/admin_import.php | 2 +- e107_plugins/list_new/list_admin_class.php | 20 +-- e107_plugins/list_new/list_class.php | 6 +- e107_plugins/log/admin_config.php | 2 +- e107_plugins/log/consolidate.php | 2 +- e107_plugins/log/log.php | 6 +- e107_plugins/log/loginfo.php | 6 +- e107_plugins/log/stats.php | 28 +-- e107_plugins/news/news.php | 4 +- e107_plugins/news/news_months_menu.php | 2 +- e107_plugins/online/online_shortcodes.php | 8 +- e107_plugins/pm/pm_class.php | 2 +- e107_plugins/poll/poll_class.php | 8 +- e107_plugins/rss_menu/rss.php | 6 +- e107_plugins/search_menu/search_menu.php | 20 +-- e107_plugins/siteinfo/e_shortcode.php | 2 +- e107_plugins/siteinfo/sitebutton_menu.php | 2 +- e107_plugins/tinymce4/wysiwyg.php | 2 +- e107_plugins/trackback/trackbackClass.php | 4 +- e107_plugins/user/e_dashboard.php | 2 +- e107_tests/composer.lock | 160 +++++++++--------- e107_tests/tests/unit/e_fileTest.php | 26 ++- e107_tests/tests/unit/e_formTest.php | 14 +- online.php | 16 +- 91 files changed, 522 insertions(+), 482 deletions(-) diff --git a/class2.php b/class2.php index 29e162be9..76020d1a6 100755 --- a/class2.php +++ b/class2.php @@ -2636,11 +2636,11 @@ class error_handler "; $text .= !empty($val['class']) ? $val['class']."->" : ''; $text .= !empty($val['include_filename']) ? "include: ". str_replace($this->docroot,'', $val['include_filename']) : ''; - $text .= !empty($val['function']) ? $val['function']."(" : ""; + $text .= !empty($val['function']) ? htmlentities($val['function'])."(" : ""; $text .= !empty($val['params']) ? print_r($val['params'],true) : ''; $text .= !empty($val['function']) ? ")" : ""; $text .=" - "; + "; $text .= str_replace($this->docroot,'', $val['file']).":".$val['line']; $text .= " "; diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index 5e1cb2d61..ce9d51499 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -639,7 +639,7 @@ class admin_log_form_ui extends e_admin_form_ui $text = str_replace("
","\n",$text); $text = str_replace("\","/",$text); - if(substr($text,0,2) == '\n') // cleanup (not sure of the cause) + if(strpos($text,'\n') === 0) // cleanup (not sure of the cause) { $text = substr($text,2); } diff --git a/e107_admin/boot.php b/e107_admin/boot.php index 1141c8187..c00fe5a97 100644 --- a/e107_admin/boot.php +++ b/e107_admin/boot.php @@ -341,7 +341,7 @@ if (!function_exists("parse_admin")) $adtmp = explode("\n", $ADMINLAYOUT); - for ($a = 0; $a < count($adtmp); $a++) + for ($a = 0, $aMax = count($adtmp); $a < $aMax; $a++) { if (preg_match("/{.+?}/", $adtmp[$a])) { diff --git a/e107_admin/emoticon.php b/e107_admin/emoticon.php index 90fb5720c..c25097d84 100644 --- a/e107_admin/emoticon.php +++ b/e107_admin/emoticon.php @@ -61,28 +61,28 @@ $filtered = e107::getParser()->filter($_POST); // Check for pack-related buttons pressed foreach($filtered as $key => $value) { - if(strstr($key, "subPack_")) + if(strpos($key, "subPack_") !== false) { $subpack = str_replace("subPack_", "", $key); $emote->emoteConf($subpack); break; } - if(strstr($key, "XMLPack_")) + if(strpos($key, "XMLPack_") !== false) { $subpack = str_replace("XMLPack_", "", $key); $emote->emoteXML($subpack); break; } - if(strstr($key, "defPack_")) + if(strpos($key, "defPack_") !== false) { e107::getConfig()->set('emotepack', str_replace("defPack_", "", $key))->save(true,true,true); e107::getLog()->add('EMOTE_01', $pref['emotepack'], E_LOG_INFORMATIVE, ''); break; } - if(strstr($key, "scanPack_")) + if(strpos($key, "scanPack_") !== false) { $one_pack = str_replace("scanPack_", "", $key); break; @@ -203,9 +203,9 @@ class emotec foreach($emoteArray as $emote) { - if (strstr($emote['fname'], ".pak") - || strstr($emote['fname'], ".xml") - || strstr($emote['fname'], "phpBB")) + if (strpos($emote['fname'], ".pak") !== false + || strpos($emote['fname'], ".xml") !== false + || strpos($emote['fname'], "phpBB") !== false) { $can_scan = TRUE; // Allow re-scan of config files } @@ -474,15 +474,15 @@ class emotec $confFile = ''; foreach($fileArray as $k => $file) { - if(strstr($file['fname'], ".xml")) + if(strpos($file['fname'], ".xml") !== false) { $confFile = array('file' => $file['fname'], 'type' => "xml"); } - else if(strstr($file['fname'], ".pak")) + else if(strpos($file['fname'], ".pak") !== false) { $confFile = array('file' => $file['fname'], 'type' => "pak"); } - else if(strstr($file['fname'], ".php")) + else if(strpos($file['fname'], ".php") !== false) { $confFile = array('file' => $file['fname'], 'type' => "php"); } @@ -501,7 +501,7 @@ class emotec $contentArray = array(); foreach($pakconf as $line) { - if(trim($line) && strstr($line, "=+") && !strstr($line, ".txt") && !strstr($line, ".html") && !strstr($line, "cvs")) $contentArray[] = $line; + if(trim($line) && strpos($line, "=+") !== false && strpos($line, ".txt") === false && strpos($line, ".html") === false && strpos($line, "cvs") === false) $contentArray[] = $line; } $confArray = array(); foreach($contentArray as $pakline) @@ -554,7 +554,7 @@ class emotec if ($xml_type) { - for($a=0; $a < count($match[0]); $a++) + for($a=0, $aMax = count($match[0]); $a < $aMax; $a++) { $e_file = ''; switch ($xml_type) diff --git a/e107_admin/frontpage.php b/e107_admin/frontpage.php index 456907a5f..8d9c22ce7 100644 --- a/e107_admin/frontpage.php +++ b/e107_admin/frontpage.php @@ -254,7 +254,7 @@ if(isset($_POST['fp_save_new'])) if($temp['order'] == 0) // New index to add { $ind = 0; - for($i = 1; $i <= count($fp_settings); $i ++) + for($i = 1, $iMax = count($fp_settings); $i <= $iMax; $i ++) { if($fp_settings[$i]['class'] == $temp['class']) $ind = $i; @@ -307,7 +307,7 @@ if($fp_update_prefs) { // Save the two arrays $fp_list = array(); $fp_force = array(); - for($i = 1; $i <= count($fp_settings); $i ++) + for($i = 1, $iMax = count($fp_settings); $i <= $iMax; $i ++) { $fp_list[$fp_settings[$i]['class']] = $fp_settings[$i]['page']; $fp_force[$fp_settings[$i]['class']] = $fp_settings[$i]['force']; diff --git a/e107_admin/lancheck.php b/e107_admin/lancheck.php index 5318d3d61..05a656399 100644 --- a/e107_admin/lancheck.php +++ b/e107_admin/lancheck.php @@ -1146,7 +1146,7 @@ class lancheck $input .= $diz; $message .= str_replace("\n","
",$diz); - for ($i=0; $iisTable($table_name,$languageSelected)) ? " checked='checked'" : ""; @@ -1524,7 +1524,7 @@ class lanDeveloper asort($_SESSION['languageTools_lanFileList']); foreach($_SESSION['languageTools_lanFileList'] as $val) { - if(strstr($val,e_SYSTEM)) + if(strpos($val, e_SYSTEM) !== false) { continue; } diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index d347540cf..06da446e1 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -1502,13 +1502,13 @@ class news_form_ui extends e_admin_form_ui
'; - $val = strstr($curVal, "[img]http") ? $curVal : str_replace("[img]../", "[img]", $curVal); + $val = strpos($curVal, "[img]http") !== false ? $curVal : str_replace("[img]../", "[img]", $curVal); $text .= "
"; $text .= $frm->bbarea('news_body', $val, 'news', 'news', 'large'); $text .= "
"; $text .= "
"; - $val = (strstr($curValExt, "[img]http") ? $curValExt : str_replace("[img]../", "[img]",$curValExt)); + $val = (strpos($curValExt, "[img]http") !== false ? $curValExt : str_replace("[img]../", "[img]",$curValExt)); $text .= $frm->bbarea('news_extended', $val, 'extended', 'news','large'); $text .= "
diff --git a/e107_admin/theme.php b/e107_admin/theme.php index de8a98a30..38ed52cab 100644 --- a/e107_admin/theme.php +++ b/e107_admin/theme.php @@ -1248,7 +1248,7 @@ class theme_builder extends e_admin_ui foreach($matches[1] as $i => $m) { $leg[$m] = strip_tags($matches[3][$i]); - if(substr($m,0,5) == 'theme' || $m == "CUSTOMPAGES") + if(strpos($m,'theme') === 0 || $m == "CUSTOMPAGES") { $search[] = $matches[0][$i]; } diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 12b582fb1..85c2bad11 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -1509,7 +1509,7 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Avatar paths require updating.'); foreach($avatar_images as $av) { - $apath = (strstr($av['path'],'public/')) ? e_AVATAR_UPLOAD : e_AVATAR_DEFAULT; + $apath = (strpos($av['path'], 'public/') !== false) ? e_AVATAR_UPLOAD : e_AVATAR_DEFAULT; if(rename($av['path'].$av['fname'], $apath. $av['fname'])===false) { diff --git a/e107_core/bbcodes/bb_block.php b/e107_core/bbcodes/bb_block.php index 9775e961b..b33a1a00e 100644 --- a/e107_core/bbcodes/bb_block.php +++ b/e107_core/bbcodes/bb_block.php @@ -31,9 +31,9 @@ class bb_block extends e_bb_base $parms = eHelper::scParams($parm); $safe = array(); - if(vartrue($parms['class'])) $safe['class'] = eHelper::secureClassAttr($parms['class']); - if(vartrue($parms['id'])) $safe['id'] = eHelper::secureIdAttr($parms['id']); - if(vartrue($parms['style'])) $safe['style'] = eHelper::secureStyleAttr($parms['style']); + if(!empty($parms['class'])) $safe['class'] = eHelper::secureClassAttr($parms['class']); + if(!empty($parms['id'])) $safe['id'] = eHelper::secureIdAttr($parms['id']); + if(!empty($parms['style'])) $safe['style'] = eHelper::secureStyleAttr($parms['style']); if($safe) { return '[block='.eHelper::buildAttr($safe).']'.$code_text.'[/block]'; diff --git a/e107_core/bbcodes/bb_h.php b/e107_core/bbcodes/bb_h.php index 99fc8bf5f..f99d243cb 100644 --- a/e107_core/bbcodes/bb_h.php +++ b/e107_core/bbcodes/bb_h.php @@ -31,15 +31,15 @@ class bb_h extends e_bb_base $parms = $bparms[2]; unset($bparms); - if(vartrue($parms['class'])) + if(!empty($parms['class'])) { $safe['class'] = eHelper::secureClassAttr($parms['class']); } - if(vartrue($parms['id'])) + if(!empty($parms['id'])) { $safe['id'] = eHelper::secureIdAttr($parms['id']); } - if(vartrue($parms['style'])) + if(!empty($parms['style'])) { $safe['style'] = eHelper::secureStyleAttr($parms['style']); } diff --git a/e107_core/bbcodes/link.bb b/e107_core/bbcodes/link.bb index f1730e845..db2083103 100644 --- a/e107_core/bbcodes/link.bb +++ b/e107_core/bbcodes/link.bb @@ -37,7 +37,7 @@ global $pref; $parm = $parm." ".$extras; } - if(substr($parm,0,6) == "mailto") + if(strpos($parm, 'mailto') === 0) { list($pre,$email) = explode(":",$parm); list($p1,$p2) = explode("@",$email); diff --git a/e107_core/controllers/index/index.php b/e107_core/controllers/index/index.php index 229caa3d6..2a3f37e69 100644 --- a/e107_core/controllers/index/index.php +++ b/e107_core/controllers/index/index.php @@ -45,7 +45,7 @@ class core_index_index_controller extends eController } else { // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules - if(vartrue($pref['frontpage'])) + if(!empty($pref['frontpage'])) { foreach ($pref['frontpage'] as $fk=>$fp) { diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 83724f512..55c74ef02 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -483,7 +483,7 @@ class admin_shortcodes } - if(vartrue($pref['e_latest_list'])) + if(!empty($pref['e_latest_list'])) { foreach($pref['e_latest_list'] as $val) { @@ -948,7 +948,7 @@ class admin_shortcodes global $ns, $pref, $array_functions, $tp; $e107_var = array(); - if (strstr(e_SELF, '/admin.php')) + if (strpos(e_SELF, '/admin.php') !== false) { $active_page = 'x'; } @@ -1042,7 +1042,7 @@ class admin_shortcodes ob_start(); $text = ""; $i = 0; - if (strstr(e_SELF, '/admin.php')) + if (strpos(e_SELF, '/admin.php') !== false) { global $sql; if ($sql ->select('plugin', '*', 'plugin_installflag=1')) @@ -1317,7 +1317,7 @@ class admin_shortcodes - if(vartrue($pref['e_status_list'])) + if(!empty($pref['e_status_list'])) { foreach($pref['e_status_list'] as $val) { @@ -2082,7 +2082,7 @@ Inverse 10 10 // e107::getDebug()->log($catid); - if(vartrue($pref['admin_slidedown_subs']) && vartrue($array_sub_functions[$key])) + if(!empty($pref['admin_slidedown_subs']) && !empty($array_sub_functions[$key])) { $tmp['sub_class'] = 'sub'; foreach ($array_sub_functions[$key] as $subkey => $subsubitem) diff --git a/e107_core/shortcodes/batch/comment_shortcodes.php b/e107_core/shortcodes/batch/comment_shortcodes.php index 8ba49994a..94f29bca3 100644 --- a/e107_core/shortcodes/batch/comment_shortcodes.php +++ b/e107_core/shortcodes/batch/comment_shortcodes.php @@ -22,7 +22,7 @@ class comment_shortcodes extends e_shortcode $pref = e107::getPref(); $form = e107::getForm(); - if(vartrue($pref['nested_comments'])) + if(!empty($pref['nested_comments'])) { $options = array( 'class' => 'comment subject-input form-control', @@ -381,7 +381,7 @@ class comment_shortcodes extends e_shortcode { $adop_icon = (file_exists(THEME."images/commentedit.png") ? "".COMLAN_318."" : LAN_EDIT); //Searching for '.' is BAD!!! It breaks mod rewritten requests. Why is this needed at all? - if (strstr(e_QUERY, "&")) + if (strpos(e_QUERY, "&") !== false) { return "{$adop_icon}"; } diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php index 3d23854f5..5576651b9 100644 --- a/e107_core/shortcodes/batch/page_shortcodes.php +++ b/e107_core/shortcodes/batch/page_shortcodes.php @@ -59,7 +59,7 @@ class cpage_shortcodes extends e_shortcode $id = $this->var['page_chapter']; - if(vartrue($this->chapterData[$id]['chapter_id']) && $this->chapterData[$id]['chapter_parent'] > 0) + if(!empty($this->chapterData[$id]['chapter_id']) && $this->chapterData[$id]['chapter_parent'] > 0) { return $this->chapterData[$id]; } @@ -78,7 +78,7 @@ class cpage_shortcodes extends e_shortcode $row = $this->chapterData[$cid]; - if(vartrue($row['chapter_id']) && $row['chapter_parent'] < 1) + if(!empty($row['chapter_id']) && $row['chapter_parent'] < 1) { return $row; } diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index 88d8e2679..ddb4fe323 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -165,7 +165,7 @@ class user_shortcodes extends e_shortcode $pref = e107::getPref(); $ldata = e107::getRank()->getRanks($this->var['user_id']); //, (USER && $forum->isModerator(USERID))); - if(vartrue($ldata['special'])) + if(!empty($ldata['special'])) { $r = $ldata['special']; } diff --git a/e107_core/shortcodes/single/imageselector.php b/e107_core/shortcodes/single/imageselector.php index a9738c6dd..ad7aaaf66 100644 --- a/e107_core/shortcodes/single/imageselector.php +++ b/e107_core/shortcodes/single/imageselector.php @@ -8,7 +8,7 @@ function imageselector_shortcode($parm = '', $mod = '') $sql = e107::getDb('imageselector.sc'); $tp = e107::getParser(); - if (strstr($parm, "=")) + if (strpos($parm, "=") !== false) { // query style parms. parse_str($parm, $parms); extract($parms); @@ -36,7 +36,7 @@ function imageselector_shortcode($parm = '', $mod = '') if ($scaction == 'select' || $scaction == 'all') { // Media manager support - if(vartrue($parms['media'])) + if(!empty($parms['media'])) { $qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") "; $qry .= vartrue($parms['media']) && $parms['media'] !== 'all' ? " AND media_category='".$tp->toDB($parms['media'])."' " : " AND `media_category` NOT REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' "; diff --git a/e107_core/shortcodes/single/nextprev.php b/e107_core/shortcodes/single/nextprev.php index 6209b33db..7581d0c77 100644 --- a/e107_core/shortcodes/single/nextprev.php +++ b/e107_core/shortcodes/single/nextprev.php @@ -86,7 +86,7 @@ function nextprev_shortcode($parm = '') $check_render = true; - if(vartrue($parm['glyphs']) && (deftrue('BOOTSTRAP'))) + if(!empty($parm['glyphs']) && (deftrue('BOOTSTRAP'))) { if(deftrue('FONTAWESOME')) { diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index 5a92d8628..ca926d458 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -823,12 +823,12 @@ if ($e107_popup != 1) { * fix - only when e_FRONTPAGE set to true * @see core_index_index_controller/actionIndex */ - if(deftrue('e_FRONTPAGE') && strstr($HEADER,"{WMESSAGE")===false && strstr($FOOTER,"{WMESSAGE")===false) // Auto-detection to override old pref. + if(deftrue('e_FRONTPAGE') && strpos($HEADER, "{WMESSAGE") === false && strpos($FOOTER, "{WMESSAGE") === false) // Auto-detection to override old pref. { echo e107::getParser()->parseTemplate("{WMESSAGE}"); } - if(!deftrue('e_IFRAME') && (strstr($HEADER,"{ALERTS}")===false && strstr($FOOTER,"{ALERTS}")===false)) // Old theme, missing {ALERTS} + if(!deftrue('e_IFRAME') && (strpos($HEADER, "{ALERTS}") === false && strpos($FOOTER, "{ALERTS}") === false)) // Old theme, missing {ALERTS} { if(deftrue('e_DEBUG')) { diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index b67402f18..ae5aecac9 100755 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -1462,7 +1462,7 @@ class e_admin_dispatcher $this->_current_controller->setRequest($request)->init(); } - if(vartrue($this->modes[$request->getModeName()]['ui'])) + if(!empty($this->modes[$request->getModeName()]['ui'])) { $class_name = $this->modes[$request->getModeName()]['ui']; $class_path = vartrue($this->modes[$request->getModeName()]['uipath']); @@ -2402,7 +2402,7 @@ class e_admin_controller if(!$path && $this->getParam('modes')) { $modes = $this->getParam('modes'); - if(vartrue($modes[$mode]) && vartrue($modes[$mode]['url'])) + if(!empty($modes[$mode]) && !empty($modes[$mode]['url'])) { $path = e107::getParser()->replaceConstants($modes[$mode]['url'], 'abs'); } @@ -3851,7 +3851,7 @@ class e_admin_controller_ui extends e_admin_controller } */ - if(vartrue($attributes['dataPath'])) + if(!empty($attributes['dataPath'])) { $model->setData($attributes['dataPath'], $value); } @@ -4494,7 +4494,7 @@ class e_admin_controller_ui extends e_admin_controller ".vartrue($tparams['joinType'], 'LEFT JOIN')." {$tparams['__tableFrom']} ON ".(vartrue($tparams['leftTable']) ? $tparams['leftTable'].'.' : $tablePath)."`".vartrue($tparams['leftField'])."` = {$tparams['__tablePath']}`".vartrue($tparams['rightField'])."`".(vartrue($tparams['whereJoin']) ? ' '.$tparams['whereJoin'] : ''); // Prepare Where - if(vartrue($tparams['where'])) + if(!empty($tparams['where'])) { $jwhere[] = $tparams['where']; } @@ -6516,7 +6516,7 @@ class e_admin_ui extends e_admin_controller_ui $dataFields[$key] = vartrue($att['data'], 'string'); // create validation array - if(vartrue($att['validate'])) + if(!empty($att['validate'])) { $validateRules[$key] = array((true === $att['validate'] ? 'required' : $att['validate']), varset($att['rule']), $att['title'], varset($att['error'], $att['help'])); } @@ -6591,7 +6591,7 @@ class e_admin_ui extends e_admin_controller_ui { continue; } - if(vartrue($att['validate'])) + if(!empty($att['validate'])) { $this->validationRules[$key] = array((true === $att['validate'] ? 'required' : $att['validate']), varset($att['rule']), $att['title'], varset($att['error'], vartrue($att['help']))); } @@ -7698,7 +7698,7 @@ class e_admin_form_ui extends e_form unset($options['clearAll']); } - if(vartrue($opts['simple'])) + if(!empty($opts['simple'])) { foreach ($options as $value) { @@ -7720,7 +7720,7 @@ class e_admin_form_ui extends e_form else { unset($options['addAll'], $options['clearAll']); - if(vartrue($opts['simple'])) + if(!empty($opts['simple'])) { foreach($options as $k) { @@ -7768,7 +7768,7 @@ class e_admin_form_ui extends e_form if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']); $opts = $parms['__options']; - if(vartrue($opts['multiple']) && $type === 'batch') + if(!empty($opts['multiple']) && $type === 'batch') { // no batch support for multiple, should have some for filters soon continue 2; @@ -7788,7 +7788,7 @@ class e_admin_form_ui extends e_form case 'lanlist': // use the array $parm; if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']); $opts = $parms['__options']; - if(vartrue($opts['multiple'])) + if(!empty($opts['multiple'])) { // no batch support for multiple, should have some for filters soon continue 2; diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 2682bf84f..30752f2ab 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -1853,7 +1853,7 @@ class eRouter eFront::isLegacy(varset($config['legacy'])); // Don't allow single entry if required by module config - if(vartrue($config['noSingleEntry'])) + if(!empty($config['noSingleEntry'])) { $request->routed = true; if(!eFront::isLegacy()) @@ -1884,10 +1884,10 @@ class eRouter } // parse callback - if(vartrue($config['selfParse'])) + if(!empty($config['selfParse'])) { // controller/action[/additional/parms] - if(vartrue($config['urlSuffix'])) $rawPathInfo = $this->removeUrlSuffix($rawPathInfo, $config['urlSuffix']); + if(!empty($config['urlSuffix'])) $rawPathInfo = $this->removeUrlSuffix($rawPathInfo, $config['urlSuffix']); $route = $this->configCallback($module, 'parse', array($rawPathInfo, $_GET, $request, $this, $config), $config['location']); } // default module route @@ -1936,7 +1936,7 @@ class eRouter if(isset($_GET[$key]) && !$request->isRequestParam($key)) { // sanitize - $vars->$key = preg_replace('/[^\d\w\-]/', '', $_GET[$key]); + $vars->$key = preg_replace('/[^\w\-]/', '', $_GET[$key]); } } } @@ -2177,7 +2177,7 @@ class eRouter $urlSuffix = ''; // Fix base url for legacy links - if(vartrue($config['noSingleEntry'])) $base = $options['full'] ? SITEURL : e_HTTP; + if(!empty($config['noSingleEntry'])) $base = $options['full'] ? SITEURL : e_HTTP; elseif(self::FORMAT_GET !== $config['format']) { $urlSuffix = $this->urlSuffix; @@ -2185,7 +2185,7 @@ class eRouter } // Create by config callback - if(vartrue($config['selfCreate'])) + if(!empty($config['selfCreate'])) { $tmp = $this->configCallback($module, 'create', array(array($route[1], $route[2]), $params, $options), $config['location']); @@ -4768,7 +4768,7 @@ class eHelper $title = str_replace(array('/',' ',","),' ',$title); $title = str_replace(array("&","(",")"),'',$title); - $title = preg_replace('/[^\w\d\pL\s.-]/u', '', strip_tags(e107::getParser()->toHTML($title, TRUE))); + $title = preg_replace('/[^\w\pL\s.-]/u', '', strip_tags(e107::getParser()->toHTML($title, TRUE))); $title = trim(preg_replace('/[\s]+/', ' ', str_replace('_', ' ', $title))); $title = str_replace(array(' - ',' -','- ','--'),'-',$title); // cleanup to avoid --- diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index af33ee1b2..508ea7fd3 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -139,7 +139,7 @@ class e_bbcode // $matches[4] - '=' or ':' according to the separator used // $matches[5] - any parameter - $content = preg_split('#(\[(?:\w|/\w).*?\])#mis', $value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); + $content = preg_split('#(\[(?:\w|/\w).*?\])#ms', $value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); foreach ($content as $cont) { // Each chunk is either a bbcode or a piece of text @@ -448,11 +448,11 @@ class e_bbcode foreach($mtch[1] as $i) { - if(substr($i,0,4)=='http') + if(strpos($i,'http') === 0) { $ret[] = $i; } - elseif(substr($i,0,3)=="{e_") + elseif(strpos($i,"{e_") === 0) { $ret[] = $tp->replaceConstants($i,'full'); } @@ -827,7 +827,7 @@ class e_bbcode - if(substr($text,0,6)=='[html]') + if(strpos($text,'[html]') === 0) { return $text; } diff --git a/e107_handlers/bounce_handler.php b/e107_handlers/bounce_handler.php index 7070fbf07..124890d98 100644 --- a/e107_handlers/bounce_handler.php +++ b/e107_handlers/bounce_handler.php @@ -365,7 +365,7 @@ elseif(self::is_RFC1892_multipart_report($head_hash) === true) { $rpt_hash = self::parse_machine_parsable_body_part($mime_sections['machine_parsable_body_part']); - for($i = 0; $i < count($rpt_hash['per_recipient']); $i++) + for($i = 0, $iMax = count($rpt_hash['per_recipient']); $i < $iMax; $i++) { $output[$i]['recipient'] = self::get_recipient($rpt_hash['per_recipient'][$i]); $output[$i]['status'] = $rpt_hash['per_recipient'][$i]['Status']; @@ -378,7 +378,7 @@ // Up to 50 email addresses can be listed on each header. // There can be multiple X-Failed-Recipients: headers. - (not supported) $arrFailed = explode(',', $head_hash['X-failed-recipients']); - for($j = 0; $j < count($arrFailed); $j++) + for($j = 0, $jMax = count($arrFailed); $j < $jMax; $j++) { $output[$j]['recipient'] = trim($arrFailed[$j]); $output[$j]['status'] = self::get_status_code_from_text($output[$j]['recipient'], $arrBody, 0); @@ -389,7 +389,7 @@ { // oh god it could be anything, but at least it has mime parts, so let's try anyway $arrFailed = self::find_email_addresses($mime_sections['first_body_part']); - for($j = 0; $j < count($arrFailed); $j++) + for($j = 0, $jMax = count($arrFailed); $j < $jMax; $j++) { $output[$j]['recipient'] = trim($arrFailed[$j]); $output[$j]['status'] = self::get_status_code_from_text($output[$j]['recipient'], $arrBody, 0); @@ -404,7 +404,7 @@ // about 100% accuracy or if you want very fast performance. // Leave it turned on if you know that all messages to be analyzed are bounces. $arrFailed = self::find_email_addresses($body); - for($j = 0; $j < count($arrFailed); $j++) + for($j = 0, $jMax = count($arrFailed); $j < $jMax; $j++) { $output[$j]['recipient'] = trim($arrFailed[$j]); $output[$j]['status'] = self::get_status_code_from_text($output[$j]['recipient'], $arrBody, 0); @@ -421,12 +421,12 @@ static function get_status_code_from_text($recipient, $arrBody, $index) { - for($i = $index; $i < count($arrBody); $i++) + for($i = $index, $iMax = count($arrBody); $i < $iMax; $i++) { $line = trim($arrBody[$i]); /******** recurse into the email if you find the recipient ********/ - if(stristr($line, $recipient) !== false) + if(stripos($line, $recipient) !== false) { // the status code MIGHT be in the next few lines after the recipient line, // depending on the message from the foreign host... What a laugh riot! @@ -440,83 +440,83 @@ /******** exit conditions ********/ // if it's the end of the human readable part in this stupid bounce - if(stristr($line, '------ This is a copy of the message') !== false) + if(stripos($line, '------ This is a copy of the message') !== false) { return ''; } //if we see an email address other than our current recipient's, if(count(self::find_email_addresses($line)) >= 1 - && stristr($line, $recipient) === false - && strstr($line, 'FROM:<') === false) + && stripos($line, $recipient) === false + && strpos($line, 'FROM:<') === false) { // Kanon added this line because Hotmail puts the e-mail address too soon and there actually is error message stuff after it. return ''; } /******** pattern matching ********/ - if(stristr($line, 'no such address') !== false - || stristr($line, 'Recipient address rejected') !== false - || stristr($line, 'User unknown in virtual alias table') !== false) + if(stripos($line, 'no such address') !== false + || stripos($line, 'Recipient address rejected') !== false + || stripos($line, 'User unknown in virtual alias table') !== false) { return '5.1.1'; } - elseif(stristr($line, 'unrouteable mail domain') !== false - || stristr($line, 'Esta casilla ha expirado por falta de uso') !== false) + elseif(stripos($line, 'unrouteable mail domain') !== false + || stripos($line, 'Esta casilla ha expirado por falta de uso') !== false) { return '5.1.2'; } - elseif(stristr($line, 'mailbox is full') !== false - || stristr($line, 'Mailbox quota usage exceeded') !== false - || stristr($line, 'User mailbox exceeds allowed size') !== false) + elseif(stripos($line, 'mailbox is full') !== false + || stripos($line, 'Mailbox quota usage exceeded') !== false + || stripos($line, 'User mailbox exceeds allowed size') !== false) { return '4.2.2'; } - elseif(stristr($line, 'not yet been delivered') !== false) + elseif(stripos($line, 'not yet been delivered') !== false) { return '4.2.0'; } - elseif(stristr($line, 'mailbox unavailable') !== false) + elseif(stripos($line, 'mailbox unavailable') !== false) { return '5.2.0'; } - elseif(stristr($line, 'Unrouteable address') !== false) + elseif(stripos($line, 'Unrouteable address') !== false) { return '5.4.4'; } - elseif(stristr($line, 'retry timeout exceeded') !== false) + elseif(stripos($line, 'retry timeout exceeded') !== false) { return '4.4.7'; } - elseif(stristr($line, 'The account or domain may not exist, they may be blacklisted, or missing the proper dns entries.') !== false) + elseif(stripos($line, 'The account or domain may not exist, they may be blacklisted, or missing the proper dns entries.') !== false) { // Kanon added return '5.2.0'; // I guess.... seems like 5.1.1, 5.1.2, or 5.4.4 would fit too, but 5.2.0 seemed most generic } - elseif(stristr($line, '554 TRANSACTION FAILED') !== false) + elseif(stripos($line, '554 TRANSACTION FAILED') !== false) { // Kanon added return '5.5.4'; // I think this should be 5.7.1. "SMTP error from remote mail server after end of data: ... (HVU:B1) http://postmaster.info.aol.com/errors/554hvub1.html" -- AOL rejects messages that have links to certain sites in them. } - elseif(stristr($line, 'Status: 4.4.1') !== false - || stristr($line, 'delivery temporarily suspended') !== false) + elseif(stripos($line, 'Status: 4.4.1') !== false + || stripos($line, 'delivery temporarily suspended') !== false) { // Kanon added return '4.4.1'; } - elseif(stristr($line, '550 OU-002') !== false - || stristr($line, 'Mail rejected by Windows Live Hotmail for policy reasons') !== false) + elseif(stripos($line, '550 OU-002') !== false + || stripos($line, 'Mail rejected by Windows Live Hotmail for policy reasons') !== false) { // Kanon added return '5.5.0'; // Again, why isn't this 5.7.1 instead? } - elseif(stristr($line, 'PERM_FAILURE: DNS Error: Domain name not found') !== false) + elseif(stripos($line, 'PERM_FAILURE: DNS Error: Domain name not found') !== false) { // Kanon added return '5.1.2'; // Not sure if this is right code. Just copied from above. } - elseif(stristr($line, 'Delivery attempts will continue to be made for') !== false) + elseif(stripos($line, 'Delivery attempts will continue to be made for') !== false) { // Kanon added. From Symantec_AntiVirus_for_SMTP_Gateways@uqam.ca return '4.2.0'; // I'm not sure why Symantec delayed this message, but x.2.x means something to do with the mailbox, which seemed appropriate. x.5.x (protocol) or x.7.x (security) also seem possibly appropriate. It seems a lot of times it's x.5.x when it seems to me it should be x.7.x, so maybe x.5.x is standard when mail is rejected due to spam-like characteristics instead of x.7.x like I think it should be. } - elseif(stristr($line, '554 delivery error:') !== false) + elseif(stripos($line, '554 delivery error:') !== false) { return '5.5.4'; // rogers.com } - elseif(strstr($line, '550-5.1.1') !== false - || stristr($line, 'This Gmail user does not exist.') !== false) + elseif(strpos($line, '550-5.1.1') !== false + || stripos($line, 'This Gmail user does not exist.') !== false) { // Kanon added return '5.1.1'; // Or should it be 5.5.0? } @@ -724,7 +724,7 @@ $hash['per_message']['Reporting-mta']['addr'] = trim($arr[1]); } //Per-Recipient DSN fields - for($i = 0; $i < count($hash['per_recipient']); $i++) + for($i = 0, $iMax = count($hash['per_recipient']); $i < $iMax; $i++) { $temp = self::standard_parser(explode("\r\n", $hash['per_recipient'][$i])); $arr = explode(';', $temp['Final-recipient']); @@ -749,7 +749,7 @@ if($judgement == 'transient') { - if(stristr($temp['Action'], 'failed') !== false) + if(stripos($temp['Action'], 'failed') !== false) { $temp['Action'] = 'transient'; $temp['Status'] = '4.3.0'; @@ -822,7 +822,7 @@ $hash = array(); - for($i = 0; $i < count($dsn_fields); $i++) + for($i = 0, $iMax = count($dsn_fields); $i < $iMax; $i++) { if($i == 0) { diff --git a/e107_handlers/cli_class.php b/e107_handlers/cli_class.php index 3e5b61452..149bee9b7 100644 --- a/e107_handlers/cli_class.php +++ b/e107_handlers/cli_class.php @@ -69,7 +69,7 @@ class eCLI if(preg_match("/^-([a-zA-Z0-9]+)/", $matches[0], $match)) { $string = $match[1]; - for($i=0; strlen($string) > $i; $i++) + for($i=0, $iMax = strlen($string); $iMax > $i; $i++) { $_ARG[$string[$i]] = true; } diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index b0203ce7d..525ec08e0 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -168,7 +168,7 @@ class comment $sql = e107::getDb(); $tp = e107::getParser(); - if(vartrue($pref['comments_disabled']) || $this->engine != 'e107') + if(!empty($pref['comments_disabled']) || $this->engine != 'e107') { return null; } @@ -733,7 +733,7 @@ class comment $eaction = 'edit'; $editpid = $_GET['comment_id']; } - elseif (strstr(e_QUERY, "edit")) + elseif (strpos(e_QUERY, "edit") !== false) { $eaction = "edit"; $tmp = explode(".", e_QUERY); @@ -1254,7 +1254,7 @@ class comment $type = $this->getCommentType($table); $sort = vartrue($pref['comments_sort'],'desc'); - if(vartrue($pref['nested_comments'])) + if(!empty($pref['nested_comments'])) { $query = "SELECT c.*, u.*, ue.*, r.* FROM #comments AS c LEFT JOIN #user AS u ON c.comment_author_id = u.user_id diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php index ebce4fb3e..547c9f5d0 100644 --- a/e107_handlers/cron_class.php +++ b/e107_handlers/cron_class.php @@ -428,12 +428,12 @@ class CronParser */ function expand_ranges($str) { - if (strstr($str, ",")) + if (strpos($str, ",") !== false) { $arParts = explode(',', $str); foreach ($arParts AS $part) { - if (strstr($part, '-')) + if (strpos($part, '-') !== false) { $arRange = explode('-', $part); for ($i = $arRange[0]; $i <= $arRange[1]; $i++) @@ -447,7 +447,7 @@ class CronParser } } } - elseif (strstr($str, '-')) + elseif (strpos($str, '-') !== false) { $arRange = explode('-', $str); for ($i = $arRange[0]; $i <= $arRange[1]; $i++) diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php index e18c83e40..79d1466a4 100644 --- a/e107_handlers/date_handler.php +++ b/e107_handlers/date_handler.php @@ -94,7 +94,7 @@ class e_date return $marray; } - if(substr($type,0,3) == 'day') + if(strpos($type, 'day') === 0) { $days = array(); for ($i=2; $i < 9; $i++) diff --git a/e107_handlers/db_table_admin_class.php b/e107_handlers/db_table_admin_class.php index 19aafeaf9..b9f5a8eb7 100644 --- a/e107_handlers/db_table_admin_class.php +++ b/e107_handlers/db_table_admin_class.php @@ -350,7 +350,7 @@ class db_table_admin return FALSE; } $found = FALSE; - for ($k = $i + 1; $k < count($list1); $k++) + for ($k = $i + 1, $kMax = count($list1); $k < $kMax; $k++) { // echo "Compare ".$list1[$k]['name'].' with '.$list2[0]['name']; if (strcasecmp($list1[$k]['name'], $list2[0]['name']) == 0) @@ -371,7 +371,7 @@ class db_table_admin } $found = FALSE; - for ($k = 0; $k < count($list2); $k++) + for ($k = 0, $kMax = count($list2); $k < $kMax; $k++) { // echo "Compare ".$list1[$i]['name'].' with '.$list2[$k]['name']; if (strcasecmp($list1[$i]['name'], $list2[$k]['name']) == 0) @@ -522,7 +522,7 @@ class db_table_admin return "Not an array
"; } $text = ""; - for ($i = 0; $i < count($result[0]); $i++) + for ($i = 0, $iMax = count($result[0]); $i < $iMax; $i++) { $text .= ""; $text .= ""; @@ -540,7 +540,7 @@ class db_table_admin return "Not an array
"; } $text = "
{$result[0][$i]}{$result[1][$i]}
"; - for ($i = 0; $i < count($result); $i++) + for ($i = 0, $iMax = count($result); $i < $iMax; $i++) { $text .= ""; $text .= ""; diff --git a/e107_handlers/db_verify_class.php b/e107_handlers/db_verify_class.php index 048b5d247..a3ad5332d 100755 --- a/e107_handlers/db_verify_class.php +++ b/e107_handlers/db_verify_class.php @@ -749,7 +749,7 @@ class db_verify { $key = array_flip($tabl); - if(substr($cur,0,4)=="lan_") // language table adjustment. + if(strpos($cur,"lan_") === 0) // language table adjustment. { list($tmp,$lang,$cur) = explode("_",$cur,3); } @@ -773,7 +773,7 @@ class db_verify function getFixQuery($mode, $table, $field, $sqlFileData, $engine = 'MyISAM' ) { - if(substr($mode,0,5)== 'index') + if(strpos($mode, 'index') === 0) { $fdata = $this->getIndex($sqlFileData); $newval = $this->toMysql($fdata[$field],'index'); diff --git a/e107_handlers/debug_handler.php b/e107_handlers/debug_handler.php index b1b40342f..048b6465d 100644 --- a/e107_handlers/debug_handler.php +++ b/e107_handlers/debug_handler.php @@ -122,7 +122,7 @@ class e107_debug { public static function activated() { - if ((strstr(e_MENU, "debug") || isset($_COOKIE['e107_debug_level'])) || deftrue('e_DEBUG')) // ADMIN and getperms('0') are not available at this point. + if (isset($_COOKIE['e107_debug_level']) || deftrue('e_DEBUG') || (strpos(e_MENU, "debug") === 0)) // ADMIN and getperms('0') are not available at this point. { return true; } diff --git a/e107_handlers/e_db_pdo_class.php b/e107_handlers/e_db_pdo_class.php index 7d5b0ceeb..683f98c18 100644 --- a/e107_handlers/e_db_pdo_class.php +++ b/e107_handlers/e_db_pdo_class.php @@ -328,7 +328,7 @@ class e_db_pdo implements e_db { $this->dbg->log($query); } - if ($debug !== false || strstr($_SERVER['QUERY_STRING'], 'showsql')) + if ($debug !== false || strpos($_SERVER['QUERY_STRING'], 'showsql') !== false) { $debugQry = is_array($query) ? print_a($query,true) : $query; $queryinfo[] = "{$qry_from}: ".$debugQry; @@ -1615,7 +1615,7 @@ class e_db_pdo implements e_db foreach($this->mySQLtableList as $tab) { - if(substr($tab,0,4) == "lan_") + if(strpos($tab,"lan_") === 0) { list($tmp,$lng,$tableName) = explode("_",$tab,3); @@ -2277,13 +2277,13 @@ class e_db_pdo implements e_db foreach($this->mySQLtableList as $tab) { - if(substr($tab,0,4)!='lan_') + if(strpos($tab,'lan_') === 0) { - $nolan[] = $tab; + $lan[] = $tab; } else { - $lan[] = $tab; + $nolan[] = $tab; } } @@ -2433,7 +2433,7 @@ class e_db_pdo implements e_db // $dbtable = $this->mySQLdefaultdb; $fileName = ($table =='*') ? str_replace(" ","_",SITENAME) : $table; - $fileName = preg_replace('/[^\w]/i',"",$fileName); + $fileName = preg_replace('/[\W]/',"",$fileName); $backupFile = ($file) ? e_BACKUP.$file : e_BACKUP.strtolower($fileName)."_".$this->mySQLPrefix.date("Y-m-d-H-i-s").".sql"; @@ -2679,7 +2679,7 @@ class e_db_pdo implements e_db // File structure is a nested array - first level is table name, second level is either false (for do nothing) or array(_FIELD_DEFS => array(), _NOTNULL => array()) $temp = file_get_contents($defFile); // Strip any comments (only /*...*/ supported) - $temp = preg_replace("#\/\*.*?\*\/#mis", '', $temp); + $temp = preg_replace("#\/\*.*?\*\/#ms", '', $temp); //echo "Check: {$defFile}, {$tableName}
"; if ($temp !== false) { diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index dc7873c04..5d32cf6a9 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1172,13 +1172,13 @@ class e_parse extends e_parser foreach($tags as $tag) { - if(!$tag[2] || !preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/si', $tag[2])) + if(!$tag[2] || !preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { - if(preg_match('/<[\w]+[^>]*>/s', $tag[0])) + if(preg_match('/<[\w]+[^>]*>/', $tag[0])) { array_unshift($openTags, $tag[2]); } - else if(preg_match('/<\/([\w]+)[^>]*>/s', $tag[0], $closeTag)) + else if(preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { $pos = array_search($closeTag[1], $openTags); if($pos !== false) @@ -2836,7 +2836,7 @@ class e_parse extends e_parser - if(strstr($url,e_MEDIA) || strstr($url,e_SYSTEM)) // prevent disclosure of 'hashed' path. + if(strpos($url, e_MEDIA) !== false || strpos($url, e_SYSTEM) !== false) // prevent disclosure of 'hashed' path. { $raw = true; } @@ -2965,7 +2965,7 @@ class e_parse extends e_parser $ret = array(); - if(strstr($url, 'thumb.php') && !empty($qry)) // Regular + if(!empty($qry) && strpos($url, 'thumb.php') !== false) // Regular { parse_str($qry,$val); $ret = $val; @@ -3152,17 +3152,17 @@ class e_parse extends e_parser $ext = strtolower($options['ext']); return $base.'media/img/'.base64_encode($options['thurl']).'.'.str_replace('jpeg', 'jpg', $ext); } - elseif(strstr($url, 'e_MEDIA_IMAGE')) // media images. + elseif(strpos($url, 'e_MEDIA_IMAGE') !== false) // media images. { $sefPath = 'media/img/'; $clean = array('{e_MEDIA_IMAGE}','e_MEDIA_IMAGE/'); } - elseif(strstr($url, 'e_AVATAR')) // avatars + elseif(strpos($url, 'e_AVATAR') !== false) // avatars { $sefPath = 'media/avatar/'; $clean = array('{e_AVATAR}','e_AVATAR/'); } - elseif(strstr($url, 'e_THEME')) // theme folder images. + elseif(strpos($url, 'e_THEME') !== false) // theme folder images. { $sefPath = 'theme/img/'; $clean = array('{e_THEME}','e_THEME/'); @@ -3176,7 +3176,7 @@ class e_parse extends e_parser // Build URL for ReWriteRule ^media\/img\/(a)?([\d]*)x(a)?([\d]*)\/(.*)?$ thumb.php?src=e_MEDIA_IMAGE/$5&$1w=$2&$3h=$4 $sefUrl = $base.$sefPath; - if(vartrue($options['aw']) || vartrue($options['ah'])) + if(!empty($options['aw']) || !empty($options['ah'])) { $sefUrl .= 'a'.intval($options['aw']) .'xa'. intval($options['ah']); } @@ -4790,7 +4790,7 @@ class e_parser */ public function isBBcode($text) { - if(preg_match('#(?<=<)\w+(?=[^<]*?>)#', $text)) + if(strpos($text,'[')=== false || preg_match('#(?<=<)\w+(?=[^<]*?>)#', $text)) { return false; } diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index cb6880d63..a8c3cb9f5 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -84,7 +84,7 @@ * * @var array */ - public $dirFilter; + public $dirFilter = array(); /** * Array of file names to ignore (in addition to any set by caller) @@ -227,10 +227,9 @@ */ function get_files($path, $fmask = '', $omit = 'standard', $recurse_level = 0) { - $ret = array(); $invert = false; - if(substr($fmask, 0, 1) == '~') + if(strpos($fmask,'~') === 0) { $invert = true; // Invert selection - exclude files which match selection $fmask = substr($fmask, 1); @@ -240,11 +239,14 @@ { return $ret; } + + if(substr($path, -1) == '/') { $path = substr($path, 0, -1); } + if(!is_dir($path) || !$handle = opendir($path)) { return $ret; @@ -263,19 +265,22 @@ while(false !== ($file = readdir($handle))) { - if(is_dir($path . '/' . $file)) - { // Its a directory - recurse into it unless a filtered directory or required depth achieved - // Must always check for '.' and '..' - if(($file != '.') && ($file != '..') && !in_array($file, $this->dirFilter) && !in_array($file, $omit) && ($recurse_level > 0)) - { - $xx = $this->get_files($path . '/' . $file, $fmask, $omit, $recurse_level - 1); - $ret = array_merge($ret, $xx); - } + if($file === '.' || $file === '..') + { + continue; + } + + if(($recurse_level > 0) && !in_array($file, $this->dirFilter) && !in_array($file, $omit) && is_dir($path . '/' . $file)) + { + // Its a directory - recurse into it unless a filtered directory or required depth achieved + $xx = $this->get_files($path . '/' . $file, $fmask, $omit, $recurse_level - 1); + $ret = array_merge($ret, $xx); + } else { // Now check against standard reject list and caller-specified list - if(($fmask == '') || ($invert != preg_match("#" . $fmask . "#", $file))) + if(empty($fmask) || ($invert != preg_match("#" . $fmask . "#", $file))) { // File passes caller's filter here $rejected = false; @@ -467,7 +472,7 @@ } // Auto-Fix Files without an extensions using known mime-type. - if(empty($finfo['pathinfo']['extension']) && !is_dir($path_to_file) && !empty($finfo['mime'])) + if(empty($finfo['pathinfo']['extension']) && !empty($finfo['mime']) && !is_dir($path_to_file)) { if($ext = $this->getFileExtension($finfo['mime'])) { @@ -652,14 +657,14 @@ // $mes = e107::getMessage(); - $address = str_replace(array("\r", "\n", "\t"), '', $address); // May be paranoia, but streaky thought it might be a good idea + // May be paranoia, but streaky thought it might be a good idea - $address = str_replace('&', '&', $address); + $address = str_replace(array("\r", "\n", "\t", '&'), array('', '', '', '&'), $address); // ... and there shouldn't be unprintable characters in the URL anyway $requireCurl = false; - if(vartrue($options['decode'], false)) + if(!empty($options['decode'])) { $address = urldecode($address); } @@ -778,7 +783,9 @@ { $ret = array(); - if(substr($path, -1) == '/') + $path = rtrim($path,'/'); + if($path[strlen($path) - 1] === '/') + // if(substr($path, -1) == '/') { $path = substr($path, 0, -1); } @@ -799,9 +806,10 @@ $omit = array($omit); } } + while(false !== ($file = readdir($handle))) { - if(is_dir($path . '/' . $file) && ($file != '.') && ($file != '..') && !in_array($file, $this->dirFilter) && !in_array($file, $omit) && ($fmask == '' || preg_match("#" . $fmask . "#", $file))) + if(($file != '.') && ($file != '..') && !in_array($file, $this->dirFilter) && !in_array($file, $omit) && is_dir($path . '/' . $file) && ($fmask == '' || preg_match("#" . $fmask . "#", $file))) { $ret[] = $file; } @@ -1105,7 +1113,7 @@ $path_public = realpath($FILES_DIRECTORY . "public/"); - if(!strstr($path, $path_downloads) && !strstr($path, $path_public) && !strstr($path, $MEDIA_DIRECTORY) && !strstr($path, $SYSTEM_DIRECTORY)) + if(strpos($path, $path_downloads) === false && strpos($path, $path_public) === false && strpos($path, $MEDIA_DIRECTORY) === false && strpos($path, $SYSTEM_DIRECTORY) === false) { if(E107_DEBUG_LEVEL > 0 && ADMIN) { @@ -1127,7 +1135,7 @@ if(is_file($filename) && is_readable($filename) && connection_status() == 0) { $seek = 0; - if(strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) + if(strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== false) { $file = preg_replace('/\./', '%2e', $file, substr_count($file, '.') - 1); } @@ -1278,7 +1286,7 @@ $newFile = e_BACKUP . eHelper::title2sef(SITENAME) . "_" . date("Y-m-d-H-i-s") . ".zip"; } - if(is_null($filePaths)) + if($filePaths === null) { return "No file-paths set!"; } @@ -1561,7 +1569,7 @@ // print_a($headers); - return (stripos($headers[0], "200 OK") || stripos($headers[0], "302")) ? true : false; + return (stripos($headers[0], "200 OK") || strpos($headers[0], "302")) ? true : false; } @@ -1761,8 +1769,8 @@ // language. // eg. https://github.com/e107translations/Spanish/archive/v2.1.5.zip default: - $localfile = str_replace('https://github.com/e107translations/', '', $url); // 'e107-master.zip'; - $localfile = str_replace('/archive/v', '-', $localfile); //remove dirs. + // 'e107-master.zip'; + $localfile = str_replace(array('https://github.com/e107translations/', '/archive/v'), array('', '-'), $url); //remove dirs. $remotefile = $url; $excludes = array(); $excludeMatch = array('alt_auth', 'tagwords', 'faqs'); diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 4e65573b6..e469b7c4e 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -133,7 +133,7 @@ class e_form parse_str($options, $options); } - if(vartrue($options['class'])) + if(!empty($options['class'])) { $class = "class='".$options['class']."'"; } @@ -807,7 +807,7 @@ class e_form } // TODO: remove typeahead. - if(vartrue($options['typeahead'])) + if(!empty($options['typeahead'])) { if(vartrue($options['typeahead']) == 'users') { @@ -816,13 +816,13 @@ class e_form } } - if(vartrue($options['size']) && !is_numeric($options['size'])) + if(!empty($options['size']) && !is_numeric($options['size'])) { $options['class'] .= " input-".$options['size']; unset($options['size']); // don't include in html 'size='. } - $mlength = vartrue($maxlength) ? "maxlength=".$maxlength : ""; + $mlength = !empty($maxlength) ? "maxlength=".$maxlength : ""; $type = varset($options['type']) == 'email' ? 'email' : 'text'; // used by $this->email(); @@ -1041,7 +1041,7 @@ class e_form $url .= "&iframe=1"; - if(vartrue($extras['w'])) + if(!empty($extras['w'])) { $url .= "&w=".$extras['w']; } @@ -1129,7 +1129,7 @@ class e_form $optioni = $idinput."-options"; - $path = (substr($curVal,0,8) == '-upload-') ? '{e_AVATAR}upload/' : '{e_AVATAR}default/'; + $path = (strpos($curVal,'-upload-') === 0) ? '{e_AVATAR}upload/' : '{e_AVATAR}default/'; $newVal = str_replace('-upload-','',$curVal); $img = (strpos($curVal,"://")!==false) ? $curVal : $tp->thumbUrl($path.$newVal); @@ -2024,7 +2024,7 @@ class e_form $addon = ""; $gen = ""; - if(vartrue($options['generate'])) + if(!empty($options['generate'])) { $gen = ' '.LAN_GENERATE.' '; @@ -2034,7 +2034,7 @@ class e_form } } - if(vartrue($options['strength'])) + if(!empty($options['strength'])) { $addon .= "
"; } @@ -2060,7 +2060,7 @@ class e_form $options['class'] .= ' form-control'; } - if(vartrue($options['size']) && !is_numeric($options['size'])) + if(!empty($options['size']) && !is_numeric($options['size'])) { $options['class'] .= " input-".$options['size']; unset($options['size']); // don't include in html 'size='. @@ -2197,7 +2197,7 @@ class e_form - if(vartrue($options['btn-label'])) + if(!empty($options['btn-label'])) { $interval = vartrue($options['interval'],1000); $text .= ''.$options['btn-label'].''; @@ -2230,12 +2230,12 @@ class e_form $options['class'] = ''; } - if(vartrue($options['size']) && !is_numeric($options['size'])) + if(!empty($options['size']) && !is_numeric($options['size'])) { $options['class'] .= " form-control input-".$options['size']; unset($options['size']); // don't include in html 'size='. } - elseif(!vartrue($options['noresize'])) + elseif(empty($options['noresize'])) { $options['class'] = (isset($options['class']) && $options['class']) ? $options['class'].' e-autoheight' : 'tbox col-md-7 span7 e-autoheight form-control'; } @@ -2643,7 +2643,7 @@ class e_form $text .= "get_attributes($options, $name, $value)." />"; - if(vartrue($options['help'])) + if(!empty($options['help'])) { $text .= "
".$options['help']."
"; } @@ -2690,7 +2690,7 @@ class e_form $options_off = array_merge($options_off, $options); - if(vartrue($options['class']) == 'e-expandit' || vartrue($options['expandit'])) // See admin->prefs 'Single Login' for an example. + if(vartrue($options['class']) == 'e-expandit' || !empty($options['expandit'])) // See admin->prefs 'Single Login' for an example. { $options_on = array_merge($options, array('class' => 'e-expandit-on')); $options_off = array_merge($options, array('class' => 'e-expandit-off')); @@ -2833,7 +2833,7 @@ class e_form if(is_string($elements)) parse_str($elements, $elements); if(!is_array($options)) parse_str($options, $options); $help = ''; - if(vartrue($options['help'])) + if(!empty($options['help'])) { $help = "
".$options['help']."
"; unset($options['help']); @@ -3791,12 +3791,16 @@ var_dump($select_options);*/ case 'other': if($optval) $ret .= " $optval"; break; + + default: + if(strpos($option,'data-') === 0) + { + $ret .= " ".$option."='{$optval}'"; + } + break; } - if(substr($option,0,5) =='data-') - { - $ret .= " ".$option."='{$optval}'"; - } + } @@ -3861,7 +3865,10 @@ var_dump($select_options);*/ foreach (array_keys($user_options) as $key) { - if(!isset($def_options[$key]) && substr($key,0,5)!='data-') unset($user_options[$key]); // data-xxxx exempt //remove it? + if(!isset($def_options[$key]) && strpos($key,'data-') !== 0) + { + unset($user_options[$key]); // data-xxxx exempt //remove it? + } } } else @@ -4328,7 +4335,7 @@ var_dump($select_options);*/ { continue; } - elseif(vartrue($data['type']) != 'method' && empty($data['forced']) && !isset($fieldvalues[$field]) && $fieldvalues[$field] !== null) + elseif(vartrue($data['type']) !== 'method' && empty($data['forced']) && !isset($fieldvalues[$field]) && $fieldvalues[$field] !== null) { $text .= "
{$result[$i][0]}{$result[$i][1]} @@ -4461,7 +4468,7 @@ var_dump($select_options);*/ $source = e107::getParser()->toJSON($jsonArray, true); - $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + $mode = preg_replace('/[\W]/', '', vartrue($_GET['mode'], '')); if(!isset($options['url'])) { @@ -4609,7 +4616,7 @@ var_dump($select_options);*/ if(!empty($parms['sort']) && empty($attributes['grid'])) { - $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + $mode = preg_replace('/[\W]/', '', vartrue($_GET['mode'], '')); $from = intval(vartrue($_GET['from'],0)); $text .= "".ADMIN_SORT_ICON." "; } @@ -4998,7 +5005,7 @@ var_dump($select_options);*/ $tpl = $this->text($field, $value, 80, $options); - $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + $mode = preg_replace('/[\W]/', '', vartrue($_GET['mode'], '')); $value = "" . $value . ""; } @@ -5012,15 +5019,15 @@ var_dump($select_options);*/ $value = defset($value,$value); } - if(vartrue($parms['truncate'])) + if(!empty($parms['truncate'])) { $value = $tp->text_truncate($value, $parms['truncate'], '...'); } - elseif(vartrue($parms['htmltruncate'])) + elseif(!empty($parms['htmltruncate'])) { $value = $tp->html_truncate($value, $parms['htmltruncate'], '...'); } - if(vartrue($parms['wrap'])) + if(!empty($parms['wrap'])) { $value = $tp->htmlwrap($value, (int)$parms['wrap'], varset($parms['wrapChar'], ' ')); } @@ -5070,7 +5077,7 @@ var_dump($select_options);*/ if($attributes['type'] == 'bbarea' && !isset($parms['bb'])) $parms['bb'] = true; //force bb parsing for bbareas $elid = trim(str_replace('_', '-', $field)).'-'.$id; if(!vartrue($parms['noparse'])) $value = $tp->toHTML($value, (vartrue($parms['bb']) ? true : false), vartrue($parms['parse'])); - if(vartrue($parms['expand']) || vartrue($parms['truncate']) || vartrue($parms['htmltruncate'])) + if(!empty($parms['expand']) || !empty($parms['truncate']) || !empty($parms['htmltruncate'])) { $ttl = vartrue($parms['expand']); if($ttl == 1) @@ -5083,13 +5090,13 @@ var_dump($select_options);*/ } $oldval = $value; - if(vartrue($parms['truncate'])) + if(!empty($parms['truncate'])) { $value = $oldval = strip_tags($value); $value = $tp->text_truncate($value, $parms['truncate'], ''); $toexpand = $value != $oldval; } - elseif(vartrue($parms['htmltruncate'])) + elseif(!empty($parms['htmltruncate'])) { $value = $tp->html_truncate($value, $parms['htmltruncate'], ''); $toexpand = $value != $oldval; @@ -5112,7 +5119,7 @@ var_dump($select_options);*/ break; case 'file': - if(vartrue($parms['base'])) + if(!empty($parms['base'])) { $url = $parms['base'].$value; } @@ -5190,9 +5197,9 @@ var_dump($select_options);*/ { $thparms['w'] = intval($parms['thumb']); } - elseif(vartrue($parms['thumb_aw'])) // Legacy v2. + elseif(!empty($parms['thumb_aw'])) // Legacy v2. { - $thparms['aw'] = intval($parms['thumb_aw']); + $thparms['aw'] = (int) $parms['thumb_aw']; } if(!empty($parms['legacyPath'])) @@ -5420,7 +5427,7 @@ var_dump($select_options);*/ // $tpl = $this->userpicker($field, '', $ttl, $id, array('id' => $fieldID, 'selectize' => array('e_editable' => $eEditableID))); $tpl = $this->userpicker($fieldID, array('user_id'=>$id, 'user_name'=>$ttl), array('id' => $fieldID, 'inline' => $eEditableID)); - $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + $mode = preg_replace('/[\W]/', '', vartrue($_GET['mode'], '')); $value = "" . $ttl . ""; } @@ -5480,7 +5487,7 @@ var_dump($select_options);*/ return $this->renderInline($field, $id, $attributes['title'], $value, $dispValue, 'select', $wparms, array('class'=>'e-editable-boolean '.$styleClass)); } - if(vartrue($parms['reverse'])) + if(!empty($parms['reverse'])) { $value = ($value) ? $false : ADMIN_TRUE_ICON; } @@ -5512,7 +5519,7 @@ var_dump($select_options);*/ case 'email': if(!$value) break; $ttl = $value; - if(vartrue($parms['truncate'])) + if(!empty($parms['truncate'])) { $ttl = $tp->text_truncate($value, $parms['truncate'], '...'); } @@ -5561,7 +5568,7 @@ var_dump($select_options);*/ if(empty($attributes['noedit']) && !empty($parms['editable'])) // avoid bad markup, better solution coming up { - $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + $mode = preg_replace('/[\W]/', '', vartrue($_GET['mode'], '')); $methodParms = call_user_func_array(array($this, $meth), array($_value, 'inline', $parms)); $inlineParms = (!empty($methodParms['inlineParms'])) ? $methodParms['inlineParms'] : null; @@ -5730,9 +5737,9 @@ var_dump($select_options);*/ } // Two modes of read-only. 1 = read-only, but only when there is a value, 2 = read-only regardless. - if(vartrue($attributes['readonly']) && (vartrue($value) || vartrue($attributes['readonly'])===2)) // quick fix (maybe 'noedit'=>'readonly'?) + if(!empty($attributes['readonly']) && (!empty($value) || vartrue($attributes['readonly'])===2)) // quick fix (maybe 'noedit'=>'readonly'?) { - if(vartrue($attributes['writeParms'])) // eg. different size thumbnail on the edit page. + if(!empty($attributes['writeParms'])) // eg. different size thumbnail on the edit page. { $attributes['readParms'] = $attributes['writeParms']; } @@ -5745,7 +5752,7 @@ var_dump($select_options);*/ $writeParamsDisabled = array('layouts', 'templates', 'userclass', 'userclasses'); // FIXME it breaks all list like elements - dropdowns, radio, etc - if(vartrue($required_data[0]) || vartrue($attributes['required'])) // HTML5 'required' attribute + if(!empty($required_data[0]) || !empty($attributes['required'])) // HTML5 'required' attribute { // FIXME - another approach, raise standards, remove checks if(in_array($attributes['type'], $writeParamsOptionable)) @@ -5759,7 +5766,7 @@ var_dump($select_options);*/ } // FIXME it breaks all list like elements - dropdowns, radio, etc - if(vartrue($required_data[3]) || vartrue($attributes['pattern'])) // HTML5 'pattern' attribute + if(!empty($required_data[3]) || !empty($attributes['pattern'])) // HTML5 'pattern' attribute { // FIXME - another approach, raise standards, remove checks if(in_array($attributes['type'], $writeParamsOptionable)) @@ -5878,7 +5885,7 @@ var_dump($select_options);*/ case 'textarea': $text = ""; - if(vartrue($parms['append']) && vartrue($value)) // similar to comments - TODO TBD. a 'comment' field type may be better. + if(!empty($parms['append']) && !empty($value)) // similar to comments - TODO TBD. a 'comment' field type may be better. { $attributes['readParms'] = 'bb=1'; @@ -6008,16 +6015,16 @@ var_dump($select_options);*/ // If hidden, value is updated regardless. eg. a 'last updated' field. // If not hidden, and there is a value, it is retained. eg. during the update of an existing record. // otherwise it is added. eg. during the creation of a new record. - if(vartrue($parms['auto']) && (($value == null) || vartrue($parms['hidden']))) + if(!empty($parms['auto']) && (($value == null) || !empty($parms['hidden']))) { $value = time(); } - if(vartrue($parms['readonly'])) // different to 'attribute-readonly' since the value may be auto-generated. + if(!empty($parms['readonly'])) // different to 'attribute-readonly' since the value may be auto-generated. { $ret = $this->renderValue($key, $value, $attributes).$this->hidden($key, $value); } - elseif(vartrue($parms['hidden'])) + elseif(!empty($parms['hidden'])) { $ret = $this->hidden($key, $value); } @@ -6142,7 +6149,7 @@ var_dump($select_options);*/ if(is_string($eloptions)) parse_str($eloptions, $eloptions); if($attributes['type'] === 'comma') $eloptions['multiple'] = true; unset($parms['__options']); - if(vartrue($eloptions['multiple']) && !is_array($value)) $value = explode(',', $value); + if(!empty($eloptions['multiple']) && !is_array($value)) $value = explode(',', $value); // Allow Ajax API. if(!empty($ajaxParms)) @@ -6192,7 +6199,7 @@ var_dump($select_options);*/ if((empty($value) || !empty($parms['currentInit']) && empty($parms['default']) ) || !empty($parms['current']) || (vartrue($parms['default']) == 'USERID')) // include current user by default. { $value = array('user_id'=>USERID, 'user_name'=>USERNAME); - if(vartrue($parms['current'])) + if(!empty($parms['current'])) { $parms['__options']['readonly'] = true; } @@ -6319,7 +6326,7 @@ var_dump($select_options);*/ break; } - if(vartrue($parms['expand'])) + if(!empty($parms['expand'])) { $k = "exp-".$this->name2id($key); $text = "".$parms['expand'].""; @@ -7282,12 +7289,12 @@ var_dump($select_options);*/ "; } } - elseif(vartrue($fdata['table_body'])) + elseif(!empty($fdata['table_body'])) { $text .= $fdata['table_body']; } - if(vartrue($fdata['table_note'])) + if(!empty($fdata['table_note'])) { $note = '
'.$fdata['table_note'].'
'; } diff --git a/e107_handlers/iphandler_class.php b/e107_handlers/iphandler_class.php index 67eb27c71..4511731ce 100644 --- a/e107_handlers/iphandler_class.php +++ b/e107_handlers/iphandler_class.php @@ -660,23 +660,23 @@ class eIPHandler */ public function ipDecode($ip, $IP4Legacy = TRUE) { - if (strstr($ip,'.')) + if (strpos($ip, '.') !== false) { if ($IP4Legacy) return $ip; // Assume its unencoded IPV4 $ipa = explode('.', $ip); $ip = '0:0:0:0:0:ffff:'.sprintf('%02x%02x:%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]); $ip = str_repeat('0000'.':', 5).'ffff:'.$this->ip4Encode($ip, TRUE, ':'); } - if (strstr($ip,'::')) return $ip; // Assume its a compressed IPV6 address already - if ((strlen($ip) == 8) && !strstr($ip,':')) + if (strpos($ip, '::') !== false) return $ip; // Assume its a compressed IPV6 address already + if ((strlen($ip) == 8) && strpos($ip, ':') === false) { // Assume a 'legacy' IPV4 encoding $ip = '0:0:0:0:0:ffff:'.implode(':',str_split($ip,4)); // Turn it into standard IPV6 } - elseif ((strlen($ip) == 32) && !strstr($ip,':')) + elseif ((strlen($ip) == 32) && strpos($ip, ':') === false) { // Assume a compressed hex IPV6 $ip = implode(':',str_split($ip,4)); } - if (!strstr($ip,':')) return FALSE; // Return on problem - no ':'! + if (strpos($ip, ':') === false) return FALSE; // Return on problem - no ':'! $temp = explode(':',$ip); $z = 0; // State of the 'zero manager' - 0 = not started, 1 = running, 2 = done $ret = ''; @@ -1083,7 +1083,7 @@ class eIPHandler //$admin_log->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, "BANLIST_11", 'LAN_AL_BANLIST_11', $ban_ip, FALSE, LOG_TO_ROLLING); return FALSE; } */ - if(vartrue($pref['enable_rdns_on_ban'])) + if(!empty($pref['enable_rdns_on_ban'])) { $ban_message .= 'Host: '.$this->get_host_name($ban_ip); } diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index e9329bcc9..97a84cf02 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -249,7 +249,7 @@ class e_jsmanager $customJqueryUrls = e107::getPref('library-jquery-urls'); $this->_cache_enabled = e107::getPref('jscsscachestatus',false); - if(vartrue($customJqueryUrls) && $this->_in_admin === false) + if(!empty($customJqueryUrls) && $this->_in_admin === false) { $this->_libraries['jquery'] = explode("\n", $customJqueryUrls); } @@ -269,7 +269,7 @@ class e_jsmanager if(!$this->libDisabled($id,$vis)) { - if(vartrue($this->_libraries[$id])) + if(!empty($this->_libraries[$id])) { foreach($this->_libraries[$id] as $path) { @@ -1718,7 +1718,7 @@ class e_jsmanager $parts = preg_split(":[\\\/]:", $path); // split on known directory separators // resolve relative paths - for ($i = 0; $i < count($parts); $i +=1) + for ($i = 0, $iMax = count($parts); $i < $iMax; $i +=1) { if ($parts[$i] === "..") // resolve .. { diff --git a/e107_handlers/jslib_handler.php b/e107_handlers/jslib_handler.php index d9d980ce7..fd2459110 100644 --- a/e107_handlers/jslib_handler.php +++ b/e107_handlers/jslib_handler.php @@ -199,7 +199,7 @@ class e_jslib $crc = crc32($contents); $gzdata .= gzcompress($contents, 9); - $gzdata = substr($gzdata, 0, strlen($gzdata) - 4); + $gzdata = substr($gzdata, 0, -4); $gzdata .= pack("V", $crc) . pack("V", $size); $gsize = strlen($gzdata); diff --git a/e107_handlers/language_class.php b/e107_handlers/language_class.php index 0d802c3ff..fc7de90ec 100644 --- a/e107_handlers/language_class.php +++ b/e107_handlers/language_class.php @@ -522,7 +522,7 @@ class language{ $doNothing = ''; // Do nothing as $detect_language is set. } - elseif(vartrue($pref['multilanguage_subdomain']) && $this->isLangDomain(e_DOMAIN) && (defset('MULTILANG_SUBDOMAIN') !== false)) + elseif(!empty($pref['multilanguage_subdomain']) && $this->isLangDomain(e_DOMAIN) && (defset('MULTILANG_SUBDOMAIN') !== false)) { $detect_language = (e_SUBDOMAIN) ? $this->isValid(e_SUBDOMAIN) : $pref['sitelanguage']; // Done in session handler now, based on MULTILANG_SUBDOMAIN value diff --git a/e107_handlers/magpie_rss.php b/e107_handlers/magpie_rss.php index acccb7c84..bbca269ed 100644 --- a/e107_handlers/magpie_rss.php +++ b/e107_handlers/magpie_rss.php @@ -382,7 +382,7 @@ class MagpieRSS { // if atom populate rss fields if ( $this->is_atom() ) { $this->channel['description'] = $this->channel['tagline']; - for ( $i = 0; $i < count($this->items); $i++) { + for ($i = 0, $iMax = count($this->items); $i < $iMax; $i++) { $item = $this->items[$i]; if ( isset($item['summary']) ) $item['description'] = $item['summary']; @@ -402,7 +402,7 @@ class MagpieRSS { } elseif ( $this->is_rss() ) { $this->channel['tagline'] = $this->channel['description']; - for ( $i = 0; $i < count($this->items); $i++) { + for ($i = 0, $iMax = count($this->items); $i < $iMax; $i++) { $item = $this->items[$i]; if ( isset($item['description'])) $item['summary'] = $item['description']; diff --git a/e107_handlers/mail_validation_class.php b/e107_handlers/mail_validation_class.php index 0bcf741de..b147fa25e 100644 --- a/e107_handlers/mail_validation_class.php +++ b/e107_handlers/mail_validation_class.php @@ -33,7 +33,7 @@ class email_validation_class $separator=$string; $string=$this->next_token; } - for($character=0;$charactergetRemoteContent($path); } diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index 9bb219af0..c052e7d2e 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -74,7 +74,7 @@ class e_menu { global $_E107; - if(vartrue($_E107['cli'])) + if(!empty($_E107['cli'])) { return; } @@ -640,7 +640,7 @@ class e_menu $caption = (vartrue($page['menu_icon'])) ? $tp->toIcon($page['menu_icon']) : ''; $caption .= $tp->toHTML($page['menu_title'], true, 'parse_sc, constants'); - if(vartrue($page['menu_template'])) // New v2.x templates. see core/menu_template.php + if(!empty($page['menu_template'])) // New v2.x templates. see core/menu_template.php { $template = e107::getCoreTemplate('menu',$page['menu_template'],true,true); // override and merge required. ie. when menu template is not in the theme, but only in the core. $page_shortcodes = e107::getScBatch('page',null,'cpage'); diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index a9f764b2b..7db14a011 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -566,9 +566,9 @@ class e_menuManager $sql->select("menus", "*", "menu_path NOT REGEXP('[0-9]+') "); while(list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->fetch('num')) { - if(stristr($menustr, $menu_name) === false) + if(stripos($menustr, $menu_name) === false) { - $sql2->db_Delete("menus", "menu_name='$menu_name'"); + $sql2->delete("menus", "menu_name='$menu_name'"); $message .= MENLAN_11 . " - " . $menu_name . "
"; } } @@ -1047,7 +1047,7 @@ class e_menuManager $pagelist = explode("\r\n", $pageList); - for ($i = 0 ; $i < count($pagelist) ; $i++) + for ($i = 0, $iMax = count($pagelist); $i < $iMax; $i++) { $pagelist[$i] = trim($pagelist[$i]); } @@ -1412,7 +1412,7 @@ class e_menuManager // Split up using the same function as the shortcode handler $tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $str = array(); - for($c = 0; $c < count($tmp); $c++) + for($c = 0, $cMax = count($tmp); $c < $cMax; $c++) { @@ -1485,7 +1485,7 @@ class e_menuManager // { // echo $tp->parseTemplate("{LOGO}"); // } - if(strstr($str, "SETSTYLE")) + if(strpos($str, "SETSTYLE") !== false) { $style = preg_replace("/\{SETSTYLE=(.*?)\}/si", "\\1", $str); @@ -1511,7 +1511,7 @@ class e_menuManager // $tp->parseTemplate("{NAVIGATION".$cust."}",true); // echo "Navigation Area"; // } - elseif(strstr($str, '{---MODAL---}')) + elseif(strpos($str, '{---MODAL---}') !== false) { //echo "\n \n"; echo '
'; @@ -1540,29 +1540,29 @@ class e_menuManager //echo getModal(); } - elseif(strstr($str, '{---CAPTION---}')) + elseif(strpos($str, '{---CAPTION---}') !== false) { echo LAN_CAPTION; } - elseif(strstr($str, '{LAYOUT_ID}')) + elseif(strpos($str, '{LAYOUT_ID}') !== false) { echo 'layout-'.e107::getForm()->name2id($this->curLayout); } - elseif(strstr($str, "ALERT")) + elseif(strpos($str, "ALERT") !== false) { echo ''; //echo "[Navigation Area]"; } - elseif(strstr($str, "LANGUAGELINKS")) + elseif(strpos($str, "LANGUAGELINKS") !== false) { echo "
[".LAN_LANGUAGE."]
"; } - elseif(strstr($str, "CUSTOM")) + elseif(strpos($str, "CUSTOM") !== false) { $cust = preg_replace("/\W*\{CUSTOM=(.*?)(\+.*)?\}\W*/si", "\\1", $str); echo "
[" . $cust . "]
"; } - elseif(strstr($str, "CMENU")) + elseif(strpos($str, "CMENU") !== false) { $cust = preg_replace("/\W*\{CMENU=(.*?)(\+.*)?\}\W*/si", "\\1", $str); if(isset($this->customMenu)) @@ -1572,7 +1572,7 @@ class e_menuManager echo $tp->parseTemplate("{CMENU=".$cust."}",true); // echo $this->renderPanel('Embedded Custom Menu',$cust); } - elseif(strstr($str, "SETIMAGE")) + elseif(strpos($str, "SETIMAGE") !== false) { $cust = preg_replace("/\W*\{SETIMAGE(.*?)(\+.*)?\}\W*/si", "\\1", $str); echo $tp->parseTemplate("{SETIMAGE".$cust."}",true); @@ -1583,13 +1583,13 @@ class e_menuManager echo "
[Welcome Message Area]
"; // echo $this->renderPanel('Embedded Custom Menu',$cust); }*/ - elseif(strstr($str, "{FEATUREBOX")) + elseif(strpos($str, "{FEATUREBOX") !== false) { echo "
[".LAN_PLUGIN_FEATUREBOX_NAME."]
"; // echo $this->renderPanel('Embedded Custom Menu',$cust); } // Display embedded Plugin information. - else if(strstr($str, "PLUGIN")) + else if(strpos($str, "PLUGIN") !== false) { $plug = preg_replace("/\{PLUGIN=(.*?)\}/si", "\\1", $str); $plug = trim($plug); @@ -1611,7 +1611,7 @@ class e_menuManager echo $this->renderPanel($plug, $plugtext); // $ns->tablerender($plug, $plugtext); } - else if(strstr($str, "MENU")) + else if(strpos($str, "MENU") !== false) { $matches = array(); diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index 9f4f6088b..21ff6d252 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -1130,7 +1130,7 @@ $SYSTEM_DIRECTORY = "e107_system/"; break; case "MESSAGE": - if(strstr(e_SELF, "forum_post.php")) //FIXME Shouldn't be here. + if(strpos(e_SELF, "forum_post.php") !== false) //FIXME Shouldn't be here. { return; } diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 0b2b8832c..0ce68ac31 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -379,7 +379,7 @@ class e_db_mysql implements e_db { $this->dbg->log($query); } - if ($debug !== FALSE || strstr($_SERVER['QUERY_STRING'], 'showsql')) + if ($debug !== FALSE || strpos($_SERVER['QUERY_STRING'], 'showsql') !== false) { $debugQry = is_array($query) ? print_a($query,true) : $query; $queryinfo[] = "{$qry_from}: ".$debugQry; @@ -1517,7 +1517,7 @@ class e_db_mysql implements e_db foreach($this->mySQLtableList as $tab) { - if(substr($tab,0,4) == "lan_") + if(strpos($tab, "lan_") === 0) { list($tmp,$lng,$tableName) = explode("_",$tab,3); @@ -2215,13 +2215,13 @@ class e_db_mysql implements e_db foreach($this->mySQLtableList as $tab) { - if(substr($tab,0,4)!='lan_') + if(strpos($tab,'lan_') === 0) { - $nolan[] = $tab; + $lan[] = $tab; } else { - $lan[] = $tab; + $nolan[] = $tab; } } diff --git a/e107_handlers/pcltar.lib.php b/e107_handlers/pcltar.lib.php index 393ce4106..d7eb5ee43 100644 --- a/e107_handlers/pcltar.lib.php +++ b/e107_handlers/pcltar.lib.php @@ -1916,7 +1916,7 @@ if (!defined("PCL_TAR")) $v_extract_file = FALSE; // ----- Look into the file list - for ($i=0; $i"; diff --git a/e107_handlers/pclzip.lib.php b/e107_handlers/pclzip.lib.php index 67e5688a6..7ee21cb36 100644 --- a/e107_handlers/pclzip.lib.php +++ b/e107_handlers/pclzip.lib.php @@ -1621,7 +1621,7 @@ class PclZip // ----- Check the format of each item $v_sort_flag = false; $v_sort_value = 0; - for ($j = 0; $j < count($v_work_list); $j++) { + for ($j = 0, $jMax = count($v_work_list); $j < $jMax; $j++) { // ----- Explode the item $v_item_list = explode("-", $v_work_list[$j]); $v_size_item_list = count($v_item_list); @@ -1968,7 +1968,7 @@ class PclZip $v_result_list = array(); // ----- Look each entry - for ($i = 0; $i < count($p_filedescr_list); $i++) { + for ($i = 0, $iMax = count($p_filedescr_list); $i < $iMax; $i++) { // ----- Get filedescr $v_descr = $p_filedescr_list[$i]; @@ -2204,7 +2204,7 @@ class PclZip } // ----- Create the Central Dir files header - for ($i = 0, $v_count = 0; $i < count($v_header_list); $i++) { + for ($i = 0, $v_count = 0, $iMax = count($v_header_list); $i < $iMax; $i++) { // ----- Create the file header if ($v_header_list[$i]['status'] == 'ok') { if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { @@ -2356,7 +2356,7 @@ class PclZip $v_offset = @ftell($this->zip_fd); // ----- Create the Central Dir files header - for ($i = 0, $v_count = 0; $i < count($v_header_list); $i++) { + for ($i = 0, $v_count = 0, $iMax = count($v_header_list); $i < $iMax; $i++) { // ----- Create the file header if ($v_header_list[$i]['status'] == 'ok') { if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { @@ -3174,7 +3174,7 @@ class PclZip if (($p_path != "./") && ($p_path != "/")) { // ----- Look for the path end '/' while (substr($p_path, -1) == "/") { - $p_path = substr($p_path, 0, strlen($p_path) - 1); + $p_path = substr($p_path, 0, -1); } } @@ -3623,7 +3623,7 @@ class PclZip } else { if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) { $v_dir_to_check = $p_entry['filename']; - } elseif (!strstr($p_entry['filename'], "/")) { + } elseif (strpos($p_entry['filename'], "/") === false) { $v_dir_to_check = ""; } else { $v_dir_to_check = dirname($p_entry['filename']); @@ -4613,7 +4613,7 @@ class PclZip } // ----- Look which file need to be kept - for ($i = 0; $i < count($v_header_list); $i++) { + for ($i = 0, $iMax = count($v_header_list); $i < $iMax; $i++) { // ----- Calculate the position of the header @rewind($this->zip_fd); @@ -4675,7 +4675,7 @@ class PclZip $v_offset = @ftell($v_temp_zip->zip_fd); // ----- Re-Create the Central Dir files header - for ($i = 0; $i < count($v_header_list); $i++) { + for ($i = 0, $iMax = count($v_header_list); $i < $iMax; $i++) { // ----- Create the file header if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { $v_temp_zip->privCloseFd(); @@ -4764,7 +4764,7 @@ class PclZip // ----- Remove the final '/' if (($p_is_dir) && (substr($p_dir, -1) == '/')) { - $p_dir = substr($p_dir, 0, strlen($p_dir) - 1); + $p_dir = substr($p_dir, 0, -1); } // ----- Check the directory availability @@ -5401,7 +5401,7 @@ function PclZipUtilOptionText($p_option) // -------------------------------------------------------------------------------- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) { - if (stristr(php_uname(), 'windows')) { + if (stripos(php_uname(), 'windows') !== false) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { $p_path = substr($p_path, $v_position + 1); diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 28a1c8cab..d7e4af4e7 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -2031,7 +2031,7 @@ class e107plugin $field_attrib['applicable'] = varset($field_attrib['applicable'], 'e_UC_MEMBER'); // manage parent - if(vartrue($field_attrib['parent'])) + if(!empty($field_attrib['parent'])) { foreach ($this->module['ue']->catDefinitions as $key => $value) { @@ -2292,7 +2292,7 @@ class e107plugin if ($action == 'remove') { //v2.x - if(vartrue($options['link_owner']) && $sql->select('links', 'link_id', "link_owner = '".$options['link_owner']."'")) + if(!empty($options['link_owner']) && $sql->select('links', 'link_id', "link_owner = '".$options['link_owner']."'")) { return $sql->delete('links', "link_owner = '".$options['link_owner']."' "); } @@ -3497,7 +3497,7 @@ class e107plugin $mes = e107::getMessage(); - if(vartrue($this->options['nolinks'])) + if(!empty($this->options['nolinks'])) { return null; } @@ -3705,7 +3705,7 @@ class e107plugin switch ($function) { case 'install': // Probably best to leave well alone - if(vartrue($tag['bbcodes']['@attributes']['imgResize'])) + if(!empty($tag['bbcodes']['@attributes']['imgResize'])) { e107::getConfig('core')->setPref('resize_dimensions/'.$this->plugFolder."-bbcode", array('w'=>300,'h'=>300)); $this->log('Adding imageResize for: '.$this->plugFolder); @@ -3713,7 +3713,7 @@ class e107plugin break; case 'uninstall': // Probably best to leave well alone - if(vartrue($tag['bbcodes']['@attributes']['imgResize'])) + if(!empty($tag['bbcodes']['@attributes']['imgResize'])) { //e107::getConfig('core')->removePref('resize_dimensions/'.$this->plugFolder); //e107::getConfig('core')->removePref('e_imageresize/'.$this->plugFolder); @@ -3903,7 +3903,7 @@ class e107plugin // $this->log("  Pref: ".$key." => ".$value); - if(substr($value,0,5) == "e_UC_") // Convert Userclass constants. + if(strpos($value,"e_UC_") === 0) // Convert Userclass constants. { $value = constant($value); } @@ -4974,14 +4974,14 @@ class e107plugin $ret['adminLinks']['link'][0]['@attributes']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small); $ret['adminLinks']['link'][0]['@attributes']['primary'] = 'true'; } - if(vartrue($eplug_link) && varset($eplug_link_name) && varset($eplug_link_url)) + if(!empty($eplug_link) && varset($eplug_link_name) && varset($eplug_link_url)) { $ret['siteLinks']['link'][0]['@attributes']['url'] = $tp->createConstants($eplug_link_url, 1); $ret['siteLinks']['link'][0]['@attributes']['perm'] = varset($eplug_link_perms); $ret['siteLinks']['link'][0]['@value'] = varset($eplug_link_name); } - if(vartrue($eplug_userclass) && vartrue($eplug_userclass_description)) + if(!empty($eplug_userclass) && !empty($eplug_userclass_description)) { $ret['userClasses']['class'][0]['@attributes']['name'] = $eplug_userclass; $ret['userClasses']['class'][0]['@attributes']['description'] = $eplug_userclass_description; diff --git a/e107_handlers/rate_class.php b/e107_handlers/rate_class.php index 3f8554b23..897459c90 100644 --- a/e107_handlers/rate_class.php +++ b/e107_handlers/rate_class.php @@ -304,7 +304,7 @@ class rater $rating = array(); $rateusers = explode(".", $rowgr['rate_voters']); - for($i = 0; $i < count($rateusers); $i++) + for($i = 0, $iMax = count($rateusers); $i < $iMax; $i++) { if(strpos($rateusers[$i], $sep)) { diff --git a/e107_handlers/search_class.php b/e107_handlers/search_class.php index 4b7e42f41..e58c9cd1d 100644 --- a/e107_handlers/search_class.php +++ b/e107_handlers/search_class.php @@ -272,7 +272,7 @@ class e_search $this -> text = $row[$field]; foreach ($this -> keywords['match'] as $k_key => $this -> query) { - if (stristr($this -> text, $this -> query) !== FALSE) + if (stripos($this->text, $this->query) !== false) { if ($this -> keywords['exact'][$k_key] || $this -> keywords['boolean'][$k_key]) { diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 390100ebc..f7cf38532 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -291,11 +291,9 @@ class e_parse_shortcode $methods = get_class_methods($class); foreach($methods as $meth) { - if(substr($meth,0,3) == 'sc_') + if(strpos($meth,'sc_') === 0) { $this->addonOverride[$meth] = $class; - - } } } @@ -1005,6 +1003,7 @@ class e_parse_shortcode */ function doCode($matches) { + // e107::getDebug()->log($matches[1]); // print_a($matches); if(in_array($matches[0],$this->ignoreCodes)) // Ignore all {e_PLUGIN}, {THEME} etc. otherwise it will just return blank for these items. diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index bc00b8fad..0121eb3a1 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -52,7 +52,7 @@ class sitelinks else { $this->eLinkList['head_menu'][] = $row; - if(vartrue($row['link_function'])) + if(!empty($row['link_function'])) { $parm = false; list($path,$method) = explode("::",$row['link_function']); @@ -67,7 +67,7 @@ class sitelinks { $class = $path."_sitelink"; $sublinkArray = e107::callMethod($class,$method,$parm); //TODO Cache it. - if(vartrue($sublinkArray)) + if(!empty($sublinkArray)) { $this->eLinkList['sub_'.$row['link_id']] = $sublinkArray; } @@ -312,7 +312,7 @@ class sitelinks $style['linkclass_hilite'] = ""; } - if(vartrue($linkInfo['link_sefurl']) && !empty($linkInfo['link_owner'])) + if(!empty($linkInfo['link_sefurl']) && !empty($linkInfo['link_owner'])) { $linkInfo['link_url'] = e107::url($linkInfo['link_owner'],$linkInfo['link_sefurl']) ; // $linkInfo['link_sefurl']; } @@ -322,7 +322,7 @@ class sitelinks // If submenu: Fix Name, Add Indentation. if ($submenu == true) { - if(substr($linkInfo['link_name'],0,8) == "submenu.") + if(strpos($linkInfo['link_name'], 'submenu.') === 0) { $tmp = explode('.', $linkInfo['link_name'], 3); $linkInfo['link_name'] = $tmp[2]; @@ -525,7 +525,7 @@ class sitelinks } // --------------- highlighting for plugins. ---------------- - if(stristr($link, $PLUGINS_DIRECTORY) !== FALSE && stristr($link, "custompages") === FALSE) + if(stripos($link, $PLUGINS_DIRECTORY) !== false && stripos($link, "custompages") === false) { if($link_qry) { // plugin links with queries @@ -534,7 +534,7 @@ class sitelinks else { // plugin links without queries $link = str_replace("../", "", $link); - if(stristr(dirname(e_SELF), dirname($link)) !== FALSE) + if(stripos(dirname(e_SELF), dirname($link)) !== false) { return TRUE; } @@ -786,7 +786,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } $this->admin_cat['lrg_img'][5] = $tp->toGlyph('e-manage-32'); $this->admin_cat['sort'][5] = TRUE; - if(vartrue($pref['admin_separate_plugins'])) + if(!empty($pref['admin_separate_plugins'])) { $this->admin_cat['title'][6] = ADLAN_CL_7; $this->admin_cat['id'][6] = 'plugMenu'; @@ -1446,7 +1446,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } $replace['LINK_CLASS'] = varset($e107_vars[$act]['link_class']); $replace['SUB_CLASS'] = ''; - if(vartrue($e107_vars[$act]['image_src']) && strstr($e107_vars[$act]['image_src'],'.glyph')) + if(!empty($e107_vars[$act]['image_src']) && strpos($e107_vars[$act]['image_src'], '.glyph') !== false) { $replace['LINK_IMAGE'] = $tp->toGlyph($e107_vars[$act]['image_src'], array('space'=>' ')); } diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index a0144ed55..1ba36701b 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -622,14 +622,14 @@ class e_theme $themeArray[$file]['files'][] = $file2; - if(strstr($file2, "preview.")) + if(strpos($file2, "preview.") !== false) { $themeArray[$file]['preview'] = e_THEME.$file."/".$file2; } // ---------------- get information string for css file - Legacy mode (no theme.xml) - if(strstr($file2, ".css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0) + if(strpos($file2, ".css") !== false && strpos($file2, "menu.css") === false && strpos($file2, "e_") !== 0) { if($cssContents = file_get_contents(e_THEME.$file."/".$file2)) { @@ -741,7 +741,7 @@ class e_theme { foreach ($themeContentsArray as $line) { - if(strstr($line, "CUSTOMPAGES")) + if(strpos($line, "CUSTOMPAGES") !== false) { try { @@ -1147,7 +1147,7 @@ class themeHandler foreach ($_POST as $key=>$post) { - if(strstr($key, "preview")) + if(strpos($key, "preview") !== false) { // $this -> id = str_replace("preview_", "", $key); $this->id = key($post); @@ -1168,7 +1168,7 @@ class themeHandler } }*/ - if(strstr($key, "selectadmin")) + if(strpos($key, "selectadmin") !== false) { $this->id = key($post); $this->setAdminTheme(); @@ -1304,14 +1304,14 @@ class themeHandler $themeArray[$file]['files'][] = $file2; - if(strstr($file2, "preview.")) + if(strpos($file2, "preview.") !== false) { $themeArray[$file]['preview'] = e_THEME.$file."/".$file2; } // ---------------- get information string for css file - Legacy mode (no theme.xml) - if(strstr($file2, ".css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0) + if(strpos($file2, ".css") !== false && strpos($file2, "menu.css") === false && strpos($file2, "e_") !== 0) { if($cssContents = file_get_contents(e_THEME.$file."/".$file2)) { @@ -1555,7 +1555,7 @@ class themeHandler $mp = $this->getMarketplace(); $from = intval(varset($_GET['frm'])); $limit = 96; // FIXME - ajax pages load - $srch = preg_replace('/[^\w]/','', vartrue($_GET['srch'])); + $srch = preg_replace('/[\W]/','', vartrue($_GET['srch'])); // check for cURL if(!function_exists('curl_init')) @@ -2212,7 +2212,7 @@ class themeHandler $price = ''; - if(substr($theme['thumbnail'],0,4) == 'http') + if(strpos($theme['thumbnail'],'http') === 0) { $thumbPath = $theme['thumbnail']; $previewPath = $theme['preview'][0]; diff --git a/e107_handlers/upload_handler.php b/e107_handlers/upload_handler.php index 7f193d0b2..5a530b577 100644 --- a/e107_handlers/upload_handler.php +++ b/e107_handlers/upload_handler.php @@ -631,7 +631,7 @@ function get_image_mime($filename, $extended = false) // Otherwise, it could be in the supplementary list $tmp = explode(',', $unknown); - for($i = 0; $i < count($tmp); $i++) + for($i = 0, $iMax = count($tmp); $i < $iMax; $i++) { $tmp[$i] = strtolower(trim(str_replace('.', '', $tmp[$i]))); } diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index 0ac89baee..cd299ca9a 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -1966,12 +1966,12 @@ class e_userperms $ret['core'] = $this->core_perms; $ret['plugin'] = $this->plugin_perms; - if(vartrue($this->language_perms)) + if(!empty($this->language_perms)) { $ret['language'] = $this->language_perms; } - if(vartrue($this->main_perms)) + if(!empty($this->main_perms)) { $ret['main'] = $this->main_perms; } diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index 7e63f5b33..c9763f401 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -1322,13 +1322,13 @@ class e_system_user extends e_user_model break; case 'notify': - if(vartrue($userInfo['mail_body'])) $template = $userInfo['mail_body']; //$NOTIFY_HEADER.$userInfo['mail_body'].$NOTIFY_FOOTER; + if(!empty($userInfo['mail_body'])) $template = $userInfo['mail_body']; //$NOTIFY_HEADER.$userInfo['mail_body'].$NOTIFY_FOOTER; $ret['template'] = 'notify'; break; case 'email': case 'default': - if(vartrue($userInfo['mail_body'])) $template = $userInfo['mail_body']; //$EMAIL_HEADER.$userInfo['mail_body'].$EMAIL_FOOTER; + if(!empty($userInfo['mail_body'])) $template = $userInfo['mail_body']; //$EMAIL_HEADER.$userInfo['mail_body'].$EMAIL_FOOTER; $ret['template'] = 'default'; break; } @@ -1400,7 +1400,7 @@ class e_system_user extends e_user_model } $HEAD .= "\n"; - if(vartrue($SIGNUPEMAIL_BACKGROUNDIMAGE)) // @deprecated. + if(!empty($SIGNUPEMAIL_BACKGROUNDIMAGE)) // @deprecated. { $HEAD .= "\n"; } diff --git a/e107_handlers/validator_class.php b/e107_handlers/validator_class.php index accf7e1b3..71548c311 100644 --- a/e107_handlers/validator_class.php +++ b/e107_handlers/validator_class.php @@ -628,12 +628,12 @@ class e_validator $this->addValidateResult($name, self::ERR_NOT_FILE); return false; } - if(vartrue($params['writable']) && !is_writable($path)) + if(!empty($params['writable']) && !is_writable($path)) { $this->addValidateResult($name, self::ERR_WRITABLE_FILE); return false; } - if(vartrue($params['size'])) + if(!empty($params['size'])) { $tmp = $this->parseMinMax($cond); $fs = filesize($path); @@ -1273,7 +1273,7 @@ class validatorClass { // Exact match search (noticed with exclamation mark in the end of the word) $errMsg = ERR_DISALLOWED_TEXT_EXACT_MATCH; } - elseif(stristr($v, trim($disallow))) + elseif(stripos($v, trim($disallow)) !== false) { // Wild card search $errMsg = ERR_DISALLOWED_TEXT; } diff --git a/e107_plugins/blogcalendar_menu/archive.php b/e107_plugins/blogcalendar_menu/archive.php index 695295f7b..80eea7de0 100644 --- a/e107_plugins/blogcalendar_menu/archive.php +++ b/e107_plugins/blogcalendar_menu/archive.php @@ -45,7 +45,7 @@ $pref['blogcal_ws'] = "monday"; $cur_year = date("Y"); $cur_month = date("n"); $cur_day = date("j"); -if (strstr(e_QUERY, "year")) +if (strpos(e_QUERY, "year") !== false) { $tmp = explode(".", e_QUERY); if (is_numeric($tmp[1])) diff --git a/e107_plugins/blogcalendar_menu/blogcalendar_menu.php b/e107_plugins/blogcalendar_menu/blogcalendar_menu.php index 50d2bc3c4..8ae79dbc9 100644 --- a/e107_plugins/blogcalendar_menu/blogcalendar_menu.php +++ b/e107_plugins/blogcalendar_menu/blogcalendar_menu.php @@ -45,7 +45,7 @@ if(false === $cached) // get the requested and current date information // ---------------------------------------------- list($cur_year, $cur_month, $cur_day) = explode(" ", date("Y n j")); - if (e_PAGE == 'news.php' && strstr(e_QUERY, "day")) + if (e_PAGE == 'news.php' && strpos(e_QUERY, "day") !== false) { $tmp = explode(".", e_QUERY); // Core now support legacy queries - use just the old way @@ -67,7 +67,7 @@ if(false === $cached) $req_day = ""; } } - elseif(e_PAGE == 'news.php' && strstr(e_QUERY, "month")) + elseif(e_PAGE == 'news.php' && strpos(e_QUERY, "month") !== false) { $tmp = explode(".", e_QUERY); // Core now support legacy queries - use just the old way diff --git a/e107_plugins/chatbox_menu/chat.php b/e107_plugins/chatbox_menu/chat.php index d5123986d..2c62bae79 100755 --- a/e107_plugins/chatbox_menu/chat.php +++ b/e107_plugins/chatbox_menu/chat.php @@ -87,7 +87,7 @@ if ( ! empty($_POST['moderate']) && CB_MOD) { $fs = false; -if (strstr(e_QUERY, "fs")) { +if (strpos(e_QUERY, "fs") !== false) { $cgtm = intval(str_replace(".fs", "", e_QUERY)); $fs = true; } diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index 639eb934a..d27cfb95d 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -1113,7 +1113,7 @@ class download_shortcodes extends e_shortcode private function renderNewIcon() { - if(strstr(IMAGE_NEW,'parseTemplate($row['download_url'],true); // support for shortcode-driven dynamic URLS. e107::redirect(decorate_download_location($download_url)); diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 13e435be3..01e5cfd08 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -1636,7 +1636,7 @@ class forum_post_handler $_thumb = ''; $_fname = ''; $fpath = ''; - if(strstr($upload['type'], 'image')) + if(strpos($upload['type'], 'image') !== false) { $_type = 'img'; diff --git a/e107_plugins/import/admin_import.php b/e107_plugins/import/admin_import.php index e28e7bd7b..fa3445660 100644 --- a/e107_plugins/import/admin_import.php +++ b/e107_plugins/import/admin_import.php @@ -1541,7 +1541,7 @@ function csv_split(&$data,$delim=',',$enveloper='') $enclosed = false; // $fldcount=0; // $linecount=0; - for($i=0;$irow['HELP'] = LIST_ADMIN_SECT_3; $this->row['CONTID'] = "list-new-{$type}-expandable-sections"; $this->row['FIELD'] = ""; - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD'] .= $rs->form_checkbox($this->parent->sections[$i]."_".$type."_display", 1, (vartrue($this->parent->list_pref[$this->parent->sections[$i]."_".$type."_display"]) ? "1" : "0"))." ".$this->parent->titles[$i]."
"; } @@ -127,7 +127,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_6; $this->row['CONTID'] = "list-new-{$type}-expandable-display-style"; $this->row['FIELD'] = ""; - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD'] .= $rs->form_checkbox($this->parent->sections[$i]."_".$type."_open", 1, (vartrue($this->parent->list_pref[$this->parent->sections[$i]."_".$type."_open"]) ? "1" : "0"))." ".$this->parent->titles[$i]."
"; } @@ -139,7 +139,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_9; $this->row['CONTID'] = "list-new-{$type}-expandable-author"; $this->row['FIELD'] = ""; - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD'] .= $rs->form_checkbox($this->parent->sections[$i]."_".$type."_author", 1, (vartrue($this->parent->list_pref[$this->parent->sections[$i]."_".$type."_author"]) ? "1" : "0"))." ".$this->parent->titles[$i]."
"; } @@ -151,7 +151,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_12; $this->row['FIELD'] = ""; $this->row['CONTID'] = "list-new-{$type}-expandable-category"; - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD'] .= $rs->form_checkbox($this->parent->sections[$i]."_".$type."_category", 1, (vartrue($this->parent->list_pref[$this->parent->sections[$i]."_".$type."_category"]) ? "1" : "0"))." ".$this->parent->titles[$i]."
"; } @@ -163,7 +163,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_15; $this->row['FIELD'] = ""; $this->row['CONTID'] = "list-new-{$type}-expandable-date"; - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD'] .= $rs->form_checkbox($this->parent->sections[$i]."_".$type."_date", 1, (vartrue($this->parent->list_pref[$this->parent->sections[$i]."_".$type."_date"]) ? "1" : "0"))." ".$this->parent->titles[$i]."
"; } @@ -178,7 +178,7 @@ class list_admin $iconlist = $fl->get_files($this->parent->plugin_dir."images/"); $frm = e107::getForm(); - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $name = $this->parent->sections[$i]."_".$type."_icon"; $curVal = $this->parent->list_pref[$this->parent->sections[$i]."_".$type."_icon"]; @@ -210,7 +210,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_18; $this->row['CONTID'] = "list-new-{$type}-expandable-amount"; $this->row['FIELD'] = $this->parseTemplate('FIELD_TABLE_START'); - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD_TITLE'] = $this->parent->titles[$i]; $this->row['FIELD_ITEM'] = $rs->form_select_open($this->parent->sections[$i]."_".$type."_amount"); @@ -231,7 +231,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_21; $this->row['CONTID'] = "list-new-{$type}-expandable-order"; $this->row['FIELD'] = $this->parseTemplate('FIELD_TABLE_START'); - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD_TITLE'] = $this->parent->titles[$i]; $this->row['FIELD_ITEM'] = $rs->form_select_open($this->parent->sections[$i]."_".$type."_order"); @@ -251,7 +251,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_SECT_27; $this->row['CONTID'] = "list-new-{$type}-expandable-caption"; $this->row['FIELD'] = $this->parseTemplate('FIELD_TABLE_START'); - for($i=0;$iparent->sections);$i++) + for($i=0, $iMax = count($this->parent->sections); $i< $iMax; $i++) { $this->row['FIELD_TITLE'] = $this->parent->titles[$i]; $this->row['FIELD_ITEM'] = $rs->form_text($this->parent->sections[$i]."_".$type."_caption", 30, e107::getParser()->toHTML($this->parent->list_pref[$this->parent->sections[$i]."_".$type."_caption"],"","defs"), "50", "tbox"); @@ -472,7 +472,7 @@ class list_admin $this->row['HELP'] = LIST_ADMIN_LAN_22; $this->row['CONTID'] = "list-new-page-{$type}-expandable-colomn"; $this->row['FIELD'] = $rs->form_select_open($type."_colomn"); - for($a=1; $a<=count($this->parent->sections); $a++) + for($a=1, $aMax = count($this->parent->sections); $a<= $aMax; $a++) { $this->row['FIELD'] .= ($this->parent->list_pref[$type."_colomn"] == $a ? $rs->form_option($a, 1, $a) : $rs->form_option($a, 0, $a)); } diff --git a/e107_plugins/list_new/list_class.php b/e107_plugins/list_new/list_class.php index cf94b2b58..e62c53c77 100644 --- a/e107_plugins/list_new/list_class.php +++ b/e107_plugins/list_new/list_class.php @@ -165,7 +165,7 @@ class listclass function prepareSectionArray($mode) { //section reference - for($i=0;$isections);$i++) + for($i=0, $iMax = count($this->sections); $i< $iMax; $i++) { $s = $this->sections[$i]; if(vartrue($this->list_pref[$s."_".$mode."_display"]) == '1') @@ -200,7 +200,7 @@ class listclass function getDefaultSections() { //default always present sections - for($i=0;$idefaultArray);$i++) + for($i=0, $iMax = count($this->defaultArray); $i< $iMax; $i++) { $this->sections[] = $this->defaultArray[$i]; $this->titles[] = $this->defaultArray[$i]; @@ -293,7 +293,7 @@ class listclass $prf = array(); //section preferences - for($i=0;$isections);$i++) + for($i=0, $iMax = count($this->sections); $i< $iMax; $i++) { $s = $this->sections[$i]; if(!in_array($this->sections[$i], $this->defaultArray)) diff --git a/e107_plugins/log/admin_config.php b/e107_plugins/log/admin_config.php index 462ae9cff..1c4da02e1 100644 --- a/e107_plugins/log/admin_config.php +++ b/e107_plugins/log/admin_config.php @@ -623,7 +623,7 @@ e107::css('inline', 'td.last.options { padding-right:20px } '); $info['url'] = preg_replace("/(\s)|(\')|(\")|(eself)|( )/", "", $info['url']); $info['url'] = str_replace("\\", "", $info['url']); $page = trim($page); - if($page && !strstr($page, "cache") && !strstr($page, "file:")) + if($page && strpos($page, "cache") === false && strpos($page, "file:") === false) { if($loop){ $data .= ",\n"; } $data .= $quote.$page.$quote." => array('url' => '".$info['url']."', 'ttl' => ".$info['ttl'].", 'unq' => ".$info['unq'].")"; diff --git a/e107_plugins/log/consolidate.php b/e107_plugins/log/consolidate.php index 37730a852..6f0800a7d 100644 --- a/e107_plugins/log/consolidate.php +++ b/e107_plugins/log/consolidate.php @@ -536,7 +536,7 @@ class logConsolidate if($vars = $this->splitRawBackupLine($buffer)) { - if(substr($vars['eself'],0,7) == 'file://') + if(strpos($vars['eself'],'file://') === 0) { continue; } diff --git a/e107_plugins/log/log.php b/e107_plugins/log/log.php index 9bc4f5f60..21ea04316 100644 --- a/e107_plugins/log/log.php +++ b/e107_plugins/log/log.php @@ -152,7 +152,7 @@ if ($err_code = strip_tags((isset($vals['err_direct']) ? $vals['err_direct'] : ' $err_code .= ':'; } -if(strstr($ref, 'admin')) +if(strpos($ref, 'admin') !== false) { $ref = FALSE; } @@ -162,7 +162,7 @@ $agent = $_SERVER['HTTP_USER_AGENT']; $ip = e107::getIPHandler()->ipDecode(USERIP); $oldref = $ref; // backup for search string being stripped off for referer -if($ref && !strstr($ref, $_SERVER['HTTP_HOST'])) +if($ref && strpos($ref, $_SERVER['HTTP_HOST']) === false) { if(preg_match("#http://(.*?)($|/)#is", $ref, $match)) { @@ -262,7 +262,7 @@ else -if(!strstr($ipAddresses, $ip)) +if(strpos($ipAddresses, $ip) === false) { /* unique visit */ if(!$flag) { diff --git a/e107_plugins/log/loginfo.php b/e107_plugins/log/loginfo.php index aecba6a22..e8bc866db 100644 --- a/e107_plugins/log/loginfo.php +++ b/e107_plugins/log/loginfo.php @@ -63,7 +63,7 @@ else } /* referer data ... */ -if($ref && !strstr($ref, $_SERVER['HTTP_HOST'])) +if($ref && strpos($ref, $_SERVER['HTTP_HOST']) === false) { if(preg_match("#http://(.*?)($|/)#is", $ref, $match)) { @@ -97,7 +97,7 @@ if(preg_match("#q=(.*?)($|&)#is", $oldref, $match)) if ($tmp = gethostbyaddr(getenv('REMOTE_ADDR'))) { $host = trim(strtolower(substr($tmp, strrpos($tmp, ".")+1))); - if(!is_numeric($host) && !strstr($host, "calhost")) + if(!is_numeric($host) && strpos($host, "calhost") === false) { if(array_key_exists($host, $domainInfo)) { @@ -303,7 +303,7 @@ function getOs($agent) { if (preg_match("#".$info['rule']."#i", $agent, $results)) { - if(strstr($key, "win")) + if(strpos($key, "win") !== false) { return ($info['name']); } diff --git a/e107_plugins/log/stats.php b/e107_plugins/log/stats.php index 4b877f369..6f0c6a9c8 100644 --- a/e107_plugins/log/stats.php +++ b/e107_plugins/log/stats.php @@ -1113,7 +1113,7 @@ class siteStats $image = ""; foreach ($this->browser_map as $name => $file) { - if(strstr($key, $name)) + if(strpos($key, $name) !== false) { $image = "{$file}.png"; break; @@ -1249,17 +1249,17 @@ class siteStats foreach($osArray as $key => $info) { $image = ""; - if(strstr($key, "Windows")) { $image = "windows.png"; } - elseif(strstr($key, "Mac")) { $image = "mac.png"; } - elseif(strstr($key, "Linux")) { $image = "linux.png"; } - elseif(strstr($key, "BeOS")) { $image = "beos.png"; } - elseif(strstr($key, "FreeBSD")) { $image = "freebsd.png"; } - elseif(strstr($key, "NetBSD")) { $image = "netbsd.png"; } - elseif(strstr($key, "Unspecified")) { $image = "unspecified.png"; } - elseif(strstr($key, "OpenBSD")) { $image = "openbsd.png"; } - elseif(strstr($key, "Unix")) { $image = "unix.png"; } - elseif(strstr($key, "Spiders")) { $image = "spiders.png"; } - elseif(stristr($key, "Android")) { $image = "android.png"; } + if(strpos($key, "Windows") !== false) { $image = "windows.png"; } + elseif(strpos($key, "Mac") !== false) { $image = "mac.png"; } + elseif(strpos($key, "Linux") !== false) { $image = "linux.png"; } + elseif(strpos($key, "BeOS") !== false) { $image = "beos.png"; } + elseif(strpos($key, "FreeBSD") !== false) { $image = "freebsd.png"; } + elseif(strpos($key, "NetBSD") !== false) { $image = "netbsd.png"; } + elseif(strpos($key, "Unspecified") !== false) { $image = "unspecified.png"; } + elseif(strpos($key, "OpenBSD") !== false) { $image = "openbsd.png"; } + elseif(strpos($key, "Unix") !== false) { $image = "unix.png"; } + elseif(strpos($key, "Spiders") !== false) { $image = "spiders.png"; } + elseif(stripos($key, "Android") !== false) { $image = "android.png"; } $percentage = round(($info/$total) * 100, 2); $var = array( @@ -1451,7 +1451,7 @@ class siteStats { foreach($screenArray as $key => $info) { - if(strstr($key, "@") && !strstr($key, "undefined") && preg_match("/(\d+)x(\d+)@(\d+)/", $key)) + if(strpos($key, "@") !== false && strpos($key, "undefined") === false && preg_match("/(\d+)x(\d+)@(\d+)/", $key)) { $percentage = round(($info/$total) * 100, 2); $var = array( @@ -1771,7 +1771,7 @@ class siteStats if($entry) { list($url, $total, $unique) = explode("|", $entry); - if(strstr($url, "/")) + if(strpos($url, "/") !== false) { $urlname = preg_replace("/\.php|\?.*/", "", substr($url, (strrpos($url, "/")+1))); } diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 0c8e117f5..6acf2a1ac 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -1050,7 +1050,7 @@ class news_front } else // No News - empty. { - $text .= "
".(strstr(e_QUERY, "month") ? LAN_NEWS_462 : LAN_NEWS_83)."
"; + $text .= "
".(strpos(e_QUERY, "month") !== false ? LAN_NEWS_462 : LAN_NEWS_83)."
"; } if(!empty($template['end'])) @@ -1939,7 +1939,7 @@ if(is_dir("remotefile")) { $crem = $file -> get_files(e_BASE."remotefile", '~Readme\.txt'); if(count($crem)) { foreach($crem as $loadrem) { - if(strstr($loadrem['fname'], "load_")) { + if(strpos($loadrem['fname'], "load_") !== false) { require_once(e_BASE."remotefile/".$loadrem['fname']); } } diff --git a/e107_plugins/news/news_months_menu.php b/e107_plugins/news/news_months_menu.php index 3ea568f5b..66dadfd79 100644 --- a/e107_plugins/news/news_months_menu.php +++ b/e107_plugins/news/news_months_menu.php @@ -71,7 +71,7 @@ if(false === $cached) } $req_year = $cur_year; - if(e_PAGE == 'news.php' && strstr(e_QUERY, "month")) + if(e_PAGE == 'news.php' && strpos(e_QUERY, "month") !== false) { $tmp = explode('.', e_QUERY); $item = $tmp[1]; diff --git a/e107_plugins/online/online_shortcodes.php b/e107_plugins/online/online_shortcodes.php index a87556311..9a2d95275 100644 --- a/e107_plugins/online/online_shortcodes.php +++ b/e107_plugins/online/online_shortcodes.php @@ -231,17 +231,17 @@ class online_shortcodes extends e_shortcode $pinfo = 'download.php'; $online_location_page = 'download'; } - elseif (strstr($online_location_page, 'forum')) + elseif (strpos($online_location_page, 'forum') !== false) { $pinfo = e_PLUGIN.'forum/forum.php'; $online_location_page = 'forum'; } - elseif (strstr($online_location_page, 'content')) + elseif (strpos($online_location_page, 'content') !== false) { $pinfo = 'content.php'; $online_location_page = 'content'; } - elseif (strstr($online_location_page, 'comment')) + elseif (strpos($online_location_page, 'comment') !== false) { $pinfo = 'comment.php'; $online_location_page = 'comment'; @@ -325,7 +325,7 @@ class online_shortcodes extends e_shortcode $ADMIN_DIRECTORY = e107::getFolder('admin'); $pinfo = (isset($currentMember['pinfo'])) ? $currentMember['pinfo'] : ''; - return !strstr($pinfo, $ADMIN_DIRECTORY) ? + return strpos($pinfo, $ADMIN_DIRECTORY) === false ? "".$currentMember['page']."" : $currentMember['page']; } diff --git a/e107_plugins/pm/pm_class.php b/e107_plugins/pm/pm_class.php index 3a24ceba0..1cf614dd4 100755 --- a/e107_plugins/pm/pm_class.php +++ b/e107_plugins/pm/pm_class.php @@ -858,7 +858,7 @@ class private_message if (connection_status() == 0) { - if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { + if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== false) { $file = preg_replace('/\./', '%2e', $file, substr_count($file, '.') - 1); } if (isset($_SERVER['HTTP_RANGE'])) diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index e34b56952..075ac4634 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -47,7 +47,7 @@ class poll foreach($_COOKIE as $cookie_name => $cookie_val) { // Collect poll cookies - if(substr($cookie_name,0,5) == 'poll_') + if(strpos($cookie_name,'poll_') === 0) { // e107::getDebug()->log("Poll: ".$cookie_name); list($str, $int) = explode('_', $cookie_name, 2); @@ -62,7 +62,7 @@ class poll if (count($arr_polls_cookies) > 1) { // Remove all except first (assumption: there is always only one active poll) rsort($arr_polls_cookies); - for($i = 1; $i < count($arr_polls_cookies); $i++) + for($i = 1, $iMax = count($arr_polls_cookies); $i < $iMax; $i++) { cookie("poll_{$arr_polls_cookies[$i]}", "", (time() - 2592000)); } @@ -175,7 +175,7 @@ class poll else { $votes = ''; - for($a=1; $a<=count($_POST['poll_option']); $a++) + for($a=1, $aMax = count($_POST['poll_option']); $a<= $aMax; $a++) { $votes .= '0'.chr(1); } @@ -516,7 +516,7 @@ class poll case 'voted': case 'results' : - if ($pollArray['poll_result_type'] && !strstr(e_SELF, "comment.php")) + if ($pollArray['poll_result_type'] && strpos(e_SELF, "comment.php") === false) { $text = "


".LAN_THANK_YOU."

".POLLAN_40."


"; } diff --git a/e107_plugins/rss_menu/rss.php b/e107_plugins/rss_menu/rss.php index 95cb5e56a..9d5a2be6f 100644 --- a/e107_plugins/rss_menu/rss.php +++ b/e107_plugins/rss_menu/rss.php @@ -455,7 +455,7 @@ class rssCreate break; case 2: // RSS 2.0 - $sitebutton = (strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON)); + $sitebutton = (strpos(SITEBUTTON, "http:") !== false ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON)); echo " @@ -494,7 +494,7 @@ class rssCreate echo " ".$tp->toRss($rss_title)." - ".(strstr(SITEBUTTON, "http:")!==FALSE ? SITEBUTTON : SITEURL.str_replace("../", "",SITEBUTTON))." + ".(strpos(SITEBUTTON, "http:") !== false ? SITEBUTTON : SITEURL.str_replace("../", "",SITEBUTTON))." ".$pref['siteurl']." 88 31 @@ -680,7 +680,7 @@ class rssCreate e107\n"; ///icon.jpg\n echo " - ".(strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON))."\n + ".(strpos(SITEBUTTON, "http:") !== false ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON))."\n ".$pref['siteadmin']." - ".$this->nospam($pref['siteadminemail'])."\n"; if($pref['sitedescription']){ echo " diff --git a/e107_plugins/search_menu/search_menu.php b/e107_plugins/search_menu/search_menu.php index cd0dbdcea..f33d61b6e 100644 --- a/e107_plugins/search_menu/search_menu.php +++ b/e107_plugins/search_menu/search_menu.php @@ -19,25 +19,25 @@ if (!defined('e107_INIT')) { exit; } // include_lan(e_PLUGIN."search_menu/languages/".e_LANGUAGE.".php"); -if (strstr(e_PAGE, "news.php")) { +if (strpos(e_PAGE, "news.php") !== false) { $page = 0; -} elseif(strstr(e_PAGE, "comment.php")) { +} elseif(strpos(e_PAGE, "comment.php") !== false) { $page = 1; -} elseif(strstr(e_PAGE, "content.php") && strstr(e_QUERY, "content")) { +} elseif(strpos(e_PAGE, "content.php") !== false && strpos(e_QUERY, "content") !== false) { $page = 2; -} elseif(strstr(e_PAGE, "content.php") && strstr(e_QUERY, "review")) { +} elseif(strpos(e_PAGE, "content.php") !== false && strpos(e_QUERY, "review") !== false) { $page = 3; -} elseif(strstr(e_PAGE, "content.php") && strstr(e_QUERY, "content")) { +} elseif(strpos(e_PAGE, "content.php") !== false && strpos(e_QUERY, "content") !== false) { $page = 4; -} elseif(strstr(e_PAGE, "chat.php")) { +} elseif(strpos(e_PAGE, "chat.php") !== false) { $page = 5; -} elseif(strstr(e_PAGE, "links.php")) { +} elseif(strpos(e_PAGE, "links.php") !== false) { $page = 6; -} elseif(strstr(e_PAGE, "forum")) { +} elseif(strpos(e_PAGE, "forum") !== false) { $page = 7; -} elseif(strstr(e_PAGE, "user.php") || strstr(e_PAGE, "usersettings.php")) { +} elseif(strpos(e_PAGE, "user.php") !== false || strpos(e_PAGE, "usersettings.php") !== false) { $page = 8; -} elseif(strstr(e_PAGE, "download.php")) { +} elseif(strpos(e_PAGE, "download.php") !== false) { $page = 9; } else { $page = 99; diff --git a/e107_plugins/siteinfo/e_shortcode.php b/e107_plugins/siteinfo/e_shortcode.php index 8b150c410..fc9507be6 100644 --- a/e107_plugins/siteinfo/e_shortcode.php +++ b/e107_plugins/siteinfo/e_shortcode.php @@ -17,7 +17,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin. } else { - $path = (strstr(SITEBUTTON, 'http:') ? SITEBUTTON : e_IMAGE.SITEBUTTON); + $path = (strpos(SITEBUTTON, 'http:') !== false ? SITEBUTTON : e_IMAGE.SITEBUTTON); } if($parm['type'] == 'email' || $parm == 'email') // (retain {} constants ) diff --git a/e107_plugins/siteinfo/sitebutton_menu.php b/e107_plugins/siteinfo/sitebutton_menu.php index d1a451769..af6a7c97f 100644 --- a/e107_plugins/siteinfo/sitebutton_menu.php +++ b/e107_plugins/siteinfo/sitebutton_menu.php @@ -17,7 +17,7 @@ if (!defined('e107_INIT')) { exit; } // echo "parm=".$parm; //FIXME - just for testing only. -if(strstr(SITEBUTTON, "://")) // external url. +if(strpos(SITEBUTTON, "://") !== false) // external url. { $path = SITEBUTTON; } diff --git a/e107_plugins/tinymce4/wysiwyg.php b/e107_plugins/tinymce4/wysiwyg.php index 887f918dc..5b06b3088 100644 --- a/e107_plugins/tinymce4/wysiwyg.php +++ b/e107_plugins/tinymce4/wysiwyg.php @@ -122,7 +122,7 @@ define('USE_GZIP', true); $compression_browser_support = false; $compression_server_support = false; -if(strstr(varset($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip')) +if(strpos(varset($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== false) { $compression_browser_support = true; } diff --git a/e107_plugins/trackback/trackbackClass.php b/e107_plugins/trackback/trackbackClass.php index dfbf012ba..6f7582f06 100644 --- a/e107_plugins/trackback/trackbackClass.php +++ b/e107_plugins/trackback/trackbackClass.php @@ -30,7 +30,7 @@ class trackbackClass $permLink = urlencode(stripslashes($e107->base_path.$permLink)); $query_string = "title=".$title."&url=".$permLink."&blog_name=".$blog_name."&excerpt=".$excerpt; - if (strstr($pingUrl, '?')) + if (strpos($pingUrl, '?') !== false) { $pingUrl .= "&".$query_string; $fp = fopen($pingUrl, 'r'); @@ -80,7 +80,7 @@ class trackbackClass } - if(strstr($response, "0")) + if(strpos($response, "0") !== false) { return FALSE; } diff --git a/e107_plugins/user/e_dashboard.php b/e107_plugins/user/e_dashboard.php index c74fa4f42..630b6cbba 100644 --- a/e107_plugins/user/e_dashboard.php +++ b/e107_plugins/user/e_dashboard.php @@ -141,7 +141,7 @@ class user_dashboard // plugin-folder + '_url' if($entry) { list($url, $total, $unique) = explode("|", $entry); - if(strstr($url, "/")) + if(strpos($url, "/") !== false) { $urlname = preg_replace("/\.php|\?.*/", "", substr($url, (strrpos($url, "/")+1))); } diff --git a/e107_tests/composer.lock b/e107_tests/composer.lock index 8f95ce0fd..ec4dac1c6 100644 --- a/e107_tests/composer.lock +++ b/e107_tests/composer.lock @@ -72,16 +72,16 @@ }, { "name": "codeception/codeception", - "version": "4.1.12", + "version": "4.1.13", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "fc550bf6e90d69fbfc8ab7e9e0a330ac98ffafdd" + "reference": "e817f83fe019ed3f9c280254b88f90cc70c3d7cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/fc550bf6e90d69fbfc8ab7e9e0a330ac98ffafdd", - "reference": "fc550bf6e90d69fbfc8ab7e9e0a330ac98ffafdd", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/e817f83fe019ed3f9c280254b88f90cc70c3d7cf", + "reference": "e817f83fe019ed3f9c280254b88f90cc70c3d7cf", "shasum": "" }, "require": { @@ -155,7 +155,7 @@ ], "support": { "issues": "https://github.com/Codeception/Codeception/issues", - "source": "https://github.com/Codeception/Codeception/tree/4.1.12" + "source": "https://github.com/Codeception/Codeception/tree/4.1.13" }, "funding": [ { @@ -163,7 +163,7 @@ "type": "open_collective" } ], - "time": "2020-11-16T06:36:57+00:00" + "time": "2020-12-20T13:35:09+00:00" }, { "name": "codeception/lib-asserts", @@ -338,20 +338,20 @@ }, { "name": "codeception/module-db", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/Codeception/module-db.git", - "reference": "d5f1def43c1f0ebdd57d506224c4a4632e3a6059" + "reference": "8c8076cd05d4db95798acd7dba2a56578210982c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/module-db/zipball/d5f1def43c1f0ebdd57d506224c4a4632e3a6059", - "reference": "d5f1def43c1f0ebdd57d506224c4a4632e3a6059", + "url": "https://api.github.com/repos/Codeception/module-db/zipball/8c8076cd05d4db95798acd7dba2a56578210982c", + "reference": "8c8076cd05d4db95798acd7dba2a56578210982c", "shasum": "" }, "require": { - "codeception/codeception": "^4.0", + "codeception/codeception": "*@dev", "php": ">=5.6.0 <9.0" }, "conflict": { @@ -384,9 +384,9 @@ ], "support": { "issues": "https://github.com/Codeception/module-db/issues", - "source": "https://github.com/Codeception/module-db/tree/1.0.2" + "source": "https://github.com/Codeception/module-db/tree/1.1.0" }, - "time": "2020-10-23T18:21:20+00:00" + "time": "2020-12-20T13:37:07+00:00" }, { "name": "codeception/module-phpbrowser", @@ -891,16 +891,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.10.3", + "version": "v4.10.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "dbe56d23de8fcb157bbc0cfb3ad7c7de0cfb0984" + "reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dbe56d23de8fcb157bbc0cfb3ad7c7de0cfb0984", - "reference": "dbe56d23de8fcb157bbc0cfb3ad7c7de0cfb0984", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c6d052fc58cb876152f89f532b95a8d7907e7f0e", + "reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e", "shasum": "" }, "require": { @@ -941,9 +941,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.3" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.4" }, - "time": "2020-12-03T17:45:45+00:00" + "time": "2020-12-20T10:01:03+00:00" }, { "name": "phar-io/manifest", @@ -1007,16 +1007,16 @@ }, { "name": "phar-io/version", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "726c026815142e4f8677b7cb7f2249c9ffb7ecae" + "reference": "e4782611070e50613683d2b9a57730e9a3ba5451" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/726c026815142e4f8677b7cb7f2249c9ffb7ecae", - "reference": "726c026815142e4f8677b7cb7f2249c9ffb7ecae", + "url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451", + "reference": "e4782611070e50613683d2b9a57730e9a3ba5451", "shasum": "" }, "require": { @@ -1052,9 +1052,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.0.3" + "source": "https://github.com/phar-io/version/tree/3.0.4" }, - "time": "2020-11-30T09:21:21+00:00" + "time": "2020-12-13T23:18:30+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1216,16 +1216,16 @@ }, { "name": "phpspec/prophecy", - "version": "1.12.1", + "version": "1.12.2", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "8ce87516be71aae9b956f81906aaf0338e0d8a2d" + "reference": "245710e971a030f42e08f4912863805570f23d39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/8ce87516be71aae9b956f81906aaf0338e0d8a2d", - "reference": "8ce87516be71aae9b956f81906aaf0338e0d8a2d", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/245710e971a030f42e08f4912863805570f23d39", + "reference": "245710e971a030f42e08f4912863805570f23d39", "shasum": "" }, "require": { @@ -1237,7 +1237,7 @@ }, "require-dev": { "phpspec/phpspec": "^6.0", - "phpunit/phpunit": "^8.0 || ^9.0 <9.3" + "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { @@ -1277,9 +1277,9 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.12.1" + "source": "https://github.com/phpspec/prophecy/tree/1.12.2" }, - "time": "2020-09-29T09:10:42+00:00" + "time": "2020-12-19T10:15:11+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2920,16 +2920,16 @@ }, { "name": "symfony/browser-kit", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "4fc769a12282a12bc47f883f04f01ff3777e369b" + "reference": "87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/4fc769a12282a12bc47f883f04f01ff3777e369b", - "reference": "4fc769a12282a12bc47f883f04f01ff3777e369b", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a", + "reference": "87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a", "shasum": "" }, "require": { @@ -2971,7 +2971,7 @@ "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/browser-kit/tree/v5.2.0" + "source": "https://github.com/symfony/browser-kit/tree/v5.2.1" }, "funding": [ { @@ -2987,20 +2987,20 @@ "type": "tidelift" } ], - "time": "2020-11-14T11:04:29+00:00" + "time": "2020-12-18T08:03:05+00:00" }, { "name": "symfony/console", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3e0564fb08d44a98bd5f1960204c958e57bd586b" + "reference": "47c02526c532fb381374dab26df05e7313978976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3e0564fb08d44a98bd5f1960204c958e57bd586b", - "reference": "3e0564fb08d44a98bd5f1960204c958e57bd586b", + "url": "https://api.github.com/repos/symfony/console/zipball/47c02526c532fb381374dab26df05e7313978976", + "reference": "47c02526c532fb381374dab26df05e7313978976", "shasum": "" }, "require": { @@ -3068,7 +3068,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.0" + "source": "https://github.com/symfony/console/tree/v5.2.1" }, "funding": [ { @@ -3084,20 +3084,20 @@ "type": "tidelift" } ], - "time": "2020-11-28T11:24:18+00:00" + "time": "2020-12-18T08:03:05+00:00" }, { "name": "symfony/css-selector", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "b8d8eb06b0942e84a69e7acebc3e9c1e6e6e7256" + "reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/b8d8eb06b0942e84a69e7acebc3e9c1e6e6e7256", - "reference": "b8d8eb06b0942e84a69e7acebc3e9c1e6e6e7256", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/f789e7ead4c79e04ca9a6d6162fc629c89bd8054", + "reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054", "shasum": "" }, "require": { @@ -3133,7 +3133,7 @@ "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.2.0" + "source": "https://github.com/symfony/css-selector/tree/v5.2.1" }, "funding": [ { @@ -3149,7 +3149,7 @@ "type": "tidelift" } ], - "time": "2020-10-28T21:31:18+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3220,16 +3220,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "0969122fe144dd8ab2e8c98c7e03eedc621b368c" + "reference": "ee7cf316fb0de786cfe5ae32ee79502b290c81ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/0969122fe144dd8ab2e8c98c7e03eedc621b368c", - "reference": "0969122fe144dd8ab2e8c98c7e03eedc621b368c", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/ee7cf316fb0de786cfe5ae32ee79502b290c81ea", + "reference": "ee7cf316fb0de786cfe5ae32ee79502b290c81ea", "shasum": "" }, "require": { @@ -3274,7 +3274,7 @@ "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dom-crawler/tree/v5.2.0" + "source": "https://github.com/symfony/dom-crawler/tree/v5.2.1" }, "funding": [ { @@ -3290,20 +3290,20 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:01:57+00:00" + "time": "2020-12-18T08:02:46+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "aa13a09811e6d2ad43f8fb336bebdb7691d85d3c" + "reference": "1c93f7a1dff592c252574c79a8635a8a80856042" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/aa13a09811e6d2ad43f8fb336bebdb7691d85d3c", - "reference": "aa13a09811e6d2ad43f8fb336bebdb7691d85d3c", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1c93f7a1dff592c252574c79a8635a8a80856042", + "reference": "1c93f7a1dff592c252574c79a8635a8a80856042", "shasum": "" }, "require": { @@ -3359,7 +3359,7 @@ "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.1" }, "funding": [ { @@ -3375,7 +3375,7 @@ "type": "tidelift" } ], - "time": "2020-11-01T16:14:45+00:00" + "time": "2020-12-18T08:03:05+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -3458,16 +3458,16 @@ }, { "name": "symfony/finder", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "fd8305521692f27eae3263895d1ef1571c71a78d" + "reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/fd8305521692f27eae3263895d1ef1571c71a78d", - "reference": "fd8305521692f27eae3263895d1ef1571c71a78d", + "url": "https://api.github.com/repos/symfony/finder/zipball/0b9231a5922fd7287ba5b411893c0ecd2733e5ba", + "reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba", "shasum": "" }, "require": { @@ -3499,7 +3499,7 @@ "description": "Symfony Finder Component", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.2.0" + "source": "https://github.com/symfony/finder/tree/v5.2.1" }, "funding": [ { @@ -3515,7 +3515,7 @@ "type": "tidelift" } ], - "time": "2020-11-18T09:42:36+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4084,16 +4084,16 @@ }, { "name": "symfony/string", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "40e975edadd4e32cd16f3753b3bad65d9ac48242" + "reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/40e975edadd4e32cd16f3753b3bad65d9ac48242", - "reference": "40e975edadd4e32cd16f3753b3bad65d9ac48242", + "url": "https://api.github.com/repos/symfony/string/zipball/5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed", + "reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed", "shasum": "" }, "require": { @@ -4147,7 +4147,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.0" + "source": "https://github.com/symfony/string/tree/v5.2.1" }, "funding": [ { @@ -4163,20 +4163,20 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:08:07+00:00" + "time": "2020-12-05T07:33:16+00:00" }, { "name": "symfony/yaml", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "bb73619b2ae5121bbbcd9f191dfd53ded17ae598" + "reference": "290ea5e03b8cf9b42c783163123f54441fb06939" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/bb73619b2ae5121bbbcd9f191dfd53ded17ae598", - "reference": "bb73619b2ae5121bbbcd9f191dfd53ded17ae598", + "url": "https://api.github.com/repos/symfony/yaml/zipball/290ea5e03b8cf9b42c783163123f54441fb06939", + "reference": "290ea5e03b8cf9b42c783163123f54441fb06939", "shasum": "" }, "require": { @@ -4222,7 +4222,7 @@ "description": "Symfony Yaml Component", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.2.0" + "source": "https://github.com/symfony/yaml/tree/v5.2.1" }, "funding": [ { @@ -4238,7 +4238,7 @@ "type": "tidelift" } ], - "time": "2020-11-28T10:57:20+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "theseer/tokenizer", diff --git a/e107_tests/tests/unit/e_fileTest.php b/e107_tests/tests/unit/e_fileTest.php index b8da65b79..9e4406f4f 100644 --- a/e107_tests/tests/unit/e_fileTest.php +++ b/e107_tests/tests/unit/e_fileTest.php @@ -163,12 +163,14 @@ class e_fileTest extends \Codeception\Test\Unit { } - +*/ public function testGet_dirs() { - + $actual = $this->fl->get_dirs(e_LANGUAGEDIR); + $expected = array ( 0 => 'English' ); + $this->assertSame($expected, $actual); } - +/* public function testGetErrorMessage() { @@ -387,12 +389,26 @@ class e_fileTest extends \Codeception\Test\Unit { } - +*/ public function testGet_files() { + $reject = array('style.*'); + $result = $this->fl->get_files(e_THEME."voux/", "\.php|\.css|\.xml|preview\.jpg|preview\.png", $reject, 1); + + $files = array(); + foreach($result as $f) + { + $files[] = $f['fname']; + } + + $this->assertContains('install.xml', $files); // 1 level deep. + $this->assertContains('theme.php', $files); + $this->assertContains('theme.xml', $files); + $this->assertNotContains('style.css', $files); + } - +/* public function testGetUserDir() { diff --git a/e107_tests/tests/unit/e_formTest.php b/e107_tests/tests/unit/e_formTest.php index 4da546ad6..9448d847c 100644 --- a/e107_tests/tests/unit/e_formTest.php +++ b/e107_tests/tests/unit/e_formTest.php @@ -744,12 +744,22 @@ class e_formTest extends \Codeception\Test\Unit { } - +*/ public function testGet_attributes() { + $options = array( + 'class' => 'myclass', + 'id' => 'custom-id', + 'readonly' => true, + 'data-something' => 'custom-att' + ); + $actual = $this->_frm->get_attributes($options); + $expected = " class='myclass' id='custom-id' readonly='readonly' data-something='custom-att'"; + + $this->assertSame($expected, $actual); } - +/* public function test_format_id() { diff --git a/online.php b/online.php index 65962b3f9..a6f998f15 100644 --- a/online.php +++ b/online.php @@ -65,7 +65,7 @@ list($oid, $oname) = explode(".", $uinfo, 2); $online_location = $pinfo; $online_location_page = substr(strrchr($online_location, "/"), 1); - if(!strstr($online_location, "forum_") || !strstr($online_location, "content.php") || !strstr($online_location, "comment.php")) + if(strpos($online_location, "forum_") === false || strpos($online_location, "content.php") === false || strpos($online_location, "comment.php") === false) { $online_location_page = str_replace(".php", "", substr(strrchr($online_location, "/"), 1)); } @@ -180,7 +180,7 @@ $scArray = array(); - if(strstr($online_location, "content.php")) + if(strpos($online_location, "content.php") !== false) { $tmp = explode(".", substr(strrchr($online_location, "php."), 2)); if($tmp[0] == "article") @@ -221,7 +221,7 @@ } } - if(strstr($online_location, "comment.php")) + if(strpos($online_location, "comment.php") !== false) { $tmp = explode(".php.", $online_location); $tmp = explode(".", $tmp[1]); @@ -253,10 +253,10 @@ } } - if(strstr($online_location, "forum")) + if(strpos($online_location, "forum") !== false) { $tmp = explode(".", substr(strrchr($online_location, "php."), 2)); - if(strstr($online_location, "_viewtopic")) + if(strpos($online_location, "_viewtopic") !== false) { if($tmp[2]) { @@ -281,7 +281,7 @@ $online_location_page = ONLINE_EL13 . ": \"" . CLASSRESTRICTED . "\""; } } - elseif(strstr($online_location, "_viewforum")) + elseif(strpos($online_location, "_viewforum") !== false) { $sql->select("forum", "forum_name, forum_class", "forum_id=" . intval($tmp[0])); $forum = $sql->fetch(); @@ -293,7 +293,7 @@ $online_location_page = ONLINE_EL13 . ": \"" . CLASSRESTRICTED . "\""; } } - elseif(strstr($online_location, "_post")) + elseif(strpos($online_location, "_post") !== false) { $sql->select("forum_thread", "thread_name, thread_forum_id", "thread_forum_id=" . intval($tmp[0]) . " AND thread_parent=0"); $forum_thread = $sql->fetch(); @@ -304,7 +304,7 @@ } } - if(strstr($online_location, "admin")) + if(strpos($online_location, "admin") !== false) { $class_check = false; $online_location_page = ADMINAREA;