public static function createFromString($command, $unverifiedExecution = false)
 {
     if ($command == '') {
         return null;
     }
     $request = new WebConsoleRequest();
     $args = ServerTools::parseCommandlineString($command);
     $request->command = $args[0];
     $request->isUnverifiedExecution = $unverifiedExecution;
     $get = array();
     if (count($args) > 1) {
         $args = array_splice($args, 1);
         foreach ($args as $arg) {
             if (substr($arg, 0, 2) == '--') {
                 $get[substr($arg, 2)] = true;
             } elseif (substr($arg, 0, 1) == '-') {
                 $s = explode('=', $arg, 2);
                 $get[substr($s[0], 1)] = count($s) == 2 ? $s[1] : '';
             } else {
                 $get[] = $arg;
             }
         }
     }
     $request->args = new ArrayFilter($get);
     $request->fullCommand = WebConsoleTools::constructCommandString($request->command, $request->args);
     return $request;
 }
Example #2
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;
 }