bootstrap.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 models directory.
  49. */
  50. define('MODELS', APP.'Model'.DS);
  51. /**
  52. * Path to model behaviors directory.
  53. */
  54. define('BEHAVIORS', MODELS.'Behavior'.DS);
  55. /**
  56. * Path to the application's controllers directory.
  57. */
  58. define('CONTROLLERS', APP.'Controller'.DS);
  59. /**
  60. * Path to the application's components directory.
  61. */
  62. define('COMPONENTS', CONTROLLERS.'Component'.DS);
  63. /**
  64. * Path to the application's libs directory.
  65. */
  66. define('APPLIBS', APP.'Lib'.DS);
  67. /**
  68. * Path to the application's views directory.
  69. */
  70. define('VIEWS', APP.'View'.DS);
  71. /**
  72. * Path to the application's helpers directory.
  73. */
  74. define('HELPERS', VIEWS.'Helper'.DS);
  75. /**
  76. * Path to the application's view's layouts directory.
  77. */
  78. define('LAYOUTS', VIEWS.'layouts'.DS);
  79. /**
  80. * Path to the application's view's elements directory.
  81. * It's supposed to hold pieces of PHP/HTML that are used on multiple pages
  82. * and are not linked to a particular layout (like polls, footers and so on).
  83. */
  84. define('ELEMENTS', VIEWS.'elements'.DS);
  85. /**
  86. * Path to the configuration files directory.
  87. */
  88. if (!defined('CONFIGS')) {
  89. define('CONFIGS', APP.'config'.DS);
  90. }
  91. /**
  92. * Path to the libs directory.
  93. */
  94. define('LIBS', CAKE);
  95. /**
  96. * Path to the public CSS directory.
  97. */
  98. define('CSS', WWW_ROOT.'css'.DS);
  99. /**
  100. * Path to the public JavaScript directory.
  101. */
  102. define('JS', WWW_ROOT.'js'.DS);
  103. /**
  104. * Path to the public images directory.
  105. */
  106. define('IMAGES', WWW_ROOT.'img'.DS);
  107. /**
  108. * Path to the console libs direcotry.
  109. */
  110. define('CONSOLE_LIBS', CAKE . 'Console' . DS);
  111. /**
  112. * Path to the tests directory.
  113. */
  114. if (!defined('TESTS')) {
  115. define('TESTS', APP.'tests'.DS);
  116. }
  117. /**
  118. * Path to the core tests directory.
  119. */
  120. if (!defined('CAKE_TESTS')) {
  121. define('CAKE_TESTS', CAKE.'tests'.DS);
  122. }
  123. /**
  124. * Path to the test suite.
  125. */
  126. define('CAKE_TESTS_LIB', LIBS . 'TestSuite' . DS);
  127. /**
  128. * Path to the controller test directory.
  129. */
  130. define('CONTROLLER_TESTS', TESTS.'Case'.DS.'Controller'.DS);
  131. /**
  132. * Path to the components test directory.
  133. */
  134. define('COMPONENT_TESTS', TESTS.'Case'.DS.'Component'.DS);
  135. /**
  136. * Path to the helpers test directory.
  137. */
  138. define('HELPER_TESTS', TESTS.'Case'.DS.'View'.DS.'Helper'.DS);
  139. /**
  140. * Path to the models' test directory.
  141. */
  142. define('MODEL_TESTS', TESTS.'Case'.DS.'Model'.DS);
  143. /**
  144. * Path to the lib test directory.
  145. */
  146. define('LIB_TESTS', CAKE_TESTS.'Case'.DS.'Lib'.DS);
  147. /**
  148. * Path to the temporary files directory.
  149. */
  150. if (!defined('TMP')) {
  151. define('TMP', APP.'tmp'.DS);
  152. }
  153. /**
  154. * Path to the logs directory.
  155. */
  156. define('LOGS', TMP.'logs'.DS);
  157. /**
  158. * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
  159. */
  160. define('CACHE', TMP.'cache'.DS);
  161. /**
  162. * Path to the vendors directory.
  163. */
  164. if (!defined('VENDORS')) {
  165. define('VENDORS', ROOT . DS . 'vendors' . DS);
  166. }
  167. /**
  168. * Web path to the public images directory.
  169. */
  170. if (!defined('IMAGES_URL')) {
  171. define('IMAGES_URL', 'img/');
  172. }
  173. /**
  174. * Web path to the CSS files directory.
  175. */
  176. if (!defined('CSS_URL')) {
  177. define('CSS_URL', 'css/');
  178. }
  179. /**
  180. * Web path to the js files directory.
  181. */
  182. if (!defined('JS_URL')) {
  183. define('JS_URL', 'js/');
  184. }
  185. require LIBS . 'basics.php';
  186. require LIBS . 'Core' . DS .'App.php';
  187. require LIBS . 'Error' . DS . 'exceptions.php';
  188. spl_autoload_register(array('App', 'load'));
  189. App::uses('ErrorHandler', 'Error');
  190. App::uses('Configure', 'Core');
  191. App::uses('Cache', 'Cache');
  192. App::uses('Object', 'Core');
  193. Configure::bootstrap(isset($boot) ? $boot : true);
  194. /**
  195. * Full url prefix
  196. */
  197. if (!defined('FULL_BASE_URL')) {
  198. $s = null;
  199. if (env('HTTPS')) {
  200. $s ='s';
  201. }
  202. $httpHost = env('HTTP_HOST');
  203. if (isset($httpHost)) {
  204. define('FULL_BASE_URL', 'http'.$s.'://'.$httpHost);
  205. }
  206. unset($httpHost, $s);
  207. }