1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-25 00:41:52 +02:00

Code speed optimization

This commit is contained in:
Cameron
2020-12-12 11:32:23 -08:00
parent d090b19c73
commit cf14705535
17 changed files with 48 additions and 45 deletions

View File

@@ -180,7 +180,7 @@ class upload_ui extends e_admin_ui
protected function handleListUploadActiveBatch($selected, $value = null)
{
$ids = array_map('intval', array_values($selected));
$ids = array_map('\intval', array_values($selected));
foreach ($ids as $id)
{
$model = $this->getTreeModel()->getNode($id);

View File

@@ -55,7 +55,7 @@ global $pref;
if(!$parm) $link = $code_text;
if($link == "external" && $extras == "")
if($link == "external" && empty($extras))
{
$link = $code_text;
$extras = "rel=external";

View File

@@ -1,12 +1,12 @@
//<?php
global $loop_uid;
if($parm == "" && is_numeric($loop_uid))
if(empty($parm) && is_numeric($loop_uid))
{
$parm = $loop_uid;
}
if(is_numeric($parm))
{
if(intval($parm) == USERID)
if((int) $parm == USERID)
{
$image = USERPHOTO;
}

View File

@@ -360,7 +360,7 @@ e107::getJs()->renderJs('footer_inline', true);
// see e107.js and class2.php
// This must be done as late as possible in page processing.
$_serverTime = time();
$lastSet = isset($_COOKIE['e107_tdSetTime']) ? intval($_COOKIE['e107_tdSetTime']) : 0;
$lastSet = isset($_COOKIE['e107_tdSetTime']) ? (int) $_COOKIE['e107_tdSetTime'] : 0;
$_serverPath = e_HTTP;
$_serverDomain = deftrue('MULTILANG_SUBDOMAIN') ? '.'.e_DOMAIN : '';
if (abs($_serverTime - $lastSet) > 120)

View File

@@ -210,7 +210,7 @@ class core_news_sef_noid_url extends eUrlConfig
else
{
if(!is_numeric($parts[1])) $id = $this->categoryIdByTitle($parts[1]);
else $id = intval($parts[1]);
else $id = (int) $parts[1];
}
if(!$id)
{

View File

@@ -63,7 +63,8 @@ class ArrayData {
*/
function ReadArray($ArrayData)
{
if ($ArrayData == ""){
if (empty($ArrayData))
{
return false;
}

View File

@@ -435,7 +435,7 @@ class e_array {
$ArrayData = $sourceArrayData;
if ($ArrayData == "")
if (empty($ArrayData))
{
return false;
}

View File

@@ -4316,7 +4316,7 @@ class e107
}
}
if ($_SERVER['PHP_SELF'] == "" && !empty($_SERVER['SCRIPT_NAME']))
if (empty($_SERVER['PHP_SELF']) && !empty($_SERVER['SCRIPT_NAME']))
{
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
}

View File

@@ -762,7 +762,7 @@ class e_parse extends e_parser
if (isset($match[1]))
{
$chop = intval(strlen($match[1]) / 2);
$chop = (int) (strlen($match[1]) / 2);
$ans = substr($match[1], 0, $chop).'##xss##'.substr($match[1], $chop);
}
else
@@ -2523,17 +2523,17 @@ class e_parse extends e_parser
{
if($w !== null)
{
$this->thumbWidth = intval($w);
$this->thumbWidth = (int) $w;
}
if($h !== null)
{
$this->thumbHeight = intval($h);
$this->thumbHeight = (int) $h;
}
if($crop !== null)
{
$this->thumbCrop = intval($crop);
$this->thumbCrop = (int) $crop;
}
}
@@ -2543,7 +2543,7 @@ class e_parse extends e_parser
if($val !== null)
{
$this->thumbEncode = intval($val);
$this->thumbEncode = (int) $val;
return null;
}
@@ -2574,7 +2574,7 @@ class e_parse extends e_parser
{
if($width !== null)
{
$this->thumbWidth = intval($width);
$this->thumbWidth = (int) $width;
}
return $this->thumbWidth;
@@ -2588,7 +2588,7 @@ class e_parse extends e_parser
{
if($status !== false)
{
$this->thumbCrop = intval($status);
$this->thumbCrop = (int) $status;
}
return $this->thumbCrop;
@@ -2604,7 +2604,7 @@ class e_parse extends e_parser
{
if($height !== null)
{
$this->thumbHeight = intval($height);
$this->thumbHeight = (int) $height;
}
return $this->thumbHeight;
@@ -2902,7 +2902,7 @@ class e_parse extends e_parser
$options['h'] = $options['ah'] ;
}
$thurl .= 'aw='.intval($options['w']).'&amp;ah='.intval($options['h']);
$thurl .= 'aw='.(int) $options['w'].'&amp;ah='.(int) $options['h'];
if(!is_numeric($options['crop']))
{
@@ -2914,7 +2914,7 @@ class e_parse extends e_parser
else
{
$thurl .= 'w='.intval($options['w']).'&amp;h='.intval($options['h']);
$thurl .= 'w='.(int) $options['w'].'&amp;h='.(int) $options['h'];
}

View File

@@ -1742,7 +1742,7 @@ class e_jsmanager
$i -= 1;
}
if ($i > 0 && $parts[$i] === "") // remove empty parts
if ($i > 0 && empty($parts[$i])) // remove empty parts
{
unset($parts[$i]);
$parts = array_values($parts);

View File

@@ -939,6 +939,7 @@ class e_library_manager
*/
public function detect($name)
{
// Re-use the statically cached value of info() to save memory.
$library = &$this->info($name);
@@ -1202,6 +1203,7 @@ class e_library_manager
public function load($name, $variant = null)
{
// Re-use the statically cached value to save memory.
static $loaded;
if(!isset($loaded[$name]))
@@ -1216,7 +1218,7 @@ class e_library_manager
$library = e107::unserialize($cached);
}
if(!varset($library, false))
if(empty($library))
{
$library = $this->detect($name);
$cacheData = e107::serialize($library, 'json');

View File

@@ -85,7 +85,7 @@ class userlogin
$forceLogin = ($autologin === 'signup');
if(!$forceLogin && $autologin === 'provider') $forceLogin = 'provider';
if($username == "" || (($userpass == "") && ($response == '') && $forceLogin !== 'provider'))
if(empty($username) || (empty($userpass) && empty($response) && $forceLogin !== 'provider'))
{ // Required fields blank
return $this->invalidLogin($username,LOGIN_BLANK_FIELD);
}

View File

@@ -651,7 +651,7 @@ class rater
}
}
$rate .= "<img src='".e_IMAGE_ABS."rate/boxend.png' alt='' style='height:8px; vertical-align:middle' />";
if($ratearray[2] == ""){ $ratearray[2] = 0; }
if(empty($ratearray[2])){ $ratearray[2] = 0; }
$rate .= "&nbsp;".$ratearray[1].".".$ratearray[2];
if(!$userid){
$rate .= " - ".$ratearray[0]."&nbsp;";

View File

@@ -93,8 +93,8 @@ class user_select
}
if ($class == e_UC_MEMBER)
{
$sql -> db_Select("userclass_classes", "userclass_id, userclass_name", "ORDER BY userclass_name", "nowhere");
while ($row = $sql -> db_Fetch())
$sql -> select("userclass_classes", "userclass_id, userclass_name", "ORDER BY userclass_name", "nowhere");
while ($row = $sql -> fetch())
{
if (check_class($row['userclass_id']) || ADMINPERMS == '0')
{
@@ -104,8 +104,8 @@ class user_select
}
else
{
$sql -> db_Select("userclass_classes", "userclass_id, userclass_name", "userclass_id='".intval($class)."' ORDER BY userclass_name");
while ($row = $sql -> db_Fetch())
$sql -> select("userclass_classes", "userclass_id, userclass_name", "userclass_id='".intval($class)."' ORDER BY userclass_name");
while ($row = $sql -> fetch())
{
$text .= "<option value='".$row['userclass_id'].":".$row['userclass_name']."'>".$row['userclass_name']."</option>";
}
@@ -143,7 +143,7 @@ class user_select
</script>";
list($form_type, $form_id) = explode(".", $user_form);
if($form_id == "") { $form_id = $form_type; }
if(empty($form_id)) { $form_id = $form_type; }
if ($type == 'list')
{
@@ -183,8 +183,8 @@ class user_select
function real_name($_id)
{
global $sql;
$sql -> db_Select("user", "user_name", "user_id='".intval($_id)."' ");
if ($row = $sql -> db_Fetch())
$sql ->select("user", "user_name", "user_id='".intval($_id)."' ");
if ($row = $sql ->fetch())
{
return $row['user_name'];
}
@@ -210,7 +210,7 @@ class user_select
}
else
{
if($elementID == "")
if(empty($elementID))
{
$elementID = $elementType;
}
@@ -297,9 +297,9 @@ class user_select
function findusers($s,$banned=FALSE) {
global $sql, $tp;
$inc = ($banned == FALSE) ? " AND user_ban != 1" : "";
if ($sql->db_Select("user", "*", "user_name LIKE '%".$tp -> toDB($s)."%'".$inc))
if ($sql->select("user", "*", "user_name LIKE '%".$tp -> toDB($s)."%'".$inc))
{
while ($row = $sql -> db_Fetch()) {
while ($row = $sql ->fetch()) {
$ret[strtolower($row['user_name'])] = $row['user_name'];
}
ksort($ret);

View File

@@ -445,11 +445,11 @@ class e_install
{
$_POST['stage'] = 1;
}
$_POST['stage'] = intval($_POST['stage']);
$_POST['stage'] = (int) $_POST['stage'];
if(!empty($_POST['back']))
{
$_POST['stage'] = intval($_POST['back']);
$_POST['stage'] = (int) $_POST['back'];
}
switch ($_POST['stage'])
@@ -2332,8 +2332,8 @@ function create_tables_unattended()
$einstall->previous_steps['admin']['password'] = (isset($_GET['admin_password']) ? $_GET['admin_password'] : 'admin_password');
$einstall->previous_steps['admin']['email'] = (isset($_GET['admin_email']) ? $_GET['admin_email'] : 'admin_email@xxx.com');
$einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? intval($_GET['gen']) : 1;
$einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 1;
$einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? (int) $_GET['gen'] : 1;
$einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? (int) $_GET['plugins'] : 1;
$einstall->previous_steps['prefs']['sitename'] = isset($_GET['sitename']) ? urldecode($_GET['sitename']) : LANINS_113;
$einstall->previous_steps['prefs']['sitetheme'] = isset($_GET['theme']) ? urldecode($_GET['theme']) : 'bootstrap3';

View File

@@ -185,7 +185,7 @@
$tmp = explode(".", substr(strrchr($online_location, "php."), 2));
if($tmp[0] == "article")
{
$sql->select("content", "content_heading, content_class", "content_id='" . intval($tmp[1]) . "'");
$sql->select("content", "content_heading, content_class", "content_id='" . (int) $tmp[1] . "'");
$content = $sql->fetch();
$online_location_page = ARTICLE . ": " . $content['content_heading'];
$online_location = str_replace("php.", "php?", $online_location);
@@ -197,7 +197,7 @@
}
elseif($tmp[0] == "review")
{
$sql->select("content", "content_heading, content_class", "content_id='" . intval($tmp[1]) . "'");
$sql->select("content", "content_heading, content_class", "content_id='" . (int) $tmp[1] . "'");
$content = $sql->fetch();
$online_location_page = REVIEW . ": " . $content['content_heading'];
$online_location = str_replace("php.", "php?", $online_location);

View File

@@ -115,16 +115,16 @@ class pageClass
if(!vartrue($_GET['id'])) // legacy URLs /page.php?x
{
$tmp = explode(".", e_QUERY);
$this->pageID = intval($tmp[0]);
$this->pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0);
$this->pageID = (int) $tmp[0];
$this->pageSelected = (isset($tmp[1]) ? (int) $tmp[1] : 0);
$this->pageTitles = array();
$this->bullet = '';
}
else // NEW URLS /page.php?id=x
{
$tmp = explode(".", e_QUERY);
$this->pageID = intval($_GET['id']);
$this->pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0); // Not sure what this is?
$this->pageID = (int) $_GET['id'];
$this->pageSelected = (isset($tmp[1]) ? (int) $tmp[1] : 0); // Not sure what this is?
$this->pageTitles = array();
$this->bullet = ''; // deprecated - use CSS instead.
}
@@ -170,11 +170,11 @@ class pageClass
switch ($request)
{
case 'listChapters':
$id = intval($_GET['bk']);
$id = (int) $_GET['bk'];
break;
case 'listPages':
$id = intval($_GET['ch']);
$id = (int) $_GET['ch'];
break;
case 'showPage':