1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

PHP 7.3 fix

This commit is contained in:
Cameron
2019-02-08 11:01:42 -08:00
parent 6df31a233d
commit ee04ccc7db

View File

@@ -253,13 +253,26 @@ $tmp = e_ROOT.$HANDLERS_DIRECTORY;
e107_require_once($tmp.'/e107_class.php'); e107_require_once($tmp.'/e107_class.php');
unset($tmp); unset($tmp);
/** @note compact() causes issues with PHP7.3 */
$dirPaths = array('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY');
$e107_paths = array();
foreach($dirPaths as $v)
{
if(isset($$v))
{
$e107_paths[$v] = $$v;
}
}
// $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY');
$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY'); $sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLport'); if(isset($mySQLport))
{
$sql_info['mySQLport'] = $mySQLport;
}
$e107 = e107::getInstance()->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array())); $e107 = e107::getInstance()->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array()));
e107::getSingleton('eIPHandler'); // This auto-handles bans etc e107::getSingleton('eIPHandler'); // This auto-handles bans etc
unset($dirPaths,$sql_info,$e107_paths);
/** /**
* NEW - system security levels * NEW - system security levels
@@ -874,6 +887,7 @@ if (!function_exists('checkvalidtheme'))
} }
} }
closedir($handle); closedir($handle);
return null;
} }
$e107tmp_theme = 'bootstrap3'; // set to bootstrap3 by default. search_validtheme(); $e107tmp_theme = 'bootstrap3'; // set to bootstrap3 by default. search_validtheme();
@@ -940,7 +954,9 @@ if (!class_exists('e107table', false))
/** /**
* Set a unique id for use in tablestyle() method/function * Set a unique id for use in tablestyle() method/function
*
* @param string $id * @param string $id
* @return e107table
*/ */
public function setUniqueId($id) public function setUniqueId($id)
{ {
@@ -962,6 +978,8 @@ if (!class_exists('e107table', false))
} }
$this->content[$type] = (string) $val; $this->content[$type] = (string) $val;
return $this;
} }
@@ -1002,12 +1020,11 @@ if (!class_exists('e107table', false))
} }
/** /**
* @param $caption string caption text * @param string $caption caption text
* @param $text string * @param string $text
* @param $mode unique identifier * @param string $mode unique identifier
* @param $return boolean : return the html instead of echo it. * @param boolean $return : return the html instead of echo it.
* @return null * @return null
*/ */
public function tablerender($caption, $text, $mode = 'default', $return = false) public function tablerender($caption, $text, $mode = 'default', $return = false)
@@ -1120,7 +1137,7 @@ e107::getIPHandler()->ban();
if(varset($pref['force_userupdate']) && USER && !isset($_E107['no_forceuserupdate']) && $_SERVER['QUERY_STRING'] !== 'logout') if(varset($pref['force_userupdate']) && USER && !isset($_E107['no_forceuserupdate']) && $_SERVER['QUERY_STRING'] !== 'logout')
{ {
if(force_userupdate($currentUser)) if(isset($currentUser) && force_userupdate($currentUser))
{ {
header('Location: '.SITEURL.'usersettings.php?update'); header('Location: '.SITEURL.'usersettings.php?update');
exit(); exit();
@@ -1165,7 +1182,7 @@ if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'ses
{ {
if (check_class(varset($pref['user_audit_class'],''))) // Need to note in user audit trail if (check_class(varset($pref['user_audit_class'],''))) // Need to note in user audit trail
{ {
e107::getLog()->user_audit(USER_AUDIT_LOGOUT, '', USERID, USERNAME); e107::getLog()->user_audit(USER_AUDIT_LOGOUT, null, USERID, USERNAME);
} }
} }
@@ -1479,7 +1496,14 @@ else
define('ANON', false); define('ANON', false);
} }
if (empty($pref['newsposts']) ? define('ITEMVIEW', 15) : define('ITEMVIEW', $pref['newsposts'])); if(empty($pref['newsposts']))
{
define('ITEMVIEW', 15);
}
else
{
define('ITEMVIEW', $pref['newsposts']);
}
if ($pref['antiflood1'] == 1 && !defined('FLOODPROTECT')) if ($pref['antiflood1'] == 1 && !defined('FLOODPROTECT'))
{ {
@@ -1575,11 +1599,13 @@ function check_email($email)
} }
//--------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------
/** /**
* @param $var is a single class number or name, or a comma-separated list of the same. * @param mixed $var is a single class number or name, or a comma-separated list of the same.
* @param $userclass a custom list of userclasses or leave blank for the current user's permissions. * @param mixed $userclass a custom list of userclasses or leave blank for the current user's permissions.
* If a class is prefixed with '-' this means 'exclude' - returns FALSE if the user is in this class (overrides 'includes'). * If a class is prefixed with '-' this means 'exclude' - returns FALSE if the user is in this class (overrides 'includes').
* Otherwise returns TRUE if the user is in any of the classes listed in $var. * Otherwise returns TRUE if the user is in any of the classes listed in $var.
* @param int $uid
* @return bool
*/ */
function check_class($var, $userclass = USERCLASS_LIST, $uid = 0) function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
{ {
@@ -1614,7 +1640,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
$v = trim($v); $v = trim($v);
$invert = FALSE; $invert = FALSE;
//value to test is a userclass name (or garbage, of course), go get the id //value to test is a userclass name (or garbage, of course), go get the id
if( ! is_numeric($v)) if(!is_numeric($v))
{ {
if (substr($v, 0, 1) == '-') if (substr($v, 0, 1) == '-')
{ {
@@ -1650,14 +1676,18 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
} }
/**
* @param $arg
* @param bool|mixed|string $ap
* @return bool
*/
function getperms($arg, $ap = ADMINPERMS) function getperms($arg, $ap = ADMINPERMS)
{ {
// $ap = "4"; // Just for testing. // $ap = "4"; // Just for testing.
if(!ADMIN || trim($ap) === '') if(!ADMIN || trim($ap) === '')
{ {
return FALSE; return false;
} }
if($arg === 0) // Common-error avoidance with getperms(0) if($arg === 0) // Common-error avoidance with getperms(0)
@@ -1667,7 +1697,7 @@ function getperms($arg, $ap = ADMINPERMS)
if ($ap === '0' || $ap === '0.') // BC fix. if ($ap === '0' || $ap === '0.') // BC fix.
{ {
return TRUE; 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))
@@ -1686,7 +1716,7 @@ function getperms($arg, $ap = ADMINPERMS)
if(in_array($arg,$ap_array,FALSE)) if(in_array($arg,$ap_array,FALSE))
{ {
return TRUE; return true;
} }
elseif(strpos($arg, "|")) // check for multiple perms - separated by '|'. elseif(strpos($arg, "|")) // check for multiple perms - separated by '|'.
{ {
@@ -1695,13 +1725,13 @@ function getperms($arg, $ap = ADMINPERMS)
{ {
if(in_array($val,$ap_array)) if(in_array($val,$ap_array))
{ {
return TRUE; return true;
} }
} }
} }
else else
{ {
return FALSE; return false;
} }
} }
@@ -1709,6 +1739,8 @@ function getperms($arg, $ap = ADMINPERMS)
* @deprecated * @deprecated
* Get the user data from user and user_extended tables * Get the user data from user and user_extended tables
* SO MUCH DEPRECATED! Use e107::user($uid); * SO MUCH DEPRECATED! Use e107::user($uid);
* @param int $uid
* @param string $extra
* @return array * @return array
*/ */
function get_user_data($uid, $extra = '') function get_user_data($uid, $extra = '')
@@ -1739,6 +1771,10 @@ function get_user_data($uid, $extra = '')
/** /**
* @deprecated * @deprecated
* @example Use instead: e107::getConfig(alias)->->setPref($array)->save(); Not to be used for saving plugin or theme prefs! * @example Use instead: e107::getConfig(alias)->->setPref($array)->save(); Not to be used for saving plugin or theme prefs!
* @param string $table
* @param int|mixed $uid
* @param string $row_val
* @return bool|int|string
*/ */
function save_prefs($table = 'core', $uid = USERID, $row_val = '') function save_prefs($table = 'core', $uid = USERID, $row_val = '')
{ {
@@ -2041,7 +2077,7 @@ e107::getDebug()->log("Timezone: ".USERTIMEZONE); // remove later on.
->remove('sitetheme') ->remove('sitetheme')
->remove('sitetheme_custompages') ->remove('sitetheme_custompages')
->remove('sitetheme_deflayout') ->remove('sitetheme_deflayout')
->save(false); ->save();
} }
@@ -2067,12 +2103,13 @@ $sql->db_Mark_Time('(After Go online)');
/** /**
* Set Cookie * Set Cookie
*
* @param string $name * @param string $name
* @param string $value * @param string $value
* @param integer $expire seconds * @param integer $expire seconds
* @param string $path * @param string $path
* @param string $domain * @param string $domain
* @param boolean $secure * @param int $secure
* @return void * @return void
*/ */
function cookie($name, $value, $expire=0, $path = e_HTTP, $domain = '', $secure = 0) function cookie($name, $value, $expire=0, $path = e_HTTP, $domain = '', $secure = 0)
@@ -2213,7 +2250,7 @@ function class_list($uid = '')
* @Deprecated by e107::lan(); * @Deprecated by e107::lan();
* @param string $path * @param string $path
* @param boolean $force [optional] Please use the default * @param boolean $force [optional] Please use the default
* @return void * @return bool
*/ */
function include_lan($path, $force = false) function include_lan($path, $force = false)
{ {
@@ -2323,6 +2360,7 @@ class error_handler
protected $xdebug = false; protected $xdebug = false;
protected $docroot = ''; protected $docroot = '';
protected $label = array(); protected $label = array();
protected $color = null;
function __construct() function __construct()
{ {
@@ -2363,6 +2401,14 @@ class error_handler
} }
} }
/**
* @param $type
* @param $message
* @param $file
* @param $line
* @param $context
* @return bool
*/
function handle_error($type, $message, $file, $line, $context) { function handle_error($type, $message, $file, $line, $context) {
$startup_error = (!defined('E107_DEBUG_LEVEL')); // Error before debug system initialized $startup_error = (!defined('E107_DEBUG_LEVEL')); // Error before debug system initialized
@@ -2425,6 +2471,8 @@ class error_handler
$error['trace'] = $backtrace; $error['trace'] = $backtrace;
$this->errors[] = $error; $this->errors[] = $error;
} }
break;
default: default:
return true; return true;
break; break;
@@ -2502,6 +2550,10 @@ class error_handler
return ($ret) ? "<table class='table table-condensed fborder'>\n".$ret."</table>" : FALSE; return ($ret) ? "<table class='table table-condensed fborder'>\n".$ret."</table>" : FALSE;
} }
/**
* @param $information
* @param $level
*/
function trigger_error($information, $level) function trigger_error($information, $level)
{ {
trigger_error($information); trigger_error($information);
@@ -2646,6 +2698,9 @@ class e_http_header
} }
/**
* @param $header
*/
private function unsetHeader($header) private function unsetHeader($header)
{ {
header_remove($header); header_remove($header);