|
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: Apache404.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
20 */ |
|
21 |
|
22 /** Zend_Controller_Request_Http */ |
|
23 require_once 'Zend/Controller/Request/Http.php'; |
|
24 |
|
25 /** Zend_Uri */ |
|
26 require_once 'Zend/Uri.php'; |
|
27 |
|
28 /** |
|
29 * Zend_Controller_Request_Apache404 |
|
30 * |
|
31 * HTTP request object for use with Zend_Controller family. Extends basic HTTP |
|
32 * request object to allow for two edge cases when using Apache: |
|
33 * - Using Apache's 404 handler instead of mod_rewrite to direct requests |
|
34 * - Using the PT flag in rewrite rules |
|
35 * |
|
36 * In each case, the URL to check against is found in REDIRECT_URL, not |
|
37 * REQUEST_URI. |
|
38 * |
|
39 * @uses Zend_Controller_Request_Http |
|
40 * @package Zend_Controller |
|
41 * @subpackage Request |
|
42 */ |
|
43 class Zend_Controller_Request_Apache404 extends Zend_Controller_Request_Http |
|
44 { |
|
45 public function setRequestUri($requestUri = null) |
|
46 { |
|
47 $parseUriGetVars = false; |
|
48 if ($requestUri === null) { |
|
49 if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch |
|
50 $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; |
|
51 } elseif (isset($_SERVER['REDIRECT_URL'])) { // Check if using mod_rewrite |
|
52 $requestUri = $_SERVER['REDIRECT_URL']; |
|
53 if (isset($_SERVER['REDIRECT_QUERYSTRING'])) { |
|
54 $parseUriGetVars = $_SERVER['REDIRECT_QUERYSTRING']; |
|
55 } |
|
56 } elseif (isset($_SERVER['REQUEST_URI'])) { |
|
57 $requestUri = $_SERVER['REQUEST_URI']; |
|
58 } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI |
|
59 $requestUri = $_SERVER['ORIG_PATH_INFO']; |
|
60 if (!empty($_SERVER['QUERY_STRING'])) { |
|
61 $requestUri .= '?' . $_SERVER['QUERY_STRING']; |
|
62 } |
|
63 } else { |
|
64 return $this; |
|
65 } |
|
66 } elseif (!is_string($requestUri)) { |
|
67 return $this; |
|
68 } else { |
|
69 if (false !== ($pos = strpos($requestUri, '?'))) { |
|
70 $parseUriGetVars = substr($requestUri, $pos + 1); |
|
71 } |
|
72 } |
|
73 |
|
74 if ($parseUriGetVars) { |
|
75 // Set GET items, if available |
|
76 parse_str($parseUriGetVars, $_GET); |
|
77 } |
|
78 |
|
79 $this->_requestUri = $requestUri; |
|
80 return $this; |
|
81 } |
|
82 } |