File indexing completed on 2024-12-22 05:36:33

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Controller
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /** Zend_Controller_Request_Http */
0023 // require_once 'Zend/Controller/Request/Http.php';
0024 
0025 /** Zend_Uri */
0026 // require_once 'Zend/Uri.php';
0027 
0028 /**
0029  * Zend_Controller_Request_Apache404
0030  *
0031  * HTTP request object for use with Zend_Controller family. Extends basic HTTP
0032  * request object to allow for two edge cases when using Apache:
0033  * - Using Apache's 404 handler instead of mod_rewrite to direct requests
0034  * - Using the PT flag in rewrite rules
0035  *
0036  * In each case, the URL to check against is found in REDIRECT_URL, not
0037  * REQUEST_URI.
0038  *
0039  * @uses       Zend_Controller_Request_Http
0040  * @package    Zend_Controller
0041  * @subpackage Request
0042  */
0043 class Zend_Controller_Request_Apache404 extends Zend_Controller_Request_Http
0044 {
0045     public function setRequestUri($requestUri = null)
0046     {
0047         $parseUriGetVars = false;
0048         if ($requestUri === null) {
0049             if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
0050                 $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
0051             } elseif (isset($_SERVER['REDIRECT_URL'])) {  // Check if using mod_rewrite
0052                 $requestUri = $_SERVER['REDIRECT_URL'];
0053                 if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
0054                     $parseUriGetVars = $_SERVER['REDIRECT_QUERY_STRING'];
0055                 }
0056             } elseif (isset($_SERVER['REQUEST_URI'])) {
0057                 $requestUri = $_SERVER['REQUEST_URI'];
0058             } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
0059                 $requestUri = $_SERVER['ORIG_PATH_INFO'];
0060                 if (!empty($_SERVER['QUERY_STRING'])) {
0061                     $requestUri .= '?' . $_SERVER['QUERY_STRING'];
0062                 }
0063             } else {
0064                 return $this;
0065             }
0066         } elseif (!is_string($requestUri)) {
0067             return $this;
0068         } else {
0069             if (false !== ($pos = strpos($requestUri, '?'))) {
0070                 $parseUriGetVars = substr($requestUri, $pos + 1);
0071             }
0072         }
0073 
0074         if ($parseUriGetVars) {
0075             // Set GET items, if available
0076             parse_str($parseUriGetVars, $_GET);
0077         }
0078 
0079         $this->_requestUri = $requestUri;
0080         return $this;
0081     }
0082 }