2
0

Apache404.php 2.8 KB

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