Current file: htdocs/lib/Zend/Controller/Request/Http.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 46 CRAP
3.38%3.38%
3.38% 11 / 325
 
Zend_Controller_Request_Http
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 46
3.38%3.38%
3.38% 11 / 325
 __construct($uri = null)
0.00%0.00%
0.00% 0 / 1 30
0.00%0.00%
0.00% 0 / 16
 __get($key)
0.00%0.00%
0.00% 0 / 1 15.05
57.89%57.89%
57.89% 11 / 19
 get($key)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 __set($key, $value)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 set($key, $value)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 __isset($key)
0.00%0.00%
0.00% 0 / 1 56
0.00%0.00%
0.00% 0 / 15
 has($key)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 setQuery($spec, $value = null)
0.00%0.00%
0.00% 0 / 1 42
0.00%0.00%
0.00% 0 / 9
 getQuery($key = null, $default = null)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 3
 setPost($spec, $value = null)
0.00%0.00%
0.00% 0 / 1 42
0.00%0.00%
0.00% 0 / 9
 getPost($key = null, $default = null)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 3
 getCookie($key = null, $default = null)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 3
 getServer($key = null, $default = null)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 3
 getEnv($key = null, $default = null)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 3
 setRequestUri($requestUri = null)
0.00%0.00%
0.00% 0 / 1 182
0.00%0.00%
0.00% 0 / 32
 getRequestUri()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 setBaseUrl($baseUrl = null)
0.00%0.00%
0.00% 0 / 1 600
0.00%0.00%
0.00% 0 / 45
 getBaseUrl()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 setBasePath($basePath = null)
0.00%0.00%
0.00% 0 / 1 42
0.00%0.00%
0.00% 0 / 18
 getBasePath()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 setPathInfo($pathInfo = null)
