Exemplo n.º 1
0
 public static function Run()
 {
     if (isset(self::$config['profiler']) && self::$config['profiler'] == $_SERVER['REMOTE_ADDR']) {
         Profiler::start();
     }
     App::init();
     self::$registry->router->setVariables();
     self::$registry->xajax = new Xajax();
     if (self::$registry->router->getMode() == 0) {
         $url = preg_replace_callback('~[^a-zA-Z0-9:/\\?,_-]+~', function ($s) {
             return urlencode($s[0]);
         }, self::$registry->router->getUri());
         self::$registry->xajax->configure('requestURI', $url);
     } else {
         // force language in admin mode
         Session::unsetActiveLanguage();
         self::$registry->core->setLanguage('pl');
         Translation::loadTranslations();
     }
     self::$registry->xajaxInterface = new XajaxInterface();
     self::$registry->right = new Right(self::$registry);
     Session::clearTemp();
     DEFINE('URL', App::getHost(1) . '/' . LOCAL_CATALOG);
     App::checkSSL();
     if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
         DEFINE('DESIGNPATH', str_replace('http://', 'https://', App::getURLForDesignDirectory()));
     } else {
         DEFINE('DESIGNPATH', App::getURLForDesignDirectory());
     }
     // remember login and password
     if (self::$registry->router->getModeFromRoute() == 'admin') {
         if ((int) Session::getActiveUserid() === 0) {
             App::getModel('login')->getAdminAutologinKey();
         }
     } else {
         if ((int) Session::getActiveClientid() === 0) {
             App::getModel('clientlogin')->getAutologinKey();
         }
     }
     self::$registry->template = new Template(self::$registry, self::$registry->router->getMode());
     self::$registry->template->setStaticTemplateVariables();
     $content = self::$registry->router->controllerLoader();
     if (isset(self::$config['profiler']) && self::$config['profiler'] == $_SERVER['REMOTE_ADDR']) {
         Profiler::stop();
         $content .= Profiler::getInfo();
     }
     $response = new Response($content);
     $response->send();
     App::getModel('csrfprotection')->reindex();
 }