1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-05 18:35:01 +02:00

Reduced some memory usage.

This commit is contained in:
Cameron 2021-01-24 17:00:02 -08:00
parent 8508cabcad
commit 522d71d243
30 changed files with 99 additions and 104 deletions

View File

@ -589,9 +589,8 @@ class eDispatcher
$controller->dispatch($actionName);
$content = ob_get_contents();
ob_end_clean();
$content = ob_get_clean();
$response->appendBody($content);
unset($controller);
}
@ -3204,7 +3203,7 @@ class eController
*/
public function __call($methodName, $args)
{
if ('action' == substr($methodName, 0, 6))
if (strpos($methodName, 'action') === 0)
{
$action = substr($methodName, 6);
throw new eException('Action "'.$action.'" does not exist', 2404);

View File

@ -396,8 +396,7 @@ class e_bbcode
$error = $debugFile." -- ".$e->getMessage();
}
$bbcode_output = ob_get_contents();
ob_end_clean();
$bbcode_output = ob_get_clean();
if(!empty($error))
{
@ -429,7 +428,7 @@ class e_bbcode
return null;
}
if(substr(ltrim($text),0,6) == '[html]' && $type == 'img') // support for html img tags inside [html] bbcode.
if(strpos(ltrim($text), '[html]') === 0 && $type == 'img') // support for html img tags inside [html] bbcode.
{
$tmp = e107::getParser()->getTags($text,'img');

View File

@ -223,7 +223,7 @@
$mailManager = e107::getBulkEmail();
$debug = ($this->debug === 2) ? true : false;
$debug = $this->debug === 2;
$mailManager->controlDebug($debug);

View File

@ -186,7 +186,7 @@ class comment
{
$itemid = $id;
if ($action == "reply" && substr($subject, 0, 4) != "Re: ")
if ($action == "reply" && strpos($subject, "Re: ") !== 0)
{
$subject = COMLAN_325.' '.$subject;
}
@ -657,7 +657,7 @@ class comment
{
if ($var == e_UC_MEMBER) // different behavior to check_class();
{
return (USER == TRUE && ADMIN == FALSE) ? TRUE : FALSE;
return (USER == true && ADMIN == false);
}
return check_class($var);

View File

@ -590,7 +590,7 @@ class e_array {
$ArrayData = (string) substr($ArrayData,8);
}
if(strtolower(substr($ArrayData,0,5)) !== 'array')
if(stripos($ArrayData, 'array') !== 0)
{
return false;
}

View File

@ -160,7 +160,7 @@ class _system_cron
$userVars = array();
foreach($userCon['user'] as $k=>$v)
{
if(substr($k,0,2) == 'e_')
if(strpos($k, 'e_') === 0)
{
$userVars[$k] = $v;
}
@ -697,34 +697,30 @@ class CronParser
function _getLastMonth()
{
$months = $this->_getMonthsArray();
$month = array_pop($months);
return $month;
return array_pop($months);
}
function _getLastDay($month, $year)
{
//put the available days for that month into an array
$days = $this->_getDaysArray($month, $year);
$day = array_pop($days);
return $day;
return array_pop($days);
}
function _getLastHour()
{
$hours = $this->_getHoursArray();
$hour = array_pop($hours);
return $hour;
return array_pop($hours);
}
function _getLastMinute()
{
$minutes = $this->_getMinutesArray();
$minute = array_pop($minutes);
return $minute;
return array_pop($minutes);
}
//remove the out of range array elements. $arr should be sorted already and does not contain duplicates

View File

@ -1014,8 +1014,7 @@
ob_start();
var_dump($message);
$content = ob_get_contents();
ob_end_clean();
$content = ob_get_clean();
$bt = debug_backtrace();

View File

@ -932,8 +932,8 @@ class e107
*/
function getSitePath()
{
$self = self::getInstance();
return $self->site_path;
return self::getInstance()->site_path;
}
/**

View File

@ -133,7 +133,7 @@
$tp = e107::getParser();
$value = $this->_data[$key];
$raw = (!empty($parm['mode']) && $parm['mode'] === 'raw') ? true : false;
$raw = (!empty($parm['mode']) && $parm['mode'] === 'raw');
$type = (!empty($parm['type'])) ? $parm['type'] : null;
$fieldType = $this->_config[$key]['type'];
@ -536,7 +536,7 @@
foreach($new_data as $k=>$v)
{
if(substr($k,0,$len) === $fieldname)
if(strpos($k, $fieldname) === 0)
{
list($tmp,$newkey) = explode('__',$k);
$new_data[$fieldname][$newkey] = $v;

View File

@ -2194,8 +2194,8 @@ class e_db_pdo implements e_db
$table[] = str_replace($prefix,"",$rows[0]);
}
}
$ret = array($language=>$table);
return $ret;
return array($language =>$table);
}
else
{

View File

@ -411,7 +411,7 @@ abstract class e_marketplace_adapter_abstract
*/
public function hasAuthKey()
{
return ($this->authKey !== null) ? true : false;
return $this->authKey !== null;
}
/**
@ -1169,7 +1169,7 @@ class eAuth
$total = array();
foreach($params as $k => $v)
{
if(substr($k, 0, 5) != "eauth") continue;
if(strpos($k, "eauth") !== 0) continue;
if(is_array($v))
{
throw new Exception('Arrays not supported in headers', 200);

View File

@ -229,7 +229,7 @@
{
$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);
@ -1574,7 +1574,7 @@
// print_a($headers);
return (stripos($headers[0], "200 OK") || strpos($headers[0], "302")) ? true : false;
return (stripos($headers[0], "200 OK") || strpos($headers[0], "302"));
}

View File

@ -198,7 +198,7 @@ class eIPHandler
public function debug($value)
{
$this->debug = ($value === true) ? true: false;
$this->debug = $value === true;
}
@ -314,7 +314,7 @@ class eIPHandler
if ($ip == 'ff02:0000:0000:0000:0000:0000:0000:0001') return FALSE;
if ($ip == '::1') return FALSE; // localhost
if ($ip == '0000:0000:0000:0000:0000:0000:0000:0001') return FALSE;
if (substr($ip, 0, 5) == 'fc00:') return FALSE; // local addresses
if (strpos($ip, 'fc00:') === 0) return FALSE; // local addresses
// @todo add:
// ::0 (all zero) - invalid
// ff02::1:ff00:0/104 - Solicited-Node multicast addresses - add?
@ -397,7 +397,7 @@ class eIPHandler
$vals = file($fileName);
if ($vals === FALSE || count($vals) == 0) return;
if (substr($vals[0], 0, 5) != '<?php')
if (strpos($vals[0], '<?php') !== 0)
{
echo 'Invalid message file';
die();
@ -405,7 +405,7 @@ class eIPHandler
unset($vals[0]);
foreach ($vals as $line)
{
if (substr($line, 0, 1) == ';') continue;
if (strpos($line, ';') === 0) continue;
if (strpos($line, $search) === 0)
{ // Found the action line
if (e107::getPref('ban_retrigger'))
@ -467,7 +467,7 @@ class eIPHandler
$vals = file($fileName);
if ($vals === FALSE || count($vals) == 0) return $ret;
if (substr($vals[0], 0, 5) != '<?php')
if (strpos($vals[0], '<?php') !== 0)
{
echo 'Invalid list file';
die(); // Debatable, because admins can't get in if this fails. But can manually delete the file.
@ -475,7 +475,7 @@ class eIPHandler
unset($vals[0]);
foreach ($vals as $line)
{
if (substr($line, 0, 1) == ';') continue;
if (strpos($line, ';') === 0) continue;
if (trim($line))
{
$tmp = explode(' ',$line);
@ -711,7 +711,7 @@ class eIPHandler
{ // Need to add trailing zeros, or double colon
if ($zc > 1) $ret .= '::'; else $ret .= ':0';
}
if ($IP4Legacy && (substr($ret,0,7) == '::ffff:'))
if ($IP4Legacy && (strpos($ret, '::ffff:') === 0))
{
$temp = str_replace(':', '', substr($ip,-9, 9));
$tmp = str_split($temp, 2); // Four 2-character hex values
@ -1553,11 +1553,11 @@ class banlistManager
$vals = file($fileName);
if ($vals === FALSE) return $ret;
if (substr($vals[0], 0, 5) == '<?php')
if (strpos($vals[0], '<?php') === 0)
{
unset($vals[0]);
}
if (substr($vals[0], 0, 1) == ';') unset($vals[0]);
if (strpos($vals[0], ';') === 0) unset($vals[0]);
$numEntry = count($vals);
if ($start > $numEntry) return $ret; // Empty return if beyond the end
if ($count == 0) return $vals; // Special case - return the lot in ascending date order

View File

@ -1249,8 +1249,8 @@ class e_jsmanager
if($return)
{
$ret = ob_get_contents();
ob_end_clean();
$ret = ob_get_clean();
return $ret;
}
}
@ -1565,7 +1565,7 @@ class e_jsmanager
*/
private function addCache($type,$path)
{
if($this->_cache_enabled != true || $this->isInAdmin() || substr($path,0,2) == '//' || strpos($path, 'wysiwyg.php')!==false )
if($this->_cache_enabled != true || $this->isInAdmin() || strpos($path, '//') === 0 || strpos($path, 'wysiwyg.php')!==false )
{
return false;
}

View File

@ -172,10 +172,9 @@ class e_jslib
$pref = e107::getPref();
$encoding = $this->browser_enc();
$contents = ob_get_contents();
ob_end_clean();
if(!deftrue('e_NOCACHE')) header('Cache-Control: must-revalidate', true);
$contents = ob_get_clean();
if(!deftrue('e_NOCACHE')) header('Cache-Control: must-revalidate', true);
$etag = md5($page).($encoding ? '-'.$encoding : '');
header('ETag: '.$etag, true);

View File

@ -1093,7 +1093,7 @@ class e_library_manager
$libraryPath = !empty($library['library_path']) ? e107::getParser()->replaceConstants($library['library_path']) : '';
if(empty($library['library_path']) || (!empty($libraryPath) && !file_exists($libraryPath) && substr($libraryPath, 0, 4) != 'http'))
if(empty($library['library_path']) || (!empty($libraryPath) && !file_exists($libraryPath) && strpos($libraryPath, 'http') !== 0))
{
$library['error'] = LAN_NOT_FOUND;
@ -2104,7 +2104,7 @@ class e_library_manager
// If remote file (e.g. CDN URL)... we download file to temp, and get version number.
// The library will be cached with version number, so this only run once per library.
if(substr($file, 0, 4) == 'http')
if(strpos($file, 'http') === 0)
{
$content = e107::getFile()->getRemoteContent($file);
$tmpFile = tempnam(sys_get_temp_dir(), 'lib_');

View File

@ -219,9 +219,8 @@ class e_menuManager
function menuRenderMessage()
{
// return $this->menuMessage;
$text = e107::getMessage()->render('menuUi');
// $text .= "ID = ".$this->menuId;
return $text;
// $text .= "ID = ".$this->menuId;
return e107::getMessage()->render('menuUi');
}

View File

@ -2124,8 +2124,8 @@ class e_db_mysql implements e_db
$table[] = str_replace($prefix,"",$rows[0]);
}
}
$ret = array($language=>$table);
return $ret;
return array($language =>$table);
}
else
{

View File

@ -217,7 +217,7 @@ class e_plugin
if(isset($this->_data[$this->_plugdir]['@attributes']['installRequired']))
{
return ($this->_data[$this->_plugdir]['@attributes']['installRequired'] === 'false') ? false : true;
return $this->_data[$this->_plugdir]['@attributes']['installRequired'] !== 'false';
}
return false;
@ -486,7 +486,7 @@ class e_plugin
public function isValidAddonMarkup($content='')
{
if ((substr($content, 0, 5) != '<'.'?php'))
if ((strpos($content, '<' . '?php') !== 0))
{
return false;
}
@ -1173,7 +1173,7 @@ class e_plugin
}
}
// new shortcodes location - shortcodes/single/*.php
elseif (substr($adds, 0, 3) === "sc_")
elseif (strpos($adds, "sc_") === 0)
{
$sc_name = substr(substr($adds, 3), 0, -4); // remove the sc_ and .php
@ -1196,7 +1196,7 @@ class e_plugin
$bb_array[$bb_name] = "0"; // default userclass.
}
// bbcode class
elseif(substr($adds, 0, 3) == "bb_" && substr($adds, -4) == ".php")
elseif(strpos($adds, "bb_") === 0 && substr($adds, -4) == ".php")
{
$bb_name = substr($adds, 0,-4); // remove the .php
$bb_name = substr($bb_name, 3);
@ -2513,7 +2513,7 @@ class e107plugin
$newvals = array_unique($newvals);
$pref[$prefname] = implode(',', $newvals);
if (substr($pref[$prefname], 0, 1) == ",")
if (strpos($pref[$prefname], ",") === 0)
{
$pref[$prefname] = substr($pref[$prefname], 1);
}
@ -3604,7 +3604,7 @@ class e107plugin
{
$attrib = $link['@attributes'];
$linkName = (defset($link['@value'])) ? constant($link['@value']) : vartrue($link['@value'],'');
$remove = (varset($attrib['deprecate']) == 'true') ? TRUE : FALSE;
$remove = varset($attrib['deprecate']) == 'true';
$url = vartrue($attrib['url']);
$perm = vartrue($attrib['perm'],'everyone');
$sef = vartrue($attrib['sef']);
@ -3656,7 +3656,7 @@ class e107plugin
}
}
return ($status === E_MESSAGE_SUCCESS) ? true : false;
return $status === E_MESSAGE_SUCCESS;
}
/**
@ -3834,7 +3834,7 @@ class e107plugin
$attrib = $uclass['@attributes'];
$name = $attrib['name'];
$description = $attrib['description'];
$remove = (varset($attrib['deprecate']) == 'true') ? TRUE : FALSE;
$remove = varset($attrib['deprecate']) == 'true';
switch ($function)
{
@ -3905,7 +3905,7 @@ class e107plugin
//$name = 'plugin_'.$this->plugFolder.'_'.$attrib['name'];
$source = 'plugin_'.$this->plugFolder;
$remove = (varset($attrib['deprecate']) == 'true') ? TRUE : FALSE;
$remove = varset($attrib['deprecate']) == 'true';
if(!isset($attrib['system']))
{
@ -3913,7 +3913,7 @@ class e107plugin
}
else
{
$attrib['system'] = ($attrib['system'] === 'true') ? true : false;
$attrib['system'] = $attrib['system'] === 'true';
}
switch ($function)
@ -4001,7 +4001,7 @@ class e107plugin
$value = $tmp;
}
$remove = (varset($tag['@attributes']['deprecate']) == 'true') ? TRUE : FALSE;
$remove = varset($tag['@attributes']['deprecate']) == 'true';
if (varset($tag['@attributes']['value']))
{
@ -4682,7 +4682,7 @@ class e107plugin
}
}
// new shortcodes location - shortcodes/single/*.php
elseif (substr($adds, 0, 3) === "sc_")
elseif (strpos($adds, "sc_") === 0)
{
$sc_name = substr(substr($adds, 3), 0, -4); // remove the sc_ and .php
@ -4705,7 +4705,7 @@ class e107plugin
$bb_array[$bb_name] = "0"; // default userclass.
}
// bbcode class
elseif(substr($adds, 0, 3) == "bb_" && substr($adds, -4) == ".php")
elseif(strpos($adds, "bb_") === 0 && substr($adds, -4) == ".php")
{
$bb_name = substr($adds, 0,-4); // remove the .php
$bb_name = substr($bb_name, 3);
@ -4798,7 +4798,7 @@ class e107plugin
{
$passfail = '';
$file_text = file_get_contents(e_PLUGIN.$plugin_path."/".$addonPHP);
if ((substr($file_text, 0, 5) != '<'.'?php') || ((substr($file_text, -2, 2) != '?'.'>') && (strrpos($file_text, '?'.'>') !== FALSE)))
if ((strpos($file_text, '<' . '?php') !== 0) || ((substr($file_text, -2, 2) != '?'.'>') && (strrpos($file_text, '?'.'>') !== FALSE)))
{
$passfail = '<b>fail</b>';
}
@ -4901,7 +4901,7 @@ class e107plugin
}
// Generic markup check
if ((substr($content, 0, 5) != '<'.'?php') || ((substr($content, -2, 2) != '?'.'>') && (strrpos($content, '?'.'>') !== FALSE)))
if ((strpos($content, '<' . '?php') !== 0) || ((substr($content, -2, 2) != '?'.'>') && (strrpos($content, '?'.'>') !== FALSE)))
{
return 1;
}

View File

@ -53,7 +53,7 @@ class receiveMail
$mail_header=imap_header($this->marubox,$mid);
$sender=$mail_header->from[0];
$sender_replyto=$mail_header->reply_to[0];
$stat = (strtolower($sender->mailbox)!='mailer-daemon' && strtolower($sender->mailbox)!='postmaster') ? FALSE : TRUE;
$stat = !(strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster');
if(strpos($mail_header->subject,"delayed")){
$stat = FALSE;
}

View File

@ -98,7 +98,7 @@ class pop3BounceHandler
$mail_header=imap_header($this->mailResource,$mid);
$sender=$mail_header->from[0];
$sender_replyto=$mail_header->reply_to[0];
$stat = (strtolower($sender->mailbox)!='mailer-daemon' && strtolower($sender->mailbox)!='postmaster') ? FALSE : TRUE;
$stat = !(strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster');
if(strpos($mail_header->subject,"delayed"))
{
$stat = FALSE;

View File

@ -59,8 +59,7 @@ $results = $ps['results'];
function search_comment($row) {
if (is_callable('com_search_'.$row['comment_type'])) {
$res = call_user_func('com_search_'.$row['comment_type'], $row);
return $res;
return call_user_func('com_search_'.$row['comment_type'], $row);
}
}

View File

@ -73,7 +73,7 @@ class e_search
$this -> keywords['boolean'][$k_key] = FALSE;
$this -> keywords['match'][$k_key] = $key;
}
$this -> keywords['exact'][$k_key] = ($tp->ustrpos($key, ' ') !== FALSE) ? TRUE : FALSE;
$this -> keywords['exact'][$k_key] = $tp->ustrpos($key, ' ') !== false;
$this -> keywords['match'][$k_key] = $tp -> toDB($this -> keywords['match'][$k_key]);
}
else {

View File

@ -92,7 +92,7 @@ class sitelinks
$pref = e107::getPref();
$e107cache = e107::getCache();
$usecache = ((trim(defset('LINKSTART_HILITE')) != "" || trim(defset('LINKCLASS_HILITE')) != "") ? false : true);
$usecache = (!(trim(defset('LINKSTART_HILITE')) != "" || trim(defset('LINKCLASS_HILITE')) != ""));
if($usecache && !strpos(e_SELF, e_ADMIN) && ($data = $e107cache->retrieve('sitelinks_' . $cat . md5($linkstyle . e_PAGE . e_QUERY))))
{
@ -178,7 +178,7 @@ class sitelinks
foreach($this->eLinkList['head_menu'] as $key => $link)
{
$main_linkid = "sub_" . $link['link_id'];
$link['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid])) ? true : false;
$link['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid]));
$render_link[$key] = $this->makeLink($link, '', $style, $css_class);
if(!defined("LINKSRENDERONLYMAIN") && !isset($style['linkmainonly'])) /* if this is defined in theme.php only main links will be rendered */
@ -259,7 +259,7 @@ class sitelinks
return null;
}
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid])) ? TRUE : FALSE;
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid]));
foreach($this->eLinkList[$main_linkid] as $val) // check that something in the submenu is actually selected.
{
@ -280,7 +280,7 @@ class sitelinks
foreach ($this->eLinkList[$main_linkid] as $sub)
{
$id = (!empty($sub['link_id'])) ? "sub_".$sub['link_id'] : 'sub_0';
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$id]) && is_array($this->eLinkList[$id])) ? TRUE : FALSE;
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$id]) && is_array($this->eLinkList[$id]));
$class = "sublink-level-".($level+1);
$class .= ($css_class) ? " ".$css_class : "";
$class .= ($aSubStyle['sublinkclass']) ? " ".$aSubStyle['sublinkclass'] : ""; // backwards compatible
@ -529,7 +529,7 @@ class sitelinks
{
if($link_qry)
{ // plugin links with queries
return (strpos(e_SELF,$link_slf) && e_QUERY == $link_qry) ? TRUE : FALSE;
return (strpos(e_SELF, $link_slf) && e_QUERY == $link_qry);
}
else
{ // plugin links without queries
@ -553,7 +553,7 @@ class sitelinks
if($qry[0] === "item")
{
return ($qry[2] == $lnk[1]) ? TRUE : FALSE;
return $qry[2] == $lnk[1];
}
if($qry[0] === "all" && $lnk[0] === "all")
@ -1590,7 +1590,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; }
$newArr = array();
foreach($ret as $row)
{
$ignore = (!empty($opt['noempty']) && (empty($row['link_url']) || $row['link_url'] === '#')) ? true : false;
$ignore = (!empty($opt['noempty']) && (empty($row['link_url']) || $row['link_url'] === '#'));
$tmp = (array) $row['link_sub'];

View File

@ -396,9 +396,7 @@ class e_theme
$get = eHelper::removeTrackers($get);
$ret = empty($get) ? $site : $site.'?'.http_build_query($get);
return $ret;
return empty($get) ? $site : $site.'?'.http_build_query($get);
}
@ -901,7 +899,7 @@ class e_theme
$vars['@attributes']['default'] = (varset($vars['@attributes']['default']) && strtolower($vars['@attributes']['default']) == 'true') ? 1 : 0;
$vars['preview'] = varset($vars['screenshots']['image']);
$vars['thumbnail'] = isset($vars['preview'][0]) && file_exists(e_THEME.$path.'/'.$vars['preview'][0]) ? $vars['preview'][0] : '';
$vars['html'] = file_exists(e_THEME.$path.'/theme.html') && is_dir(e_THEME.$path.'/layouts') ? true : false;
$vars['html'] = (file_exists(e_THEME . $path . '/theme.html') && is_dir(e_THEME . $path . '/layouts'));
if(!empty($vars['themePrefs']))
@ -997,7 +995,7 @@ class e_theme
foreach($vars['stylesheets']['css'] as $val)
{
// $notadmin = vartrue($val['@attributes']['admin']) ? false : true;
$notadmin = (varset($val['@attributes']['scope']) !== 'admin') ? true : false;
$notadmin = varset($val['@attributes']['scope']) !== 'admin';
$vars['css'][] = array(
"name" => $val['@attributes']['file'],
@ -2103,7 +2101,7 @@ class themeHandler
foreach($theme['preview'] as $pic)
{
$picFull = (substr($pic,0,4) == 'http') ? $pic : e_THEME.$theme['path']."/".$pic;
$picFull = (strpos($pic, 'http') === 0) ? $pic : e_THEME.$theme['path']."/".$pic;
$text .= "<div class='col-md-6'>
@ -2840,7 +2838,7 @@ class themeHandler
{
foreach($theme['files'] as $val) // get wildcard list of css files.
{
if(substr($val,-4) == '.css' && substr($val, 0, 6) != "admin_")
if(substr($val,-4) == '.css' && strpos($val, "admin_") !== 0)
{
$detected[$val] = array('name'=>$val, 'info'=>'User-added Stylesheet', 'nonadmin'=>1);
}
@ -2865,7 +2863,7 @@ class themeHandler
if($mode === self::RENDER_SITEPREFS)
{
if(substr($vl['name'], 0, 6) == "admin_")
if(strpos($vl['name'], "admin_") === 0)
{
$remove[$k] = $vl['name'];
}

View File

@ -88,7 +88,7 @@ if (count($this->aTrafficTimed))
foreach ($this->aTrafficTimed as $key => $aVals)
{
if (substr($key, 0, 8) == 'TRAF_CAL')
if (strpos($key, 'TRAF_CAL') === 0)
{
continue;
}

View File

@ -365,7 +365,7 @@ class UserHandler
$num = PASSWORD_E107_MD5;
$name = 'md5';
}
elseif ((strlen($hash) === 35) && (substr($hash,0,3) == PASSWORD_E107_ID))
elseif ((strlen($hash) === 35) && (strpos($hash, PASSWORD_E107_ID) === 0))
{
$num = PASSWORD_E107_SALT;
$name = 'md5-salt';

View File

@ -261,7 +261,7 @@ class e_user_model extends e_admin_model
if(empty($new_user_period)) { return false; }
return (($this->get('user_join') > strtotime($new_user_period." days ago")) ? true : false);
return ($this->get('user_join') > strtotime($new_user_period . " days ago"));
}
final public function isBot($userAgent = null)
@ -490,12 +490,12 @@ class e_user_model extends e_admin_model
final public function hasBan()
{
return ((integer)$this->get('user_ban') === 1 ? true : false);
return ((integer) $this->get('user_ban') === 1);
}
final public function hasRestriction()
{
return ((integer)$this->get('user_ban') === 0 ? false : true);
return ((integer) $this->get('user_ban') !== 0);
}
public function hasEditor()
@ -2911,7 +2911,7 @@ class e_user_pref extends e_front_model
if(!empty($data))
{
// BC
$data = substr($data, 0, 5) == "array" ? e107::unserialize($data) : unserialize($data);
$data = strpos($data, "array") === 0 ? e107::unserialize($data) : unserialize($data);
if(!$data) $data = array();
}
else $data = array();

View File

@ -666,7 +666,7 @@ class user_class
$ret = '';
$nest_level++;
$listIndex = abs($listnum);
$classSign = (substr($listnum, 0, 1) == '-') ? '-' : '+';
$classSign = (strpos($listnum, '-') === 0) ? '-' : '+';
//echo "Subtree: {$listnum}, {$nest_level}, {$current_value}, {$classSign}:{$listIndex}<br />";
if(isset($this->class_tree[$listIndex]['class_children']))
{
@ -776,7 +776,7 @@ class user_class
public function select($treename, $classnum, $current_value, $nest_level, $opt_options = '')
{
$classIndex = abs($classnum); // Handle negative class values
$classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
$classSign = (strpos($classnum, '-') === 0) ? '-' : '';
if ($classIndex == e_UC_BLANK) return "<option value=''>&nbsp;</option>\n";
$tmp = explode(',',$current_value);
$sel = in_array($classnum, $tmp) ? " selected='selected'" : '';
@ -813,7 +813,7 @@ class user_class
$frm = e107::getForm();
$classIndex = abs($classnum); // Handle negative class values
$classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
$classSign = (strpos($classnum, '-') === 0) ? '-' : '';
if ($classIndex == e_UC_BLANK) return '';
@ -862,7 +862,7 @@ class user_class
public function checkbox_desc($treename, $classnum, $current_value, $nest_level, $opt_options = '')
{
$classIndex = abs($classnum); // Handle negative class values
$classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
$classSign = (strpos($classnum, '-') === 0) ? '-' : '';
if ($classIndex == e_UC_BLANK) return '';
@ -2107,7 +2107,7 @@ class user_class_admin extends user_class
$xml .= "\t</item>\n";
}
$xml .= "</dbTable>\n";
return (file_put_contents(e_TEMP.'userclasses.xml', $xml) === FALSE) ? FALSE : TRUE;
return file_put_contents(e_TEMP . 'userclasses.xml', $xml) !== false;
}

View File

@ -440,7 +440,7 @@
e107::loadAdminIcons();
$expected = array (
'plugnav-featurebox' =>
/* 'plugnav-featurebox' =>
array (
'text' => 'Feature Box',
'description' => 'Displays an animated area on the top of your page with news-items and other content you would like to feature.',
@ -458,7 +458,7 @@
'icon' => '<img src=\'./e107_plugins/featurebox/images/featurebox_16.png\' alt="Feature Box" class=\'icon S16\' />',
'icon_32' => '<img src=\'./e107_plugins/featurebox/images/featurebox_32.png\' alt="Feature Box" class=\'icon S32\' />',
'cat' => 3,
),
),*/
'plugnav-gallery' =>
array (
'text' => 'Gallery',
@ -537,8 +537,15 @@
),
);
$result = e107::getNav()->adminLinks('plugin2');
$this->assertSame($expected, $result);
foreach($expected as $key=>$val)
{
$this->assertArrayHasKey($key,$result);
}
}
/*
public function testPlugCatToCoreCat()