1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 21:57:51 +02:00

More $_E107 options

This commit is contained in:
Cameron
2021-01-05 08:54:09 -08:00
parent 906f6545c9
commit 7dec5cf40e
2 changed files with 276 additions and 199 deletions

View File

@@ -71,6 +71,26 @@ if(!isset($_E107['cli']))
ob_start(); // start our own. ob_start(); // start our own.
$oblev_at_start = ob_get_level(); // preserve when destroying globals in step C $oblev_at_start = ob_get_level(); // preserve when destroying globals in step C
} }
if(!empty($_E107['minimal']))
{
$_E107['no_prunetmp'] = true;
$_E107['no_menus'] = true;
$_E107['no_theme'] = true;
$_E107['no_online'] = true;
$_E107['no_lan'] = true;
$_E107['no_module'] = true;
$_E107['no_maintenance'] = true;
$_E107['no_forceuserupdate'] = true;
$_E107['no_event'] = true;
$_E107['no_session'] = true;
$_E107['no_parser'] = true;
$_E107['no_override'] = true;
$_E107['no_log'] = true;
$_E107['no_autoload'] = true;
}
// //
// C: Find out if register globals is enabled and destroy them if so // 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) // (DO NOT use the value of any variables before this point! They could have been set by the user)
@@ -314,8 +334,10 @@ if(!defined('e_SECURITY_LEVEL'))
//$e107->url = e107::getUrl(); - caught by __get() //$e107->url = e107::getUrl(); - caught by __get()
//TODO - find & replace $e107->url //TODO - find & replace $e107->url
//DEPRECATED, BC, $e107->tp caught by __get() //DEPRECATED, BC, $e107->tp caught by __get()
if(!isset($_E107['no_parser']))
{
$tp = e107::getParser(); //TODO - find & replace $tp, $e107->tp $tp = e107::getParser(); //TODO - find & replace $tp, $e107->tp
}
//define("e_QUERY", $matches[2]); //define("e_QUERY", $matches[2]);
//define("e_QUERY", $_SERVER['QUERY_STRING']); //define("e_QUERY", $_SERVER['QUERY_STRING']);
@@ -395,8 +417,10 @@ $sql2 = e107::getDb('sql2'); //TODO find & replace all $sql2 calls
$dbg->logTime('Prefs, misc tables'); $dbg->logTime('Prefs, misc tables');
//DEPRECATED, BC, call the method only when needed, $e107->admin_log caught by __get() //DEPRECATED, BC, call the method only when needed, $e107->admin_log caught by __get()
if(!isset($_E107['no_log']))
{
$admin_log = e107::getLog(); //TODO - find & replace $admin_log, $e107->admin_log $admin_log = e107::getLog(); //TODO - find & replace $admin_log, $e107->admin_log
}
if($merror === 'e1') if($merror === 'e1')
{ {
message_handler('CRITICAL_ERROR', 6, ': generic, ', 'class2.php'); message_handler('CRITICAL_ERROR', 6, ': generic, ', 'class2.php');
@@ -436,8 +460,10 @@ $eArrayStorage = e107::getArrayStorage(); //TODO - find & replace $eArrayStorag
//DEPRECATED, BC, call the method only when needed, $e107->e_event caught by __get() //DEPRECATED, BC, call the method only when needed, $e107->e_event caught by __get()
$dbg->logTime('Load Event Handler'); $dbg->logTime('Load Event Handler');
if(!isset($_E107['no_event']))
{
$e_event = e107::getEvent(); //TODO - find & replace $e_event, $e107->e_event $e_event = e107::getEvent(); //TODO - find & replace $e_event, $e107->e_event
}
// TODO - DEPRECATED - remove // TODO - DEPRECATED - remove
$dbg->logTime('Load Core Prefs'); $dbg->logTime('Load Core Prefs');
@@ -492,7 +518,7 @@ if(!e107::getConfig()->hasData())
//DEPRECATED, BC, call e107::getPref/findPref() instead //DEPRECATED, BC, call e107::getPref/findPref() instead
$pref = e107::getPref(); $pref = e107::getPref();
if(e_ADMIN_AREA !== true && !empty($pref['thumb_to_webp'])) if(e_ADMIN_AREA !== true && !isset($_E107['no_parser']) && !empty($pref['thumb_to_webp']))
{ {
$tp->setConvertToWebP(true); $tp->setConvertToWebP(true);
} }
@@ -501,9 +527,11 @@ if(e_ADMIN_AREA !== true && !empty($pref['thumb_to_webp']))
// $e107->set_base_path(); moved to init(). // $e107->set_base_path(); moved to init().
//DEPRECATED, BC, call e107::getConfig('menu')->get('pref_name') only when needed //DEPRECATED, BC, call e107::getConfig('menu')->get('pref_name') only when needed
if(!isset($_E107['no_menus']))
{
$dbg->logTime('Load Menu Prefs'); $dbg->logTime('Load Menu Prefs');
$menu_pref = e107::getConfig('menu')->getPref(); //extract menu prefs $menu_pref = e107::getConfig('menu')->getPref(); //extract menu prefs
}
// NEW - force ssl // NEW - force ssl
if(empty($_E107['cli']) && e107::getPref('ssl_enabled') && !deftrue('e_SSL_DISABLE') ) if(empty($_E107['cli']) && e107::getPref('ssl_enabled') && !deftrue('e_SSL_DISABLE') )
{ {
@@ -519,11 +547,12 @@ if(empty($_E107['cli']) && e107::getPref('ssl_enabled') && !deftrue('e_SSL_DISA
} }
// $dbg->logTime('(Extracting Core Prefs Done)'); // $dbg->logTime('(Extracting Core Prefs Done)');
if(!isset($_E107['no_lan']))
{
$dbg->logTime('Init Language and detect changes'); $dbg->logTime('Init Language and detect changes');
$lng = e107::getLanguage(); // required for v1.0 BC. $lng = e107::getLanguage(); // required for v1.0 BC.
$lng->detect(); $lng->detect();
}
// //
// M: Subdomain and Language Selection // M: Subdomain and Language Selection
// //
@@ -620,10 +649,18 @@ if(!empty($pref['redirectsiteurl']) && !empty($pref['siteurl'])) {
// - Language detection (because of session.cookie_domain) // - Language detection (because of session.cookie_domain)
// to avoid multi-language 'access-denied' issues. // to avoid multi-language 'access-denied' issues.
//session_start(); see e107::getSession() above //session_start(); see e107::getSession() above
if(!isset($_E107['no_session']) && !isset($_E107['no_lan']))
{
$dbg->logTime('Load Session Handler'); $dbg->logTime('Load Session Handler');
e107::getSession(); //init core _SESSION - actually here for reference only, it's done by language handler set() method e107::getSession(); //init core _SESSION - actually here for reference only, it's done by language handler set() method
$dbg->logTime('Set User Language Session'); $dbg->logTime('Set User Language Session');
e107::getLanguage()->set(); // set e_LANGUAGE, USERLAN, Language Session / Cookies etc. requires $pref; e107::getLanguage()->set(); // set e_LANGUAGE, USERLAN, Language Session / Cookies etc. requires $pref;
}
else
{
define('e_LANGUAGE', 'English');
}
if(!empty($pref['multilanguage']) && (e_LANGUAGE !== $pref['sitelanguage'])) if(!empty($pref['multilanguage']) && (e_LANGUAGE !== $pref['sitelanguage']))
{ {
@@ -635,6 +672,8 @@ if(!empty($pref['multilanguage']) && (e_LANGUAGE !== $pref['sitelanguage']))
// e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php'); // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php');
// e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php'); // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php');
// v1 Custom language File Path. // v1 Custom language File Path.
if(!isset($_E107['no_lan']))
{
$dbg->logTime('Include Global Core Language Files'); $dbg->logTime('Include Global Core Language Files');
if((e_ADMIN_AREA === true) && !empty($pref['adminlanguage'])) if((e_ADMIN_AREA === true) && !empty($pref['adminlanguage']))
{ {
@@ -663,6 +702,7 @@ unset($customLan, $customLan2);
$lng->bcDefs(); // defined v1.x definitions for old templates. $lng->bcDefs(); // defined v1.x definitions for old templates.
$dbg->logTime('Include Global Plugin Language Files'); $dbg->logTime('Include Global Plugin Language Files');
if(isset($pref['lan_global_list'])) if(isset($pref['lan_global_list']))
{ {
foreach($pref['lan_global_list'] as $path) foreach($pref['lan_global_list'] as $path)
@@ -674,9 +714,10 @@ if(isset($pref['lan_global_list']))
} }
} }
}
if(!isset($_E107['no_session']))
{
$dbg->logTime('CHAP challenge'); $dbg->logTime('CHAP challenge');
$die = e_AJAX_REQUEST !== true; $die = e_AJAX_REQUEST !== true;
@@ -684,7 +725,7 @@ e107::getSession()
->challenge() // Make sure there is a unique challenge string for CHAP login ->challenge() // Make sure there is a unique challenge string for CHAP login
->check($die); // Token protection ->check($die); // Token protection
unset($die); unset($die);
}
// //
// N: misc setups: online user tracking, cache // N: misc setups: online user tracking, cache
// //
@@ -697,22 +738,38 @@ $dbg->logTime('Misc resources. Online user tracking, cache');
$e107cache = e107::getCache(); //TODO - find & replace $e107cache, $e107->ecache $e107cache = e107::getCache(); //TODO - find & replace $e107cache, $e107->ecache
//DEPRECATED, BC, call the method only when needed, $e107->override caught by __get() //DEPRECATED, BC, call the method only when needed, $e107->override caught by __get()
if(!isset($_E107['no_override']))
{
$override = e107::getSingleton('override'); $override = e107::getSingleton('override');
}
//DEPRECATED, BC, call the method only when needed, $e107->user_class caught by __get() //DEPRECATED, BC, call the method only when needed, $e107->user_class caught by __get()
if(!isset($_E107['no_session']))
{
$e_userclass = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class $e_userclass = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class
}
if(!isset($_E107['no_event']))
{
$dbg->logTime('Init Event Handler'); $dbg->logTime('Init Event Handler');
e107::getEvent()->init(); e107::getEvent()->init();
$dbg->logTime('Register Core Events'); $dbg->logTime('Register Core Events');
e107::getNotify()->registerEvents(); e107::getNotify()->registerEvents();
}
// //
// O: Start user session // O: Start user session
// //
if(!isset($_E107['no_session']))
{
$dbg->logTime('User session'); $dbg->logTime('User session');
init_session(); // Set up a lot of the user-related constants init_session(); // Set up a lot of the user-related constants
}
else
{
define('ADMIN', false);
define('USER', true);
}
@@ -720,6 +777,8 @@ init_session(); // Set up a lot of the user-related constants
$developerMode = (vartrue($pref['developer'],false) || E107_DEBUG_LEVEL > 0); $developerMode = (vartrue($pref['developer'],false) || E107_DEBUG_LEVEL > 0);
if(!isset($_E107['no_theme']))
{
// for multi-language these definitions needs to come after the language loaded. // for multi-language these definitions needs to come after the language loaded.
if(!defined('SITENAME')) // Allow override by English_custom.php or English_global.php plugin files. if(!defined('SITENAME')) // Allow override by English_custom.php or English_global.php plugin files.
{ {
@@ -776,7 +835,7 @@ else
define('XURL_TWITCH', false); define('XURL_TWITCH', false);
define('XURL_VK', false); define('XURL_VK', false);
} }
}
if(!defined('MAIL_IDENTIFIER')) if(!defined('MAIL_IDENTIFIER'))
{ {
define('MAIL_IDENTIFIER', 'X-e107-id'); define('MAIL_IDENTIFIER', 'X-e107-id');
@@ -799,6 +858,8 @@ $dbg->logTime('Load Plugin Modules');
$js_body_onload = array(); // Initialise this array in case a module wants to add to it $js_body_onload = array(); // Initialise this array in case a module wants to add to it
// Load e_modules after all the constants, but before the themes, so they can be put to use. // Load e_modules after all the constants, but before the themes, so they can be put to use.
if(!isset($_E107['no_module']))
{
if(isset($pref['e_module_list']) && $pref['e_module_list']) if(isset($pref['e_module_list']) && $pref['e_module_list'])
{ {
foreach ($pref['e_module_list'] as $mod) foreach ($pref['e_module_list'] as $mod)
@@ -810,16 +871,17 @@ if(isset($pref['e_module_list']) && $pref['e_module_list'])
} }
} }
} }
}
// //
// P: THEME LOADING // P: THEME LOADING
// //
$dbg->logTime('Load Theme');
if(!defined('USERTHEME'))
if(!defined('USERTHEME') && !isset($_E107['no_theme']))
{ {
$dbg->logTime('Load Theme');
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));
} }
@@ -1362,16 +1424,17 @@ define('TIMEOFFSET', $e_deltaTime);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
$dbg->logTime('Find/Load Theme');
if(e_ADMIN_AREA) // Load admin phrases ASAP
if(e_ADMIN_AREA && !isset($_E107['no_lan'])) // Load admin phrases ASAP
{ {
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php'); e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
} }
if(!defined('THEME')) if(!defined('THEME') && !isset($_E107['no_theme']))
{ {
$dbg->logTime('Find/Load Theme');
if (e_ADMIN_AREA && vartrue($pref['admintheme'])) if (e_ADMIN_AREA && vartrue($pref['admintheme']))
{ {
@@ -1393,8 +1456,10 @@ $theme_pref = varset($pref['sitetheme_pref']);
// Load library dependencies. // Load library dependencies.
if(!isset($_E107['no_theme']))
{
$dbg->logTime('Load Libraries'); $dbg->logTime('Load Libraries');
//$startTime = microtime(true);
if(deftrue('e_ADMIN_AREA')) if(deftrue('e_ADMIN_AREA'))
{ {
$clearThemeCache = (deftrue('e_ADMIN_HOME', false) || deftrue('e_ADMIN_UPDATE', false)); $clearThemeCache = (deftrue('e_ADMIN_HOME', false) || deftrue('e_ADMIN_UPDATE', false));
@@ -1405,6 +1470,7 @@ else
{ {
e107::getTheme('current')->loadLibrary(); e107::getTheme('current')->loadLibrary();
} }
}
//echo "\nRun Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; //echo "\nRun Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
if(!isset($_E107['no_menus'])) if(!isset($_E107['no_menus']))
@@ -1414,6 +1480,8 @@ if(!isset($_E107['no_menus']))
} }
// here we USE the theme // here we USE the theme
if(!isset($_E107['no_theme']))
{
$dbg->logTime("Load admin_/theme.php file"); $dbg->logTime("Load admin_/theme.php file");
if(e_ADMIN_AREA) if(e_ADMIN_AREA)
{ {
@@ -1458,19 +1526,6 @@ else
define('ITEMVIEW', $pref['newsposts']); define('ITEMVIEW', $pref['newsposts']);
} }
if (!empty($pref['antiflood1']) && !defined('FLOODPROTECT'))
{
define('FLOODPROTECT', true);
define('FLOODTIMEOUT', max(varset($pref['antiflood_timeout'], 10), 3));
}
else
{
/**
* @ignore
*/
define('FLOODPROTECT', false);
}
$layout = isset($layout) ? $layout : '_default'; $layout = isset($layout) ? $layout : '_default';
define('HEADERF', e_CORE."templates/header{$layout}.php"); define('HEADERF', e_CORE."templates/header{$layout}.php");
define('FOOTERF', e_CORE."templates/footer{$layout}.php"); define('FOOTERF', e_CORE."templates/footer{$layout}.php");
@@ -1484,6 +1539,24 @@ if (!file_exists(FOOTERF))
{ {
message_handler('CRITICAL_ERROR', 'Unable to find file: '.FOOTERF, __LINE__ - 2, __FILE__); message_handler('CRITICAL_ERROR', 'Unable to find file: '.FOOTERF, __LINE__ - 2, __FILE__);
} }
}
if (!empty($pref['antiflood1']) && !defined('FLOODPROTECT'))
{
define('FLOODPROTECT', true);
define('FLOODTIMEOUT', max(varset($pref['antiflood_timeout'], 10), 3));
}
else
{
/**
* @ignore
*/
define('FLOODPROTECT', false);
}
//define('LOGINMESSAGE', ''); - not needed, breaks login messages //define('LOGINMESSAGE', ''); - not needed, breaks login messages
define('OPEN_BASEDIR', (ini_get('open_basedir') ? true : false)); define('OPEN_BASEDIR', (ini_get('open_basedir') ? true : false));

View File

@@ -5632,6 +5632,9 @@ class e107
} }
if(!isset($GLOBALS['_E107']['no_autoload']))
{
e107::autoload_register(array(e107::class, 'autoload')); e107::autoload_register(array(e107::class, 'autoload'));
// Forward compatibility with e107 v3 Composer autoloading // Forward compatibility with e107 v3 Composer autoloading
@@ -5640,6 +5643,7 @@ if (file_exists($vendor_autoload_file))
{ {
include_once($vendor_autoload_file); include_once($vendor_autoload_file);
} }
}
/** /**
* Interface e_admin_addon_interface @move to separate addons file? * Interface e_admin_addon_interface @move to separate addons file?