1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-16 11:36:08 +02:00

Code optimization for speed and reduced memory usage.

This commit is contained in:
Cameron
2020-12-20 11:50:10 -08:00
parent 6b5cc07929
commit 601df26d51
91 changed files with 522 additions and 482 deletions

View File

@@ -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]';

View File

@@ -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']);
}

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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 <span class="badge badge-inverse">10</span>
// 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)

View File

@@ -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") ? "<img src='".THEME_ABS."images/commentedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' class='icon' />" : 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 "<a data-target='".e_HTTP."comment.php' id='e-comment-edit-".$this->var['comment_id']."' class='btn btn-default btn-secondary btn-mini btn-xs e-comment-edit' href='".e_SELF."?".e_QUERY."&amp;comment=edit&amp;comment_id=".$this->var['comment_id']."'>{$adop_icon}</a>";
}

View File

@@ -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;
}

View File

@@ -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'];
}

View File

@@ -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' ";

View File

@@ -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'))
{

View File

@@ -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'))
{