Esempio n. 1
0
 /**
  * Analise a url comparando se existe uma roda cadastrada. retorna um
  * Request tratado
  * @param \S9\Pattern\Request $oRequest
  * @return \S9\Pattern\Request tratado
  */
 public function analyzer(Request $oRequest)
 {
     $URI = $oRequest->getURI();
     $route = $this->get($URI);
     #Não é uma Route válido
     if (!$route) {
         $controller = implode("\\", array($oRequest->getItem("MODULE"), "Controller", array_shift(array_reverse(explode("\\", $oRequest->getItem("CONTROLLER"))))));
         if (!class_exists($controller)) {
             $oRequest->setItem("MODULE", "Padrao");
             $oRequest->setItem("CONTROLLER", "Padrao\\Controller\\Error");
             $oRequest->setItem("ACTION", "error404");
             return $oRequest;
         } else {
             $oRequest->setItem("CONTROLLER", $controller);
         }
         if (!$oRequest->getItem("ACTION")) {
             $oRequest->setItem("ACTION", "index");
         }
         return $oRequest;
     } else {
         $controller = implode("\\", array($route["MODULE"], "Controller", $route["CONTROLLER"]));
         if (!class_exists($controller)) {
             $oRequest->setItem("MODULE", "Padrao");
             $oRequest->setItem("CONTROLLER", "Padrao\\Controller\\Error");
             $oRequest->setItem("ACTION", "error404");
             return $oRequest;
         } else {
             $oRequest->setItem("MODULE", $route["MODULE"]);
             $oRequest->setItem("CONTROLLER", $controller);
             $oRequest->setItem("ACTION", $route["ACTION"]);
             if (isset($route["PARAMS"])) {
                 $route["PARAMS"] = unserialize($route["PARAMS"]);
                 foreach ($route["PARAMS"] as $key => $value) {
                     $oRequest->setParam($key, $value);
                 }
             }
             if (isset($route["PERMISSION"])) {
                 $route["PERMISSION"] = unserialize($route["PERMISSION"]);
                 $oRequest->setItem("PERMISSION", $route["PERMISSION"]);
             }
             return $oRequest;
         }
     }
 }
Esempio n. 2
0
 /**
  * Carrega as configurações inicias definidas no php.ini
  */
 protected function boot()
 {
     $oRequest = new Request();
     $configs = $this->getConfigs();
     $sessionName = md5($configs["key"] . $oRequest->getItem("REMOTE_ADDR") . $oRequest->getItem("HTTP_USER_AGENT"));
     $sessionPath = isset($configs["save_path"]) ? $configs["save_path"] : ini_get('session.save_path');
     $sessionCookiePath = isset($configs["cookie_path"]) ? $configs["cookie_path"] : ini_get('session.cookie_path');
     $sessionCacheExpire = isset($configs["cache_expire"]) ? $configs["cache_expire"] : ini_get('session.cache_expire');
     $this->setSessionName($sessionName);
     $this->setSessionPath($sessionPath);
     $this->setSessionCookiePath($sessionCookiePath);
     $this->setSessionCacheExpire($sessionCacheExpire);
     #Desabilita o Acesso via Javascript aos Cookies da Sessions
     #http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-httponly
     $this->defineParams("session.cookie_httponly", TRUE);
 }