Esempio n. 1
0
 /**
  * Parse Request URL
  *
  * @return string Request URI parsed
  */
 protected function parseRequestUri()
 {
     // static cached
     static $return = null;
     if ($return !== null) {
         return $return;
     }
     if (!Server::get('REQUEST_URI') && !Server::get('SCRIPT_NAME')) {
         $return = '';
         return $return;
     }
     // add Request URI
     // $requri = Path::cleanSlashed(Request::getHost().'/'.Server::get('REQUEST_URI'));
     $requri = Server::get('REQUEST_URI');
     $requri = substr($requri, 0, 1) == '/' ? $requri : "/{$requri}";
     $requri = rtrim(Request::getHost(), '/') . $requri;
     $uri = parse_url('http://' . $requri);
     $query = isset($uri['query']) ? $uri['query'] : '';
     $uri = isset($uri['path']) ? $uri['path'] : '';
     $script_name = Server::get('SCRIPT_NAME');
     if (isset($script_name[0])) {
         /**
          * Set New URL Path
          */
         if (strpos($uri, $script_name) === 0) {
             $uri = substr($uri, strlen($script_name));
         } elseif (strpos($uri, dirname($script_name)) === 0) {
             $uri = substr($uri, strlen(dirname($script_name)));
         }
     }
     // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
     // URI is found, and also fixes the QUERY_STRING server var and $_GET array.
     if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0) {
         $query = explode('?', $query, 2);
         $uri = $query[0];
         $_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
     } else {
         $_SERVER['QUERY_STRING'] = $query;
     }
     // replace server attributes
     Server::replace($_SERVER);
     // parse the string
     parse_str($_SERVER['QUERY_STRING'], $_GET);
     // replace get
     Get::replace($_GET);
     if ($uri === '/' || $uri === '') {
         $return = '/';
     } else {
         $return = Path::removeRelativeDirectory($uri);
     }
     return $return;
 }
Esempio n. 2
0
 /**
  * Get Server parameter Request
  *
  * @param  string $key     Key Name
  * @param  mix    $default default returning value if not exist
  * @return mixed
  */
 public static function get($key, $default = null)
 {
     return Get::get($key, $default);
 }