예제 #1
0
파일: Request.php 프로젝트: n3b/symfony
    /**
     * Overrides the PHP global variables according to this request instance.
     *
     * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE.
     * $_FILES is never override, see rfc1867
     *
     * @api
     */
    public function overrideGlobals()
    {
        $_GET = $this->query->all();
        $_POST = $this->request->all();
        $_SERVER = $this->server->all();
        $_COOKIE = $this->cookies->all();

        foreach ($this->headers->all() as $key => $value) {
            $key = strtoupper(str_replace('-', '_', $key));
            if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
                $_SERVER[$key] = implode(', ', $value);
            } else {
                $_SERVER['HTTP_'.$key] = implode(', ', $value);
            }
        }

        $request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE);

        $requestOrder = ini_get('request_order') ?: ini_get('variable_order');
        $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';

        $_REQUEST = array();
        foreach (str_split($requestOrder) as $order) {
            $_REQUEST = array_merge($_REQUEST, $request[$order]);
        }
    }
예제 #2
0
 /**
  * Overrides the PHP global variables according to this request instance.
  *
  * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE, and $_FILES.
  *
  * @api
  */
 public function overrideGlobals()
 {
     $_GET = $this->query->all();
     $_POST = $this->request->all();
     $_SERVER = $this->server->all();
     $_COOKIE = $this->cookies->all();
     // FIXME: populate $_FILES
     foreach ($this->headers->all() as $key => $value) {
         $key = strtoupper(str_replace('-', '_', $key));
         if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
             $_SERVER[$key] = implode(', ', $value);
         } else {
             $_SERVER['HTTP_' . $key] = implode(', ', $value);
         }
     }
     // FIXME: should read variables_order and request_order
     // to know which globals to merge and in which order
     $_REQUEST = array_merge($_GET, $_POST);
 }