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

Issue #5120 Use static methods.

This commit is contained in:
camer0n
2023-12-18 14:38:04 -08:00
parent ab5f0fb911
commit 63d3c075c3
4 changed files with 38 additions and 82 deletions

View File

@@ -93,30 +93,6 @@ if(!empty($_E107['minimal']))
//
// C: Find out if register globals is enabled and destroy them if so
// (DO NOT use the value of any variables before this point! They could have been set by the user)
//
// Can't be moved to e107, required here for e107_config vars security
/*$register_globals = true;
if(function_exists('ini_get'))
{
$register_globals = ini_get('register_globals');
}*/
// Destroy! (if we need to)
/*
if($register_globals === true)
{
if(isset($_REQUEST['_E107'])) { unset($_E107); }
foreach($GLOBALS as $global=>$var)
{
if (!preg_match('/^(_POST|_GET|_COOKIE|_SERVER|_FILES|_SESSION|GLOBALS|HTTP.*|_REQUEST|_E107|retrieve_prefs|eplug_admin|eTimingStart.*|oblev_.*)$/', $global))
{
unset($$global);
}
}
unset($global);
}*/
// Set Absolute file-path of directory containing class2.php
@@ -159,7 +135,7 @@ else
unset($retrieve_prefs);
}
$config = include(e_ROOT.'e107_config.php');
include(e_ROOT.'e107_config.php');
if(!defined('e_POWEREDBY_DISABLE'))
{
@@ -183,7 +159,7 @@ if(empty($PLUGINS_DIRECTORY))
//define("MPREFIX", $mySQLprefix); moved to $e107->set_constants()
if(empty($mySQLdefaultdb) && empty($config))
if(empty($mySQLdefaultdb) && !class_exists('e107_config'))
{
// e107_config.php is either empty, not valid or doesn't exist so redirect to installer..
header('Location: install.php');
@@ -235,9 +211,9 @@ if(!class_exists('e107_config')) // old e107_config.php format.
}
else // New e107_config.php format. v2.4+
{
$e107_paths = $config->paths();
$sql_info = $config->database();
$E107_CONFIG = $config->other() ?? [];
$e107_paths = e107_config::paths();
$sql_info = e107_config::database();
$E107_CONFIG = e107_config::other() ?? [];
}
@@ -297,15 +273,6 @@ if(E107_DEBUG_LEVEL)
$dbg->logTime('Init ErrHandler');
}
//
// I: Sanity check on e107_config.php
// e107_config.php upgrade check
// obsolete check, rewrite it
// if (!$ADMIN_DIRECTORY && !$DOWNLOADS_DIRECTORY)
// {
// message_handler('CRITICAL_ERROR', 8, ': generic, ', 'e107_config.php');
// exit;
// }
//
// J: MYSQL INITIALIZATION
@@ -433,9 +400,6 @@ $pref = e107::getPref(); // include pref class.
$sysprefs = new prefs;
//DEPRECATED, BC, call e107::getPref/findPref() instead
//this could be part of e107->init() method now, prefs will be auto-initialized
//when proper called (e107::getPref())
// $e107->set_base_path(); moved to init().
//DEPRECATED, BC, call e107::getConfig('menu')->get('pref_name') only when needed
if(!isset($_E107['no_menus']))

View File

@@ -109,7 +109,7 @@ class e_db_pdo implements e_db
$this->mySQLlanguage = e107::getLanguage()->e_language;
}
if (E107_DEBUG_LEVEL > 0)
if (defset('E107_DEBUG_LEVEL') > 0)
{
$this->debugMode = true;
}

View File

@@ -40,7 +40,7 @@ const e_MOD_REWRITE = true;
class e107_config
{
public function database()
public static function database()
{
return [
'server' => '{{ mySQLserver }}',
@@ -52,7 +52,7 @@ class e107_config
];
}
public function paths()
public static function paths()
{
return [
'admin' => 'e107_admin/',
@@ -68,7 +68,7 @@ class e107_config
];
}
public function other()
public static function other()
{
return [
'site_path' => '000000test'
@@ -76,4 +76,3 @@ class e107_config
}
}
return new e107_config;

View File

@@ -28,8 +28,7 @@ function thumbExceptionHandler(Throwable $exception)
{
http_response_code(500);
echo "Fatal Thumbnail Error\n";
echo $exception->getMessage();
error_log($exception->getMessage());
}
function thumbErrorHandler($errno, $errstr, $errfile, $errline)
@@ -73,7 +72,7 @@ class e_thumbpage
function __construct()
{
$self = realpath(__DIR__);
$self = realpath(__DIR__);
$e_ROOT = $self."/";
@@ -109,43 +108,37 @@ class e_thumbpage
$tmp = $self.DIRECTORY_SEPARATOR.$HANDLERS_DIRECTORY;
//Core functions - now API independent
@require($tmp.DIRECTORY_SEPARATOR.'core_functions.php');
require($tmp.DIRECTORY_SEPARATOR.'core_functions.php');
//e107 class
@require($tmp.DIRECTORY_SEPARATOR.'e107_class.php');
require($tmp.DIRECTORY_SEPARATOR.'e107_class.php');
$e107_paths = compact(
'ADMIN_DIRECTORY',
'FILES_DIRECTORY',
'IMAGES_DIRECTORY',
'THEMES_DIRECTORY',
'PLUGINS_DIRECTORY',
'HANDLERS_DIRECTORY',
'LANGUAGES_DIRECTORY',
'HELP_DIRECTORY',
'DOWNLOADS_DIRECTORY',
'UPLOADS_DIRECTORY',
'MEDIA_DIRECTORY',
'CACHE_DIRECTORY',
'LOGS_DIRECTORY',
'WEB_DIRECTORY',
'SYSTEM_DIRECTORY',
'CORE_DIRECTORY'
);
if(!class_exists('e107_config')) // old e107_config.php format.
{
$dirNames = ['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 = e107::getInstance();
$e107_paths = [];
foreach ($dirNames as $name)
{
if (isset($$name))
{
$e107_paths[$name] = $$name;
}
}
$e107->site_path = substr(md5($mySQLdefaultdb.".".$mySQLprefix),0,10);
$sql_info = array_combine(array_map(function($k) {
return str_replace('mySQL', '', $k);
}, array_keys($legacy_sql_info)),
$legacy_sql_info
);
}
else // New e107_config.php format. v2.4+
{
$e107_paths = e107_config::paths();
$sql_info = e107_config::database();
$E107_CONFIG = e107_config::other() ?? [];
}
$e107->prepare_request();
$e107->setDirs($e107_paths, varset($E107_CONFIG, array()));
$e107->set_constants();
$e107->set_paths();
$e107->file_path = $e107->fix_windows_paths($self)."/";
$e107->set_base_path();
$e107->set_request(false);
unset($tmp, $self);
$e107->set_urls(false);
$e107 = e107::getInstance()->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array()));
// basic Admin area detection - required for proper path parsing
define('ADMIN', strpos(e_SELF, (e107::getFolder('admin')) != false || strpos(e_PAGE, 'admin') !== false));
@@ -153,7 +146,7 @@ class e_thumbpage
// See https://github.com/e107inc/e107/issues/3033
$e107->set_urls_deferred();
$pref = $e107->getPref();
$pref = e107::getPref();
require_once(e_HANDLER."e_thumbnail_class.php");