Beispiel #1
0
 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'));
 }
Beispiel #2
0
 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()));
     }
 }