Exemple #1
0
 /**
  * Sets the url parameters
  * @param int $base_pos What position to start looking for a match
  */
 private function set_url_parameters($base_pos = 0)
 {
     // get the URL path
     $path = parse_url(Request::server('REQUEST_URI'), PHP_URL_PATH);
     $url_parameters = array_values(array_filter(explode('/', $path), array($this, "validate_filter")));
     $this->url_parameters = $base_pos > 0 ? array_slice($url_parameters, $base_pos) : $url_parameters;
     return $this;
 }
Exemple #2
0
 /**
  * Gets the current url
  * @param  boolean $force_https
  * @param  boolean $without_pararms returns the url without any get pararm
  * @return string
  */
 public static function get_request_url($force_https = false, $without_pararms = false)
 {
     $protocol = $force_https ? self::PROTOCOL_HTTPS : self::get_protocol();
     $uri = Request::server('REQUEST_URI');
     $uri = $without_pararms ? explode('?', $uri)[0] : $uri;
     return $protocol . Request::server('HTTP_HOST') . $uri;
 }
Exemple #3
0
 /**
  * Set whether the connections is https or not
  * @return App
  */
 private function set_is_https()
 {
     // get values from sever
     $https = Request::server('HTTPS');
     $port = Request::server('SERVER_PORT');
     // check if https is on
     $this->is_https = !empty($https) && 'off' !== $https || 443 == $port;
     return $this;
 }
Exemple #4
0
 /**
  * Checks whether the post max size was exceeced or not
  * @see http://us3.php.net/manual/en/features.file-upload.php#73762
  * @return boolean
  */
 protected function exceeds_post_max_size()
 {
     // get the max post size set in the config ini and the value unit used
     $post_max_size = ini_get('post_max_size');
     $unit = strtoupper(substr($post_max_size, -1));
     // set the unit multiplier to convert to bytes
     switch ($unit) {
         case 'M':
             $multiplier = 1048576;
             break;
         case 'K':
             $multiplier = 1024;
             break;
         case 'G':
             $multiplier = 1073741824;
             break;
         default:
             $multiplier = 1;
             break;
     }
     // get the post size and the max post size value in bytes
     $post_size = (int) Request::server('CONTENT_LENGTH');
     $post_max_size_bytes = $multiplier * (int) $post_max_size;
     // check if the post size exceeded the max allowed size
     if ($post_max_size && $post_size > $post_max_size_bytes) {
         $this->set_error_message(self::ERROR_CODE_INI_SIZE);
         return true;
     }
     return false;
 }