Exemple #1
0
 public function init()
 {
     if ($this->checkForMagicQuotes && ini_get('magic_quotes_gpc')) {
         $this->_get = new ArrayFilter(ServerTools::decodeMagicQuotes($_GET));
         $this->_post = new ArrayFilter(ServerTools::decodeMagicQuotes($_POST));
         $this->_cookies = new ArrayFilter(ServerTools::decodeMagicQuotes($_COOKIE));
     } else {
         $this->_get = new ArrayFilter($_GET);
         $this->_post = new ArrayFilter($_POST);
         $this->_cookies = new ArrayFilter($_COOKIE);
     }
     $this->_server = new ArrayFilter($_SERVER);
     $this->_files = new ArrayFilter($_FILES);
     $this->_setBasePaths();
     $this->_setBaseUrls();
     $r = new Request($this->_retrieveUrl(), $this->_get, $this->_post);
     $r->files = $this->_files;
     $r->cookies = $this->_cookies;
     $r->server = $this->_server;
     $r->method = strtoupper($this->_server->get('REQUEST_METHOD'));
     // Removed GET config parameters (Grout_*) and move them to config array
     $get = $this->_get->getData();
     $config = array();
     foreach ($get as $key => $value) {
         if (substr($key, 0, 6) === 'Grout_') {
             $config[$key] = $value;
         }
     }
     foreach ($config as $key => $value) {
         unset($get[$key]);
     }
     $r->get->setData($get);
     $r->config->setData($config);
     if ($urlPrefix = $r->config->get('Grout_UrlPrefix')) {
         $this->app->url .= $urlPrefix;
         $r->url = substr($r->url, strlen($urlPrefix));
     }
     return $r;
 }