示例#1
0
 public function __construct()
 {
     $cookie = filter_input_array(INPUT_COOKIE);
     if (!is_array($cookie)) {
         $cookie = [];
     }
     parent::__construct($cookie);
 }
示例#2
0
 public function __construct()
 {
     $post = filter_input_array(INPUT_POST);
     if (!is_array($post)) {
         $post = [];
     }
     parent::__construct($post);
 }
示例#3
0
文件: EnvBag.php 项目: dspbee/pivasic
 public function __construct()
 {
     $env = filter_input_array(INPUT_ENV);
     if (!is_array($env)) {
         $env = [];
     }
     parent::__construct($env);
 }
示例#4
0
文件: GetBag.php 项目: dspbee/pivasic
 public function __construct()
 {
     $get = filter_input_array(INPUT_GET);
     if (!is_array($get)) {
         $get = [];
     }
     parent::__construct($get);
 }
示例#5
0
 /**
  * @param ValueBag $attributes
  * @param bool     $override
  *
  * @return $this
  */
 public function merge(ValueBag $attributes, $override = false)
 {
     foreach ($attributes->all() as $key => $value) {
         if (!$this->has($key) || $override) {
             $this->set($key, $value);
         }
     }
     return $this;
 }
示例#6
0
 public function __construct()
 {
     parent::__construct([]);
 }
示例#7
0
 /**
  * Gets the HTTP headers.
  */
 public function __construct()
 {
     $headers = [];
     $server = filter_input_array(INPUT_SERVER);
     $contentHeaders = ['CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true];
     foreach ($server as $key => $value) {
         if (0 === strpos($key, 'HTTP_')) {
             $headers[substr($key, 5)] = $value;
         } elseif (isset($contentHeaders[$key])) {
             $headers[$key] = $value;
         }
     }
     if (isset($server['PHP_AUTH_USER'])) {
         $headers['PHP_AUTH_USER'] = $server['PHP_AUTH_USER'];
         $headers['PHP_AUTH_PW'] = isset($server['PHP_AUTH_PW']) ? $server['PHP_AUTH_PW'] : '';
     } else {
         /*
          * php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
          * For this workaround to work, add these lines to your .htaccess file:
          * RewriteCond %{HTTP:Authorization} ^(.+)$
          * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
          *
          * A sample .htaccess file:
          * RewriteEngine On
          * RewriteCond %{HTTP:Authorization} ^(.+)$
          * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
          * RewriteCond %{REQUEST_FILENAME} !-f
          * RewriteRule ^(.*)$ app.php [QSA,L]
          */
         $authorizationHeader = null;
         if (isset($server['HTTP_AUTHORIZATION'])) {
             $authorizationHeader = $server['HTTP_AUTHORIZATION'];
         } elseif (isset($server['REDIRECT_HTTP_AUTHORIZATION'])) {
             $authorizationHeader = $server['REDIRECT_HTTP_AUTHORIZATION'];
         }
         if (null !== $authorizationHeader) {
             if (0 === stripos($authorizationHeader, 'basic ')) {
                 // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic
                 $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2);
                 if (count($exploded) == 2) {
                     list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
                 }
             } elseif (empty($server['PHP_AUTH_DIGEST']) && 0 === stripos($authorizationHeader, 'digest ')) {
                 // In some circumstances PHP_AUTH_DIGEST needs to be set
                 $headers['PHP_AUTH_DIGEST'] = $authorizationHeader;
                 $server['PHP_AUTH_DIGEST'] = $authorizationHeader;
             } elseif (0 === stripos($authorizationHeader, 'bearer ')) {
                 /*
                  * XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables,
                  *      I'll just set $headers['AUTHORIZATION'] here.
                  *      http://php.net/manual/en/reserved.variables.server.php
                  */
                 $headers['AUTHORIZATION'] = $authorizationHeader;
             }
         }
     }
     // PHP_AUTH_USER/PHP_AUTH_PW
     if (isset($headers['PHP_AUTH_USER'])) {
         $headers['AUTHORIZATION'] = 'Basic ' . base64_encode($headers['PHP_AUTH_USER'] . ':' . $headers['PHP_AUTH_PW']);
     } elseif (isset($headers['PHP_AUTH_DIGEST'])) {
         $headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST'];
     }
     parent::__construct($headers);
 }