/framework/core/app/Globals.php

http://zoop.googlecode.com/ · PHP · 79 lines · 49 code · 11 blank · 19 comment · 17 complexity · 55ec0c691d44daf3921dba9c8846065f MD5 · raw file

  1. <?php
  2. /**
  3. * app::config.php
  4. *
  5. * @author Rick Gigger
  6. * @version $Id$
  7. * @copyright __MyCompanyName__, 16 February, 2007
  8. * @package app
  9. **/
  10. //////////////////////////////////////////////
  11. //
  12. // What we really want here is to define the following contants:
  13. //
  14. // 1) script_url the url up to index.php or whatever the script name is
  15. // 2) virtual_path the virtual path. this comes directly after scriptname.php
  16. // 3) virtual_url the url up through index.php and also the virtual path
  17. //
  18. //////////////////////////////////////////////
  19. // echo_r($_SERVER);
  20. if(php_sapi_name() != "cli")
  21. {
  22. if( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' )
  23. $protocol = 'https://';
  24. else
  25. $protocol = 'http://';
  26. $sslProtocol = 'https://';
  27. $host = $_SERVER['HTTP_HOST'];
  28. $virtualPath = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (isset($_SERVER["ORIG_PATH_INFO"]) ? $_SERVER["ORIG_PATH_INFO"] : '');
  29. // what other situations besides mod_rewrite set this to 200?
  30. if(isset($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] == 200)
  31. {
  32. $uri = $_SERVER['REQUEST_URI'];
  33. if($pos = strpos($uri, '?'))
  34. $uri = substr($uri, 0, $pos);
  35. if( $virtualPath && substr($uri, 0-strlen($virtualPath)) == $virtualPath )
  36. $realPath = substr($uri, 0, strlen($uri) - strlen($virtualPath));
  37. else
  38. $realPath = $_SERVER['SCRIPT_NAME'];
  39. }
  40. else
  41. {
  42. $realPath = $_SERVER['SCRIPT_NAME'];
  43. }
  44. define('root_url', $protocol . $host);
  45. define('ssl_root_url', $sslProtocol . $host);
  46. if(defined('script_url'))
  47. {
  48. define('back_script_url', root_url . $realPath);
  49. define('back_virtual_url', back_script_url . $virtualPath);
  50. define('back_pub_url', dirname(back_script_url) . '/public');
  51. }
  52. else
  53. {
  54. define('script_url', root_url . $realPath);
  55. define('ssl_script_url', ssl_root_url . $realPath);
  56. }
  57. define('app_url', dirname(script_url));
  58. if(isset($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] == 200)
  59. define('base_url', script_url . '/');
  60. else
  61. define('base_url', script_url);
  62. define('virtual_path', $virtualPath);
  63. define('virtual_url', script_url . virtual_path);
  64. define('ssl_virtual_url', ssl_script_url . virtual_path);
  65. }
  66. if(!defined('E_DEPRECATED'))
  67. define('E_DEPRECATED', 8192);
  68. define('version_53', version_compare(PHP_VERSION, '5.3.0') >= 0 ? true : false);