1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-18 03:31:54 +02:00

Code optimization and cleanup.

This commit is contained in:
Cameron 2020-12-10 15:52:48 -08:00
parent bd3a181e27
commit f605ddc552
39 changed files with 364 additions and 371 deletions

View File

@ -51,7 +51,7 @@ $oblev_before_start = ob_get_level();
// B: Remove all output buffering
//
if(!isset($_E107) || !is_array($_E107)) { $_E107 = array(); }
if(isset($_E107['cli']) && !isset($_E107['debug']) && isset($_SERVER["HTTP_USER_AGENT"]))
if(isset($_E107['cli'], $_SERVER["HTTP_USER_AGENT"]) && !isset($_E107['debug']))
{
exit();
}
@ -84,7 +84,7 @@ if(function_exists('ini_get'))
}
// Destroy! (if we need to)
if($register_globals == true)
if($register_globals === true)
{
if(isset($_REQUEST['_E107'])) { unset($_E107); }
foreach($GLOBALS as $global=>$var)
@ -94,7 +94,7 @@ if($register_globals == true)
unset($$global);
}
}
unset($global, $var);
unset($global);
}
// MOVED TO $e107->prepare_request()
@ -119,7 +119,7 @@ if($register_globals == true)
// Set Absolute file-path of directory containing class2.php
if(!defined('e_ROOT'))
{
$e_ROOT = realpath(dirname(__FILE__)."/");
$e_ROOT = realpath(__DIR__ . '/');
if ((substr($e_ROOT,-1) !== '/') && (substr($e_ROOT,-1) !== '\\') )
{
@ -225,7 +225,7 @@ if(!defined('e_POWEREDBY_DISABLE'))
define('e_POWEREDBY_DISABLE', false);
}
if(isset($CLASS2_INCLUDE) && ($CLASS2_INCLUDE!=''))
if(!empty($CLASS2_INCLUDE))
{
require_once(e_ROOT.$CLASS2_INCLUDE);
}
@ -251,9 +251,9 @@ if(empty($mySQLdefaultdb))
// Upgrade Compatibility - Disable CL_WIDGETS before e107_class.php is loaded.
$tmpPlugDir = e_ROOT.$PLUGINS_DIRECTORY;
if(is_dir($tmpPlugDir."/cl_widgets"))
if(is_dir($tmpPlugDir. '/cl_widgets'))
{
rename($tmpPlugDir."/cl_widgets",$tmpPlugDir."/cl_widgets__");
rename($tmpPlugDir. '/cl_widgets',$tmpPlugDir. '/cl_widgets__');
}
unset($tmpPlugDir);
//
@ -414,16 +414,17 @@ $dbg->logTime('Prefs, misc tables');
//DEPRECATED, BC, call the method only when needed, $e107->admin_log caught by __get()
$admin_log = e107::getAdminLog(); //TODO - find & replace $admin_log, $e107->admin_log
if ($merror === 'e1')
{
message_handler('CRITICAL_ERROR', 6, ': generic, ', 'class2.php');
exit;
}
elseif ($merror === 'e2')
{
message_handler("CRITICAL_ERROR", 7, ': generic, ', 'class2.php');
exit;
}
if($merror === 'e1')
{
message_handler('CRITICAL_ERROR', 6, ': generic, ', 'class2.php');
exit;
}
if ($merror === 'e2')
{
message_handler("CRITICAL_ERROR", 7, ': generic, ', 'class2.php');
exit;
}
//
// K: Load compatability mode.
@ -457,7 +458,7 @@ $e_event = e107::getEvent(); //TODO - find & replace $e_event, $e107->e_event
// TODO - DEPRECATED - remove
$dbg->logTime('Load Core Prefs');
e107_require_once(e_HANDLER."pref_class.php");
e107_require_once(e_HANDLER. 'pref_class.php');
$sysprefs = new prefs;
@ -493,16 +494,14 @@ if(!e107::getConfig()->hasData())
exit;
}
else
{
// resurrect core from old prefs
e107::getConfig()->loadData(e107::getConfig('core_old')->getPref(), false)
->save(false, true);
// resurrect core_backup from old prefs
e107::getConfig('core_backup')->loadData(e107::getConfig('core_old')->getPref(), false)
->save(false, true);
}
// resurrect core from old prefs
e107::getConfig()->loadData(e107::getConfig('core_old')->getPref(), false)
->save(false, true);
// resurrect core_backup from old prefs
e107::getConfig('core_backup')->loadData(e107::getConfig('core_old')->getPref(), false)
->save(false, true);
}
}
@ -523,11 +522,11 @@ $dbg->logTime('Load Menu Prefs');
$menu_pref = e107::getConfig('menu')->getPref(); //extract menu prefs
// NEW - force ssl
if(e107::getPref('ssl_enabled') && !deftrue('e_SSL_DISABLE') && empty($_E107['cli']))
if(empty($_E107['cli']) && e107::getPref('ssl_enabled') && !deftrue('e_SSL_DISABLE') )
{
// NOTE: e_SSL_DISABLE check is here to help webmasters fix 'ssl_enabled'
// if set by accident on site with no SSL support - just define it in e107_config.php
if(strpos(e_REQUEST_URL, 'http://') === 0)
if(strncmp(e_REQUEST_URL, 'http://', 7) === 0)
{
// e_REQUEST_URL and e_REQUEST_URI introduced
$url = 'https://'.substr(e_REQUEST_URL, 7);
@ -562,14 +561,14 @@ if(!empty($pref['redirectsiteurl']) && !empty($pref['siteurl'])) {
if(isset($pref['multilanguage_subdomain']) && $pref['multilanguage_subdomain'])
{
if(substr(e_REQUEST_URL, 7, 4)=='www.' || substr(e_REQUEST_URL, 8, 4)=='www.')
if(substr(e_REQUEST_URL, 7, 4) === 'www.' || substr(e_REQUEST_URL, 8, 4) === 'www.')
{
$self = e_REQUEST_URL;
//if(e_QUERY){ $self .= '?'.e_QUERY; }
$location = str_replace('://www.', '://', $self);
if(defined('e_DEBUG') && e_DEBUG === true)
{
echo "Redirecting to location: ".$location;
echo 'Redirecting to location: ' .$location;
}
e107::getRedirect()->go($location,true,301);
@ -581,8 +580,14 @@ if(!empty($pref['redirectsiteurl']) && !empty($pref['siteurl'])) {
{
// Find domain and port from user and from pref
list($urlbase,$urlport) = explode(':',$_SERVER['HTTP_HOST'].':');
if (!$urlport) { $urlport = $_SERVER['SERVER_PORT']; }
if (!$urlport) { $urlport = 80; }
if(!$urlport)
{
$urlport = (int) $_SERVER['SERVER_PORT'];
}
if(!$urlport)
{
$urlport = 80;
}
$aPrefURL = explode('/',$pref['siteurl'],4);
if (count($aPrefURL) > 2) // we can do this -- there's at least http[s]://dom.ain/whatever
{
@ -590,14 +595,14 @@ if(!empty($pref['redirectsiteurl']) && !empty($pref['siteurl'])) {
list($PrefSiteBase,$PrefSitePort) = explode(':',$PrefRoot.':');
if (!$PrefSitePort)
{
$PrefSitePort = ( $aPrefURL[0] == 'https:' ) ? 443 : 80; // no port so set port based on 'scheme'
$PrefSitePort = ( $aPrefURL[0] === 'https:' ) ? 443 : 80; // no port so set port based on 'scheme'
}
// Redirect only if
// -- ports do not match (http <==> https)
// -- base domain does not match (case-insensitive)
// -- NOT admin area
if (($urlport != $PrefSitePort || stripos($PrefSiteBase, $urlbase) === false) && strpos(e_REQUEST_SELF, ADMINDIR) === false)
if (($urlport !== $PrefSitePort || stripos($PrefSiteBase, $urlbase) === false) && strpos(e_REQUEST_SELF, ADMINDIR) === false)
{
$aeSELF = explode('/', e_REQUEST_SELF, 4);
$aeSELF[0] = $aPrefURL[0]; // Swap in correct type of query (http, https)
@ -609,9 +614,9 @@ if(!empty($pref['redirectsiteurl']) && !empty($pref['siteurl'])) {
// header("Location: {$location}", true, 301); // send 301 header, not 302
if(defined('e_DEBUG') && e_DEBUG === true)
{
echo "DEBUG INFO: site-redirect preference enabled.<br />Redirecting to: <a hre='".$location."'>".$location."</a>";
echo "<br />e_DOMAIN: ".e_DOMAIN;
echo "<br />e_SUBDOMAIN: ".e_SUBDOMAIN;
echo "DEBUG INFO: site-redirect preference enabled.<br />Redirecting to: <a hre='".$location."'>".$location. '</a>';
echo '<br />e_DOMAIN: ' .e_DOMAIN;
echo '<br />e_SUBDOMAIN: ' .e_SUBDOMAIN;
}
else
{
@ -637,7 +642,7 @@ e107::getSession(); //init core _SESSION - actually here for reference only, it'
$dbg->logTime('Set User Language Session');
e107::getLanguage()->set(); // set e_LANGUAGE, USERLAN, Language Session / Cookies etc. requires $pref;
if(varset($pref['multilanguage']) && (e_LANGUAGE != $pref['sitelanguage']))
if(!empty($pref['multilanguage']) && (e_LANGUAGE !== $pref['sitelanguage']))
{
$sql->mySQLlanguage = e_LANGUAGE;
$sql2->mySQLlanguage = e_LANGUAGE;
@ -691,7 +696,7 @@ if(isset($pref['lan_global_list']))
$dbg->logTime('CHAP challenge');
$die = (e_AJAX_REQUEST == true) ? false : true;
$die = e_AJAX_REQUEST !== true;
e107::getSession()
->challenge() // Make sure there is a unique challenge string for CHAP login
->check($die); // Token protection
@ -837,9 +842,9 @@ if(isset($pref['e_module_list']) && $pref['e_module_list'])
$dbg->logTime('Load Theme');
if(!defined("USERTHEME" ))
if(!defined('USERTHEME'))
{
define('USERTHEME', (e107::getUser()->getPref('sitetheme') && file_exists(e_THEME.e107::getUser()->getPref('sitetheme')."/theme.php") ? e107::getUser()->getPref('sitetheme') : false));
define('USERTHEME', (e107::getUser()->getPref('sitetheme') && file_exists(e_THEME.e107::getUser()->getPref('sitetheme'). '/theme.php') ? e107::getUser()->getPref('sitetheme') : false));
}
//########### Module redefinable functions ###############
@ -865,7 +870,7 @@ if (!function_exists('checkvalidtheme'))
$themeobj = new themeHandler;
$themeArray = $themeobj->getThemes('id');
$id = intval($id);
$id = (int) $id;
$themeDef = $themeobj->findDefault($themeArray[$id]);
@ -884,7 +889,7 @@ if (!function_exists('checkvalidtheme'))
return;
}
e107::getDebug()->logTime("Theme Check");
e107::getDebug()->logTime('Theme Check');
if (@fopen(e_THEME.$theme_check.'/theme.php', 'r'))
// if (is_readable(e_THEME.$theme_check.'/theme.php'))
@ -931,7 +936,7 @@ if (!function_exists('checkvalidtheme'))
}
}
e107::getDebug()->logTime("Theme Check End");
e107::getDebug()->logTime('Theme Check End');
$themes_dir = $e107->getFolder('themes');
$e107->http_theme_dir = "{$e107->server_path}{$themes_dir}{$e107->site_theme}/";
@ -961,7 +966,7 @@ if (!class_exists('e107table', false))
private $themeClass = 'theme'; // v2.3.0+
private $legacyThemeClass;
private $adminThemeClass;
public $frontend = null;
public $frontend = false;
private $uniqueId = null;
private $content = array();
private $contentTypes = array('header','footer','text','title','image', 'list');
@ -971,8 +976,8 @@ if (!class_exists('e107table', false))
public function init()
{
$this->legacyThemeClass = e107::getPref('sitetheme')."_theme"; // disabled at the moment.
$this->adminThemeClass = e107::getPref('admintheme')."_admintheme"; // Check for a class.
$this->legacyThemeClass = e107::getPref('sitetheme'). '_theme'; // disabled at the moment.
$this->adminThemeClass = e107::getPref('admintheme'). '_admintheme'; // Check for a class.
$this->load();
}
@ -988,7 +993,7 @@ if (!class_exists('e107table', false))
return null;
}
if(class_exists($this->adminThemeClass) && ($this->frontend == false))
if(($this->frontend === false) && class_exists($this->adminThemeClass))
{
/** @var e_theme_render $thm */
$this->thm = new $this->adminThemeClass();
@ -1112,7 +1117,7 @@ if (!class_exists('e107table', false))
}
if(!in_array($type,$this->contentTypes))
if(!in_array($type, $this->contentTypes, true))
{
return false;
}
@ -1188,9 +1193,9 @@ if (!class_exists('e107table', false))
if ($override_tablerender)
{
$result = call_user_func($override_tablerender, $caption, $text, $mode, $return);
$result = $override_tablerender($caption, $text, $mode, $return);
if ($result == 'return')
if ($result === 'return')
{
return '';
}
@ -1206,23 +1211,20 @@ if (!class_exists('e107table', false))
}
ob_start();
$this->tablestyle($caption, $text, $mode);
$ret=ob_get_contents();
ob_end_clean();
return $ret;
}
else
{
if(!empty($text) && $this->eMenuArea)
{
$this->eMenuCount++;
}
$this->tablestyle($caption, $text, $mode);
return '';
return ob_get_clean();
}
if(!empty($text) && $this->eMenuArea)
{
$this->eMenuCount++;
}
$this->tablestyle($caption, $text, $mode);
return '';
}
@ -1256,7 +1258,7 @@ if (!class_exists('e107table', false))
// Automatic list detection .
$isList = (strpos(ltrim($text), '<ul') === 0 );
$isList = (strncmp(ltrim($text), '<ul', 3) === 0 );
$this->setContent('list', $isList);
$options = $this->getContent();
@ -1308,7 +1310,7 @@ $e107 = e107::getInstance(); // Is this needed now?
$dbg->logTime('IP Handler and Ban Check');
e107::getIPHandler()->ban();
if(varset($pref['force_userupdate']) && USER && !isset($_E107['no_forceuserupdate']) && $_SERVER['QUERY_STRING'] !== 'logout')
if(USER && !isset($_E107['no_forceuserupdate']) && varset($pref['force_userupdate']) && $_SERVER['QUERY_STRING'] !== 'logout')
{
if(isset($currentUser) && force_userupdate($currentUser))
{
@ -1349,7 +1351,7 @@ if (isset($_POST['userlogin']) || isset($_POST['userlogin_x']))
// $_SESSION['ubrowser'] check not needed anymore - see session handler
// e_QUERY not defined in single entry mod
if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'session') && isset($_SESSION['ubrowser']) && ($_SESSION['ubrowser'] != $ubrowser))*/)
if (($_SERVER['QUERY_STRING'] === 'logout')/* || (($pref['user_tracking'] == 'session') && isset($_SESSION['ubrowser']) && ($_SESSION['ubrowser'] != $ubrowser))*/)
{
if (USER)
{
@ -1375,7 +1377,7 @@ if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'ses
e107::getUser()->logout();
// it might be removed soon
if ($pref['user_tracking'] == 'session')
if ($pref['user_tracking'] === 'session')
{
session_destroy();
$_SESSION[e_COOKIE]='';
@ -1450,7 +1452,7 @@ function systemTimeZoneIsValid($zone = '')
$zones = systemTimeZones();
$zoneKeys = array_keys($zones);
if(in_array($zone, $zoneKeys))
if(in_array($zone, $zoneKeys, true))
{
return true;
}
@ -1463,13 +1465,13 @@ $e_deltaTime = 0;
if (isset($_COOKIE['e107_tdOffset']))
{
// Actual seconds of delay. See e107.js and footer_default.php
$e_deltaTime = (15*floor((intval($_COOKIE['e107_tdOffset']) /60)/15))*60; // Delay in seconds rounded to the lowest quarter hour
$e_deltaTime = (15*floor(((int) $_COOKIE['e107_tdOffset'] /60)/15))*60; // Delay in seconds rounded to the lowest quarter hour
}
if (isset($_COOKIE['e107_tzOffset']))
{
// Relative client-to-server time zone offset in seconds.
$e_deltaTime += (-(intval($_COOKIE['e107_tzOffset']) * 60 + date("Z")));
$e_deltaTime += (-((int)$_COOKIE['e107_tzOffset'] * 60 + date('Z')));
}
define('TIMEOFFSET', $e_deltaTime);
@ -1521,18 +1523,18 @@ $dbg->logTime('Find/Load Theme-Layout'); // needs to run after checkvalidtheme()
if(deftrue('e_ADMIN_AREA'))
{
define("THEME_STYLE", $pref['admincss']);
define('THEME_STYLE', $pref['admincss']);
}
elseif(varset($pref['themecss']) && file_exists(THEME.$pref['themecss']))
{
define("THEME_STYLE", $pref['themecss']);
define('THEME_STYLE', $pref['themecss']);
}
else
{
define("THEME_STYLE", 'style.css');
define('THEME_STYLE', 'style.css');
}
if(!defined("THEME_LAYOUT"))
if(!defined('THEME_LAYOUT'))
{
$user_pref = e107::getUser()->getPref();
$pref = e107::getPref();
@ -1540,7 +1542,7 @@ if(!defined("THEME_LAYOUT"))
$cusPageDef = (empty($user_pref['sitetheme_deflayout'])) ? varset($pref['sitetheme_deflayout']) : $user_pref['sitetheme_deflayout'];
$deflayout = e107::getTheme()->getThemeLayout($cusPagePref, $cusPageDef, e_REQUEST_URL, varset($_SERVER['SCRIPT_FILENAME']));
define("THEME_LAYOUT",$deflayout);
define('THEME_LAYOUT',$deflayout);
unset($cusPageDef,$lyout,$cusPagePref,$menus_equery,$deflayout);
}
@ -1629,7 +1631,7 @@ else
define('ITEMVIEW', $pref['newsposts']);
}
if ($pref['antiflood1'] == 1 && !defined('FLOODPROTECT'))
if (!empty($pref['antiflood1']) && !defined('FLOODPROTECT'))
{
define('FLOODPROTECT', TRUE);
define('FLOODTIMEOUT', max(varset($pref['antiflood_timeout'], 10), 3));
@ -1663,8 +1665,8 @@ define('FILE_UPLOADS', (ini_get('file_uploads') ? true : false));
define('INIT', true);
if(isset($_SERVER['HTTP_REFERER']))
{
$tmp = explode("?", $_SERVER['HTTP_REFERER']);
define('e_REFERER_SELF',($tmp[0] == e_REQUEST_SELF));
$tmp = explode('?', $_SERVER['HTTP_REFERER']);
define('e_REFERER_SELF',($tmp[0] === e_REQUEST_SELF));
unset($tmp);
}
else
@ -1692,11 +1694,9 @@ function js_location($qry)
echo $error_handler->return_errors();
exit;
}
else
{
echo "<script type='text/javascript'>document.location.href='{$qry}'</script>\n";
exit;
}
echo "<script type='text/javascript'>document.location.href='{$qry}'</script>\n";
exit;
}
function check_email($email)
@ -1734,7 +1734,7 @@ function check_email($email)
function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
{
$e107 = e107::getInstance();
if($var == e_LANGUAGE)
if($var === e_LANGUAGE)
{
return TRUE;
}
@ -1753,7 +1753,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
$userclass = class_list($uid);
}
if ($userclass == '')
if (empty($userclass))
{
return FALSE;
}
@ -1770,7 +1770,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
//value to test is a userclass name (or garbage, of course), go get the id
if(!is_numeric($v))
{
if (substr($v, 0, 1) == '-')
if (strncmp($v, '-', 1) === 0)
{
$invert = TRUE;
$v = substr($v, 1);
@ -1785,7 +1785,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
if ($v !== FALSE)
{
// Ignore non-valid userclass names
if (in_array($v, $class_array) || ($v === '0') || ($v === 0))
if (($v === '0') || ($v === 0) || in_array($v, $class_array, true))
{
if ($invert)
{
@ -1793,7 +1793,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
}
$latchedAccess = TRUE;
}
elseif ($invert && count($varList) == 1)
elseif ($invert && count($varList) === 1)
{
// Handle scenario where only an 'exclude' class is passed
$latchedAccess = TRUE;
@ -1828,7 +1828,7 @@ function getperms($arg, $ap = ADMINPERMS)
return true;
}
if ($arg == 'P' && preg_match("#(.*?)/".e107::getInstance()->getFolder('plugins')."(.*?)/(.*?)#", e_SELF, $matches))
if ($arg === 'P' && preg_match('#(.*?)/' .e107::getInstance()->getFolder('plugins'). '(.*?)/(.*?)#', e_SELF, $matches))
{
$sql = e107::getDb('psql');
@ -1842,11 +1842,12 @@ function getperms($arg, $ap = ADMINPERMS)
$ap_array = explode('.',$ap);
if(in_array($arg,$ap_array,FALSE))
if (in_array($arg,$ap_array,FALSE))
{
return true;
}
elseif(strpos($arg, "|")) // check for multiple perms - separated by '|'.
if(strpos($arg, "|"))
{
$tmp = explode("|", $arg);
foreach($tmp as $val)
@ -1961,7 +1962,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
default:
$_user_pref = $tp->toDB($user_pref, true, true, 'pReFs');
$tmp = $eArrayStorage->WriteArray($_user_pref);
$sql->update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid));
$sql->update('user', "user_prefs='$tmp' WHERE user_id=". (int)$uid);
return $tmp;
break;
}
@ -2012,16 +2013,14 @@ class floodprotect
*/
$sql= e107::getDb('flood');
if (FLOODPROTECT == true)
if (FLOODPROTECT === true)
{
$sql->select($table, '*', 'ORDER BY '.$orderfield.' DESC LIMIT 1', 'no_where');
$row=$sql->fetch();
return ($row[$orderfield] > (time() - FLOODTIMEOUT) ? false : true);
}
else
{
return TRUE;
return ($row[$orderfield] <= (time() - FLOODTIMEOUT));
}
return TRUE;
}
}
@ -2181,7 +2180,7 @@ e107::getDebug()->log("Timezone: ".USERTIMEZONE); // remove later on.
if (isset($_POST['settheme']))
{
$uconfig = $user->getConfig();
if(e107::getPref('sitetheme') != $_POST['sitetheme'])
if(e107::getPref('sitetheme') !== $_POST['sitetheme'])
{
require_once(e_HANDLER."theme_handler.php");
$utheme = new themeHandler;
@ -2250,7 +2249,7 @@ function cookie($name, $value, $expire=0, $path = e_HTTP, $domain = '', $secure
{
if(!e_SUBDOMAIN || (defined('MULTILANG_SUBDOMAIN') && MULTILANG_SUBDOMAIN === TRUE))
{
$domain = (e_DOMAIN != FALSE) ? ".".e_DOMAIN : "";
$domain = (e_DOMAIN !== false) ? ".".e_DOMAIN : "";
}
setcookie($name, $value, $expire, $path, $domain, $secure, true);
@ -2260,15 +2259,15 @@ function cookie($name, $value, $expire=0, $path = e_HTTP, $domain = '', $secure
function session_set($name, $value, $expire='', $path = e_HTTP, $domain = '', $secure = 0)
{
global $pref;
if ($pref['user_tracking'] == 'session')
if ($pref['user_tracking'] === 'session')
{
$_SESSION[$name] = $value;
}
else
{
if(($domain == '' && !e_SUBDOMAIN) || (defined('MULTILANG_SUBDOMAIN') && MULTILANG_SUBDOMAIN === TRUE))
if((empty($domain) && !e_SUBDOMAIN) || (defined('MULTILANG_SUBDOMAIN') && MULTILANG_SUBDOMAIN === TRUE))
{
$domain = (e_DOMAIN != FALSE) ? ".".e_DOMAIN : "";
$domain = (e_DOMAIN !== FALSE) ? ".".e_DOMAIN : "";
}
if(defined('e_MULTISITE_MATCH'))
@ -2442,7 +2441,7 @@ function loadLanFiles($unitName, $type='runtime')
*/
function force_userupdate($currentUser)
{
if (e_PAGE == 'usersettings.php' || strpos(e_SELF, ADMINDIR) == TRUE || (defined('FORCE_USERUPDATE') && (FORCE_USERUPDATE == FALSE)))
if (e_PAGE == 'usersettings.php' || (defined('FORCE_USERUPDATE') && (FORCE_USERUPDATE == FALSE)) || strpos(e_SELF, ADMINDIR) == TRUE )
{
return FALSE;
}
@ -2451,9 +2450,9 @@ function force_userupdate($currentUser)
foreach($signup_option_names as $key => $value)
{
if (e107::getPref('signup_option_'.$value, 0) == 2 && !$currentUser['user_'.$value])
if (!$currentUser['user_'.$value] && e107::getPref('signup_option_'.$value, 0) == 2)
{
return TRUE;
return true;
}
}
@ -2524,7 +2523,7 @@ class error_handler
return;
}
if ((isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'debug=') !== false) || isset($_COOKIE['e107_debug_level']) && strpos($_SERVER['QUERY_STRING'], 'debug=-') === false )
if ((isset($_SERVER['QUERY_STRING']) && (strpos($_SERVER['QUERY_STRING'], 'debug=') !== false)) || isset($_COOKIE['e107_debug_level']) && ((strpos($_SERVER['QUERY_STRING'], 'debug=-')) === false) )
{
$this->debug = true;
error_reporting(E_ALL);
@ -2544,12 +2543,28 @@ class error_handler
*/
private function deftrue($value)
{
if (defined($value) && constant($value))
return defined($value) && constant($value);
}
private function addError($type, $message, $line, $file)
{
$error = [];
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line <mark>{$line}</mark> of {$file}<br />\n";
if($this->xdebug)
{
return true;
$backtrace = xdebug_get_function_stack();
}
else
{
$trace = debug_backtrace();
$backtrace[0] = (isset($trace[1]) ? $trace[1] : "");
$backtrace[1] = (isset($trace[2]) ? $trace[2] : "");
}
return false;
$error['trace'] = $backtrace;
$this->errors[] = $error;
}
@ -2575,42 +2590,13 @@ class error_handler
{
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line <mark>{$line}</mark> of {$file}<br />\n";
if($this->xdebug)
{
$backtrace = xdebug_get_function_stack();
}
else
{
$trace = debug_backtrace();
$backtrace[0] = (isset($trace[1]) ? $trace[1] : "");
$backtrace[1] = (isset($trace[2]) ? $trace[2] : "");
}
$error['trace'] = $backtrace;
$this->errors[] = $error;
$this->addError($type, $message,$line,$file);
}
break;
case E_WARNING:
if ($startup_error || $this->deftrue('E107_DBG_BASIC') || $this->deftrue('E107_DBG_ERRBACKTRACE'))
{
// $error['short'] = "Warning: {$message}, Line {$line} of {$file}<br />\n";
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line <mark>{$line}</mark> of {$file}<br />\n";
if($this->xdebug)
{
$backtrace = xdebug_get_function_stack();
}
else
{
$trace = debug_backtrace();
$backtrace[0] = (isset($trace[1]) ? $trace[1] : "");
$backtrace[1] = (isset($trace[2]) ? $trace[2] : "");
}
$error['trace'] = $backtrace;
$this->errors[] = $error;
$this->addError($type, $message,$line,$file);
}
break;
case E_USER_ERROR:
@ -2630,7 +2616,6 @@ class error_handler
break;
}
unset($context);
return null;
}
@ -2740,12 +2725,12 @@ class e_http_header
function __construct()
{
if (strstr(varset($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip'))
if (strpos(varset($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== false)
{
$this->compression_browser_support = true;
}
if(ini_get("zlib.output_compression")=='' && function_exists("gzencode"))
if(function_exists("gzencode") && ini_get("zlib.output_compression")=='')
{
$this->compression_server_support = true;
}
@ -2826,7 +2811,7 @@ class e_http_header
$server = array();
foreach($_SERVER as $k=>$v)
{
if(substr($k,0,4) == 'HTTP')
if(strncmp($k, 'HTTP', 4) === 0)
{
$server[$k] = $v;
}
@ -2899,7 +2884,7 @@ class e_http_header
// $this->setHeader("Cache-Control: must-revalidate", true);
if($canCache && !deftrue('e_NOCACHE') && $_SERVER['REQUEST_METHOD'] === 'GET' && $_SERVER['QUERY_STRING'] != 'logout')
if($_SERVER['REQUEST_METHOD'] === 'GET' && $_SERVER['QUERY_STRING'] != 'logout' && $canCache && !deftrue('e_NOCACHE'))
{
// header("Cache-Control: must-revalidate", true);
if(e107::getPref('site_page_expires')) // TODO - allow per page

View File

@ -34,7 +34,7 @@ $_E107['no_menus'] = true;
$_E107['allow_guest'] = true; // allow crons to run while in members-only mode.
$_E107['no_maintenance'] = true;
require_once(realpath(dirname(__FILE__) . "/class2.php"));
require_once(realpath(__DIR__ . "/class2.php"));
require_once(e_HANDLER . "cron_class.php");
$cron = new cronScheduler();

View File

@ -44,11 +44,11 @@ if (isset($_POST['metasubmit']))
$meta_author[$lan] = $pref['meta_author'][$lan];
}
$meta_tag[e_LANGUAGE] = strip_if_magic(chop($_POST['meta']));
$meta_diz[e_LANGUAGE] = strip_if_magic(chop($_POST['meta_description']));
$meta_keywords[e_LANGUAGE] = strip_if_magic(chop($_POST['meta_keywords']));
$meta_copyright[e_LANGUAGE] = strip_if_magic(chop($_POST['meta_copyright']));
$meta_author[e_LANGUAGE] = strip_if_magic(chop($_POST['meta_author']));
$meta_tag[e_LANGUAGE] = strip_if_magic(rtrim($_POST['meta']));
$meta_diz[e_LANGUAGE] = strip_if_magic(rtrim($_POST['meta_description']));
$meta_keywords[e_LANGUAGE] = strip_if_magic(rtrim($_POST['meta_keywords']));
$meta_copyright[e_LANGUAGE] = strip_if_magic(rtrim($_POST['meta_copyright']));
$meta_author[e_LANGUAGE] = strip_if_magic(rtrim($_POST['meta_author']));
$pref['meta_news_summary'] = intval($_POST['meta_news_summary']);
$pref['meta_tag'] = $meta_tag;

View File

@ -16,7 +16,7 @@
$_E107['allow_guest'] = true; // allow crons to run while in members-only mode.
$_E107['no_maintenance'] = true;
$class2 = realpath(dirname(__FILE__) . "/../") . "/class2.php";
$class2 = realpath(__DIR__ . "/../") . "/class2.php";
@require_once($class2);
}

View File

@ -552,7 +552,7 @@ class e_date
}
else
{
preg_match('#(\d{1,2})(?:\D(\d{1,2})){0,1}(?:\D(\d{1,2})){0,1}#', $timeString, $timeVals);
preg_match('#(\d{1,2})(?:\D(\d{1,2}))?(?:\D(\d{1,2})){0,1}#', $timeString, $timeVals);
}
}
elseif ($endDay)

View File

@ -26,20 +26,20 @@
class e107_db_debug
{
private $active = false; // true when debug is active.
public $aSQLdetails = array(); // DB query analysis (in pieces for further analysis)
public $aDBbyTable = array();
public $aOBMarks = array(0 => ''); // Track output buffer level at each time mark
public $aMarkNotes = array(); // Other notes can be added and output...
public $aTimeMarks = array(); // Overall time markers
public $curTimeMark = 'Start';
public $nTimeMarks = 0; // Provide an array index for time marks. Stablizes 'current' function
// public $aGoodQueries = array();
// var $aBadQueries = array();
public $scbbcodes = array();
public $scbcount;
public $deprecated_funcs = array();
public $aLog = array(); // Generalized debug log (only seen during debug)
public $aIncList = array(); // Included files
var $aSQLdetails = array(); // DB query analysis (in pieces for further analysis)
var $aDBbyTable = array();
var $aOBMarks = array(0 => ''); // Track output buffer level at each time mark
var $aMarkNotes = array(); // Other notes can be added and output...
var $aTimeMarks = array(); // Overall time markers
var $curTimeMark = 'Start';
var $nTimeMarks = 0; // Provide an array index for time marks. Stablizes 'current' function
var $aGoodQueries = array();
var $aBadQueries = array();
var $scbbcodes = array();
var $scbcount;
var $deprecated_funcs = array();
var $aLog = array(); // Generalized debug log (only seen during debug)
var $aIncList = array(); // Included files
function __construct()
{
@ -180,15 +180,15 @@
}
/**
* @param $query
* @param $rli
* @param $origQryRes
* @param $aTrace
* @param $mytime
* @param $curtable
/**
* @param $query
* @param $rli
* @param $origQryRes
* @param $aTrace
* @param $mytime
* @param $curtable
* @return null
*/
*/
function Mark_Query($query, $rli, $origQryRes, $aTrace, $mytime, $curtable)
{
if(!$this->active)
@ -440,7 +440,7 @@
foreach($this->aTimeMarks as $item)
{
$item['What'] = str_pad($item['What'], 50);
$item['What'] = str_pad($item['What'], 50, " ", STR_PAD_RIGHT);
$text .= implode("\t\t\t", $item) . "\n";
}
@ -510,9 +510,16 @@
}
foreach($this->aTimeMarks as $tKey => $tMarker)
$obj = new ArrayObject($this->aTimeMarks);
$it = $obj->getIterator();
// while(list($tKey, $tMarker) = each($this->aTimeMarks))
foreach ($it as $tKey=>$tMarker)
{
if(!$bRowHeaders)
{
// First time: emit headers
@ -543,10 +550,10 @@
$tMem = ($tMarker['Memory']);
// if($tMem < 0) // Quick Fix for negative numbers.
// {
if($tMem < 0) // Quick Fix for negative numbers.
{
// $tMem = 0.0000000001;
// }
}
$tMarker['Memory'] = ($tMem ? number_format($tMem / 1024.0, 1) : '?'); // display if known
@ -562,7 +569,7 @@
$aSum['Memory'] = $tMem;
if($tMarker['What'] == 'Stop')
if($tMarker['What'] === 'Stop')
{
$tMarker['Time'] = '&nbsp;';
$tMarker['%Time'] = '&nbsp;';
@ -575,7 +582,10 @@
else
{
// Convert from start time to delta time, i.e. from now to next entry
$nextMarker = current($this->aTimeMarks);
// $nextMarker = current($this->aTimeMarks);
$it->next();
$nextMarker = $it->current();
$aNextT = $nextMarker['Time'];
$aThisT = $tMarker['Time'];
@ -587,9 +597,9 @@
$tMarker['Time'] = $this->highlight($tMarker['Time'], $thisDelta, .2);
$tMarker['%Time'] = $totTime ? number_format(100.0 * ($thisDelta / $totTime)) : 0;
$tMarker['%DB Count'] = number_format(100.0 * $tMarker['DB Count'] / $sql->db_QueryCount());
$tMarker['%DB Time'] = $db_time ? number_format(100.0 * $tMarker['DB Time'] / $db_time) : 0;
$tMarker['%Time'] = $totTime ? number_format(100.0 * ($thisDelta / $totTime), 0) : 0;
$tMarker['%DB Count'] = number_format(100.0 * $tMarker['DB Count'] / $sql->db_QueryCount(), 0);
$tMarker['%DB Time'] = $db_time ? number_format(100.0 * $tMarker['DB Time'] / $db_time, 0) : 0;
$tMarker['DB Time'] = number_format($tMarker['DB Time'] * 1000.0, 1);
$tMarker['OB Lev'] = $this->aOBMarks[$tKey];
@ -603,15 +613,15 @@
$text .= $this->aMarkNotes[$tKey] . "</td></tr>\n";
}
if($tMarker['What'] == 'Stop')
if($tMarker['What'] === 'Stop')
{
break;
}
}
$aSum['%Time'] = $totTime ? number_format(100.0 * ($aSum['Time'] / $totTime)) : 0;
$aSum['%DB Time'] = $db_time ? number_format(100.0 * ($aSum['DB Time'] / $db_time)) : 0;
$aSum['%DB Count'] = ($sql->db_QueryCount()) ? number_format(100.0 * ($aSum['DB Count'] / ($sql->db_QueryCount()))) : 0;
$aSum['%Time'] = $totTime ? number_format(100.0 * ($aSum['Time'] / $totTime), 0) : 0;
$aSum['%DB Time'] = $db_time ? number_format(100.0 * ($aSum['DB Time'] / $db_time), 0) : 0;
$aSum['%DB Count'] = ($sql->db_QueryCount()) ? number_format(100.0 * ($aSum['DB Count'] / ($sql->db_QueryCount())), 0) : 0;
$aSum['Time'] = number_format($aSum['Time'] * 1000.0, 1);
$aSum['DB Time'] = number_format($aSum['DB Time'] * 1000.0, 1);
@ -684,16 +694,16 @@
$aSum['DB Time'] += $curTable['DB Time'];
$aSum['DB Count'] += $curTable['DB Count'];
$curTable['%DB Count'] = number_format(100.0 * $curTable['DB Count'] / $sql->db_QueryCount());
$curTable['%DB Time'] = number_format(100.0 * $curTable['DB Time'] / $db_time);
$curTable['%DB Count'] = number_format(100.0 * $curTable['DB Count'] / $sql->db_QueryCount(), 0);
$curTable['%DB Time'] = number_format(100.0 * $curTable['DB Time'] / $db_time, 0);
$timeLabel = number_format($curTable['DB Time'] * 1000.0, 1);
$curTable['DB Time'] = $this->highlight($timeLabel, ($curTable['DB Time'] * 1000), 500); // 500 msec
$text .= "<tr><td class='forumheader3'>" . implode("&nbsp;</td><td class='forumheader3' style='text-align:right'>", array_values($curTable)) . "&nbsp;</td></tr>\n";
}
$aSum['%DB Time'] = $db_time ? number_format(100.0 * ($aSum['DB Time'] / $db_time)) : 0;
$aSum['%DB Count'] = ($sql->db_QueryCount()) ? number_format(100.0 * ($aSum['DB Count'] / ($sql->db_QueryCount()))) : 0;
$aSum['%DB Time'] = $db_time ? number_format(100.0 * ($aSum['DB Time'] / $db_time), 0) : 0;
$aSum['%DB Count'] = ($sql->db_QueryCount()) ? number_format(100.0 * ($aSum['DB Count'] / ($sql->db_QueryCount())), 0) : 0;
$aSum['DB Time'] = number_format($aSum['DB Time'] * 1000.0, 1);
$text .= "<tr><td class='fcaption'><b>" . implode("&nbsp;</td><td class='fcaption' style='text-align:right'><b>", array_values($aSum)) . "&nbsp;</b></td></tr>\n";
$text .= "\n</table><br />\n";
@ -706,10 +716,10 @@
$back_trace = debug_backtrace();
print_r($back_trace);
// print_r($back_trace);
$this->deprecated_funcs[] = array(
'func' => (isset($back_trace[1]['type']) && ($back_trace[1]['type'] == '::' || $back_trace[1]['type'] == '->') ? $back_trace[1]['class'] . $back_trace[1]['type'] . $back_trace[1]['function'] : $back_trace[1]['function']),
'func' => (isset($back_trace[1]['type']) && ($back_trace[1]['type'] === '::' || $back_trace[1]['type'] === '->') ? $back_trace[1]['class'] . $back_trace[1]['type'] . $back_trace[1]['function'] : $back_trace[1]['function']),
'file' => $back_trace[1]['file'],
'line' => $back_trace[1]['line']
);
@ -901,12 +911,11 @@
}
/**
* var_dump to debug log
*
* @param mixed $message
* @param int $TraceLev
*/
/**
* var_dump to debug log
*
* @param mixed $message
*/
function dump($message, $TraceLev = 1)
{
@ -1053,12 +1062,12 @@
{
if(defset('ADMIN_AREA'))
{
$filewanted = realpath(dirname(__FILE__)) . '/../' . $ADMIN_DIRECTORY . 'footer.php';
$filewanted = realpath(__DIR__) . '/../' . $ADMIN_DIRECTORY . 'footer.php';
require_once($filewanted);
}
elseif(defset('USER_AREA'))
{
$filewanted = realpath(dirname(__FILE__)) . '/../' . FOOTERF;
$filewanted = realpath(__DIR__) . '/../' . FOOTERF;
require_once($filewanted);
}
}

View File

@ -905,7 +905,7 @@ class e107
* @param string $class_name
* @param string|boolean $path optional script path
* @param string $regpath additional registry path
* @return Object
* @return mixed
*/
public static function getSingleton($class_name, $path = true, $regpath = '',$vars=null)
{
@ -972,7 +972,7 @@ class e107
* @param string $class_name
* @param mixed $arguments
* @param string|boolean $path optional script path
* @return object|null
* @return mixed
*/
public static function getObject($class_name, $arguments = null, $path = true)
{
@ -1305,7 +1305,7 @@ class e107
/**
* Retrieve sc parser singleton object
*
* @return e_parse_shortcode
* @return e_parse_shortcode|array
*/
public static function getScParser()
{
@ -1316,7 +1316,7 @@ class e107
/**
* Retrieve secure_image singleton object
*
* @return secure_image
* @return array|Object|secure_image
*/
public static function getSecureImg()
{
@ -1557,7 +1557,7 @@ class e107
}
// Get the currently used theme.
if ($themedir == 'current')
if ($themedir === 'current')
{
// If we are in the admin area.
if (deftrue('e_ADMIN_AREA', false))
@ -1813,7 +1813,7 @@ class e107
* @param integer $user_id target user
* @param boolean $checkIfCurrent if tru user_id will be compared to current user, if there is a match
* current user object will be returned
* @return e_system_user
* @return e_system_user|e_user
*/
public static function getSystemUser($user_id, $checkIfCurrent = true)
{
@ -1836,11 +1836,11 @@ class e107
/**
* Simple replacement for deprecated get_user_data(). e107::user();
* @param $uid integer user_id or leave empty for currently logged in user.
* @return array of user data
* @return array|false of user data
*/
public static function user($uid=null)
{
$uid = intval($uid);
$uid = (int) $uid;
if(empty($uid)){ return false; }
@ -2648,12 +2648,9 @@ class e107
//$debug_backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
$mes->addDebug('Executing <strong>'.$class_name.' :: '.$method_name.'()</strong>');
}
return call_user_func(array($obj, $method_name),$param, $param2);
}
else
{
// $mes->addDebug('Function <strong>'.$class_name.' :: '.$method_name.'()</strong> NOT found.');
return $obj->$method_name($param, $param2);
}
}
return FALSE;
}
@ -3287,7 +3284,7 @@ class e107
*
* @param string $fname filename without the extension part (e.g. 'comment')
* @param boolean $admin true if it's an administration language file
* @return bool
* @return bool|null
*/
public static function coreLan($fname, $admin = false)
{
@ -3297,7 +3294,7 @@ class e107
}
$cstring = 'corelan/'.e_LANGUAGE.'_'.$fname.($admin ? '_admin' : '_front');
if(self::getRegistry($cstring)) return;
if(self::getRegistry($cstring)) return null;
$fname = ($admin ? 'admin/' : '').'lan_'.preg_replace('/[^\w]/', '', trim($fname, '/')).'.php';
$path = e_LANGUAGEDIR.e_LANGUAGE.'/'.$fname;
@ -3333,12 +3330,12 @@ class e107
* @param string $plugin plugin name
* @param string $fname filename without the extension part (e.g. 'common')
* @param boolean $flat false (default, preferred) Language folder structure; true - prepend Language to file name
* @return bool
* @return bool|null
*/
public static function plugLan($plugin, $fname = '', $flat = false)
{
$cstring = 'pluglan/'.e_LANGUAGE.'_'.$plugin.'_'.$fname.($flat ? '_1' : '_0');
if(self::getRegistry($cstring)) return;
if(self::getRegistry($cstring)) return null;
$plugin = preg_replace('/[^\w]/', '', $plugin);
@ -3413,7 +3410,7 @@ class e107
* @param string $fname filename without the extension part (e.g. 'common' for common.php)
* @param string $theme theme name, if null current theme will be used
* @param boolean $flat false (default, preferred) Language folder structure; true - prepend Language to file name
* @return bool
* @return bool|null
*/
public static function themeLan($fname = '', $theme = null, $flat = false)
{
@ -3421,7 +3418,7 @@ class e107
else $theme = e_THEME.preg_replace('#[^\w/]#', '', $theme).'/languages/';
$cstring = 'themelan/'.$theme.$fname.($flat ? '_1' : '_0');
if(self::getRegistry($cstring)) return;
if(self::getRegistry($cstring)) return null;
if($fname) $fname = e_LANGUAGE.($flat ? '_' : '/').preg_replace('#[^\w/]#', '', trim($fname, '/'));
else $fname = e_LANGUAGE;
@ -3700,7 +3697,7 @@ class e107
$urlTemplate = $tp->replaceConstants($urlTemplate, $options['mode']);
$legacyUrl = $tp->simpleParse($urlTemplate, $row);
$legacyUrl = preg_replace('/&?\$[\d]/i', "", $legacyUrl); // remove any left-over $x (including prefix of '&')
$legacyUrl = preg_replace('/&?\$[\d]/', "", $legacyUrl); // remove any left-over $x (including prefix of '&')
// Avoid duplicate query keys. eg. URL has ?id=x and $options['query']['id'] exists.
@ -4052,7 +4049,7 @@ class e107
// Ensure thet '.' is the first part of the include path
$inc_path = explode(PATH_SEPARATOR, ini_get('include_path'));
if($inc_path[0] != '.')
if($inc_path[0] !== '.')
{
array_unshift($inc_path, '.');
$inc_path = implode(PATH_SEPARATOR, $inc_path);
@ -4084,9 +4081,9 @@ class e107
}
if($type == "_POST" || ($type == "_SERVER" && ($key == "QUERY_STRING")))
if($type === "_POST" || ($type === "_SERVER" && ($key === "QUERY_STRING")))
{
if($type == "_POST" && ($base64 === false))
if($type === "_POST" && ($base64 === false))
{
$input = preg_replace("/(\[code\])(.*?)(\[\/code\])/is","",$input);
}
@ -4133,10 +4130,10 @@ class e107
}
if($type == "_SERVER")
if($type === "_SERVER")
{
if(($key == "QUERY_STRING") && (
if(($key === "QUERY_STRING") && (
strpos(strtolower($input),"../../")!==FALSE
|| stripos($input,"php:")!==FALSE
|| stripos($input,"data:")!==FALSE
@ -4146,7 +4143,7 @@ class e107
self::die_http_400();
}
if(($key == "HTTP_USER_AGENT") && strpos($input,"libwww-perl")!==FALSE)
if(($key === "HTTP_USER_AGENT") && strpos($input,"libwww-perl")!==FALSE)
{
self::die_http_400();
}
@ -4198,17 +4195,17 @@ class e107
if(!defined('e_MOD_REWRITE')) // Allow e107_config.php to override.
{
define('e_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE')=='On'|| getenv('REDIRECT_HTTP_MOD_REWRITE')=='On' ? true : false));
define('e_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE') === 'On'|| getenv('REDIRECT_HTTP_MOD_REWRITE') === 'On' ? true : false));
}
if(!defined('e_MOD_REWRITE_MEDIA')) // Allow e107_config.php to override.
{
define('e_MOD_REWRITE_MEDIA', (getenv('HTTP_MOD_REWRITE_MEDIA')=='On' || getenv('REDIRECT_HTTP_MOD_REWRITE_MEDIA')=='On' ? true : false));
define('e_MOD_REWRITE_MEDIA', (getenv('HTTP_MOD_REWRITE_MEDIA') === 'On' || getenv('REDIRECT_HTTP_MOD_REWRITE_MEDIA') === 'On' ? true : false));
}
if(!defined('e_MOD_REWRITE_STATIC')) // Allow e107_config.php to override.
{
define('e_MOD_REWRITE_STATIC', (getenv('HTTP_MOD_REWRITE_STATIC')=='On' || getenv('REDIRECT_HTTP_MOD_REWRITE_STATIC')=='On' ? true : false));
define('e_MOD_REWRITE_STATIC', (getenv('HTTP_MOD_REWRITE_STATIC') === 'On' || getenv('REDIRECT_HTTP_MOD_REWRITE_STATIC') === 'On' ? true : false));
}
$subdomain = false;
@ -4300,7 +4297,7 @@ class e107
// ssl_enabled pref not needed anymore, scheme is auto-detected
$this->HTTP_SCHEME = 'http';
if (
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ||
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)
)
{
@ -4333,7 +4330,7 @@ class e107
unset($http_path[$j]);
$j++;
}
$http_path = array_reverse($http_path);
$http_path = array_reverse((array) $http_path);
@ -4343,7 +4340,7 @@ class e107
//var_dump($this->server_path);
//exit;
if ($this->server_path == "//")
if ($this->server_path === "//")
{
$this->server_path = "/";
}
@ -4383,11 +4380,11 @@ class e107
}
//BC temporary fixes
if (!isset($this->e107_dirs['UPLOADS_SERVER']) && $this->e107_dirs['UPLOADS_DIRECTORY'][0] == "/")
if (!isset($this->e107_dirs['UPLOADS_SERVER']) && $this->e107_dirs['UPLOADS_DIRECTORY'][0] === "/")
{
$this->e107_dirs['UPLOADS_SERVER'] = $this->e107_dirs['UPLOADS_DIRECTORY'];
}
if (!isset($this->e107_dirs['DOWNLOADS_SERVER']) && $this->e107_dirs['DOWNLOADS_DIRECTORY'][0] == "/")
if (!isset($this->e107_dirs['DOWNLOADS_SERVER']) && $this->e107_dirs['DOWNLOADS_DIRECTORY'][0] === "/")
{
$this->e107_dirs['DOWNLOADS_SERVER'] = $this->e107_dirs['DOWNLOADS_DIRECTORY'];
}
@ -4501,7 +4498,7 @@ class e107
function fix_windows_paths($path)
{
$fixed_path = str_replace(array('\\\\', '\\'), array('/', '/'), $path);
$fixed_path = (substr($fixed_path, 1, 2) == ":/" ? substr($fixed_path, 2) : $fixed_path);
$fixed_path = (substr($fixed_path, 1, 2) === ":/" ? substr($fixed_path, 2) : $fixed_path);
return $fixed_path;
}
@ -4732,7 +4729,7 @@ class e107
{
foreach($inArray as $res)
{
if(stristr($_SERVER['QUERY_STRING'], $res))
if(stripos($_SERVER['QUERY_STRING'], $res) !== false)
{
die('Access denied.');
}
@ -4762,10 +4759,7 @@ class e107
define('e_QUERY', filter_var($e_QUERY, FILTER_SANITIZE_URL));
$_SERVER['QUERY_STRING'] = e_QUERY;
}
else
{
// define('e_QUERY', ''); // breaks news sef-urls and possibly others. Moved to index.php.
}
define('e_TBQS', $_SERVER['QUERY_STRING']);
@ -4798,7 +4792,7 @@ class e107
{
unset($_data[$check]);
self::getSession()->set('__sessionBrowserCache', $_data);
return;
return null;
}
}
@ -4807,7 +4801,7 @@ class e107
$set = e_REQUEST_URI;
}
if(empty($set) || !is_string($set) || in_array($set, $_data)) return;
if(empty($set) || !is_string($set) || in_array($set, $_data)) return null;
$_data[] = $set;
self::getSession()->set('__sessionBrowserCache', array_unique($_data));
@ -5094,7 +5088,7 @@ class e107
// Currently only batches inside shortcodes/ folder are auto-detected,
// read the todo for e_shortcode.php related problems
if('shortcodes' == $end)
if('shortcodes' === $end)
{
$filename = e_PLUGIN.$tmp[0].'/shortcodes/batch/'; // plugname/shortcodes/batch/
unset($tmp[0]);
@ -5115,7 +5109,7 @@ class e107
default: //core libraries, core shortcode batches
// core SC batch check
$end = array_pop($tmp);
if('shortcodes' == $end)
if('shortcodes' === $end)
{
$filename = e_CORE.'shortcodes/batch/'.$className.'.php'; // core shortcode batch
break;
@ -5144,7 +5138,7 @@ class e107
$levels = explode('\\', $className);
// Guard against classes that are not ours
if ($levels[0] != 'e107') return;
if ($levels[0] !== 'e107') return;
$levels[0] = e_HANDLER;
$classPath = implode('/', $levels).'.php';

View File

@ -2389,7 +2389,7 @@ class e_parse extends e_parser
// Arrays in JSON can't be associative. If the array is empty or if it
// has sequential whole number keys starting with 0, it's not associative
// so we can go ahead and convert it as an array.
if(empty($var) || array_keys($var) === range(0, sizeof($var) - 1))
if(empty($var) || array_keys($var) === range(0, count($var) - 1))
{
$output = array();
foreach($var as $v)

View File

@ -191,7 +191,7 @@ class e_thumbnail
return false;
}
if(!is_writeable(e_CACHE_IMAGE))
if(!is_writable(e_CACHE_IMAGE))
{
echo 'Cache folder not writeable! ';
return false;

View File

@ -743,8 +743,8 @@
}
else
{
socket_set_timeout($remote, $timeout);
fputs($remote, "GET " . urlencode($address) . " HTTP/1.0\r\n\r\n");
stream_set_timeout($remote, $timeout);
fwrite($remote, "GET " . urlencode($address) . " HTTP/1.0\r\n\r\n");
}
}
$fileContents = "";

View File

@ -340,7 +340,7 @@ class eIPHandler
if (!$this->isAddressRoutable($ip))
{
$ip3 = explode(',', $ip4); // May only be one address; could be several, comma separated, if multiple proxies used
$ip = trim($ip3[sizeof($ip3) - 1]); // If IP address is unroutable, replace with any forwarded_for address
$ip = trim($ip3[count($ip3) - 1]); // If IP address is unroutable, replace with any forwarded_for address
$this->logBanItem(0, 'X_Forward '.$ip4.' --> '.$ip); // Just log for interest ATM
}
}

View File

@ -1261,7 +1261,7 @@ class e_jsmanager
// Renumber integer keys as array_merge_recursive() does. Note that PHP
// automatically converts array keys that are integer strings (e.g., '1')
// to integers.
if (is_integer($key)) {
if (is_int($key)) {
$result[] = $value;
}
// Recurse when both values are arrays.

View File

@ -128,7 +128,7 @@ class Services_JSON
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
function __construct($use = 0)
{
$this->use = $use;
}
@ -373,7 +373,7 @@ class Services_JSON
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
if (is_array($var) && count($var) && (array_keys($var) !== range(0, count($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
@ -384,7 +384,7 @@ class Services_JSON
}
}
return '{' . join(',', $properties) . '}';
return '{' . implode(',', $properties) . '}';
}
// treat it like a regular array
@ -396,7 +396,7 @@ class Services_JSON
}
}
return '[' . join(',', $elements) . ']';
return '[' . implode(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
@ -411,7 +411,7 @@ class Services_JSON
}
}
return '{' . join(',', $properties) . '}';
return '{' . implode(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
@ -778,7 +778,7 @@ if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
function __construct($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
@ -792,7 +792,7 @@ if (class_exists('PEAR_Error')) {
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
function __construct($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{

View File

@ -224,7 +224,7 @@ class MagpieRSS {
elseif ($this->feed_type == ATOM and $this->incontent )
{
// if tags are inlined, then flatten
$attrs_str = join(' ',
$attrs_str = implode(' ',
array_map('map_attrs',
array_keys($attrs),
array_values($attrs) ) );
@ -265,7 +265,7 @@ class MagpieRSS {
$this->append_content( $text );
}
else {
$current_el = join('_', array_reverse($this->stack));
$current_el = implode('_', array_reverse($this->stack));
$this->append($current_el, $text);
}
}

View File

@ -82,7 +82,7 @@ class email_validation_class
{
if($this->debug)
$this->OutputDebug("C $line");
return(fputs($connection,"$line\r\n"));
return(fwrite($connection,"$line\r\n"));
}
Function ValidateEmailAddress($email)
@ -183,7 +183,7 @@ class email_validation_class
$timeout=($this->data_timeout ? $this->data_timeout : $this->timeout);
if($timeout
&& function_exists("socket_set_timeout"))
socket_set_timeout($connection,$timeout,0);
stream_set_timeout($connection,$timeout,0);
if($this->debug)
$this->OutputDebug("Connected.");
if($this->VerifyResultLines($connection,"220")>0

View File

@ -3571,7 +3571,7 @@ class e_tree_model extends e_front_model
*/
protected function countResults($sql)
{
$this->_total = is_integer($sql->total_results) ? $sql->total_results : false; //requires SQL_CALC_FOUND_ROWS in query - see db handler
$this->_total = is_int($sql->total_results) ? $sql->total_results : false; //requires SQL_CALC_FOUND_ROWS in query - see db handler
if(false === $this->_total && $this->getModelTable() && !$this->getParam('nocount'))
{
//SQL_CALC_FOUND_ROWS not found in the query, do one more query

View File

@ -531,7 +531,7 @@ if (!defined("PCL_TAR"))
}
// ----- Look if the $p_index is really an integer
if (is_integer($p_index))
if (is_int($p_index))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, $p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)
@ -915,7 +915,7 @@ if (!defined("PCL_TAR"))
// ----- Write the already read block
$v_binary_data = pack("a512", "$v_buffer");
if ($p_mode=="tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($v_temp_tar, $v_binary_data);
@ -962,7 +962,7 @@ if (!defined("PCL_TAR"))
// ----- Write the already read block
$v_binary_data = pack("a512", "$v_buffer");
if ($p_mode=="tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($v_temp_tar, $v_binary_data);
@ -1321,7 +1321,7 @@ if (!defined("PCL_TAR"))
$v_header = array();
// ----- Recuperate the current number of elt in list
$v_nb = sizeof($p_list_detail);
$v_nb = count($p_list_detail);
// ----- Check the parameters
if ($p_tar == 0)
@ -1335,7 +1335,7 @@ if (!defined("PCL_TAR"))
}
// ----- Check the arguments
if (sizeof($p_list) == 0)
if (count($p_list) == 0)
{
// ----- Error log
PclErrorLog(-3, "Invalid file list parameter (invalid or empty list)");
@ -1562,7 +1562,7 @@ if (!defined("PCL_TAR"))
{
$v_binary_data = pack("a512", "$v_buffer");
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($p_tar, $v_binary_data);
$i++;
@ -1720,7 +1720,7 @@ if (!defined("PCL_TAR"))
// ----- Write the first 148 bytes of the header in the archive
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data_first, 148);
fwrite($p_tar, $v_binary_data_first, 148);
else
gzputs($p_tar, $v_binary_data_first, 148);
@ -1728,13 +1728,13 @@ if (!defined("PCL_TAR"))
$v_checksum = sprintf("%6s ", decoct($v_checksum));
$v_binary_data = pack("a8", $v_checksum);
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data, 8);
fwrite($p_tar, $v_binary_data, 8);
else
gzputs($p_tar, $v_binary_data, 8);
// ----- Write the last 356 bytes of the header in the archive
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data_last, 356);
fwrite($p_tar, $v_binary_data_last, 356);
else
gzputs($p_tar, $v_binary_data_last, 356);
@ -1768,7 +1768,7 @@ if (!defined("PCL_TAR"))
// ----- Write the last 0 filled block for end of archive
$v_binary_data = pack("a512", "");
if ($p_mode == "tar")
fputs($p_tar, $v_binary_data);
fwrite($p_tar, $v_binary_data);
else
gzputs($p_tar, $v_binary_data);
@ -1916,7 +1916,7 @@ if (!defined("PCL_TAR"))
$v_extract_file = FALSE;
// ----- Look into the file list
for ($i=0; $i<sizeof($p_file_list); $i++)
for ($i=0; $i<count($p_file_list); $i++)
{
TrFctMessage(__FILE__, __LINE__, 2, "Compare archived file '$v_header[filename]' from asked list file '".$p_file_list[$i]."'");
@ -2013,7 +2013,7 @@ if (!defined("PCL_TAR"))
$v_extract_file = 0;
}
// ----- Look if file is write protected
else if (!is_writeable($v_header[filename]))
else if (!is_writable($v_header[filename]))
{
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '$v_header[filename]' is write protected");
@ -2260,13 +2260,13 @@ if (!defined("PCL_TAR"))
// ----- Loop on the index list
$v_index=0;
for ($i=0; ($i<sizeof($v_list)) && ($v_result); $i++)
for ($i=0; ($i<count($v_list)) && ($v_result); $i++)
{
TrFctMessage(__FILE__, __LINE__, 3, "Looking for index part '$v_list[$i]'");
// ----- Extract range
$v_index_list = explode("-", $v_list[$i]);
$v_size_index_list = sizeof($v_index_list);
$v_size_index_list = count($v_index_list);
if ($v_size_index_list == 1)
{
TrFctMessage(__FILE__, __LINE__, 3, "Only one index '$v_index_list[0]'");
@ -2311,7 +2311,7 @@ if (!defined("PCL_TAR"))
$v_tar = $p_tar;
// ----- Look the number of elements already in $p_list_detail
$v_nb = sizeof($p_list_detail);
$v_nb = count($p_list_detail);
// ----- Read the blocks
While (!($v_end_of_file = ($p_tar_mode == "tar"?feof($v_tar):gzeof($v_tar))))
@ -2493,7 +2493,7 @@ if (!defined("PCL_TAR"))
$v_extract_file = 0;
}
// ----- Look if file is write protected
else if (!is_writeable($v_header[filename]))
else if (!is_writable($v_header[filename]))
{
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '$v_header[filename]' is write protected");
@ -2749,7 +2749,7 @@ if (!defined("PCL_TAR"))
TrFctMessage(__FILE__, __LINE__, 2, "Found file '$v_header[filename]', size '$v_header[size]'");
// ----- Look for filenames to delete
for ($i=0, $v_delete_file=FALSE; ($i<sizeof($p_file_list)) && (!$v_delete_file); $i++)
for ($i=0, $v_delete_file=FALSE; ($i<count($p_file_list)) && (!$v_delete_file); $i++)
{
// ----- Compare the file names
// if ($p_file_list[$i] == $v_header[filename])
@ -2780,7 +2780,7 @@ if (!defined("PCL_TAR"))
// ----- Write the file header
if ($p_tar_mode == "tar")
{
fputs($v_temp_tar, $v_binary_data, 512);
fwrite($v_temp_tar, $v_binary_data, 512);
}
else
{
@ -2956,7 +2956,7 @@ if (!defined("PCL_TAR"))
}
// ----- Prepare the list of files
for ($i=0; $i<sizeof($p_file_list); $i++)
for ($i=0; $i<count($p_file_list); $i++)
{
// ----- Reset the found list
$v_found_list[$i] = 0;
@ -3041,7 +3041,7 @@ if (!defined("PCL_TAR"))
TrFctMessage(__FILE__, __LINE__, 2, "Found file '$v_header[filename]', size '$v_header[size]'");
// ----- Look for filenames to update
for ($i=0, $v_update_file=FALSE, $v_found_file=FALSE; ($i<sizeof($v_stored_list)) && (!$v_update_file); $i++)
for ($i=0, $v_update_file=FALSE, $v_found_file=FALSE; ($i<count($v_stored_list)) && (!$v_update_file); $i++)
{
TrFctMessage(__FILE__, __LINE__, 4, "Compare with file '$v_stored_list[$i]'");
@ -3085,7 +3085,7 @@ if (!defined("PCL_TAR"))
// ----- Write the file header
if ($p_tar_mode == "tar")
{
fputs($v_temp_tar, $v_binary_data, 512);
fwrite($v_temp_tar, $v_binary_data, 512);
}
else
{
@ -3175,7 +3175,7 @@ if (!defined("PCL_TAR"))
}
// ----- Look for files that does not exists in the archive and need to be added
for ($i=0; $i<sizeof($p_file_list); $i++)
for ($i=0; $i<count($p_file_list); $i++)
{
// ----- Look if file not found in the archive
if (!$v_found_list[$i])
@ -3522,7 +3522,7 @@ if (!defined("PCL_TAR"))
$v_list = explode("/", $p_dir);
// ----- Study directories from last to first
for ($i=sizeof($v_list)-1; $i>=0; $i--)
for ($i=count($v_list)-1; $i>=0; $i--)
{
// ----- Look for current path
if ($v_list[$i] == ".")
@ -3535,14 +3535,14 @@ if (!defined("PCL_TAR"))
// ----- Ignore it and ignore the $i-1
$i--;
}
else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))
else if (($v_list[$i] == "") && ($i!=(count($v_list)-1)) && ($i!=0))
{
// ----- Ignore only the double '//' in path,
// but not the first and last '/'
}
else
{
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
$v_result = $v_list[$i].($i!=(count($v_list)-1)?"/".$v_result:"");
}
}
}

View File

@ -161,7 +161,7 @@ if (!defined("PCLTRACE_LIB"))
$g_pcl_trace_name .= ",".$p_name;
// ----- Update the function entry
$i = sizeof($g_pcl_trace_entries);
$i = count($g_pcl_trace_entries);
$g_pcl_trace_entries[$i][name] = $p_name;
$g_pcl_trace_entries[$i][param] = $p_param;
$g_pcl_trace_entries[$i][message] = "";
@ -173,7 +173,7 @@ if (!defined("PCLTRACE_LIB"))
// ----- Update the message entry
if ($p_message != "")
{
$i = sizeof($g_pcl_trace_entries);
$i = count($g_pcl_trace_entries);
$g_pcl_trace_entries[$i][name] = "";
$g_pcl_trace_entries[$i][param] = "";
$g_pcl_trace_entries[$i][message] = $p_message;
@ -231,7 +231,7 @@ if (!defined("PCLTRACE_LIB"))
// ----- Update the message entry
if ($p_message != "")
{
$i = sizeof($g_pcl_trace_entries);
$i = count($g_pcl_trace_entries);
$g_pcl_trace_entries[$i][name] = "";
$g_pcl_trace_entries[$i][param] = "";
$g_pcl_trace_entries[$i][message] = $p_message;
@ -242,7 +242,7 @@ if (!defined("PCLTRACE_LIB"))
}
// ----- Update the function entry
$i = sizeof($g_pcl_trace_entries);
$i = count($g_pcl_trace_entries);
$g_pcl_trace_entries[$i][name] = $v_name;
$g_pcl_trace_entries[$i][param] = $p_return;
$g_pcl_trace_entries[$i][message] = "";
@ -275,7 +275,7 @@ if (!defined("PCLTRACE_LIB"))
return;
// ----- Update the entry
$i = sizeof($g_pcl_trace_entries);
$i = count($g_pcl_trace_entries);
$g_pcl_trace_entries[$i][name] = "";
$g_pcl_trace_entries[$i][param] = "";
$g_pcl_trace_entries[$i][message] = $p_message;
@ -308,7 +308,7 @@ if (!defined("PCLTRACE_LIB"))
return;
// ----- Update the entry
$i = sizeof($g_pcl_trace_entries);
$i = count($g_pcl_trace_entries);
$g_pcl_trace_entries[$i][name] = "";
$g_pcl_trace_entries[$i][param] = "";
$g_pcl_trace_entries[$i][message] = $p_message;
@ -360,7 +360,7 @@ if (!defined("PCLTRACE_LIB"))
// ----- Display
$v_again=0;
for ($i=0; $i<sizeof($g_pcl_trace_entries); $i++)
for ($i=0; $i<count($g_pcl_trace_entries); $i++)
{
// ---- Row header
echo "<tr>";

View File

@ -293,7 +293,7 @@ class PclZip
$v_size--;
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
if ((is_int($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
@ -367,7 +367,7 @@ class PclZip
}
// ----- Reformat the string list
if (sizeof($v_string_list) != 0) {
if (count($v_string_list) != 0) {
foreach ($v_string_list as $v_string) {
if ($v_string != '') {
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
@ -468,7 +468,7 @@ class PclZip
$v_size--;
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
if ((is_int($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
@ -546,7 +546,7 @@ class PclZip
}
// ----- Reformat the string list
if (sizeof($v_string_list) != 0) {
if (count($v_string_list) != 0) {
foreach ($v_string_list as $v_string) {
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
}
@ -714,7 +714,7 @@ class PclZip
$v_arg_list = func_get_args();
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
if ((is_int($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
@ -873,7 +873,7 @@ class PclZip
$v_size--;
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
if ((is_int($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
@ -949,7 +949,7 @@ class PclZip
$p_index
);
$v_options_trick = array();
$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array(
$v_result = $this->privParseOptions($v_arg_trick, count($v_arg_trick), $v_options_trick, array(
PCLZIP_OPT_BY_INDEX => 'optional'
));
if ($v_result != 1) {
@ -1445,7 +1445,7 @@ class PclZip
// ----- Check the value
$v_value = $p_options_list[$i + 1];
if ((!is_integer($v_value)) || ($v_value < 0)) {
if ((!is_int($v_value)) || ($v_value < 0)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
return PclZip::errorCode();
@ -1603,7 +1603,7 @@ class PclZip
// ----- Parse items
$v_work_list = explode(",", $p_options_list[$i + 1]);
} elseif (is_integer($p_options_list[$i + 1])) {
} elseif (is_int($p_options_list[$i + 1])) {
$v_work_list[0] = $p_options_list[$i + 1] . '-' . $p_options_list[$i + 1];
} elseif (is_array($p_options_list[$i + 1])) {
$v_work_list = $p_options_list[$i + 1];
@ -1621,10 +1621,10 @@ class PclZip
// ----- Check the format of each item
$v_sort_flag = false;
$v_sort_value = 0;
for ($j = 0; $j < sizeof($v_work_list); $j++) {
for ($j = 0; $j < count($v_work_list); $j++) {
// ----- Explode the item
$v_item_list = explode("-", $v_work_list[$j]);
$v_size_item_list = sizeof($v_item_list);
$v_size_item_list = count($v_item_list);
// ----- TBC : Here we might check that each item is a
// real integer ...
@ -1902,7 +1902,7 @@ class PclZip
break;
case PCLZIP_ATT_FILE_MTIME:
if (!is_integer($v_value)) {
if (!is_int($v_value)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". Integer expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
return PclZip::errorCode();
@ -1968,7 +1968,7 @@ class PclZip
$v_result_list = array();
// ----- Look each entry
for ($i = 0; $i < sizeof($p_filedescr_list); $i++) {
for ($i = 0; $i < count($p_filedescr_list); $i++) {
// ----- Get filedescr
$v_descr = $p_filedescr_list[$i];
@ -2008,7 +2008,7 @@ class PclZip
$this->privCalculateStoredFilename($v_descr, $p_options);
// ----- Add the descriptor in result list
$v_result_list[sizeof($v_result_list)] = $v_descr;
$v_result_list[count($v_result_list)] = $v_descr;
// ----- Look for folder
if ($v_descr['type'] == 'folder') {
@ -2204,7 +2204,7 @@ class PclZip
}
// ----- Create the Central Dir files header
for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) {
for ($i = 0, $v_count = 0; $i < count($v_header_list); $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 < sizeof($v_header_list); $i++) {
for ($i = 0, $v_count = 0; $i < count($v_header_list); $i++) {
// ----- Create the file header
if ($v_header_list[$i]['status'] == 'ok') {
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
@ -2408,10 +2408,10 @@ class PclZip
$v_header = array();
// ----- Recuperate the current number of elt in list
$v_nb = sizeof($p_result_list);
$v_nb = count($p_result_list);
// ----- Loop on the files
for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) {
for ($j = 0; ($j < count($p_filedescr_list)) && ($v_result == 1); $j++) {
// ----- Format the filename
$p_filedescr_list[$j]['filename'] = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
@ -2947,14 +2947,14 @@ class PclZip
$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len']);
// ----- Write the first 148 bytes of the header in the archive
fputs($this->zip_fd, $v_binary_data, 30);
fwrite($this->zip_fd, $v_binary_data, 30);
// ----- Write the variable fields
if (strlen($p_header['stored_filename']) != 0) {
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
fwrite($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
}
if ($p_header['extra_len'] != 0) {
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
fwrite($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
}
// ----- Return
@ -2985,17 +2985,17 @@ class PclZip
$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);
// ----- Write the 42 bytes of the header in the zip file
fputs($this->zip_fd, $v_binary_data, 46);
fwrite($this->zip_fd, $v_binary_data, 46);
// ----- Write the variable fields
if (strlen($p_header['stored_filename']) != 0) {
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
fwrite($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
}
if ($p_header['extra_len'] != 0) {
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
fwrite($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
}
if ($p_header['comment_len'] != 0) {
fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
fwrite($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
}
// ----- Return
@ -3017,11 +3017,11 @@ class PclZip
$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));
// ----- Write the 22 bytes of the header in the zip file
fputs($this->zip_fd, $v_binary_data, 22);
fwrite($this->zip_fd, $v_binary_data, 22);
// ----- Write the variable fields
if (strlen($p_comment) != 0) {
fputs($this->zip_fd, $p_comment, strlen($p_comment));
fwrite($this->zip_fd, $p_comment, strlen($p_comment));
}
// ----- Return
@ -3245,7 +3245,7 @@ class PclZip
if ((isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
// ----- Look if the filename is in the list
for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
for ($j = 0; ($j < count($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
// ----- Look for a directory
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
@ -3283,7 +3283,7 @@ class PclZip
} elseif ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
// ----- Look if the index is in the list
for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
for ($j = $j_start; ($j < count($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
$v_extract = true;
@ -3584,7 +3584,7 @@ class PclZip
}
// ----- Look if file is write protected
} elseif (!is_writeable($p_entry['filename'])) {
} elseif (!is_writable($p_entry['filename'])) {
// ----- Change the file status
$p_entry['status'] = "write_protected";
@ -4529,7 +4529,7 @@ class PclZip
if ((isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
// ----- Look if the filename is in the list
for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
for ($j = 0; ($j < count($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
// ----- Look for a directory
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
@ -4570,7 +4570,7 @@ class PclZip
} elseif ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
// ----- Look if the index is in the list
for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
for ($j = $j_start; ($j < count($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
$v_found = true;
@ -4613,7 +4613,7 @@ class PclZip
}
// ----- Look which file need to be kept
for ($i = 0; $i < sizeof($v_header_list); $i++) {
for ($i = 0; $i < count($v_header_list); $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 < sizeof($v_header_list); $i++) {
for ($i = 0; $i < count($v_header_list); $i++) {
// ----- Create the file header
if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
$v_temp_zip->privCloseFd();
@ -4700,7 +4700,7 @@ class PclZip
$v_size = @ftell($v_temp_zip->zip_fd) - $v_offset;
// ----- Create the central dir footer
if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
if (($v_result = $v_temp_zip->privWriteCentralHeader(count($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
// ----- Reset the file list
unset($v_header_list);
$v_temp_zip->privCloseFd();
@ -5147,7 +5147,7 @@ function PclZipUtilPathReduction($p_dir)
// ----- Study directories from last to first
$v_skip = 0;
for ($i = sizeof($v_list) - 1; $i >= 0; $i--) {
for ($i = count($v_list) - 1; $i >= 0; $i--) {
// ----- Look for current path
if ($v_list[$i] == ".") {
// ----- Ignore this directory
@ -5166,7 +5166,7 @@ function PclZipUtilPathReduction($p_dir)
}
// ----- Last '/' i.e. indicates a directory
} elseif ($i == (sizeof($v_list) - 1)) {
} elseif ($i == (count($v_list) - 1)) {
$v_result = $v_list[$i];
// ----- Double '/' inside the path
@ -5179,7 +5179,7 @@ function PclZipUtilPathReduction($p_dir)
if ($v_skip > 0) {
$v_skip--;
} else {
$v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? "/" . $v_result : "");
$v_result = $v_list[$i] . ($i != (count($v_list) - 1) ? "/" . $v_result : "");
}
}
}
@ -5227,9 +5227,9 @@ function PclZipUtilPathInclusion($p_dir, $p_path)
// ----- Explode dir and path by directory separator
$v_list_dir = explode("/", $p_dir);
$v_list_dir_size = sizeof($v_list_dir);
$v_list_dir_size = count($v_list_dir);
$v_list_path = explode("/", $p_path);
$v_list_path_size = sizeof($v_list_path);
$v_list_path_size = count($v_list_path);
// ----- Study directories paths
$i = 0;

View File

@ -410,7 +410,7 @@ class e_plugin
e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__);
}
return in_array($this->_plugdir, array_keys($this->_installed));
return array_key_exists($this->_plugdir, $this->_installed);
}

View File

@ -24,7 +24,7 @@ class receiveMail
var $email='';
function receiveMail($username,$password,$EmailAddress,$mailserver='localhost',$servertype='pop3',$port='110') //Constructor
function __construct($username,$password,$EmailAddress,$mailserver='localhost',$servertype='pop3',$port='110') //Constructor
{
if($servertype=='imap')
{

View File

@ -1173,7 +1173,7 @@ class e_system_user extends e_user_model
{
$userInfo = $this->getData();
}
elseif(is_object($userInfo) && get_class($userInfo) == 'e_object' || is_subclass_of($userInfo, 'e_object'))
elseif(is_object($userInfo) && get_class($userInfo) == 'e_object' || $userInfo instanceof \e_object)
{
$userInfo = $userInfo->getData();
}

View File

@ -131,7 +131,7 @@ class parseXml extends xmlClass // BC with v1.x
function characterData ($p, $data)
{
$data = trim ( chop ( $data ));
$data = trim ( rtrim ( $data ));
$data = preg_replace('/&(?!amp;)/', '&amp;', $data);
if(!array_key_exists($this -> current_tag, $this -> xmlData))
{

View File

@ -454,7 +454,7 @@ class alt_auth_admin extends alt_auth_base
break;
default :
$err = "Coding error";
var_dump($log_result);
e107::getDebug()->log($log_result);
}
if(!empty($err))

View File

@ -45,7 +45,7 @@ class auth_login extends alt_auth_base
*
* @return AUTH_xxxx result code
*/
public function auth_login()
public function __construct()
{
$this->copyAttribs = array();
$this->copyMethods = array();
@ -128,7 +128,7 @@ class auth_login extends alt_auth_base
*/
public function close()
{
if (!@ldap_close($this->connection))
if (!@ldap_unbind($this->connection))
{
$this->makeErrorText(); // Read the error code and explanatory string
return false;

View File

@ -4,7 +4,7 @@ if (!defined('e107_INIT')) { exit; }
class e_tagwords_download
{
function e_tagwords_download()
function __construct()
{
$this->e107 = e107::getInstance();

View File

@ -26,7 +26,7 @@ class adminDownload extends download
var $advancedSearchFields;
var $userclassOptions;
function adminDownload()
function __construct()
{
global $pref;
parent::download();

View File

@ -186,7 +186,7 @@ if (isset($_POST['commentsubmit']))
$ftmp = $faq->view_faq($idx) ;
if(!defined("e_PAGETITLE"))
{
define("e_PAGETITLE", LAN_FAQS_011." - ". $ftmp['title']);
e107::title( LAN_FAQS_011." - ". $ftmp['title']);
}
require_once(HEADERF);
e107::getRender()->tablerender($ftmp['caption'], $ftmp['text']);
@ -196,7 +196,7 @@ if (isset($_POST['commentsubmit']))
{
$ftmp = $faq->view_cat_list($action, $id);
define("e_PAGETITLE", strip_tags($ftmp['title'].$ftmp['caption']));
e107::title( strip_tags($ftmp['title'].$ftmp['caption']));
require_once (HEADERF);
e107::getRender()->tablerender($ftmp['caption'], $ftmp['text']);
}

View File

@ -86,7 +86,7 @@ class plugin_gallery_index_controller extends eControllerFront
private function getTemplate()
{
$template = e107::getTemplate('gallery');
$template = (array) e107::getTemplate('gallery');
$oldKeys = array(
'list_start', 'list_item', 'list_caption', 'list_end',

View File

@ -80,7 +80,7 @@ class user_import
// Constructor
function user_import()
function __construct()
{
$this->userDB = new db; // Have our own database object to write to the user table
$this->actualExtended = e107::getUserExt()->getFieldNames(); // Create list of predefined extended user fields which are present

View File

@ -13,7 +13,7 @@ if (!defined('e107_INIT')) { exit; }
class e_linkwords
{
function e_linkwords()
function __construct()
{
global $pref, $admin_log;
/* constructor */

View File

@ -28,7 +28,7 @@ class list_admin
* @return void
*
*/
function list_admin($parent)
function __construct($parent)
{
$this->e107 = e107::getInstance();
$this->parent = $parent;

View File

@ -33,7 +33,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
$realPath = e107::getParser()->replaceConstants($path);
if(defined('e_MEDIA') && is_writeable(e_MEDIA."temp/") && ($resized = e107::getMedia()->resizeImage($path, e_MEDIA."temp/".basename($realPath),'h='.$h)))
if(defined('e_MEDIA') && is_writable(e_MEDIA."temp/") && ($resized = e107::getMedia()->resizeImage($path, e_MEDIA."temp/".basename($realPath),'h='.$h)))
{
$path = e107::getParser()->createConstants($resized);
}

View File

@ -70,7 +70,7 @@ class trackbackClass
return 'trackbackClass -> sendTrackback: Unable to connect to {$trackback_url[\'host\']}.';
}
fputs($socket, $header);
fwrite($socket, $header);
$response = "";
while (!feof($socket)) {

View File

@ -47,13 +47,16 @@ class AdminLoginCest
}
public function testAdminSearchPage(AcceptanceTester $I)
public function testForMissingLans(AcceptanceTester $I)
{
$this->e107Login($I);
$I->amOnPage('/e107_admin/search.php');
$I->dontSee("LAN_PLUGIN_");
$I->see("Pages");
$I->amOnPage('/e107_plugins/gallery/admin_gallery.php');
$I->dontSee("LAN_PLUGIN_");
}

View File

@ -158,7 +158,9 @@
if ($ver > 7.0)
{
// Test WebP format resize.
// $this->markTestSkipped('must be revisited.');
// Test WebP format resize.
$tests[] = array(
'src' => 'e_PLUGIN/gallery/images/beach.webp',
'aw' => 455,

View File

@ -50,7 +50,7 @@
$_E107['single_entry'] = true; // TODO - notify class2.php
define('ROOT', dirname(__FILE__));
define('ROOT', __DIR__);
set_include_path(ROOT.PATH_SEPARATOR.get_include_path());

View File

@ -32,7 +32,7 @@ require_once("e107_admin/ver.php");
define("e_VERSION", $e107info['e107_version']);
$e_ROOT = realpath(dirname(__FILE__)."/");
$e_ROOT = realpath(__DIR__ ."/");
if ((substr($e_ROOT,-1) !== '/') && (substr($e_ROOT,-1) !== '\\') )
{
$e_ROOT .= DIRECTORY_SEPARATOR; // Should function correctly on both windows and Linux now.
@ -93,12 +93,12 @@ class installLog
static function clear()
{
if(!is_writable(dirname(__FILE__)) || !MAKE_INSTALL_LOG)
if(!is_writable(__DIR__) || !MAKE_INSTALL_LOG)
{
return null;
}
$logFile = dirname(__FILE__).'/'.self::logFile;
$logFile = __DIR__ .'/'.self::logFile;
file_put_contents($logFile,'');
}
@ -111,12 +111,12 @@ class installLog
*/
static function add($message, $type='info')
{
if(!is_writable(dirname(__FILE__)) || !MAKE_INSTALL_LOG)
if(!is_writable(__DIR__) || !MAKE_INSTALL_LOG)
{
return null;
}
$logFile = dirname(__FILE__).'/'.self::logFile; // e107InstallLog.log';
$logFile = __DIR__ .'/'.self::logFile; // e107InstallLog.log';
$now = time();
$message = $now.', '.gmstrftime('%y-%m-%d %H:%M:%S',$now)."\t".$type."\t".$message."\n";
@ -272,7 +272,7 @@ if(isset($_POST['previous_steps']))
//$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY', 'LOGS_DIRECTORY', 'SYSTEM_DIRECTORY', 'CORE_DIRECTORY');
$e107_paths = array();
$e107 = e107::getInstance();
$ebase = realpath(dirname(__FILE__));
$ebase = realpath(__DIR__);
if($e107->initInstall($e107_paths, $ebase, $override)===false)
{
die_fatal_error("Error creating the following empty file: <b>".$ebase.DIRECTORY_SEPARATOR."e107_config.php</b><br />Please create it manually and then run the installation again.");

View File

@ -73,7 +73,7 @@ class e_thumbpage
function __construct()
{
$self = realpath(dirname(__FILE__));
$self = realpath(__DIR__);
$e_ROOT = $self."/";
@ -95,7 +95,7 @@ class e_thumbpage
// support early include feature
if(isset($CLASS2_INCLUDE) && !empty($CLASS2_INCLUDE))
{
require_once(realpath(dirname(__FILE__).'/'.$CLASS2_INCLUDE));
require_once(realpath(__DIR__ .'/'.$CLASS2_INCLUDE));
}