コード例 #1
0
 private function __construct()
 {
     $this->method = $_SERVER['REQUEST_METHOD'];
     $this->uri = $_SERVER['REQUEST_URI'];
     $this->querystring = $_SERVER['QUERY_STRING'];
     $this->clientAddress = $_SERVER['REMOTE_ADDR'];
     $segments_data = explode("/", substr(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'], 1));
     if ($segments_data == null || !is_array($segments_data)) {
         $segments_data = array();
     }
     $this->segments = $segments_data;
     $this->headers = getallheaders();
     $isAjax = false;
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $isAjax = true;
     }
     $this->isajax = $isAjax;
     $data = array();
     $data = array_merge($data, $_GET);
     $data = array_merge($data, $_POST);
     $data = array_merge($data, $_FILES);
     self::$data = $data;
 }
コード例 #2
0
 private function __construct()
 {
     $domain = $_SERVER['HTTP_HOST'];
     $port = $_SERVER['SERVER_PORT'];
     $protocol = $this->isSecure() ? "https" : "http";
     $uri = $protocol . "://" . $domain . (intval($port) != 80 ? ":{$port}" : "") . $_SERVER['REQUEST_URI'];
     $this->uri = Uri::fromString($uri);
     $this->method = $_SERVER['REQUEST_METHOD'];
     $this->querystring = $_SERVER['QUERY_STRING'];
     $this->clientAddress = $_SERVER['REMOTE_ADDR'];
     $this->protocolVersion = str_replace("HTTP/", "", $_SERVER['SERVER_PROTOCOL']);
     $segments_data = explode("/", substr(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'], 1));
     if ($segments_data == null || !is_array($segments_data)) {
         $segments_data = array();
     }
     $this->segments = $segments_data;
     $this->headers = new Collection(getallheaders());
     $isAjax = false;
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $isAjax = true;
     }
     $this->isajax = $isAjax;
     $data = array();
     $data = array_merge($data, $_GET);
     $data = array_merge($data, $_POST);
     self::$data = $data;
     $files = array();
     if (is_array($_FILES)) {
         foreach (array_keys($_FILES) as $key) {
             if (is_array($_FILES[$key]['tmp_name'])) {
                 $count = count($_FILES[$key]['tmp_name']);
                 $files[$key] = array();
                 for ($i = 0; $i < $count; $i++) {
                     $files[$key][] = new UploadedFile(array('fieldname' => $key, 'tmp_filename' => $_FILES[$key]['tmp_name'][$i], 'origin_filename' => $_FILES[$key]['name'][$i], 'file_type' => $_FILES[$key]['type'][$i], 'upload_error' => $_FILES[$key]['error'][$i]));
                 }
             } else {
                 $files[$key] = new UploadedFile(array('fieldname' => $key, 'tmp_filename' => $_FILES[$key]['tmp_name'], 'origin_filename' => $_FILES[$key]['name'], 'file_type' => $_FILES[$key]['type'], 'upload_error' => $_FILES[$key]['error']));
             }
         }
     }
     $this->files = $files;
 }