XML package. Please install it to use e107. "; exit(); } if(!isset($_E107['cli'])) { while (@ob_end_clean()); // destroy all ouput buffering ob_start(); // start our own. $oblev_at_start = ob_get_level(); // preserve when destroying globals in step C } // // 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); } while (list($global) = each($GLOBALS)) { if (!preg_match('/^(_POST|_GET|_COOKIE|_SERVER|_FILES|_SESSION|GLOBALS|HTTP.*|_REQUEST|_E107|retrieve_prefs|eplug_admin|eTimingStart.*|oblev_.*)$/', $global)) { unset($$global); } } unset($global); } // MOVED TO $e107->prepare_request() // TODO - better ajax detection method (headers when possible) //define('e_AJAX_REQUEST', isset($_REQUEST['ajax_used'])); //unset($_REQUEST['ajax_used']); // removed because it's auto-appended from JS (AJAX), could break something... // //if(isset($_E107['minimal']) || e_AJAX_REQUEST) //{ // $_e107vars = array('forceuserupdate', 'online', 'theme', 'menus', 'prunetmp'); // foreach($_e107vars as $v) // { // $noname = 'no_'.$v; // if(!isset($_E107[$v])) // { // $_E107[$noname] = 1; // } // unset($_E107[$v]); // } //} // Set Absolute file-path of directory containing class2.php if(!defined('e_ROOT')) { $e_ROOT = realpath(dirname(__FILE__)."/"); if ((substr($e_ROOT,-1) !== '/') && (substr($e_ROOT,-1) !== '\\') ) { $e_ROOT .= DIRECTORY_SEPARATOR; // Should function correctly on both windows and Linux now. } define('e_ROOT', $e_ROOT); unset($e_ROOT); } // MOVED TO $e107->prepare_request() // e107 uses relative url's, which are broken by "pretty" URL's. So for now we don't support / after .php //if(($pos = strpos($_SERVER['PHP_SELF'], '.php/')) !== false) // redirect bad URLs to the correct one. //{ // $new_url = substr($_SERVER['PHP_SELF'], 0, $pos+4); // $new_loc = ($_SERVER['QUERY_STRING']) ? $new_url.'?'.$_SERVER['QUERY_STRING'] : $new_url; // header('Location: '.$new_loc); // exit(); //} // If url contains a .php in it, PHP_SELF is set wrong (imho), affecting all paths. We need to 'fix' it if it does. //$_SERVER['PHP_SELF'] = (($pos = strpos($_SERVER['PHP_SELF'], '.php')) !== false ? substr($_SERVER['PHP_SELF'], 0, $pos+4) : $_SERVER['PHP_SELF']); // // D: Setup PHP error handling // (Now we can see PHP errors) -- but note that DEBUG is not yet enabled! // $error_handler = new error_handler(); set_error_handler(array(&$error_handler, 'handle_error')); // // E: Setup other essential PHP parameters // define('e107_INIT', true); // MOVED TO $e107->prepare_request() // setup some php options //e107_ini_set('magic_quotes_runtime', 0); //e107_ini_set('magic_quotes_sybase', 0); //e107_ini_set('arg_separator.output', '&'); //e107_ini_set('session.use_only_cookies', 1); //e107_ini_set('session.use_trans_sid', 0); // DEPRECATED, use e107::getConfig() and e107::getPlugConfig() if(isset($retrieve_prefs) && is_array($retrieve_prefs)) { foreach ($retrieve_prefs as $key => $pref_name) { $retrieve_prefs[$key] = preg_replace("/\W/", '', $pref_name); } } else { unset($retrieve_prefs); } // MOVED TO e107->set_constants() //define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false)); // //// Define the domain name and subdomain name. //if($_SERVER['HTTP_HOST'] && is_numeric(str_replace(".","",$_SERVER['HTTP_HOST']))) //{ // $srvtmp = ''; // Host is an IP address. //} //else //{ // $srvtmp = explode('.',str_replace('www.', '', $_SERVER['HTTP_HOST'])); //} // //define('e_SUBDOMAIN', (count($srvtmp)>2 && $srvtmp[2] ? $srvtmp[0] : false)); // needs to be available to e107_config. // //if(e_SUBDOMAIN) //{ // unset($srvtmp[0]); //} // //define('e_DOMAIN',(count($srvtmp) > 1 ? (implode('.', $srvtmp)) : false)); // if it's an IP it must be set to false. // //unset($srvtmp); // MOVED TO $e107->prepare_request() // Ensure thet '.' is the first part of the include path //$inc_path = explode(PATH_SEPARATOR, ini_get('include_path')); //if($inc_path[0] != '.') //{ // array_unshift($inc_path, '.'); // $inc_path = implode(PATH_SEPARATOR, $inc_path); // e107_ini_set('include_path', $inc_path); //} //unset($inc_path); // // F: Grab e107_config, get directory paths and create $e107 object // @include(e_ROOT.'e107_config.php'); if(!defined('e_POWEREDBY_DISABLE')) { define('e_POWEREDBY_DISABLE', false); } if(isset($CLASS2_INCLUDE) && ($CLASS2_INCLUDE!='')) { require_once(e_ROOT.$CLASS2_INCLUDE); } if(empty($HANDLERS_DIRECTORY)) { $HANDLERS_DIRECTORY = 'e107_handlers/'; } if(empty($PLUGINS_DIRECTORY)) { $PLUGINS_DIRECTORY = 'e107_plugins/'; } //define("MPREFIX", $mySQLprefix); moved to $e107->set_constants() if(empty($mySQLdefaultdb)) { // e107_config.php is either empty, not valid or doesn't exist so redirect to installer.. header('Location: install.php'); exit(); } // Upgrade Compatibility - Disable CL_WIDGETS before e107_class.php is loaded. $tmpPlugDir = e_ROOT.$PLUGINS_DIRECTORY; if(is_dir($tmpPlugDir."/cl_widgets")) { rename($tmpPlugDir."/cl_widgets",$tmpPlugDir."/cl_widgets__"); } unset($tmpPlugDir); // // clever stuff that figures out where the paths are on the fly.. no more need for hard-coded e_HTTP :) // $tmp = e_ROOT.$HANDLERS_DIRECTORY; //Core functions - now API independent @require_once($tmp.'/core_functions.php'); e107_require_once($tmp.'/e107_class.php'); 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'); $sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix'); if(isset($mySQLport)) { $sql_info['mySQLport'] = $mySQLport; } $e107 = e107::getInstance()->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array())); e107::getSingleton('eIPHandler'); // This auto-handles bans etc unset($dirPaths,$sql_info,$e107_paths); /** * NEW - system security levels * Could be overridden by e107_config.php OR $CLASS2_INCLUDE script (if not set earlier) * * 0 disabled * 5 safe mode (balanced) * 7 high * 9 paranoid * 10 insane * for more detailed info see e_session SECURITY_LEVEL_* constants * default is e_session::SECURITY_LEVEL_BALANCED (5) */ if(!defined('e_SECURITY_LEVEL')) { require_once(e_HANDLER.'session_handler.php'); define('e_SECURITY_LEVEL', e_session::SECURITY_LEVEL_BALANCED); } // MOVED TO $e107->set_request() //$inArray = array("'", ';', '/**/', '/UNION/', '/SELECT/', 'AS '); //if (strpos($_SERVER['PHP_SELF'], 'trackback') === false) //{ // foreach($inArray as $res) // { // if(stristr($_SERVER['QUERY_STRING'], $res)) // { // die('Access denied.'); // } // } //} // // Start the parser; use it to grab the full query string // //DEPRECATED, BC //$e107->url = e107::getUrl(); - caught by __get() //TODO - find & replace $e107->url //DEPRECATED, BC, $e107->tp caught by __get() /** @var e_parse $tp */ $tp = e107::getParser(); //TODO - find & replace $tp, $e107->tp //define("e_QUERY", $matches[2]); //define("e_QUERY", $_SERVER['QUERY_STRING']); // MOVED TO $e107->set_request() //$e_QUERY = str_replace("&","&",$tp->post_toForm($e_QUERY)); //define('e_QUERY', $e_QUERY); //$e_QUERY = e_QUERY; // MOVED TO $e107->set_request() //define('e_TBQS', $_SERVER['QUERY_STRING']); //$_SERVER['QUERY_STRING'] = e_QUERY; // MOVED TO $e107->set_constants() //define('e_UC_PUBLIC', 0); //define('e_UC_MAINADMIN', 250); //define('e_UC_READONLY', 251); //define('e_UC_GUEST', 252); //define('e_UC_MEMBER', 253); //define('e_UC_ADMIN', 254); //define('e_UC_NOBODY', 255); // MOVED TO $e107->set_urls() - DEPRECATED, use e107->getFolder() //define('ADMINDIR', $ADMIN_DIRECTORY); // // H: Initialize debug handling // (NO E107 DEBUG CONSTANTS OR CODE ARE AVAILABLE BEFORE THIS POINT) // All debug objects and constants are defined in the debug handler // i.e. from here on you can use E107_DEBUG_LEVEL or any // E107_DBG_* constant for debug testing. // TODO - rewrite the debug init phase, add e107 class getters // require_once(e_HANDLER.'debug_handler.php'); if(E107_DEBUG_LEVEL && isset($db_debug) && is_object($db_debug)) { $db_debug->Mark_Time('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 // e107::getSingleton('e107_traffic'); // We start traffic counting ASAP //$eTraffic->Calibrate($eTraffic); // e107_require_once(e_HANDLER.'mysql_class.php'); //DEPRECATED, BC, $e107->sql caught by __get() /** @var e_db_mysql $sql */ $sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql $sql->db_SetErrorReporting(false); $sql->db_Mark_Time('SQL Connect'); $merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); // create after the initial connection. //DEPRECATED, BC, call the method only when needed $sql2 = e107::getDb('sql2'); //TODO find & replace all $sql2 calls $sql->db_Mark_Time('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; } // // K: Load compatability mode. // /* PHP Compatabilty should *always* be on. */ e107_require_once(e_HANDLER.'php_compatibility_handler.php'); // SITEURL constant depends on the database // See https://github.com/e107inc/e107/issues/3033 for details. $e107->set_urls_deferred(); // // L: Extract core prefs from the database // // TODO - remove it from here, auto-loaded when required $sql->db_Mark_Time('Load Cache Handler'); e107_require_once(e_HANDLER.'cache_handler.php'); //DEPRECATED, BC, call the method only when needed, $e107->arrayStorage caught by __get() $sql->db_Mark_Time('Load Array Storage Handler'); e107_require_once(e_HANDLER.'arraystorage_class.php'); // ArrayData(); BC Fix only. $eArrayStorage = e107::getArrayStorage(); //TODO - find & replace $eArrayStorage with e107::getArrayStorage(); //DEPRECATED, BC, call the method only when needed, $e107->e_event caught by __get() $sql->db_Mark_Time('Load Event Handler'); $e_event = e107::getEvent(); //TODO - find & replace $e_event, $e107->e_event // TODO - DEPRECATED - remove $sql->db_Mark_Time('Load Core Prefs'); e107_require_once(e_HANDLER."pref_class.php"); $sysprefs = new prefs; // Check core preferences //FIXME - message_handler is dying after message_handler(CRITICAL_ERROR) call e107::getConfig()->load(); // extra load, required if mysql handler already called e107::getConfig() if(!e107::getConfig()->hasData()) { // Core prefs error - admin log e107::getAdminLog()->log_event('CORE_LAN8', 'CORE_LAN7', E_LOG_WARNING); // Try for the automatic backup.. if(e107::getConfig('core_backup')->hasData()) { // auto backup found, use backup to restore the core e107::getConfig()->loadData(e107::getConfig('core_backup')->getPref(), false) ->save(false, true); message_handler('CRITICAL_ERROR', 3, __LINE__, __FILE__); } else { // No auto backup, try for the 'old' prefs system. if(!e107::getConfig('core_old')->hasData()) { // Core could not restore from automatic backup. Execution halted. e107::getAdminLog()->log_event('CORE_LAN8', 'CORE_LAN9', E_LOG_FATAL); message_handler('CRITICAL_ERROR', 3, __LINE__, __FILE__); // No old system, so point in the direction of resetcore :( message_handler('CRITICAL_ERROR', 4, __LINE__, __FILE__); //this will never appear till message_handler() is fixed 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); } } } //DEPRECATED, BC, call e107::getPref/findPref() instead $pref = e107::getPref(); //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 $sql->db_Mark_Time('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'])) { // 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) { // e_REQUEST_URL and e_REQUEST_URI introduced $url = 'https://'.substr(e_REQUEST_URL, 7); e107::redirect($url); exit; } } // $sql->db_Mark_Time('(Extracting Core Prefs Done)'); $sql->db_Mark_Time('Init Language and detect changes'); $lng = e107::getLanguage(); // required for v1.0 BC. $lng->detect(); // // M: Subdomain and Language Selection // // if a cookie name pref isn't set, make one :) // e_COOKIE used as unique session cookie name now (see session handler) if (!$pref['cookie_name']) { $pref['cookie_name'] = 'e107cookie'; } define('e_COOKIE', $pref['cookie_name']); // MOVED TO $e107->set_urls() //define('SITEURLBASE', ($pref['ssl_enabled'] == '1' ? 'https://' : 'http://').$_SERVER['HTTP_HOST']); //define('SITEURL', SITEURLBASE.e_HTTP); // if the option to force users to use a particular url for the site is enabled, redirect users there as needed // Now matches RFC 2616 (sec 3.2): case insensitive, https/:443 and http/:80 are equivalent. // And, this is robust against hack attacks. Malignant users can put **anything** in HTTP_HOST! 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.') { $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; } e107::getRedirect()->go($location,true,301); // header("Location: {$location}", true, 301); // send 301 header, not 302 exit(); } } elseif(deftrue('e_DOMAIN')) { // 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; } $aPrefURL = explode('/',$pref['siteurl'],4); if (count($aPrefURL) > 2) // we can do this -- there's at least http[s]://dom.ain/whatever { $PrefRoot = $aPrefURL[2]; list($PrefSiteBase,$PrefSitePort) = explode(':',$PrefRoot.':'); if (!$PrefSitePort) { $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) { $aeSELF = explode('/', e_REQUEST_SELF, 4); $aeSELF[0] = $aPrefURL[0]; // Swap in correct type of query (http, https) $aeSELF[1] = ''; // Defensive code: ensure http:// not http:// $aeSELF[2] = $aPrefURL[2]; // Swap in correct domain and possibly port $location = implode('/',$aeSELF).($_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : ''); $location = filter_var($location, FILTER_SANITIZE_URL); // // header("Location: {$location}", true, 301); // send 301 header, not 302 if(defined('e_DEBUG') && e_DEBUG === true) { echo "DEBUG INFO: site-redirect preference enabled.
Redirecting to: ".$location."";; echo "
e_DOMAIN: ".e_DOMAIN; echo "
e_SUBDOMAIN: ".e_SUBDOMAIN; } else { e107::getRedirect()->go($location,true,301); } exit(); } } } } /** * Set the User's Language */ // SESSION Needs to be started after: // - Site preferences are available // - Language detection (because of session.cookie_domain) // to avoid multi-language 'access-denied' issues. //session_start(); see e107::getSession() above $sql->db_Mark_Time('Load Session Handler'); e107::getSession(); //init core _SESSION - actually here for reference only, it's done by language handler set() method $sql->db_Mark_Time('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'])) { $sql->mySQLlanguage = e_LANGUAGE; $sql2->mySQLlanguage = e_LANGUAGE; } //do it only once and with the proper function // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php'); // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php'); // v1 Custom language File Path. $sql->db_Mark_Time('Include Global Core Language Files'); if((e_ADMIN_AREA === true) && !empty($pref['adminlanguage'])) { include(e_LANGUAGEDIR.$pref['adminlanguage'].'/'.$pref['adminlanguage'].'.php'); } else { include(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php'); // FASTEST - ALWAYS load } $customLan = e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php'; if(is_readable($customLan)) // FASTER - if exist, should be done 'once' by the core { include($customLan); } // v2 Custom language File Path. $customLan2 = e_SYSTEM.'/lans/'.e_LANGUAGE.'_custom.php'; if(is_readable($customLan2)) // FASTER - if exist, should be done 'once' by the core { include($customLan2); } unset($customLan, $customLan2); $lng->bcDefs(); // defined v1.x definitions for old templates. $sql->db_Mark_Time('Include Global Plugin Language Files'); if(isset($pref['lan_global_list'])) { foreach($pref['lan_global_list'] as $path) { if(e107::plugLan($path, 'global', true) === false) { e107::plugLan($path, 'global', false); } } } $sql->db_Mark_Time('CHAP challenge'); $die = (e_AJAX_REQUEST == true) ? false : true; e107::getSession() ->challenge() // Make sure there is a unique challenge string for CHAP login ->check($die); // Token protection unset($die); // // N: misc setups: online user tracking, cache // $sql->db_Mark_Time('Misc resources. Online user tracking, cache'); /** * @deprecated BC, call the method only when needed, $e107->ecache caught by __get() */ $e107cache = e107::getCache(); //TODO - find & replace $e107cache, $e107->ecache //DEPRECATED, BC, call the method only when needed, $e107->override caught by __get() $override = e107::getSingleton('override', true); //DEPRECATED, BC, call the method only when needed, $e107->user_class caught by __get() $e_userclass = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class $sql->db_Mark_Time('Init Event Handler'); e107::getEvent()->init(); $sql->db_Mark_Time('Register Core Events'); e107::getNotify()->registerEvents(); // // O: Start user session // $sql -> db_Mark_Time('User session'); init_session(); // Set up a lot of the user-related constants /** * @deprecated but necessary. BC Fix. * @return string */ function getip() { return e107::getIPHandler()->ipDecode(USERIP); } $developerMode = (vartrue($pref['developer'],false) || E107_DEBUG_LEVEL > 0); // 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. { define('SITENAME', trim($tp->toHTML($pref['sitename'], '', 'USER_TITLE,er_on,defs'))); } if(!defined('SITEDESCRIPTION')) // Allow override by English_custom.php or English_global.php plugin files. { define('SITEDESCRIPTION', $tp->toHTML($pref['sitedescription'], '', 'emotes_off,defs')); } define('SITEBUTTON', $tp->replaceConstants($pref['sitebutton'],'abs')); define('SITETAG', $tp->toHTML($pref['sitetag'], false, 'emotes_off,defs')); define('SITEADMIN', $pref['siteadmin']); define('SITEADMINEMAIL', $pref['siteadminemail']); define('SITEDISCLAIMER', $tp->toHTML($pref['sitedisclaimer'], '', 'emotes_off,defs')); define('SITECONTACTINFO', $tp->toHTML($pref['sitecontactinfo'], true, 'emotes_off,defs')); define('SITEEMAIL', vartrue($pref['replyto_email'],$pref['siteadminemail'])); define('USER_REGISTRATION', vartrue($pref['user_reg'],false)); // User Registration System Active or Not. define('e_DEVELOPER', $developerMode); define('e_VERSION', varset($pref['version'],'')); unset($developerMode); if(!empty($pref['xurl']) && is_array($pref['xurl'])) { define('XURL_FACEBOOK', vartrue($pref['xurl']['facebook'], false)); define('XURL_TWITTER', vartrue($pref['xurl']['twitter'], false)); define('XURL_YOUTUBE', vartrue($pref['xurl']['youtube'], false)); define('XURL_GOOGLE', vartrue($pref['xurl']['google'], false)); define('XURL_LINKEDIN', vartrue($pref['xurl']['linkedin'], false)); define('XURL_GITHUB', vartrue($pref['xurl']['github'], false)); define('XURL_FLICKR', vartrue($pref['xurl']['flickr'], false)); define('XURL_INSTAGRAM', vartrue($pref['xurl']['instagram'], false)); define('XURL_PINTEREST', vartrue($pref['xurl']['pinterest'], false)); define('XURL_STEAM', vartrue($pref['xurl']['steam'], false)); define('XURL_VIMEO', vartrue($pref['xurl']['vimeo'], false)); } else { define('XURL_FACEBOOK',false); define('XURL_TWITTER', false); define('XURL_YOUTUBE', false); define('XURL_GOOGLE', false); define('XURL_LINKEDIN', false); define('XURL_GITHUB', false); define('XURL_FLICKR', false); define('XURL_INSTAGRAM', false); define('XURL_PINTEREST', false); define('XURL_STEAM', false); define('XURL_VIMEO', false); } if(!defined('MAIL_IDENTIFIER')) { define('MAIL_IDENTIFIER', 'X-e107-id'); } /* Withdrawn 0.8 // legacy module.php file loading. if (isset($pref['modules']) && $pref['modules']) { $mods=explode(",", $pref['modules']); foreach ($mods as $mod) { if (is_readable(e_PLUGIN."{$mod}/module.php")) { require_once(e_PLUGIN."{$mod}/module.php"); } } } */ $sql->db_Mark_Time('Load Plugin Modules'); $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. if(isset($pref['e_module_list']) && $pref['e_module_list']) { foreach ($pref['e_module_list'] as $mod) { if (is_readable(e_PLUGIN."{$mod}/e_module.php")) { $sql->db_Mark_Time('[e_module in '.$mod.']'); require_once(e_PLUGIN."{$mod}/e_module.php"); } } } // // P: THEME LOADING // $sql->db_Mark_Time('Load Theme'); if(!defined("USERTHEME" )) { define('USERTHEME', (e107::getUser()->getPref('sitetheme') && file_exists(e_THEME.e107::getUser()->getPref('sitetheme')."/theme.php") ? e107::getUser()->getPref('sitetheme') : false)); } //########### Module redefinable functions ############### if (!function_exists('checkvalidtheme')) { function checkvalidtheme($theme_check) { // arg1 = theme to check //global $ADMIN_DIRECTORY, $tp, $e107; // global $sql; $sql = e107::getDb(); $e107 = e107::getInstance(); $tp = e107::getParser(); $ADMIN_DIRECTORY = $e107->getFolder('admin'); // e_QUERY not set when in single entry mod if (ADMIN && strpos($_SERVER['QUERY_STRING'], 'themepreview') !== false) { list($action, $id) = explode('.', $_SERVER['QUERY_STRING']); require_once(e_HANDLER.'theme_handler.php'); $themeobj = new themeHandler; $themeArray = $themeobj->getThemes('id'); $id = intval($id); $themeDef = $themeobj->findDefault($themeArray[$id]); define('THEME_LAYOUT',$themeDef); define('PREVIEWTHEME', e_THEME.$themeArray[$id].'/'); define('PREVIEWTHEMENAME', $themeArray[$id]); define('THEME', e_THEME.$themeArray[$id].'/'); define('THEME_ABS', e_THEME_ABS.$themeArray[$id].'/'); $legacy = (file_exists( e_THEME_ABS.$themeArray[$id].'/theme.xml') === false); define('THEME_LEGACY',$legacy); unset($action); return; } $sql->db_Mark_Time("Theme Check"); if (@fopen(e_THEME.$theme_check.'/theme.php', 'r')) // if (is_readable(e_THEME.$theme_check.'/theme.php')) { define('THEME', e_THEME.$theme_check.'/'); define('THEME_ABS', e_THEME_ABS.$theme_check.'/'); $legacy = (file_exists(e_THEME.$theme_check.'/theme.xml') === false); define('THEME_LEGACY',$legacy); $e107->site_theme = $theme_check; } else { function search_validtheme() { $e107 = e107::getInstance(); $th = substr(e_THEME, 0, -1); $handle = opendir($th); while ($file = readdir($handle)) { if (is_dir(e_THEME.$file) && is_readable(e_THEME.$file.'/theme.php')) { closedir($handle); $e107->site_theme = $file; return $file; } } closedir($handle); return null; } $e107tmp_theme = 'bootstrap3'; // set to bootstrap3 by default. search_validtheme(); define('THEME', e_THEME.$e107tmp_theme.'/'); define('THEME_ABS', e_THEME_ABS.$e107tmp_theme.'/'); if (ADMIN && strpos(e_SELF, $ADMIN_DIRECTORY) === false) { echo ''; $tm = e107::getSingleton('themeHandler'); $tm->setTheme($e107tmp_theme); // $config = e107::getConfig(); // $config->set('sitetheme','core'); } } $sql->db_Mark_Time("Theme Check End"); $themes_dir = $e107->getFolder('themes'); $e107->http_theme_dir = "{$e107->server_path}{$themes_dir}{$e107->site_theme}/"; } } // // Q: ALL OTHER SETUP CODE // $sql->db_Mark_Time('Misc Setup'); //------------------------------------------------------------------------------------------------------------------------------------// if (!class_exists('e107table', false)) { /** * @package e107 */ class e107table { public $eMenuCount = 0; public $eMenuArea; public $eMenuTotal = array(); public $eSetStyle; private $themeClass = ''; private $adminThemeClass = ''; public $frontend = null; private $uniqueId = null; private $content = array(); private $contentTypes = array('header','footer','text','title','image', 'list'); private $mainRenders = array(); // all renderered with style = 'default' or 'main'. function __construct() { $this->themeClass = e107::getPref('sitetheme')."_theme"; // disabled at the moment. $this->adminThemeClass = e107::getPref('admintheme')."_admintheme"; // Check for a class. } /** * Return content options for the main render that uses {SETSTYLE=default} or {SETSTYLE=main} * @return array */ private function getMainRender() { if(isset($this->mainRenders[0])) { return $this->mainRenders[0]; } return array(); } /** * Return the first caption rendered with {SETSTYLE=default} or {SETSTYLE=main} * @return |null */ public function getMainCaption() { if(isset($this->mainRenders[0]['caption'])) { return $this->mainRenders[0]['caption']; } return null; } function getMagicShortcodes() { $ret = array(); $val = $this->getMainRender(); $types = array('caption') + $this->contentTypes; foreach($types as $var) { $sc = '{---'.strtoupper($var).'---}'; $ret[$sc] = isset($val[$var]) ? (string) $val[$var] : null; } $bread = e107::breadcrumb(); $ret['{---BREADCRUMB---}'] = e107::getForm()->breadcrumb($bread); return $ret; } /** * Set the style mode for use in tablestyle() method/function * @param string $style */ public function setStyle($style) { $this->eSetStyle = (string) $style; } /** * Set a unique id for use in tablestyle() method/function * * @param string $id * @return e107table */ public function setUniqueId($id) { $this->uniqueId = !empty($id) ? eHelper::dasherize($id) : null; return $this; } /** * Set Advanced Page/Menu content (beyond just $caption and $text) * * @param string|array $type header|footer|text|title|image|list * @param string $val * @return bool|e107table */ public function setContent($type, $val) { if(is_array($type)) { foreach($this->contentTypes as $t) { $this->content[$t] = (string) $type[$t]; } } if(!in_array($type,$this->contentTypes)) { return false; } if($this->uniqueId !== null) { $key = $this->uniqueId; } else { $key = '_generic_'; e107::getMessage()->addDebug("Possible issue: Missing a Unique Tablerender ID. Use \$ns->setUniqueId() in the plugin script prior to setContent(). "); // debug only, no LAN. } $this->content[$key][$type] = (string) $val; return $this; } /** * Return the value of custom content * @param string $type header|footer|text|title|image|list * @return array */ public function getContent($type='') { $key = ($this->uniqueId !== null) ? $this->uniqueId : '_generic_'; if(empty($type)) { return $this->content[$key]; } return $this->content[$key][$type]; } /** * Return the current value of {SETSTYLE} * @return mixed */ public function getStyle() { return $this->eSetStyle; } /** * Return the currenty set uniqueId. * @return mixed */ public function getUniqueId() { return $this->uniqueId; } /** * @param string $caption caption text * @param string $text * @param string $mode unique identifier * @param boolean $return : return the html instead of echo it. * @return null */ public function tablerender($caption, $text, $mode = 'default', $return = false) { $override_tablerender = e107::getSingleton('override', e_HANDLER.'override_class.php')->override_check('tablerender'); if ($override_tablerender) { $result = call_user_func($override_tablerender, $caption, $text, $mode, $return); if ($result == 'return') { return ''; } extract($result); } if ($return) { if(!empty($text) && $this->eMenuArea) { $this->eMenuCount++; } 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 ''; } } /** * Output the styled template. * @param $caption * @param $text * @param $mode */ private function tablestyle($caption, $text, $mode) { if(class_exists($this->adminThemeClass) && ($this->frontend == false)) { /** @var e_theme_render $thm */ $thm = new $this->adminThemeClass(); } elseif(class_exists($this->themeClass)) // disabled at the moment. { /** @var e_theme_render $thm */ $thm = new $this->themeClass(); } // Automatic list detection . $isList = (strpos(ltrim($text), '