Example #1
0
File: Core.php Project: fraym/core
 /**
  * @param int $mode
  */
 public function init($mode = Core::ROUTE_NORMAL)
 {
     if (ENV == self::ENV_DEVELOPMENT) {
         error_reporting(E_ALL | E_STRICT);
         ini_set("display_errors", 1);
     }
     if (is_object($this->session) && $this->isCLI() === false) {
         $this->session->start();
     }
     $this->mode = $mode;
     $this->startTimer(__CLASS__);
     // Assign our output handler to output clean errors
     ob_start();
     // ingore user abort, is recommed for ajax request and db changes
     if ($this->request->isXmlHttpRequest()) {
         ignore_user_abort(true);
     }
     $this->registryManager->init();
     if ($this->isCLI() === false) {
         // Sanitize all request variables
         $_GET = $this->sanitize($_GET);
         $_POST = $this->sanitize($_POST);
         $_COOKIE = $this->sanitize($_COOKIE);
         if ($mode === Core::ROUTE_NORMAL) {
             $this->cache->load();
             // Try to load a site by the requested URI
             $this->route->loadSite();
             $this->response->finish(false, true);
         }
     } else {
         $params = getopt('p:');
         if ($params['p']) {
             $_SERVER['REQUEST_URI'] = $params['p'];
             $this->route->loadRoutes();
             echo $this->route->getVirtualRouteContent();
         }
     }
 }