/** * Get the HTTP method/verb of the HTTP Request * * @return HTTPRequestMethod */ public function getMethod() { return new HTTPRequestMethod($this->request->getMethod()); }
/** * @return array */ protected function getEnvData() { $result = ['ENV' => $_ENV, 'SERVER' => $_SERVER]; $Request = Instance::ensure('request', Request::className()); if ($Request instanceof \yii\web\Request) { $result['COOKIE'] = $_COOKIE; $result['GET'] = $Request->get(); $result['POST'] = $Request->post(); $result['REQUEST_BODY'] = $Request->getRawBody(); } // @todo add gzip compress return serialize($result); }
/** * Parses the user request. * * @param Request $request the request component * * @return array|boolean the route and the associated parameters. The latter is always empty * if [[enablePrettyUrl]] is false. False is returned if the current request cannot be successfully parsed. */ public function parseRequest($request) { if ($this->enablePrettyUrl) { $pathInfo = $request->getPathInfo(); /* @var $rule UrlRule */ foreach ($this->rules as $rule) { if (($result = $rule->parseRequest($this, $request)) !== FALSE) { return $result; } } if ($this->enableStrictParsing) { return FALSE; } Yii::trace('No matching URL rules. Using default URL parsing logic.', __METHOD__); $suffix = (string) $this->suffix; if ($suffix !== '' && $pathInfo !== '') { $n = strlen($this->suffix); if (substr_compare($pathInfo, $this->suffix, -$n, $n) === 0) { $pathInfo = substr($pathInfo, 0, -$n); if ($pathInfo === '') { // suffix alone is not allowed return FALSE; } } else { // suffix doesn't match return FALSE; } } return [$pathInfo, []]; } else { Yii::trace('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__); $route = $request->getQueryParam($this->routeParam, ''); if (is_array($route)) { $route = ''; } /* ~ C006 UPDATE */ // $array_qs = []; $uri = $_SERVER['REQUEST_URI']; $qs = ''; if (stripos($uri, '?') != FALSE) { list($uri, $qs) = explode('?', $_SERVER['REQUEST_URI']); $qs = urldecode($qs); } $uri = preg_replace('/[^0-9|a-z|\\-|_|\\/|\\.]/', '', strtolower(rtrim($uri, '/'))); if (TRUE && $uri && strpos($uri, 'index.php') == FALSE) { $model = AliasUrl::find()->where(['public' => $uri])->andWhere(['is_frontend' => $this->is_frontend])->orderBy("`is_frontend` DESC, CHAR_LENGTH(`public`) ASC")->asArray()->one(); if (sizeof($model)) { $private = $model['private']; if (stripos($private, '?') != FALSE) { list($private, $qs2) = explode('?', $private); $qs .= $qs2; } $array_qs = self::queryStringToArray($qs); // print_r($_SERVER); // echo PHP_EOL; // print_r($model); // echo PHP_EOL; // print_r($array_qs); // echo PHP_EOL; // echo $private; // exit; return ["" . $private, $array_qs]; } } else { $array_qs = self::queryStringToArray($qs); if (isset($array_qs['r'])) { $route = $array_qs['r']; unset($array_qs['r']); } } return ["" . $route, $array_qs]; } }