0.00%0.00%
0.00% 0 / 1 156
0.00%0.00%
0.00% 0 / 21
 getPathInfo()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 setParamSources(array $paramSources = array()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 getParamSources()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 setParam($key, $value)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 getParam($key, $default = null)
0.00%0.00%
0.00% 0 / 1 56
0.00%0.00%
0.00% 0 / 9
 getParams()
0.00%0.00%
0.00% 0 / 1 56
0.00%0.00%
0.00% 0 / 15
 setParams(array $params)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 setAlias($name, $target)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 getAlias($name)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 getAliases()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 getMethod()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 isPost()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 isGet()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 isPut()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 isDelete()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 isHead()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 isOptions()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 isXmlHttpRequest()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 isFlashRequest()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 2
 isSecure()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 getRawBody()
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 8
 getHeader($header)
0.00%0.00%
0.00% 0 / 1 56
0.00%0.00%
0.00% 0 / 16
 getScheme()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 1
 getHttpHost()
0.00%0.00%
0.00% 0 / 1 56
0.00%0.00%
0.00% 0 / 11
 getClientIp($checkProxy = true)
0.00%0.00%
0.00% 0 / 1 30
0.00%0.00%
0.00% 0 / 7


       1                 : <?php                                                                                                                                   
       2                 : /**                                                                                                                                     
       3                 :  * Zend Framework                                                                                                                       
       4                 :  *                                                                                                                                      
       5                 :  * LICENSE                                                                                                                              
       6                 :  *                                                                                                                                      
       7                 :  * This source file is subject to the new BSD license that is bundled                                                                   
       8                 :  * with this package in the file LICENSE.txt.                                                                                           
       9                 :  * It is also available through the world-wide-web at this URL:                                                                         
      10                 :  * http://framework.zend.com/license/new-bsd                                                                                            
      11                 :  * If you did not receive a copy of the license and are unable to                                                                       
      12                 :  * obtain it through the world-wide-web, please send an email                                                                           
      13                 :  * to license@zend.com so we can send you a copy immediately.                                                                           
      14                 :  *                                                                                                                                      
      15                 :  * @category   Zend                                                                                                                     
      16                 :  * @package    Zend_Controller                                                                                                          
      17                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)                                                 
      18                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License                                                            
      19                 :  * @version    $Id: Http.php 23414 2010-11-20 10:56:11Z bittarman $                                                                     
      20                 :  */                                                                                                                                     
      21                 :                                                                                                                                         
      22                 : /** @see Zend_Controller_Request_Abstract */                                                                                            
      23                 : #require_once 'Zend/Controller/Request/Abstract.php';                                                                                   
      24                 :                                                                                                                                         
      25                 : /** @see Zend_Uri */                                                                                                                    
      26                 : #require_once 'Zend/Uri.php';                                                                                                           
      27                 :                                                                                                                                         
      28                 : /**                                                                                                                                     
      29                 :  * Zend_Controller_Request_Http                                                                                                         
      30                 :  *                                                                                                                                      
      31                 :  * HTTP request object for use with Zend_Controller family.                                                                             
      32                 :  *                                                                                                                                      
      33                 :  * @uses Zend_Controller_Request_Abstract                                                                                               
      34                 :  * @package Zend_Controller                                                                                                             
      35                 :  * @subpackage Request                                                                                                                  
      36                 :  */                                                                                                                                     
      37                 : class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract                                                             
      38                 : {                                                                                                                                       
      39                 :     /**                                                                                                                                 
      40                 :      * Scheme for http                                                                                                                  
      41                 :      *                                                                                                                                  
      42                 :      */                                                                                                                                 
      43                 :     const SCHEME_HTTP  = 'http';                                                                                                        
      44                 :                                                                                                                                         
      45                 :     /**                                                                                                                                 
      46                 :      * Scheme for https                                                                                                                 
      47                 :      *                                                                                                                                  
      48                 :      */                                                                                                                                 
      49                 :     const SCHEME_HTTPS = 'https';                                                                                                       
      50                 :                                                                                                                                         
      51                 :     /**                                                                                                                                 
      52                 :      * Allowed parameter sources                                                                                                        
      53                 :      * @var array                                                                                                                       
      54                 :      */                                                                                                                                 
      55                 :     protected $_paramSources = array('_GET', '_POST');                                                                                  
      56                 :                                                                                                                                         
      57                 :     /**                                                                                                                                 
      58                 :      * REQUEST_URI                                                                                                                      
      59                 :      * @var string;                                                                                                                     
      60                 :      */                                                                                                                                 
      61                 :     protected $_requestUri;                                                                                                             
      62                 :                                                                                                                                         
      63                 :     /**                                                                                                                                 
      64                 :      * Base URL of request                                                                                                              
      65                 :      * @var string                                                                                                                      
      66                 :      */                                                                                                                                 
      67                 :     protected $_baseUrl = null;                                                                                                         
      68                 :                                                                                                                                         
      69                 :     /**                                                                                                                                 
      70                 :      * Base path of request                                                                                                             
      71                 :      * @var string                                                                                                                      
      72                 :      */                                                                                                                                 
      73                 :     protected $_basePath = null;                                                                                                        
      74                 :                                                                                                                                         
      75                 :     /**                                                                                                                                 
      76                 :      * PATH_INFO                                                                                                                        
      77                 :      * @var string                                                                                                                      
      78                 :      */                                                                                                                                 
      79                 :     protected $_pathInfo = '';                                                                                                          
      80                 :                                                                                                                                         
      81                 :     /**                                                                                                                                 
      82                 :      * Instance parameters                                                                                                              
      83                 :      * @var array                                                                                                                       
      84                 :      */                                                                                                                                 
      85                 :     protected $_params = array();                                                                                                       
      86                 :                                                                                                                                         
      87                 :     /**                                                                                                                                 
      88                 :      * Raw request body                                                                                                                 
      89                 :      * @var string|false                                                                                                                
      90                 :      */                                                                                                                                 
      91                 :     protected $_rawBody;                                                                                                                
      92                 :                                                                                                                                         
      93                 :     /**                                                                                                                                 
      94                 :      * Alias keys for request parameters                                                                                                
      95                 :      * @var array                                                                                                                       
      96                 :      */                                                                                                                                 
      97                 :     protected $_aliases = array();                                                                                                      
      98                 :                                                                                                                                         
      99                 :     /**                                                                                                                                 
     100                 :      * Constructor                                                                                                                      
     101                 :      *                                                                                                                                  
     102                 :      * If a $uri is passed, the object will attempt to populate itself using                                                            
     103                 :      * that information.                                                                                                                
     104                 :      *                                                                                                                                  
     105                 :      * @param string|Zend_Uri $uri                                                                                                      
     106                 :      * @return void                                                                                                                     
     107                 :      * @throws Zend_Controller_Request_Exception when invalid URI passed                                                                
     108                 :      */                                                                                                                                 
     109                 :     public function __construct($uri = null)                                                                                            
     110                 :     {                                                                                                                                   
     111               0 :         if (null !== $uri) {                                                                                                            
     112               0 :             if (!$uri instanceof Zend_Uri) {                                                                                            
     113               0 :                 $uri = Zend_Uri::factory($uri);                                                                                         
     114               0 :             }                                                                                                                           
     115               0 :             if ($uri->valid()) {                                                                                                        
     116               0 :                 $path  = $uri->getPath();                                                                                               
     117               0 :                 $query = $uri->getQuery();                                                                                              
     118               0 :                 if (!empty($query)) {                                                                                                   
     119               0 :                     $path .= '?' . $query;                                                                                              
     120               0 :                 }                                                                                                                       
     121                 :                                                                                                                                         
     122               0 :                 $this->setRequestUri($path);                                                                                            
     123               0 :             } else {                                                                                                                    
     124                 :                 #require_once 'Zend/Controller/Request/Exception.php';                                                                  
     125               0 :                 throw new Zend_Controller_Request_Exception('Invalid URI provided to constructor');                                     
     126                 :             }                                                                                                                           
     127               0 :         } else {                                                                                                                        
     128               0 :             $this->setRequestUri();                                                                                                     
     129                 :         }                                                                                                                               
     130               0 :     }                                                                                                                                   
     131                 :                                                                                                                                         
     132                 :     /**                                                                                                                                 
     133                 :      * Access values contained in the superglobals as public members                                                                    
     134                 :      * Order of precedence: 1. GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV                                                               
     135                 :      *                                                                                                                                  
     136                 :      * @see http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx                                                    
     137                 :      * @param string $key                                                                                                               
     138                 :      * @return mixed                                                                                                                    
     139                 :      */                                                                                                                                 
     140                 :     public function __get($key)                                                                                                         
     141                 :     {                                                                                                                                   
     142                 :         switch (true) {                                                                                                                 
     143               1 :             case isset($this->_params[$key]):                                                                                           
     144               0 :                 return $this->_params[$key];                                                                                            
     145               1 :             case isset($_GET[$key]):                                                                                                    
     146               0 :                 return $_GET[$key];                                                                                                     
     147               1 :             case isset($_POST[$key]):                                                                                                   
     148               0 :                 return $_POST[$key];                                                                                                    
     149               1 :             case isset($_COOKIE[$key]):                                                                                                 
     150               0 :                 return $_COOKIE[$key];                                                                                                  
     151               1 :             case ($key == 'REQUEST_URI'):                                                                                               
     152               0 :                 return $this->getRequestUri();                                                                                          
     153               1 :             case ($key == 'PATH_INFO'):                                                                                                 
     154               0 :                 return $this->getPathInfo();                                                                                            
     155               1 :             case isset($_SERVER[$key]):                                                                                                 
     156               0 :                 return $_SERVER[$key];                                                                                                  
     157               1 :             case isset($_ENV[$key]):                                                                                                    
     158               0 :                 return $_ENV[$key];                                                                                                     
     159               1 :             default:                                                                                                                    
     160               1 :                 return null;                                                                                                            
     161               1 :         }                                                                                                                               
     162                 :     }                                                                                                                                   
     163                 :                                                                                                                                         
     164                 :     /**                                                                                                                                 
     165                 :      * Alias to __get                                                                                                                   
     166                 :      *                                                                                                                                  
     167                 :      * @param string $key                                                                                                               
     168                 :      * @return mixed                                                                                                                    
     169                 :      */                                                                                                                                 
     170                 :     public function get($key)                                                                                                           
     171                 :     {                                                                                                                                   
     172               0 :         return $this->__get($key);                                                                                                      
     173                 :     }                                                                                                                                   
     174                 :                                                                                                                                         
     175                 :     /**                                                                                                                                 
     176                 :      * Set values                                                                                                                       
     177                 :      *                                                                                                                                  
     178                 :      * In order to follow {@link __get()}, which operates on a number of                                                                
     179                 :      * superglobals, setting values through overloading is not allowed and will                                                         
     180                 :      * raise an exception. Use setParam() instead.                                                                                      
     181                 :      *                                                                                                                                  
     182                 :      * @param string $key                                                                                                               
     183                 :      * @param mixed $value                                                                                                              
     184                 :      * @return void                                                                                                                     
     185                 :      * @throws Zend_Controller_Request_Exception                                                                                        
     186                 :      */                                                                                                                                 
     187                 :     public function __set($key, $value)                                                                                                 
     188                 :     {                                                                                                                                   
     189                 :         #require_once 'Zend/Controller/Request/Exception.php';                                                                          
     190               0 :         throw new Zend_Controller_Request_Exception('Setting values in superglobals not allowed; please use setParam()');               
     191                 :     }                                                                                                                                   
     192                 :                                                                                                                                         
     193                 :     /**                                                                                                                                 
     194                 :      * Alias to __set()                                                                                                                 
     195                 :      *                                                                                                                                  
     196                 :      * @param string $key                                                                                                               
     197                 :      * @param mixed $value                                                                                                              
     198                 :      * @return void                                                                                                                     
     199                 :      */                                                                                                                                 
     200                 :     public function set($key, $value)                                                                                                   
     201                 :     {                                                                                                                                   
     202               0 :         return $this->__set($key, $value);                                                                                              
     203                 :     }                                                                                                                                   
     204                 :                                                                                                                                         
     205                 :     /**                                                                                                                                 
     206                 :      * Check to see if a property is set                                                                                                
     207                 :      *                                                                                                                                  
     208                 :      * @param string $key                                                                                                               
     209                 :      * @return boolean                                                                                                                  
     210                 :      */                                                                                                                                 
     211                 :     public function __isset($key)                                                                                                       
     212                 :     {                                                                                                                                   
     213                 :         switch (true) {                                                                                                                 
     214               0 :             case isset($this->_params[$key]):                                                                                           
     215               0 :                 return true;                                                                                                            
     216               0 :             case isset($_GET[$key]):                                                                                                    
     217               0 :                 return true;                                                                                                            
     218               0 :             case isset($_POST[$key]):                                                                                                   
     219               0 :                 return true;                                                                                                            
     220               0 :             case isset($_COOKIE[$key]):                                                                                                 
     221               0 :                 return true;                                                                                                            
     222               0 :             case isset($_SERVER[$key]):                                                                                                 
     223               0 :                 return true;                                                                                                            
     224               0 :             case isset($_ENV[$key]):                                                                                                    
     225               0 :                 return true;                                                                                                            
     226               0 :             default:                                                                                                                    
     227               0 :                 return false;                                                                                                           
     228               0 :         }                                                                                                                               
     229                 :     }                                                                                                                                   
     230                 :                                                                                                                                         
     231                 :     /**                                                                                                                                 
     232                 :      * Alias to __isset()                                                                                                               
     233                 :      *                                                                                                                                  
     234                 :      * @param string $key                                                                                                               
     235                 :      * @return boolean                                                                                                                  
     236                 :      */                                                                                                                                 
     237                 :     public function has($key)                                                                                                           
     238                 :     {                                                                                                                                   
     239               0 :         return $this->__isset($key);                                                                                                    
     240                 :     }                                                                                                                                   
     241                 :                                                                                                                                         
     242                 :     /**                                                                                                                                 
     243                 :      * Set GET values                                                                                                                   
     244                 :      *                                                                                                                                  
     245                 :      * @param  string|array $spec                                                                                                       
     246                 :      * @param  null|mixed $value                                                                                                        
     247                 :      * @return Zend_Controller_Request_Http                                                                                             
     248                 :      */                                                                                                                                 
     249                 :     public function setQuery($spec, $value = null)                                                                                      
     250                 :     {                                                                                                                                   
     251               0 :         if ((null === $value) && !is_array($spec)) {                                                                                    
     252                 :             #require_once 'Zend/Controller/Exception.php';                                                                              
     253               0 :             throw new Zend_Controller_Exception('Invalid value passed to setQuery(); must be either array of values or key/value pair');
     254                 :         }                                                                                                                               
     255               0 :         if ((null === $value) && is_array($spec)) {                                                                                     
     256               0 :             foreach ($spec as $key => $value) {                                                                                         
     257               0 :                 $this->setQuery($key, $value);                                                                                          
     258               0 :             }                                                                                                                           
     259               0 :             return $this;                                                                                                               
     260                 :         }                                                                                                                               
     261               0 :         $_GET[(string) $spec] = $value;                                                                                                 
     262               0 :         return $this;                                                                                                                   
     263                 :     }                                                                                                                                   
     264                 :                                                                                                                                         
     265                 :     /**                                                                                                                                 
     266                 :      * Retrieve a member of the $_GET superglobal                                                                                       
     267                 :      *                                                                                                                                  
     268                 :      * If no $key is passed, returns the entire $_GET array.                                                                            
     269                 :      *                                                                                                                                  
     270                 :      * @todo How to retrieve from nested arrays                                                                                         
     271                 :      * @param string $key                                                                                                               
     272                 :      * @param mixed $default Default value to use if key not found                                                                      
     273                 :      * @return mixed Returns null if key does not exist                                                                                 
     274                 :      */                                                                                                                                 
     275                 :     public function getQuery($key = null, $default = null)                                                                              
     276                 :     {                                                                                                                                   
     277               0 :         if (null === $key) {                                                                                                            
     278               0 :             return $_GET;                                                                                                               
     279                 :         }                                                                                                                               
     280                 :                                                                                                                                         
     281               0 :         return (isset($_GET[$key])) ? $_GET[$key] : $default;                                                                           
     282                 :     }                                                                                                                                   
     283                 :                                                                                                                                         
     284                 :     /**                                                                                                                                 
     285                 :      * Set POST values                                                                                                                  
     286                 :      *                                                                                                                                  
     287                 :      * @param  string|array $spec                                                                                                       
     288                 :      * @param  null|mixed $value                                                                                                        
     289                 :      * @return Zend_Controller_Request_Http                                                                                             
     290                 :      */                                                                                                                                 
     291                 :     public function setPost($spec, $value = null)                                                                                       
     292                 :     {                                                                                                                                   
     293               0 :         if ((null === $value) && !is_array($spec)) {                                                                                    
     294                 :             #require_once 'Zend/Controller/Exception.php';                                                                              
     295               0 :             throw new Zend_Controller_Exception('Invalid value passed to setPost(); must be either array of values or key/value pair'); 
     296                 :         }                                                                                                                               
     297               0 :         if ((null === $value) && is_array($spec)) {                                                                                     
     298               0 :             foreach ($spec as $key => $value) {                                                                                         
     299               0 :                 $this->setPost($key, $value);                                                                                           
     300               0 :             }                                                                                                                           
     301               0 :             return $this;                                                                                                               
     302                 :         }                                                                                                                               
     303               0 :         $_POST[(string) $spec] = $value;                                                                                                
     304               0 :         return $this;                                                                                                                   
     305                 :     }                                                                                                                                   
     306                 :                                                                                                                                         
     307                 :     /**                                                                                                                                 
     308                 :      * Retrieve a member of the $_POST superglobal                                                                                      
     309                 :      *                                                                                                                                  
     310                 :      * If no $key is passed, returns the entire $_POST array.                                                                           
     311                 :      *                                                                                                                                  
     312                 :      * @todo How to retrieve from nested arrays                                                                                         
     313                 :      * @param string $key                                                                                                               
     314                 :      * @param mixed $default Default value to use if key not found                                                                      
     315                 :      * @return mixed Returns null if key does not exist                                                                                 
     316                 :      */                                                                                                                                 
     317                 :     public function getPost($key = null, $default = null)                                                                               
     318                 :     {                                                                                                                                   
     319               0 :         if (null === $key) {                                                                                                            
     320               0 :             return $_POST;                                                                                                              
     321                 :         }                                                                                                                               
     322                 :                                                                                                                                         
     323               0 :         return (isset($_POST[$key])) ? $_POST[$key] : $default;                                                                         
     324                 :     }                                                                                                                                   
     325                 :                                                                                                                                         
     326                 :     /**                                                                                                                                 
     327                 :      * Retrieve a member of the $_COOKIE superglobal                                                                                    
     328                 :      *                                                                                                                                  
     329                 :      * If no $key is passed, returns the entire $_COOKIE array.                                                                         
     330                 :      *                                                                                                                                  
     331                 :      * @todo How to retrieve from nested arrays                                                                                         
     332                 :      * @param string $key                                                                                                               
     333                 :      * @param mixed $default Default value to use if key not found                                                                      
     334                 :      * @return mixed Returns null if key does not exist                                                                                 
     335                 :      */                                                                                                                                 
     336                 :     public function getCookie($key = null, $default = null)                                                                             
     337                 :     {                                                                                                                                   
     338               0 :         if (null === $key) {                                                                                                            
     339               0 :             return $_COOKIE;                                                                                                            
     340                 :         }                                                                                                                               
     341                 :                                                                                                                                         
     342               0 :         return (isset($_COOKIE[$key])) ? $_COOKIE[$key] : $default;                                                                     
     343                 :     }                                                                                                                                   
     344                 :                                                                                                                                         
     345                 :     /**                                                                                                                                 
     346                 :      * Retrieve a member of the $_SERVER superglobal                                                                                    
     347                 :      *                                                                                                                                  
     348                 :      * If no $key is passed, returns the entire $_SERVER array.                                                                         
     349                 :      *                                                                                                                                  
     350                 :      * @param string $key                                                                                                               
     351                 :      * @param mixed $default Default value to use if key not found                                                                      
     352                 :      * @return mixed Returns null if key does not exist                                                                                 
     353                 :      */                                                                                                                                 
     354                 :     public function getServer($key = null, $default = null)                                                                             
     355                 :     {                                                                                                                                   
     356               0 :         if (null === $key) {                                                                                                            
     357               0 :             return $_SERVER;                                                                                                            
     358                 :         }                                                                                                                               
     359                 :                                                                                                                                         
     360               0 :         return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;                                                                     
     361                 :     }                                                                                                                                   
     362                 :                                                                                                                                         
     363                 :     /**                                                                                                                                 
     364                 :      * Retrieve a member of the $_ENV superglobal                                                                                       
     365                 :      *                                                                                                                                  
     366                 :      * If no $key is passed, returns the entire $_ENV array.                                                                            
     367                 :      *                                                                                                                                  
     368                 :      * @param string $key                                                                                                               
     369                 :      * @param mixed $default Default value to use if key not found                                                                      
     370                 :      * @return mixed Returns null if key does not exist                                                                                 
     371                 :      */                                                                                                                                 
     372                 :     public function getEnv($key = null, $default = null)                                                                                
     373                 :     {                                                                                                                                   
     374               0 :         if (null === $key) {                                                                                                            
     375               0 :             return $_ENV;                                                                                                               
     376                 :         }                                                                                                                               
     377                 :                                                                                                                                         
     378               0 :         return (isset($_ENV[$key])) ? $_ENV[$key] : $default;                                                                           
     379                 :     }                                                                                                                                   
     380                 :                                                                                                                                         
     381                 :     /**                                                                                                                                 
     382                 :      * Set the REQUEST_URI on which the instance operates                                                                               
     383                 :      *                                                                                                                                  
     384                 :      * If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'],                                                          
     385                 :      * $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].                                        
     386                 :      *                                                                                                                                  
     387                 :      * @param string $requestUri                                                                                                        
     388                 :      * @return Zend_Controller_Request_Http                                                                                             
     389                 :      */                                                                                                                                 
     390                 :     public function setRequestUri($requestUri = null)                                                                                   
     391                 :     {                                                                                                                                   
     392               0 :         if ($requestUri === null) {                                                                                                     
     393               0 :             if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch                                          
     394               0 :                 $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];                                                                           
     395               0 :             } elseif (                                                                                                                  
     396                 :                 // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)                                     
     397               0 :                 isset($_SERVER['IIS_WasUrlRewritten'])                                                                                  
     398               0 :                 && $_SERVER['IIS_WasUrlRewritten'] == '1'                                                                               
     399               0 :                 && isset($_SERVER['UNENCODED_URL'])                                                                                     
     400               0 :                 && $_SERVER['UNENCODED_URL'] != ''                                                                                      
     401               0 :                 ) {                                                                                                                     
     402               0 :                 $requestUri = $_SERVER['UNENCODED_URL'];                                                                                
     403               0 :             } elseif (isset($_SERVER['REQUEST_URI'])) {                                                                                 
     404               0 :                 $requestUri = $_SERVER['REQUEST_URI'];                                                                                  
     405                 :                 // Http proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path                  
     406               0 :                 $schemeAndHttpHost = $this->getScheme() . '://' . $this->getHttpHost();                                                 
     407               0 :                 if (strpos($requestUri, $schemeAndHttpHost) === 0) {                                                                    
     408               0 :                     $requestUri = substr($requestUri, strlen($schemeAndHttpHost));                                                      
     409               0 :                 }                                                                                                                       
     410               0 :             } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI                                                       
     411               0 :                 $requestUri = $_SERVER['ORIG_PATH_INFO'];                                                                               
     412               0 :                 if (!empty($_SERVER['QUERY_STRING'])) {                                                                                 
     413               0 :                     $requestUri .= '?' . $_SERVER['QUERY_STRING'];                                                                      
     414               0 :                 }                                                                                                                       
     415               0 :             } else {                                                                                                                    
     416               0 :                 return $this;                                                                                                           
     417                 :             }                                                                                                                           
     418               0 :         } elseif (!is_string($requestUri)) {                                                                                            
     419               0 :             return $this;                                                                                                               
     420                 :         } else {                                                                                                                        
     421                 :             // Set GET items, if available                                                                                              
     422               0 :             if (false !== ($pos = strpos($requestUri, '?'))) {                                                                          
     423                 :                 // Get key => value pairs and set $_GET                                                                                 
     424               0 :                 $query = substr($requestUri, $pos + 1);                                                                                 
     425               0 :                 parse_str($query, $vars);                                                                                               
     426               0 :                 $this->setQuery($vars);                                                                                                 
     427               0 :             }                                                                                                                           
     428                 :         }                                                                                                                               
     429                 :                                                                                                                                         
     430               0 :         $this->_requestUri = $requestUri;                                                                                               
     431               0 :         return $this;                                                                                                                   
     432                 :     }                                                                                                                                   
     433                 :                                                                                                                                         
     434                 :     /**                                                                                                                                 
     435                 :      * Returns the REQUEST_URI taking into account                                                                                      
     436                 :      * platform differences between Apache and IIS                                                                                      
     437                 :      *                                                                                                                                  
     438                 :      * @return string                                                                                                                   
     439                 :      */                                                                                                                                 
     440                 :     public function getRequestUri()                                                                                                     
     441                 :     {                                                                                                                                   
     442               0 :         if (empty($this->_requestUri)) {                                                                                                
     443               0 :             $this->setRequestUri();                                                                                                     
     444               0 :         }                                                                                                                               
     445                 :                                                                                                                                         
     446               0 :         return $this->_requestUri;                                                                                                      
     447                 :     }                                                                                                                                   
     448                 :                                                                                                                                         
     449                 :     /**                                                                                                                                 
     450                 :      * Set the base URL of the request; i.e., the segment leading to the script name                                                    
     451                 :      *                                                                                                                                  
     452                 :      * E.g.:                                                                                                                            
     453                 :      * - /admin                                                                                                                         
     454                 :      * - /myapp                                                                                                                         
     455                 :      * - /subdir/index.php                                                                                                              
     456                 :      *                                                                                                                                  
     457                 :      * Do not use the full URI when providing the base. The following are                                                               
     458                 :      * examples of what not to use:                                                                                                     
     459                 :      * - http://example.com/admin (should be just /admin)                                                                               
     460                 :      * - http://example.com/subdir/index.php (should be just /subdir/index.php)                                                         
     461                 :      *                                                                                                                                  
     462                 :      * If no $baseUrl is provided, attempts to determine the base URL from the                                                          
     463                 :      * environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and                                                                   
     464                 :      * ORIG_SCRIPT_NAME in its determination.                                                                                           
     465                 :      *                                                                                                                                  
     466                 :      * @param mixed $baseUrl                                                                                                            
     467                 :      * @return Zend_Controller_Request_Http                                                                                             
     468                 :      */                                                                                                                                 
     469                 :     public function setBaseUrl($baseUrl = null)                                                                                         
     470                 :     {                                                                                                                                   
     471               0 :         if ((null !== $baseUrl) && !is_string($baseUrl)) {                                                                              
     472               0 :             return $this;                                                                                                               
     473                 :         }                                                                                                                               
     474                 :                                                                                                                                         
     475               0 :         if ($baseUrl === null) {                                                                                                        
     476               0 :             $filename = (isset($_SERVER['SCRIPT_FILENAME'])) ? basename($_SERVER['SCRIPT_FILENAME']) : '';                              
     477                 :                                                                                                                                         
     478               0 :             if (isset($_SERVER['SCRIPT_NAME']) && basename($_SERVER['SCRIPT_NAME']) === $filename) {                                    
     479               0 :                 $baseUrl = $_SERVER['SCRIPT_NAME'];                                                                                     
     480               0 :             } elseif (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) === $filename) {                                    
     481               0 :                 $baseUrl = $_SERVER['PHP_SELF'];                                                                                        
     482               0 :             } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $filename) {                    
     483               0 :                 $baseUrl = $_SERVER['ORIG_SCRIPT_NAME']; // 1and1 shared hosting compatibility                                          
     484               0 :             } else {                                                                                                                    
     485                 :                 // Backtrack up the script_filename to find the portion matching                                                        
     486                 :                 // php_self                                                                                                             
     487               0 :                 $path    = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '';                                                     
     488               0 :                 $file    = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';                                       
     489               0 :                 $segs    = explode('/', trim($file, '/'));                                                                              
     490               0 :                 $segs    = array_reverse($segs);                                                                                        
     491               0 :                 $index   = 0;                                                                                                           
     492               0 :                 $last    = count($segs);                                                                                                
     493               0 :                 $baseUrl = '';                                                                                                          
     494                 :                 do {                                                                                                                    
     495               0 :                     $seg     = $segs[$index];                                                                                           
     496               0 :                     $baseUrl = '/' . $seg . $baseUrl;                                                                                   
     497               0 :                     ++$index;                                                                                                           
     498               0 :                 } while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos));                              
     499                 :             }                                                                                                                           
     500                 :                                                                                                                                         
     501                 :             // Does the baseUrl have anything in common with the request_uri?                                                           
     502               0 :             $requestUri = $this->getRequestUri();                                                                                       
     503                 :                                                                                                                                         
     504               0 :             if (0 === strpos($requestUri, $baseUrl)) {                                                                                  
     505                 :                 // full $baseUrl matches                                                                                                
     506               0 :                 $this->_baseUrl = $baseUrl;                                                                                             
     507               0 :                 return $this;                                                                                                           
     508                 :             }                                                                                                                           
     509                 :                                                                                                                                         
     510               0 :             if (0 === strpos($requestUri, dirname($baseUrl))) {                                                                         
     511                 :                 // directory portion of $baseUrl matches                                                                                
     512               0 :                 $this->_baseUrl = rtrim(dirname($baseUrl), '/');                                                                        
     513               0 :                 return $this;                                                                                                           
     514                 :             }                                                                                                                           
     515                 :                                                                                                                                         
     516               0 :             $truncatedRequestUri = $requestUri;                                                                                         
     517               0 :             if (($pos = strpos($requestUri, '?')) !== false) {                                                                          
     518               0 :                 $truncatedRequestUri = substr($requestUri, 0, $pos);                                                                    
     519               0 :             }                                                                                                                           
     520                 :                                                                                                                                         
     521               0 :             $basename = basename($baseUrl);                                                                                             
     522               0 :             if (empty($basename) || !strpos($truncatedRequestUri, $basename)) {                                                         
     523                 :                 // no match whatsoever; set it blank                                                                                    
     524               0 :                 $this->_baseUrl = '';                                                                                                   
     525               0 :                 return $this;                                                                                                           
     526                 :             }                                                                                                                           
     527                 :                                                                                                                                         
     528                 :             // If using mod_rewrite or ISAPI_Rewrite strip the script filename                                                          
     529                 :             // out of baseUrl. $pos !== 0 makes sure it is not matching a value                                                         
     530                 :             // from PATH_INFO or QUERY_STRING                                                                                           
     531               0 :             if ((strlen($requestUri) >= strlen($baseUrl))                                                                               
     532               0 :                 && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0)))                                                
     533               0 :             {                                                                                                                           
     534               0 :                 $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));                                                             
     535               0 :             }                                                                                                                           
     536               0 :         }                                                                                                                               
     537                 :                                                                                                                                         
     538               0 :         $this->_baseUrl = rtrim($baseUrl, '/');                                                                                         
     539               0 :         return $this;                                                                                                                   
     540                 :     }                                                                                                                                   
     541                 :                                                                                                                                         
     542                 :     /**                                                                                                                                 
     543                 :      * Everything in REQUEST_URI before PATH_INFO                                                                                       
     544                 :      * <form action="<?=$baseUrl?>/news/submit" method="POST"/>                                                                         
     545                 :      *                                                                                                                                  
     546                 :      * @return string                                                                                                                   
     547                 :      */                                                                                                                                 
     548                 :     public function getBaseUrl()                                                                                                        
     549                 :     {                                                                                                                                   
     550               0 :         if (null === $this->_baseUrl) {                                                                                                 
     551               0 :             $this->setBaseUrl();                                                                                                        
     552               0 :         }                                                                                                                               
     553                 :                                                                                                                                         
     554               0 :         return urldecode($this->_baseUrl);                                                                                              
     555                 :     }                                                                                                                                   
     556                 :                                                                                                                                         
     557                 :     /**                                                                                                                                 
     558                 :      * Set the base path for the URL                                                                                                    
     559                 :      *                                                                                                                                  
     560                 :      * @param string|null $basePath                                                                                                     
     561                 :      * @return Zend_Controller_Request_Http                                                                                             
     562                 :      */                                                                                                                                 
     563                 :     public function setBasePath($basePath = null)                                                                                       
     564                 :     {                                                                                                                                   
     565               0 :         if ($basePath === null) {                                                                                                       
     566               0 :             $filename = (isset($_SERVER['SCRIPT_FILENAME']))                                                                            
     567               0 :                       ? basename($_SERVER['SCRIPT_FILENAME'])                                                                           
     568               0 :                       : '';                                                                                                             
     569                 :                                                                                                                                         
     570               0 :             $baseUrl = $this->getBaseUrl();                                                                                             
     571               0 :             if (empty($baseUrl)) {                                                                                                      
     572               0 :                 $this->_basePath = '';                                                                                                  
     573               0 :                 return $this;                                                                                                           
     574                 :             }                                                                                                                           
     575                 :                                                                                                                                         
     576               0 :             if (basename($baseUrl) === $filename) {                                                                                     
     577               0 :                 $basePath = dirname($baseUrl);                                                                                          
     578               0 :             } else {                                                                                                                    
     579               0 :                 $basePath = $baseUrl;                                                                                                   
     580                 :             }                                                                                                                           
     581               0 :         }                                                                                                                               
     582                 :                                                                                                                                         
     583               0 :         if (substr(PHP_OS, 0, 3) === 'WIN') {                                                                                           
     584               0 :             $basePath = str_replace('\\', '/', $basePath);                                                                              
     585               0 :         }                                                                                                                               
     586                 :                                                                                                                                         
     587               0 :         $this->_basePath = rtrim($basePath, '/');                                                                                       
     588               0 :         return $this;                                                                                                                   
     589                 :     }                                                                                                                                   
     590                 :                                                                                                                                         
     591                 :     /**                                                                                                                                 
     592                 :      * Everything in REQUEST_URI before PATH_INFO not including the filename                                                            
     593                 :      * <img src="<?=$basePath?>/images/zend.png"/>                                                                                      
     594                 :      *                                                                                                                                  
     595                 :      * @return string                                                                                                                   
     596                 :      */                                                                                                                                 
     597                 :     public function getBasePath()                                                                                                       
     598                 :     {                                                                                                                                   
     599               0 :         if (null === $this->_basePath) {                                                                                                
     600               0 :             $this->setBasePath();                                                                                                       
     601               0 :         }                                                                                                                               
     602                 :                                                                                                                                         
     603               0 :         return $this->_basePath;                                                                                                        
     604                 :     }                                                                                                                                   
     605                 :                                                                                                                                         
     606                 :     /**                                                                                                                                 
     607                 :      * Set the PATH_INFO string                                                                                                         
     608                 :      *                                                                                                                                  
     609                 :      * @param string|null $pathInfo                                                                                                     
     610                 :      * @return Zend_Controller_Request_Http                                                                                             
     611                 :      */                                                                                                                                 
     612                 :     public function setPathInfo($pathInfo = null)                                                                                       
     613                 :     {                                                                                                                                   
     614               0 :         if ($pathInfo === null) {                                                                                                       
     615               0 :             $baseUrl = $this->getBaseUrl();                                                                                             
     616                 :                                                                                                                                         
     617               0 :             if (null === ($requestUri = $this->getRequestUri())) {                                                                      
     618               0 :                 return $this;                                                                                                           
     619                 :             }                                                                                                                           
     620                 :                                                                                                                                         
     621                 :             // Remove the query string from REQUEST_URI                                                                                 
     622               0 :             if ($pos = strpos($requestUri, '?')) {                                                                                      
     623               0 :                 $requestUri = substr($requestUri, 0, $pos);                                                                             
     624               0 :             }                                                                                                                           
     625                 :                                                                                                                                         
     626               0 :             $requestUri = urldecode($requestUri);                                                                                       
     627                 :                                                                                                                                         
     628                 :             if (null !== $baseUrl                                                                                                       
     629               0 :                 && ((!empty($baseUrl) && 0 === strpos($requestUri, $baseUrl))                                                           
     630               0 :                     || empty($baseUrl))                                                                                                 
     631               0 :                     && false === ($pathInfo = substr($requestUri, strlen($baseUrl)))                                                    
     632               0 :             ){                                                                                                                          
     633                 :                 // If substr() returns false then PATH_INFO is set to an empty string                                                   
     634               0 :                 $pathInfo = '';                                                                                                         
     635               0 :             } elseif (null === $baseUrl                                                                                                 
     636               0 :                     || (!empty($baseUrl) && false === strpos($requestUri, $baseUrl))                                                    
     637               0 :             ) {                                                                                                                         
     638               0 :                 $pathInfo = $requestUri;                                                                                                
     639               0 :             }                                                                                                                           
     640               0 :         }                                                                                                                               
     641                 :                                                                                                                                         
     642               0 :         $this->_pathInfo = (string) $pathInfo;                                                                                          
     643               0 :         return $this;                                                                                                                   
     644                 :     }                                                                                                                                   
     645                 :                                                                                                                                         
     646                 :     /**                                                                                                                                 
     647                 :      * Returns everything between the BaseUrl and QueryString.                                                                          
     648                 :      * This value is calculated instead of reading PATH_INFO                                                                            
     649                 :      * directly from $_SERVER due to cross-platform differences.                                                                        
     650                 :      *                                                                                                                                  
     651                 :      * @return string                                                                                                                   
     652                 :      */                                                                                                                                 
     653                 :     public function getPathInfo()                                                                                                       
     654                 :     {                                                                                                                                   
     655               0 :         if (empty($this->_pathInfo)) {                                                                                                  
     656               0 :             $this->setPathInfo();                                                                                                       
     657               0 :         }                                                                                                                               
     658                 :                                                                                                                                         
     659               0 :         return $this->_pathInfo;                                                                                                        
     660                 :     }                                                                                                                                   
     661                 :                                                                                                                                         
     662                 :     /**                                                                                                                                 
     663                 :      * Set allowed parameter sources                                                                                                    
     664                 :      *                                                                                                                                  
     665                 :      * Can be empty array, or contain one or more of '_GET' or '_POST'.                                                                 
     666                 :      *                                                                                                                                  
     667                 :      * @param  array $paramSoures                                                                                                       
     668                 :      * @return Zend_Controller_Request_Http                                                                                             
     669                 :      */                                                                                                                                 
     670                 :     public function setParamSources(array $paramSources = array())                                                                      
     671                 :     {                                                                                                                                   
     672               0 :         $this->_paramSources = $paramSources;                                                                                           
     673               0 :         return $this;                                                                                                                   
     674                 :     }                                                                                                                                   
     675                 :                                                                                                                                         
     676                 :     /**                                                                                                                                 
     677                 :      * Get list of allowed parameter sources                                                                                            
     678                 :      *                                                                                                                                  
     679                 :      * @return array                                                                                                                    
     680                 :      */                                                                                                                                 
     681                 :     public function getParamSources()                                                                                                   
     682                 :     {                                                                                                                                   
     683               0 :         return $this->_paramSources;                                                                                                    
     684                 :     }                                                                                                                                   
     685                 :                                                                                                                                         
     686                 :     /**                                                                                                                                 
     687                 :      * Set a userland parameter                                                                                                         
     688                 :      *                                                                                                                                  
     689                 :      * Uses $key to set a userland parameter. If $key is an alias, the actual                                                           
     690                 :      * key will be retrieved and used to set the parameter.                                                                             
     691                 :      *                                                                                                                                  
     692                 :      * @param mixed $key                                                                                                                
     693                 :      * @param mixed $value                                                                                                              
     694                 :      * @return Zend_Controller_Request_Http                                                                                             
     695                 :      */                                                                                                                                 
     696                 :     public function setParam($key, $value)                                                                                              
     697                 :     {                                                                                                                                   
     698               0 :         $key = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;                                                             
     699               0 :         parent::setParam($key, $value);                                                                                                 
     700               0 :         return $this;                                                                                                                   
     701                 :     }                                                                                                                                   
     702                 :                                                                                                                                         
     703                 :     /**                                                                                                                                 
     704                 :      * Retrieve a parameter                                                                                                             
     705                 :      *                                                                                                                                  
     706                 :      * Retrieves a parameter from the instance. Priority is in the order of                                                             
     707                 :      * userland parameters (see {@link setParam()}), $_GET, $_POST. If a                                                                
     708                 :      * parameter matching the $key is not found, null is returned.                                                                      
     709                 :      *                                                                                                                                  
     710                 :      * If the $key is an alias, the actual key aliased will be used.                                                                    
     711                 :      *                                                                                                                                  
     712                 :      * @param mixed $key                                                                                                                
     713                 :      * @param mixed $default Default value to use if key not found                                                                      
     714                 :      * @return mixed                                                                                                                    
     715                 :      */                                                                                                                                 
     716                 :     public function getParam($key, $default = null)                                                                                     
     717                 :     {                                                                                                                                   
     718               0 :         $keyName = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;                                                         
     719                 :                                                                                                                                         
     720               0 :         $paramSources = $this->getParamSources();                                                                                       
     721               0 :         if (isset($this->_params[$keyName])) {                                                                                          
     722               0 :             return $this->_params[$keyName];                                                                                            
     723               0 :         } elseif (in_array('_GET', $paramSources) && (isset($_GET[$keyName]))) {                                                        
     724               0 :             return $_GET[$keyName];                                                                                                     
     725               0 :         } elseif (in_array('_POST', $paramSources) && (isset($_POST[$keyName]))) {                                                      
     726               0 :             return $_POST[$keyName];                                                                                                    
     727                 :         }                                                                                                                               
     728                 :                                                                                                                                         
     729               0 :         return $default;                                                                                                                
     730                 :     }                                                                                                                                   
     731                 :                                                                                                                                         
     732                 :     /**                                                                                                                                 
     733                 :      * Retrieve an array of parameters                                                                                                  
     734                 :      *                                                                                                                                  
     735                 :      * Retrieves a merged array of parameters, with precedence of userland                                                              
     736                 :      * params (see {@link setParam()}), $_GET, $_POST (i.e., values in the                                                              
     737                 :      * userland params will take precedence over all others).                                                                           
     738                 :      *                                                                                                                                  
     739                 :      * @return array                                                                                                                    
     740                 :      */                                                                                                                                 
     741                 :     public function getParams()                                                                                                         
     742                 :     {                                                                                                                                   
     743               0 :         $return       = $this->_params;                                                                                                 
     744               0 :         $paramSources = $this->getParamSources();                                                                                       
     745               0 :         if (in_array('_GET', $paramSources)                                                                                             
     746               0 :             && isset($_GET)                                                                                                             
     747               0 :             && is_array($_GET)                                                                                                          
     748               0 :         ) {                                                                                                                             
     749               0 :             $return += $_GET;                                                                                                           
     750               0 :         }                                                                                                                               
     751               0 :         if (in_array('_POST', $paramSources)                                                                                            
     752               0 :             && isset($_POST)                                                                                                            
     753               0 :             && is_array($_POST)                                                                                                         
     754               0 :         ) {                                                                                                                             
     755               0 :             $return += $_POST;                                                                                                          
     756               0 :         }                                                                                                                               
     757               0 :         return $return;                                                                                                                 
     758                 :     }                                                                                                                                   
     759                 :                                                                                                                                         
     760                 :     /**                                                                                                                                 
     761                 :      * Set parameters                                                                                                                   
     762                 :      *                                                                                                                                  
     763                 :      * Set one or more parameters. Parameters are set as userland parameters,                                                           
     764                 :      * using the keys specified in the array.                                                                                           
     765                 :      *                                                                                                                                  
     766                 :      * @param array $params                                                                                                             
     767                 :      * @return Zend_Controller_Request_Http                                                                                             
     768                 :      */                                                                                                                                 
     769                 :     public function setParams(array $params)                                                                                            
     770                 :     {                                                                                                                                   
     771               0 :         foreach ($params as $key => $value) {                                                                                           
     772               0 :             $this->setParam($key, $value);                                                                                              
     773               0 :         }                                                                                                                               
     774               0 :         return $this;                                                                                                                   
     775                 :     }                                                                                                                                   
     776                 :                                                                                                                                         
     777                 :     /**                                                                                                                                 
     778                 :      * Set a key alias                                                                                                                  
     779                 :      *                                                                                                                                  
     780                 :      * Set an alias used for key lookups. $name specifies the alias, $target                                                            
     781                 :      * specifies the actual key to use.                                                                                                 
     782                 :      *                                                                                                                                  
     783                 :      * @param string $name                                                                                                              
     784                 :      * @param string $target                                                                                                            
     785                 :      * @return Zend_Controller_Request_Http                                                                                             
     786                 :      */                                                                                                                                 
     787                 :     public function setAlias($name, $target)                                                                                            
     788                 :     {                                                                                                                                   
     789               0 :         $this->_aliases[$name] = $target;                                                                                               
     790               0 :         return $this;                                                                                                                   
     791                 :     }                                                                                                                                   
     792                 :                                                                                                                                         
     793                 :     /**                                                                                                                                 
     794                 :      * Retrieve an alias                                                                                                                
     795                 :      *                                                                                                                                  
     796                 :      * Retrieve the actual key represented by the alias $name.                                                                          
     797                 :      *                                                                                                                                  
     798                 :      * @param string $name                                                                                                              
     799                 :      * @return string|null Returns null when no alias exists                                                                            
     800                 :      */                                                                                                                                 
     801                 :     public function getAlias($name)                                                                                                     
     802                 :     {                                                                                                                                   
     803               0 :         if (isset($this->_aliases[$name])) {                                                                                            
     804               0 :             return $this->_aliases[$name];                                                                                              
     805                 :         }                                                                                                                               
     806                 :                                                                                                                                         
     807               0 :         return null;                                                                                                                    
     808                 :     }                                                                                                                                   
     809                 :                                                                                                                                         
     810                 :     /**                                                                                                                                 
     811                 :      * Retrieve the list of all aliases                                                                                                 
     812                 :      *                                                                                                                                  
     813                 :      * @return array                                                                                                                    
     814                 :      */                                                                                                                                 
     815                 :     public function getAliases()                                                                                                        
     816                 :     {                                                                                                                                   
     817               0 :         return $this->_aliases;                                                                                                         
     818                 :     }                                                                                                                                   
     819                 :                                                                                                                                         
     820                 :     /**                                                                                                                                 
     821                 :      * Return the method by which the request was made                                                                                  
     822                 :      *                                                                                                                                  
     823                 :      * @return string                                                                                                                   
     824                 :      */                                                                                                                                 
     825                 :     public function getMethod()                                                                                                         
     826                 :     {                                                                                                                                   
     827               0 :         return $this->getServer('REQUEST_METHOD');                                                                                      
     828                 :     }                                                                                                                                   
     829                 :                                                                                                                                         
     830                 :     /**                                                                                                                                 
     831                 :      * Was the request made by POST?                                                                                                    
     832                 :      *                                                                                                                                  
     833                 :      * @return boolean                                                                                                                  
     834                 :      */                                                                                                                                 
     835                 :     public function isPost()                                                                                                            
     836                 :     {                                                                                                                                   
     837               0 :         if ('POST' == $this->getMethod()) {                                                                                             
     838               0 :             return true;                                                                                                                
     839                 :         }                                                                                                                               
     840                 :                                                                                                                                         
     841               0 :         return false;                                                                                                                   
     842                 :     }                                                                                                                                   
     843                 :                                                                                                                                         
     844                 :     /**                                                                                                                                 
     845                 :      * Was the request made by GET?                                                                                                     
     846                 :      *                                                                                                                                  
     847                 :      * @return boolean                                                                                                                  
     848                 :      */                                                                                                                                 
     849                 :     public function isGet()                                                                                                             
     850                 :     {                                                                                                                                   
     851               0 :         if ('GET' == $this->getMethod()) {                                                                                              
     852               0 :             return true;                                                                                                                
     853                 :         }                                                                                                                               
     854                 :                                                                                                                                         
     855               0 :         return false;                                                                                                                   
     856                 :     }                                                                                                                                   
     857                 :                                                                                                                                         
     858                 :     /**                                                                                                                                 
     859                 :      * Was the request made by PUT?                                                                                                     
     860                 :      *                                                                                                                                  
     861                 :      * @return boolean                                                                                                                  
     862                 :      */                                                                                                                                 
     863                 :     public function isPut()                                                                                                             
     864                 :     {                                                                                                                                   
     865               0 :         if ('PUT' == $this->getMethod()) {                                                                                              
     866               0 :             return true;                                                                                                                
     867                 :         }                                                                                                                               
     868                 :                                                                                                                                         
     869               0 :         return false;                                                                                                                   
     870                 :     }                                                                                                                                   
     871                 :                                                                                                                                         
     872                 :     /**                                                                                                                                 
     873                 :      * Was the request made by DELETE?                                                                                                  
     874                 :      *                                                                                                                                  
     875                 :      * @return boolean                                                                                                                  
     876                 :      */                                                                                                                                 
     877                 :     public function isDelete()                                                                                                          
     878                 :     {                                                                                                                                   
     879               0 :         if ('DELETE' == $this->getMethod()) {                                                                                           
     880               0 :             return true;                                                                                                                
     881                 :         }                                                                                                                               
     882                 :                                                                                                                                         
     883               0 :         return false;                                                                                                                   
     884                 :     }                                                                                                                                   
     885                 :                                                                                                                                         
     886                 :     /**                                                                                                                                 
     887                 :      * Was the request made by HEAD?                                                                                                    
     888                 :      *                                                                                                                                  
     889                 :      * @return boolean                                                                                                                  
     890                 :      */                                                                                                                                 
     891                 :     public function isHead()                                                                                                            
     892                 :     {                                                                                                                                   
     893               0 :         if ('HEAD' == $this->getMethod()) {                                                                                             
     894               0 :             return true;                                                                                                                
     895                 :         }                                                                                                                               
     896                 :                                                                                                                                         
     897               0 :         return false;                                                                                                                   
     898                 :     }                                                                                                                                   
     899                 :                                                                                                                                         
     900                 :     /**                                                                                                                                 
     901                 :      * Was the request made by OPTIONS?                                                                                                 
     902                 :      *                                                                                                                                  
     903                 :      * @return boolean                                                                                                                  
     904                 :      */                                                                                                                                 
     905                 :     public function isOptions()                                                                                                         
     906                 :     {                                                                                                                                   
     907               0 :         if ('OPTIONS' == $this->getMethod()) {                                                                                          
     908               0 :             return true;                                                                                                                
     909                 :         }                                                                                                                               
     910                 :                                                                                                                                         
     911               0 :         return false;                                                                                                                   
     912                 :     }                                                                                                                                   
     913                 :                                                                                                                                         
     914                 :     /**                                                                                                                                 
     915                 :      * Is the request a Javascript XMLHttpRequest?                                                                                      
     916                 :      *                                                                                                                                  
     917                 :      * Should work with Prototype/Script.aculo.us, possibly others.                                                                     
     918                 :      *                                                                                                                                  
     919                 :      * @return boolean                                                                                                                  
     920                 :      */                                                                                                                                 
     921                 :     public function isXmlHttpRequest()                                                                                                  
     922                 :     {                                                                                                                                   
     923               0 :         return ($this->getHeader('X_REQUESTED_WITH') == 'XMLHttpRequest');                                                              
     924                 :     }                                                                                                                                   
     925                 :                                                                                                                                         
     926                 :     /**                                                                                                                                 
     927                 :      * Is this a Flash request?                                                                                                         
     928                 :      *                                                                                                                                  
     929                 :      * @return boolean                                                                                                                  
     930                 :      */                                                                                                                                 
     931                 :     public function isFlashRequest()                                                                                                    
     932                 :     {                                                                                                                                   
     933               0 :         $header = strtolower($this->getHeader('USER_AGENT'));                                                                           
     934               0 :         return (strstr($header, ' flash')) ? true : false;                                                                              
     935                 :     }                                                                                                                                   
     936                 :                                                                                                                                         
     937                 :     /**                                                                                                                                 
     938                 :      * Is https secure request                                                                                                          
     939                 :      *                                                                                                                                  
     940                 :      * @return boolean                                                                                                                  
     941                 :      */                                                                                                                                 
     942                 :     public function isSecure()                                                                                                          
     943                 :     {                                                                                                                                   
     944               0 :         return ($this->getScheme() === self::SCHEME_HTTPS);                                                                             
     945                 :     }                                                                                                                                   
     946                 :                                                                                                                                         
     947                 :     /**                                                                                                                                 
     948                 :      * Return the raw body of the request, if present                                                                                   
     949                 :      *                                                                                                                                  
     950                 :      * @return string|false Raw body, or false if not present                                                                           
     951                 :      */                                                                                                                                 
     952                 :     public function getRawBody()                                                                                                        
     953                 :     {                                                                                                                                   
     954               0 :         if (null === $this->_rawBody) {                                                                                                 
     955               0 :             $body = file_get_contents('php://input');                                                                                   
     956                 :                                                                                                                                         
     957               0 :             if (strlen(trim($body)) > 0) {                                                                                              
     958               0 :                 $this->_rawBody = $body;                                                                                                
     959               0 :             } else {                                                                                                                    
     960               0 :                 $this->_rawBody = false;                                                                                                
     961                 :             }                                                                                                                           
     962               0 :         }                                                                                                                               
     963               0 :         return $this->_rawBody;                                                                                                         
     964                 :     }                                                                                                                                   
     965                 :                                                                                                                                         
     966                 :     /**                                                                                                                                 
     967                 :      * Return the value of the given HTTP header. Pass the header name as the                                                           
     968                 :      * plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the                                                              
     969                 :      * Accept header, 'Accept-Encoding' to get the Accept-Encoding header.                                                              
     970                 :      *                                                                                                                                  
     971                 :      * @param string $header HTTP header name                                                                                           
     972                 :      * @return string|false HTTP header value, or false if not found                                                                    
     973                 :      * @throws Zend_Controller_Request_Exception                                                                                        
     974                 :      */                                                                                                                                 
     975                 :     public function getHeader($header)                                                                                                  
     976                 :     {                                                                                                                                   
     977               0 :         if (empty($header)) {                                                                                                           
     978                 :             #require_once 'Zend/Controller/Request/Exception.php';                                                                      
     979               0 :             throw new Zend_Controller_Request_Exception('An HTTP header name is required');                                             
     980                 :         }                                                                                                                               
     981                 :                                                                                                                                         
     982                 :         // Try to get it from the $_SERVER array first                                                                                  
     983               0 :         $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header));                                                                   
     984               0 :         if (isset($_SERVER[$temp])) {                                                                                                   
     985               0 :             return $_SERVER[$temp];                                                                                                     
     986                 :         }                                                                                                                               
     987                 :                                                                                                                                         
     988                 :         // This seems to be the only way to get the Authorization header on                                                             
     989                 :         // Apache                                                                                                                       
     990               0 :         if (function_exists('apache_request_headers')) {                                                                                
     991               0 :             $headers = apache_request_headers();                                                                                        
     992               0 :             if (isset($headers[$header])) {                                                                                             
     993               0 :                 return $headers[$header];                                                                                               
     994                 :             }                                                                                                                           
     995               0 :             $header = strtolower($header);                                                                                              
     996               0 :             foreach ($headers as $key => $value) {                                                                                      
     997               0 :                 if (strtolower($key) == $header) {                                                                                      
     998               0 :                     return $value;                                                                                                      
     999                 :                 }                                                                                                                       
    1000               0 :             }                                                                                                                           
    1001               0 :         }                                                                                                                               
    1002                 :                                                                                                                                         
    1003               0 :         return false;                                                                                                                   
    1004                 :     }                                                                                                                                   
    1005                 :                                                                                                                                         
    1006                 :     /**                                                                                                                                 
    1007                 :      * Get the request URI scheme                                                                                                       
    1008                 :      *                                                                                                                                  
    1009                 :      * @return string                                                                                                                   
    1010                 :      */                                                                                                                                 
    1011                 :     public function getScheme()                                                                                                         
    1012                 :     {                                                                                                                                   
    1013               0 :         return ($this->getServer('HTTPS') == 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP;                                            
    1014                 :     }                                                                                                                                   
    1015                 :                                                                                                                                         
    1016                 :     /**                                                                                                                                 
    1017                 :      * Get the HTTP host.                                                                                                               
    1018                 :      *                                                                                                                                  
    1019                 :      * "Host" ":" host [ ":" port ] ; Section 3.2.2                                                                                     
    1020                 :      * Note the HTTP Host header is not the same as the URI host.                                                                       
    1021                 :      * It includes the port while the URI host doesn't.                                                                                 
    1022                 :      *                                                                                                                                  
    1023                 :      * @return string                                                                                                                   
    1024                 :      */                                                                                                                                 
    1025                 :     public function getHttpHost()                                                                                                       
    1026                 :     {                                                                                                                                   
    1027               0 :         $host = $this->getServer('HTTP_HOST');                                                                                          
    1028               0 :         if (!empty($host)) {                                                                                                            
    1029               0 :             return $host;                                                                                                               
    1030                 :         }                                                                                                                               
    1031                 :                                                                                                                                         
    1032               0 :         $scheme = $this->getScheme();                                                                                                   
    1033               0 :         $name   = $this->getServer('SERVER_NAME');                                                                                      
    1034               0 :         $port   = $this->getServer('SERVER_PORT');                                                                                      
    1035                 :                                                                                                                                         
    1036               0 :         if(null === $name) {                                                                                                            
    1037               0 :             return '';                                                                                                                  
    1038                 :         }                                                                                                                               
    1039               0 :         elseif (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) {                     
    1040               0 :             return $name;                                                                                                               
    1041                 :         } else {                                                                                                                        
    1042               0 :             return $name . ':' . $port;                                                                                                 
    1043                 :         }                                                                                                                               
    1044                 :     }                                                                                                                                   
    1045                 :                                                                                                                                         
    1046                 :     /**                                                                                                                                 
    1047                 :      * Get the client's IP addres                                                                                                       
    1048                 :      *                                                                                                                                  
    1049                 :      * @param  boolean $checkProxy                                                                                                      
    1050                 :      * @return string                                                                                                                   
    1051                 :      */                                                                                                                                 
    1052                 :     public function getClientIp($checkProxy = true)                                                                                     
    1053                 :     {                                                                                                                                   
    1054               0 :         if ($checkProxy && $this->getServer('HTTP_CLIENT_IP') != null) {                                                                
    1055               0 :             $ip = $this->getServer('HTTP_CLIENT_IP');                                                                                   
    1056               0 :         } else if ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {                                                   
    1057               0 :             $ip = $this->getServer('HTTP_X_FORWARDED_FOR');                                                                             
    1058               0 :         } else {                                                                                                                        
    1059               0 :             $ip = $this->getServer('REMOTE_ADDR');                                                                                      
    1060                 :         }                                                                                                                               
    1061                 :                                                                                                                                         
    1062               0 :         return $ip;                                                                                                                     
    1063                 :     }                                                                                                                                   
    1064                 : }                                                                                                                                       

Generated by PHP_CodeCoverage 1.0.4 using PHP 5.3.4 and PHPUnit 3.5.13 at Tue Jul 5 9:07:16 UTC 2011.