public static function setSite($site) { if (!static::siteExists($site)) { $site = static::$site; } static::$site = $site; $class = 'OSC\\Sites\\' . $site . '\\' . $site; $OSCOM_Site = new $class(); Registry::set('Site', $OSCOM_Site); $OSCOM_Site->setPage(); }
function __construct($module = '') { global $PHP_SELF; $this->lang = Registry::get('Language'); if (defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED)) { $this->modules = explode(';', MODULE_PAYMENT_INSTALLED); $include_modules = array(); if (tep_not_null($module) && (in_array($module . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules) || in_array($module, $this->modules))) { $this->selected_module = $module; if (strpos($module, '\\') !== false) { $class = Apps::getModuleClass($module, 'Payment'); $include_modules[] = ['class' => $module, 'file' => $class]; } else { $include_modules[] = array('class' => $module, 'file' => $module . '.php'); } } else { foreach ($this->modules as $value) { if (strpos($value, '\\') !== false) { $class = Apps::getModuleClass($value, 'Payment'); $include_modules[] = ['class' => $value, 'file' => $class]; } else { $class = basename($value, '.php'); $include_modules[] = array('class' => $class, 'file' => $value); } } } for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) { if (strpos($include_modules[$i]['class'], '\\') !== false) { Registry::set('Payment_' . str_replace('\\', '_', $include_modules[$i]['class']), new $include_modules[$i]['file']()); } else { $this->lang->loadDefinitions('modules/payment/' . pathinfo($include_modules[$i]['file'], PATHINFO_FILENAME)); include 'includes/modules/payment/' . $include_modules[$i]['file']; $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'](); } } // if there is only one payment method, select it as default because in // checkout_confirmation.php the $_SESSION['payment'] variable is being assigned the // $_POST['payment'] value which will be empty (no radio button selection possible) if (tep_count_payment_modules() == 1 && (!isset($_SESSION['payment']) || $_SESSION['payment'] != $include_modules[0]['class'])) { $_SESSION['payment'] = $include_modules[0]['class']; } if (tep_not_null($module) && (in_array($module . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules) || in_array($module, $this->modules))) { if (strpos($module, '\\') !== false) { $OSCOM_PM = Registry::get('Payment_' . str_replace('\\', '_', $module)); if (isset($OSCOM_PM->form_action_url)) { $this->form_action_url = $OSCOM_PM->form_action_url; } } elseif (isset($GLOBALS[$module]->form_action_url)) { $this->form_action_url = $GLOBALS[$module]->form_action_url; } } } }
public static function setSite($site) { if (!empty($site)) { static::$site = $site; } $class = 'OSC\\Sites\\' . static::$site . '\\' . static::$site; if (is_subclass_of($class, 'OSC\\OM\\SitesInterface')) { $OSCOM_Site = new $class(); Registry::set('Site', $OSCOM_Site); $OSCOM_Site->setPage(); } else { trigger_error('OSC\\OM\\OSCOM::setSite() - ' . $site . ': Site does not implement OSC\\OM\\SitesInterface and cannot be loaded.'); exit; } }
function __construct($module = '') { global $PHP_SELF; $this->lang = Registry::get('Language'); if (defined('MODULE_SHIPPING_INSTALLED') && tep_not_null(MODULE_SHIPPING_INSTALLED)) { $this->modules = explode(';', MODULE_SHIPPING_INSTALLED); $include_modules = array(); $code = null; if (isset($module) && is_array($module) && isset($module['id'])) { if (strpos($module['id'], '\\') !== false) { list($vendor, $app, $module) = explode('\\', $module['id']); list($module, $method) = explode('_', $module); $code = $vendor . '\\' . $app . '\\' . $module; } elseif (strpos($module['id'], '_') !== false) { $code = substr($module['id'], 0, strpos($module['id'], '_')); } } if (isset($code) && (in_array($code . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules) || in_array($code, $this->modules))) { if (strpos($code, '\\') !== false) { $class = Apps::getModuleClass($code, 'Shipping'); $include_modules[] = ['class' => $code, 'file' => $class]; } else { $include_modules[] = ['class' => $code, 'file' => $code . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1)]; } } else { foreach ($this->modules as $value) { if (strpos($value, '\\') !== false) { $class = Apps::getModuleClass($value, 'Shipping'); $include_modules[] = ['class' => $value, 'file' => $class]; } else { $class = substr($value, 0, strrpos($value, '.')); $include_modules[] = ['class' => $class, 'file' => $value]; } } } for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) { if (strpos($include_modules[$i]['class'], '\\') !== false) { Registry::set('Shipping_' . str_replace('\\', '_', $include_modules[$i]['class']), new $include_modules[$i]['file']()); } else { $this->lang->loadDefinitions('modules/shipping/' . pathinfo($include_modules[$i]['file'], PATHINFO_FILENAME)); include 'includes/modules/shipping/' . $include_modules[$i]['file']; $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'](); } } } }
function __construct() { $this->lang = Registry::get('Language'); if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) { $this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED); foreach ($this->modules as $value) { if (strpos($value, '\\') !== false) { $class = Apps::getModuleClass($value, 'OrderTotal'); Registry::set('OrderTotal_' . str_replace('\\', '_', $value), new $class()); } else { $this->lang->loadDefinitions('modules/order_total/' . pathinfo($value, PATHINFO_FILENAME)); include 'includes/modules/order_total/' . $value; $class = substr($value, 0, strrpos($value, '.')); $GLOBALS[$class] = new $class(); } } } }
public function call($group, $hook, $action = 'execute', $flatten = false) { if (!isset($this->hooks[$this->site][$group][$hook][$action])) { $this->register($group, $hook, $action); } $result = []; foreach ($this->hooks[$this->site][$group][$hook][$action] as $code) { $class = Apps::getModuleClass($code, 'Hooks'); $regclass = 'Hook_' . str_replace(['/', '\\'], '_', $code); if (!Registry::exists($regclass)) { Registry::set($regclass, new $class()); } $bait = Registry::get($regclass)->{$action}(); if (!empty($bait)) { $result[] = $bait; } } if ($flatten === true) { $result = implode('', $result); } return $result; }
$request_type = 'SSL'; define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG); // set the cookie domain $cookie_domain = HTTPS_COOKIE_DOMAIN; $cookie_path = HTTPS_COOKIE_PATH; } else { $request_type = 'NONSSL'; define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG); $cookie_domain = HTTP_COOKIE_DOMAIN; $cookie_path = HTTP_COOKIE_PATH; } // set php_self in the local scope $req = parse_url($_SERVER['SCRIPT_NAME']); $PHP_SELF = substr($req['path'], $request_type == 'NONSSL' ? strlen(DIR_WS_HTTP_CATALOG) : strlen(DIR_WS_HTTPS_CATALOG)); Registry::set('Cache', new Cache()); Registry::set('Db', Db::initialize()); $OSCOM_Db = Registry::get('Db'); // set the application parameters $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']); //, null, null, null, 'configuration'); // TODO add cache when supported by admin while ($Qcfg->fetch()) { define($Qcfg->value('k'), $Qcfg->value('v')); } // if gzip_compression is enabled, start to buffer the output if (GZIP_COMPRESSION == 'true' && extension_loaded('zlib') && !headers_sent()) { if ((int) ini_get('zlib.output_compression') < 1) { if (PHP_VERSION < '5.4' || PHP_VERSION > '5.4.5') { // see PHP bug 55544 ob_start('ob_gzhandler'); } } elseif (function_exists('ini_set')) {
protected function init() { global $request_type, $cookie_domain, $cookie_path, $PHP_SELF, $SID, $currencies, $messageStack, $oscTemplate, $breadcrumb; Registry::set('Cache', new Cache()); $OSCOM_Db = Db::initialize(); Registry::set('Db', $OSCOM_Db); // set the application parameters $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']); //, null, null, null, 'configuration'); // TODO add cache when supported by admin while ($Qcfg->fetch()) { define($Qcfg->value('k'), $Qcfg->value('v')); } // set the type of request (secure or not) if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { $request_type = 'SSL'; define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG); $cookie_domain = HTTPS_COOKIE_DOMAIN; $cookie_path = HTTPS_COOKIE_PATH; } else { $request_type = 'NONSSL'; define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG); $cookie_domain = HTTP_COOKIE_DOMAIN; $cookie_path = HTTP_COOKIE_PATH; } // set php_self in the global scope $req = parse_url($_SERVER['SCRIPT_NAME']); $PHP_SELF = substr($req['path'], $request_type == 'NONSSL' ? strlen(DIR_WS_HTTP_CATALOG) : strlen(DIR_WS_HTTPS_CATALOG)); // set the session name and save path session_name('oscomid'); session_save_path(SESSION_WRITE_DIRECTORY); // set the session cookie parameters session_set_cookie_params(0, $cookie_path, $cookie_domain); if (function_exists('ini_set')) { ini_set('session.use_only_cookies', SESSION_FORCE_COOKIE_USE == 'True' ? 1 : 0); } // set the session ID if it exists if (SESSION_FORCE_COOKIE_USE == 'False') { if (isset($_GET[session_name()]) && (!isset($_COOKIE[session_name()]) || $_COOKIE[session_name()] != $_GET[session_name()])) { session_id($_GET[session_name()]); } elseif (isset($_POST[session_name()]) && (!isset($_COOKIE[session_name()]) || $_COOKIE[session_name()] != $_POST[session_name()])) { session_id($_POST[session_name()]); } } // start the session if (SESSION_FORCE_COOKIE_USE == 'True') { tep_setcookie('cookie_test', 'please_accept_for_session', time() + 60 * 60 * 24 * 30); if (isset($_COOKIE['cookie_test'])) { tep_session_start(); } } elseif (SESSION_BLOCK_SPIDERS == 'True') { $user_agent = ''; if (isset($_SERVER['HTTP_USER_AGENT'])) { $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); } $spider_flag = false; if (!empty($user_agent)) { foreach (file(OSCOM::BASE_DIR . 'spiders.txt') as $spider) { if (!empty($spider)) { if (strpos($user_agent, $spider) !== false) { $spider_flag = true; break; } } } } if ($spider_flag === false) { tep_session_start(); } } else { tep_session_start(); } $this->ignored_actions[] = session_name(); // initialize a session token if (!isset($_SESSION['sessiontoken'])) { $_SESSION['sessiontoken'] = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand()); } // set SID once, even if empty $SID = defined('SID') ? SID : ''; // verify the ssl_session_id if the feature is enabled if ($request_type == 'SSL' && SESSION_CHECK_SSL_SESSION_ID == 'True' && ENABLE_SSL == true && session_status() === PHP_SESSION_ACTIVE) { if (!isset($_SESSION['SSL_SESSION_ID'])) { $_SESSION['SESSION_SSL_ID'] = $_SERVER['SSL_SESSION_ID']; } if ($_SESSION['SESSION_SSL_ID'] != $_SERVER['SSL_SESSION_ID']) { tep_session_destroy(); OSCOM::redirect('ssl_check.php'); } } // verify the browser user agent if the feature is enabled if (SESSION_CHECK_USER_AGENT == 'True') { if (!isset($_SESSION['SESSION_USER_AGENT'])) { $_SESSION['SESSION_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; } if ($_SESSION['SESSION_USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) { tep_session_destroy(); OSCOM::redirect('index.php', 'Account&LogIn'); } } // verify the IP address if the feature is enabled if (SESSION_CHECK_IP_ADDRESS == 'True') { if (!isset($_SESSION['SESSION_IP_ADDRESS'])) { $_SESSION['SESSION_IP_ADDRESS'] = tep_get_ip_address(); } if ($_SESSION['SESSION_IP_ADDRESS'] != tep_get_ip_address()) { tep_session_destroy(); OSCOM::redirect('index.php', 'Account&LogIn'); } } // create the shopping cart if (!isset($_SESSION['cart']) || !is_object($_SESSION['cart']) || get_class($_SESSION['cart']) != 'shoppingCart') { $_SESSION['cart'] = new \shoppingCart(); } // include currencies class and create an instance $currencies = new \currencies(); // set the language if (!isset($_SESSION['language']) || isset($_GET['language'])) { $lng = new \language(); if (isset($_GET['language']) && !empty($_GET['language'])) { $lng->set_language($_GET['language']); } else { $lng->get_browser_language(); } $_SESSION['language'] = $lng->language['directory']; $_SESSION['languages_id'] = $lng->language['id']; } // include the language translations $system_locale_numeric = setlocale(LC_NUMERIC, 0); include OSCOM::BASE_DIR . 'languages/' . $_SESSION['language'] . '.php'; setlocale(LC_NUMERIC, $system_locale_numeric); // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634) // currency if (!isset($_SESSION['currency']) || isset($_GET['currency']) || USE_DEFAULT_LANGUAGE_CURRENCY == 'true' && LANGUAGE_CURRENCY != $_SESSION['currency']) { if (isset($_GET['currency']) && $currencies->is_set($_GET['currency'])) { $_SESSION['currency'] = $_GET['currency']; } else { $_SESSION['currency'] = USE_DEFAULT_LANGUAGE_CURRENCY == 'true' && $currencies->is_set(LANGUAGE_CURRENCY) ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } // navigation history if (!isset($_SESSION['navigation']) || !is_object($_SESSION['navigation']) || get_class($_SESSION['navigation']) != 'navigationHistory') { $_SESSION['navigation'] = new \navigationHistory(); } $_SESSION['navigation']->add_current_page(); $messageStack = new \messageStack(); tep_update_whos_online(); tep_activate_banners(); tep_expire_banners(); tep_expire_specials(); $oscTemplate = new \oscTemplate(); $breadcrumb = new \breadcrumb(); $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER); $breadcrumb->add(HEADER_TITLE_CATALOG, OSCOM::link('index.php')); Registry::set('Hooks', new Hooks()); }
use OSC\OM\Db; use OSC\OM\FileSystem; use OSC\OM\Hash; use OSC\OM\HTML; use OSC\OM\Language; use OSC\OM\OSCOM; use OSC\OM\Registry; $OSCOM_Db = Db::initialize($_POST['DB_SERVER'], $_POST['DB_SERVER_USERNAME'], $_POST['DB_SERVER_PASSWORD'], $_POST['DB_DATABASE']); Registry::set('Db', $OSCOM_Db); $OSCOM_Db->setTablePrefix($_POST['DB_TABLE_PREFIX']); $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']); while ($Qcfg->fetch()) { define($Qcfg->value('k'), $Qcfg->value('v')); } $OSCOM_Language = new Language(); Registry::set('Language', $OSCOM_Language); $OSCOM_Db->save('configuration', ['configuration_value' => $_POST['CFG_STORE_NAME']], ['configuration_key' => 'STORE_NAME']); $OSCOM_Db->save('configuration', ['configuration_value' => $_POST['CFG_STORE_OWNER_NAME']], ['configuration_key' => 'STORE_OWNER']); $OSCOM_Db->save('configuration', ['configuration_value' => $_POST['CFG_STORE_OWNER_EMAIL_ADDRESS']], ['configuration_key' => 'STORE_OWNER_EMAIL_ADDRESS']); if (!empty($_POST['CFG_STORE_OWNER_NAME']) && !empty($_POST['CFG_STORE_OWNER_EMAIL_ADDRESS'])) { $OSCOM_Db->save('configuration', ['configuration_value' => '"' . trim($_POST['CFG_STORE_OWNER_NAME']) . '" <' . trim($_POST['CFG_STORE_OWNER_EMAIL_ADDRESS']) . '>'], ['configuration_key' => 'EMAIL_FROM']); } else { $OSCOM_Db->save('configuration', ['configuration_value' => $_POST['CFG_STORE_OWNER_EMAIL_ADDRESS']], ['configuration_key' => 'EMAIL_FROM']); } if (!empty($_POST['CFG_ADMINISTRATOR_USERNAME'])) { $Qcheck = $OSCOM_Db->prepare('select user_name from :table_administrators where user_name = :user_name'); $Qcheck->bindValue(':user_name', $_POST['CFG_ADMINISTRATOR_USERNAME']); $Qcheck->execute(); if ($Qcheck->fetch() !== false) { $OSCOM_Db->save('administrators', ['user_password' => Hash::encrypt(trim($_POST['CFG_ADMINISTRATOR_PASSWORD']))], ['user_name' => $_POST['CFG_ADMINISTRATOR_USERNAME']]); } else {
public static function getModuleClass($module, $type) { if (!Registry::exists('ModuleType' . $type)) { $class = 'OSC\\OM\\Modules\\' . $type; if (!class_exists($class)) { trigger_error('OSC\\OM\\Apps::getModuleClass(): ' . $type . ' module class not found in OSC\\OM\\Modules\\'); return $result; } Registry::set('ModuleType' . $type, new $class()); } $OSCOM_Type = Registry::get('ModuleType' . $type); return $OSCOM_Type->getClass($module); }
protected function init() { global $request_type, $cookie_domain, $cookie_path, $PHP_SELF, $login_request, $messageStack, $cfgModules; Registry::set('Cache', new Cache()); $OSCOM_Db = Db::initialize(); Registry::set('Db', $OSCOM_Db); // TODO legacy tep_db_connect() or die('Unable to connect to database server!'); // set the application parameters $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']); //, null, null, null, 'configuration'); // TODO add cache when supported by admin while ($Qcfg->fetch()) { define($Qcfg->value('k'), $Qcfg->value('v')); } // Used in the "Backup Manager" to compress backups define('LOCAL_EXE_GZIP', 'gzip'); define('LOCAL_EXE_GUNZIP', 'gunzip'); define('LOCAL_EXE_ZIP', 'zip'); define('LOCAL_EXE_UNZIP', 'unzip'); // Define how do we update currency exchange rates // Possible values are 'oanda' 'xe' or '' define('CURRENCY_SERVER_PRIMARY', 'oanda'); define('CURRENCY_SERVER_BACKUP', 'xe'); // set the type of request (secure or not) if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { $request_type = 'SSL'; $cookie_domain = HTTPS_COOKIE_DOMAIN; $cookie_path = HTTPS_COOKIE_PATH; } else { $request_type = 'NONSSL'; $cookie_domain = HTTP_COOKIE_DOMAIN; $cookie_path = HTTP_COOKIE_PATH; } // set php_self in the global scope $req = parse_url($_SERVER['SCRIPT_NAME']); $PHP_SELF = substr($req['path'], $request_type == 'SSL' ? strlen(DIR_WS_HTTPS_ADMIN) : strlen(DIR_WS_ADMIN)); // set the session name and save path tep_session_name('oscomadminid'); tep_session_save_path(SESSION_WRITE_DIRECTORY); // set the session cookie parameters // set the session cookie parameters session_set_cookie_params(0, $cookie_path, $cookie_domain); if (function_exists('ini_set')) { ini_set('session.use_only_cookies', SESSION_FORCE_COOKIE_USE == 'True' ? 1 : 0); } // lets start our session tep_session_start(); // TODO remove when no more global sessions exist foreach ($_SESSION as $k => $v) { $GLOBALS[$k] =& $_SESSION[$k]; } // set the language if (!isset($_SESSION['language']) || isset($_GET['language'])) { $lng = new \language(); if (isset($_GET['language']) && !empty($_GET['language'])) { $lng->set_language($_GET['language']); } else { $lng->get_browser_language(); } $_SESSION['language'] = $lng->language['directory']; $_SESSION['languages_id'] = $lng->language['id']; } // redirect to login page if administrator is not yet logged in if (!isset($_SESSION['admin'])) { $redirect = false; $current_page = $PHP_SELF; // if the first page request is to the login page, set the current page to the index page // so the redirection on a successful login is not made to the login page again if ($current_page == FILENAME_LOGIN && !isset($_SESSION['redirect_origin'])) { $current_page = FILENAME_DEFAULT; } if ($current_page != FILENAME_LOGIN) { if (!isset($_SESSION['redirect_origin'])) { $_SESSION['redirect_origin'] = ['page' => $current_page, 'get' => []]; } // try to automatically login with the HTTP Authentication values if it exists if (!isset($_SESSION['auth_ignore'])) { if (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($_SERVER['PHP_AUTH_PW'])) { $_SESSION['redirect_origin']['auth_user'] = $_SERVER['PHP_AUTH_USER']; $_SESSION['redirect_origin']['auth_pw'] = $_SERVER['PHP_AUTH_PW']; } } $redirect = true; } if (!isset($login_request) || isset($_GET['login_request']) || isset($_POST['login_request']) || isset($_COOKIE['login_request']) || isset($_SESSION['login_request']) || isset($_FILES['login_request']) || isset($_SERVER['login_request'])) { $redirect = true; } if ($redirect == true) { tep_redirect(tep_href_link(FILENAME_LOGIN, isset($_SESSION['redirect_origin']['auth_user']) ? 'action=process' : '')); } } // include the language translations $_system_locale_numeric = setlocale(LC_NUMERIC, 0); require DIR_FS_ADMIN . 'includes/languages/' . $_SESSION['language'] . '.php'; setlocale(LC_NUMERIC, $_system_locale_numeric); // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634) $current_page = basename($PHP_SELF); if (file_exists(DIR_FS_ADMIN . 'includes/languages/' . $_SESSION['language'] . '/' . $current_page)) { include DIR_FS_ADMIN . 'includes/languages/' . $_SESSION['language'] . '/' . $current_page; } $messageStack = new \messageStack(); $cfgModules = new \cfg_modules(); Registry::set('Hooks', new Hooks()); }
protected function init() { global $PHP_SELF, $currencies, $messageStack, $oscTemplate, $breadcrumb; $OSCOM_Cookies = new Cookies(); Registry::set('Cookies', $OSCOM_Cookies); try { $OSCOM_Db = Db::initialize(); Registry::set('Db', $OSCOM_Db); } catch (\Exception $e) { include OSCOM::getConfig('dir_root') . 'includes/error_documents/maintenance.php'; exit; } Registry::set('Hooks', new Hooks()); // set the application parameters $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']); //, null, null, null, 'configuration'); // TODO add cache when supported by admin while ($Qcfg->fetch()) { define($Qcfg->value('k'), $Qcfg->value('v')); } // set php_self in the global scope $req = parse_url($_SERVER['SCRIPT_NAME']); $PHP_SELF = substr($req['path'], strlen(OSCOM::getConfig('http_path', 'Shop'))); $OSCOM_Session = Session::load(); Registry::set('Session', $OSCOM_Session); // start the session $OSCOM_Session->start(); $this->ignored_actions[] = session_name(); $OSCOM_Language = new Language(); // $OSCOM_Language->setUseCache(true); Registry::set('Language', $OSCOM_Language); // create the shopping cart if (!isset($_SESSION['cart']) || !is_object($_SESSION['cart']) || get_class($_SESSION['cart']) != 'shoppingCart') { $_SESSION['cart'] = new \shoppingCart(); } // include currencies class and create an instance $currencies = new \currencies(); // set the language if (!isset($_SESSION['language']) || isset($_GET['language'])) { if (isset($_GET['language']) && !empty($_GET['language']) && $OSCOM_Language->exists($_GET['language'])) { $OSCOM_Language->set($_GET['language']); } $_SESSION['language'] = $OSCOM_Language->get('code'); } // include the language translations $OSCOM_Language->loadDefinitions('main'); // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634) $system_locale_numeric = setlocale(LC_NUMERIC, 0); setlocale(LC_ALL, explode(';', OSCOM::getDef('system_locale'))); setlocale(LC_NUMERIC, $system_locale_numeric); // currency if (!isset($_SESSION['currency']) || isset($_GET['currency']) || USE_DEFAULT_LANGUAGE_CURRENCY == 'true' && OSCOM::getDef('language_currency') != $_SESSION['currency']) { if (isset($_GET['currency']) && $currencies->is_set($_GET['currency'])) { $_SESSION['currency'] = $_GET['currency']; } else { $_SESSION['currency'] = USE_DEFAULT_LANGUAGE_CURRENCY == 'true' && $currencies->is_set(OSCOM::getDef('language_currency')) ? OSCOM::getDef('language_currency') : DEFAULT_CURRENCY; } } // navigation history if (!isset($_SESSION['navigation']) || !is_object($_SESSION['navigation']) || get_class($_SESSION['navigation']) != 'navigationHistory') { $_SESSION['navigation'] = new \navigationHistory(); } $_SESSION['navigation']->add_current_page(); $messageStack = new \messageStack(); tep_update_whos_online(); tep_activate_banners(); tep_expire_banners(); tep_expire_specials(); $oscTemplate = new \oscTemplate(); $breadcrumb = new \breadcrumb(); $breadcrumb->add(OSCOM::getDef('header_title_top'), OSCOM::getConfig('http_server', 'Shop')); $breadcrumb->add(OSCOM::getDef('header_title_catalog'), OSCOM::link('index.php')); }
protected function init() { global $PHP_SELF, $login_request, $cfgModules, $oscTemplate; $OSCOM_Cookies = new Cookies(); Registry::set('Cookies', $OSCOM_Cookies); try { $OSCOM_Db = Db::initialize(); Registry::set('Db', $OSCOM_Db); } catch (\Exception $e) { include OSCOM::getConfig('dir_root', 'Shop') . 'includes/error_documents/maintenance.php'; exit; } Registry::set('Hooks', new Hooks()); Registry::set('MessageStack', new MessageStack()); // set the application parameters $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']); //, null, null, null, 'configuration'); // TODO add cache when supported by admin while ($Qcfg->fetch()) { define($Qcfg->value('k'), $Qcfg->value('v')); } // Used in the "Backup Manager" to compress backups define('LOCAL_EXE_GZIP', 'gzip'); define('LOCAL_EXE_GUNZIP', 'gunzip'); define('LOCAL_EXE_ZIP', 'zip'); define('LOCAL_EXE_UNZIP', 'unzip'); // set php_self in the global scope $req = parse_url($_SERVER['SCRIPT_NAME']); $PHP_SELF = substr($req['path'], strlen(OSCOM::getConfig('http_path'))); $OSCOM_Session = Session::load(); Registry::set('Session', $OSCOM_Session); $OSCOM_Session->start(); $OSCOM_Language = new Language(); Registry::set('Language', $OSCOM_Language); // set the language if (!isset($_SESSION['language']) || isset($_GET['language'])) { if (isset($_GET['language']) && !empty($_GET['language']) && $OSCOM_Language->exists($_GET['language'])) { $OSCOM_Language->set($_GET['language']); } $_SESSION['language'] = $OSCOM_Language->get('code'); } // redirect to login page if administrator is not yet logged in if (!isset($_SESSION['admin'])) { $redirect = false; $current_page = $PHP_SELF; // if the first page request is to the login page, set the current page to the index page // so the redirection on a successful login is not made to the login page again if ($current_page == FILENAME_LOGIN && !isset($_SESSION['redirect_origin'])) { $current_page = FILENAME_DEFAULT; } if ($current_page != FILENAME_LOGIN) { if (!isset($_SESSION['redirect_origin'])) { $_SESSION['redirect_origin'] = ['page' => $current_page, 'get' => []]; } // try to automatically login with the HTTP Authentication values if it exists if (!isset($_SESSION['auth_ignore'])) { if (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($_SERVER['PHP_AUTH_PW'])) { $_SESSION['redirect_origin']['auth_user'] = $_SERVER['PHP_AUTH_USER']; $_SESSION['redirect_origin']['auth_pw'] = $_SERVER['PHP_AUTH_PW']; } } $redirect = true; } if (!isset($login_request) || isset($_GET['login_request']) || isset($_POST['login_request']) || isset($_COOKIE['login_request']) || isset($_SESSION['login_request']) || isset($_FILES['login_request']) || isset($_SERVER['login_request'])) { $redirect = true; } if ($redirect == true) { OSCOM::redirect(FILENAME_LOGIN, isset($_SESSION['redirect_origin']['auth_user']) ? 'action=process' : ''); } } // include the language translations $OSCOM_Language->loadDefinitions('main'); // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634) $system_locale_numeric = setlocale(LC_NUMERIC, 0); setlocale(LC_ALL, explode(';', OSCOM::getDef('system_locale'))); setlocale(LC_NUMERIC, $system_locale_numeric); $current_page = basename($PHP_SELF); if ($OSCOM_Language->definitionsExist(pathinfo($current_page, PATHINFO_FILENAME))) { $OSCOM_Language->loadDefinitions(pathinfo($current_page, PATHINFO_FILENAME)); } $oscTemplate = new \oscTemplate(); $cfgModules = new \cfg_modules(); if (!FileSystem::isWritable(ErrorHandler::getDirectory())) { Registry::get('MessageStack')->add('The log directory is not writable. Please allow the web server to write to: ' . FileSystem::displayPath(ErrorHandler::getDirectory())); } }