bootstrap.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. /**
  3. * Basic Cake functionality.
  4. *
  5. * Handles loading of core files needed on every request
  6. *
  7. * PHP 5
  8. *
  9. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10. * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. *
  12. * Licensed under The MIT License
  13. * Redistributions of files must retain the above copyright notice.
  14. *
  15. * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link http://cakephp.org CakePHP(tm) Project
  17. * @package cake.config
  18. * @since CakePHP(tm) v 0.2.9
  19. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  20. */
  21. if (!defined('E_DEPRECATED')) {
  22. define('E_DEPRECATED', 8192);
  23. }
  24. error_reporting(E_ALL & ~E_DEPRECATED);
  25. /**
  26. * If the index.php file is used instead of an .htaccess file
  27. * or if the user can not set the web root to use the public
  28. * directory we will define ROOT there, otherwise we set it
  29. * here.
  30. */
  31. if (!defined('ROOT')) {
  32. define('ROOT', '../');
  33. }
  34. if (!defined('WEBROOT_DIR')) {
  35. define('WEBROOT_DIR', 'webroot');
  36. }
  37. /**
  38. * Path to the cake directory.
  39. */
  40. define('CAKE', CORE_PATH . 'Cake' . DS);
  41. /**
  42. * Path to the application's directory.
  43. */
  44. if (!defined('APP')) {
  45. define('APP', ROOT.DS.APP_DIR.DS);
  46. }
  47. /**
  48. * Path to the application's libs directory.
  49. */
  50. define('APPLIBS', APP.'Lib'.DS);
  51. /**
  52. * Path to the configuration files directory.
  53. */
  54. if (!defined('CONFIGS')) {
  55. define('CONFIGS', APP.'Config'.DS);
  56. }
  57. /**
  58. * Path to the libs directory.
  59. */
  60. define('LIBS', CAKE);
  61. /**
  62. * Path to the public CSS directory.
  63. */
  64. define('CSS', WWW_ROOT.'css'.DS);
  65. /**
  66. * Path to the public JavaScript directory.
  67. */
  68. define('JS', WWW_ROOT.'js'.DS);
  69. /**
  70. * Path to the public images directory.
  71. */
  72. define('IMAGES', WWW_ROOT.'img'.DS);
  73. /**
  74. * Path to the tests directory.
  75. */
  76. if (!defined('TESTS')) {
  77. define('TESTS', APP.'Test'.DS);
  78. }
  79. /**
  80. * Path to the core tests directory.
  81. */
  82. if (!defined('CAKE_TESTS')) {
  83. define('CAKE_TESTS', CAKE.'Test'.DS);
  84. }
  85. /**
  86. * Path to the helpers test directory.
  87. */
  88. define('HELPER_TESTS', TESTS.'Case'.DS.'View'.DS.'Helper'.DS);
  89. /**
  90. * Path to the models' test directory.
  91. */
  92. define('MODEL_TESTS', TESTS.'Case'.DS.'Model'.DS);
  93. /**
  94. * Path to the lib test directory.
  95. */
  96. define('LIB_TESTS', CAKE_TESTS.'Case'.DS.'Lib'.DS);
  97. /**
  98. * Path to the temporary files directory.
  99. */
  100. if (!defined('TMP')) {
  101. define('TMP', APP.'tmp'.DS);
  102. }
  103. /**
  104. * Path to the logs directory.
  105. */
  106. define('LOGS', TMP.'logs'.DS);
  107. /**
  108. * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
  109. */
  110. define('CACHE', TMP.'cache'.DS);
  111. /**
  112. * Path to the vendors directory.
  113. */
  114. if (!defined('VENDORS')) {
  115. define('VENDORS', ROOT . DS . 'vendors' . DS);
  116. }
  117. /**
  118. * Web path to the public images directory.
  119. */
  120. if (!defined('IMAGES_URL')) {
  121. define('IMAGES_URL', 'img/');
  122. }
  123. /**
  124. * Web path to the CSS files directory.
  125. */
  126. if (!defined('CSS_URL')) {
  127. define('CSS_URL', 'css/');
  128. }
  129. /**
  130. * Web path to the js files directory.
  131. */
  132. if (!defined('JS_URL')) {
  133. define('JS_URL', 'js/');
  134. }
  135. require LIBS . 'basics.php';
  136. require LIBS . 'Core' . DS .'App.php';
  137. require LIBS . 'Error' . DS . 'exceptions.php';
  138. spl_autoload_register(array('App', 'load'));
  139. App::uses('ErrorHandler', 'Error');
  140. App::uses('Configure', 'Core');
  141. App::uses('Cache', 'Cache');
  142. App::uses('Object', 'Core');
  143. Configure::bootstrap(isset($boot) ? $boot : true);
  144. /**
  145. * Full url prefix
  146. */
  147. if (!defined('FULL_BASE_URL')) {
  148. $s = null;
  149. if (env('HTTPS')) {
  150. $s ='s';
  151. }
  152. $httpHost = env('HTTP_HOST');
  153. if (isset($httpHost)) {
  154. define('FULL_BASE_URL', 'http'.$s.'://'.$httpHost);
  155. }
  156. unset($httpHost, $s);
  157. }