bootstrap.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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
  18. * @subpackage cake.cake
  19. * @since CakePHP(tm) v 0.2.9
  20. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  21. */
  22. if (!defined('E_DEPRECATED')) {
  23. define('E_DEPRECATED', 8192);
  24. }
  25. error_reporting(E_ALL & ~E_DEPRECATED);
  26. /**
  27. * If the index.php file is used instead of an .htaccess file
  28. * or if the user can not set the web root to use the public
  29. * directory we will define ROOT there, otherwise we set it
  30. * here.
  31. */
  32. if (!defined('ROOT')) {
  33. define('ROOT', '../');
  34. }
  35. if (!defined('WEBROOT_DIR')) {
  36. define('WEBROOT_DIR', 'webroot');
  37. }
  38. /**
  39. * Path to the cake directory.
  40. */
  41. define('CAKE', CORE_PATH . 'Cake' . DS);
  42. /**
  43. * Path to the application's directory.
  44. */
  45. if (!defined('APP')) {
  46. define('APP', ROOT.DS.APP_DIR.DS);
  47. }
  48. /**
  49. * Path to the application's models directory.
  50. */
  51. define('MODELS', APP.'models'.DS);
  52. /**
  53. * Path to model behaviors directory.
  54. */
  55. define('BEHAVIORS', MODELS.'behaviors'.DS);
  56. /**
  57. * Path to the application's controllers directory.
  58. */
  59. define('CONTROLLERS', APP.'controllers'.DS);
  60. /**
  61. * Path to the application's components directory.
  62. */
  63. define('COMPONENTS', CONTROLLERS.'components'.DS);
  64. /**
  65. * Path to the application's libs directory.
  66. */
  67. define('APPLIBS', APP.'libs'.DS);
  68. /**
  69. * Path to the application's views directory.
  70. */
  71. define('VIEWS', APP.'views'.DS);
  72. /**
  73. * Path to the application's helpers directory.
  74. */
  75. define('HELPERS', VIEWS.'helpers'.DS);
  76. /**
  77. * Path to the application's view's layouts directory.
  78. */
  79. define('LAYOUTS', VIEWS.'layouts'.DS);
  80. /**
  81. * Path to the application's view's elements directory.
  82. * It's supposed to hold pieces of PHP/HTML that are used on multiple pages
  83. * and are not linked to a particular layout (like polls, footers and so on).
  84. */
  85. define('ELEMENTS', VIEWS.'elements'.DS);
  86. /**
  87. * Path to the configuration files directory.
  88. */
  89. if (!defined('CONFIGS')) {
  90. define('CONFIGS', APP.'config'.DS);
  91. }
  92. /**
  93. * Path to the libs directory.
  94. */
  95. define('LIBS', CAKE);
  96. /**
  97. * Path to the public CSS directory.
  98. */
  99. define('CSS', WWW_ROOT.'css'.DS);
  100. /**
  101. * Path to the public JavaScript directory.
  102. */
  103. define('JS', WWW_ROOT.'js'.DS);
  104. /**
  105. * Path to the public images directory.
  106. */
  107. define('IMAGES', WWW_ROOT.'img'.DS);
  108. /**
  109. * Path to the console libs direcotry.
  110. */
  111. define('CONSOLE_LIBS', CAKE . 'Console' . DS);
  112. /**
  113. * Path to the tests directory.
  114. */
  115. if (!defined('TESTS')) {
  116. define('TESTS', APP.'tests'.DS);
  117. }
  118. /**
  119. * Path to the core tests directory.
  120. */
  121. if (!defined('CAKE_TESTS')) {
  122. define('CAKE_TESTS', CAKE.'tests'.DS);
  123. }
  124. /**
  125. * Path to the test suite.
  126. */
  127. define('CAKE_TESTS_LIB', CAKE_TESTS.'lib'.DS);
  128. /**
  129. * Path to the controller test directory.
  130. */
  131. define('CONTROLLER_TESTS', TESTS.'cases'.DS.'controllers'.DS);
  132. /**
  133. * Path to the components test directory.
  134. */
  135. define('COMPONENT_TESTS', TESTS.'cases'.DS.'components'.DS);
  136. /**
  137. * Path to the helpers test directory.
  138. */
  139. define('HELPER_TESTS', TESTS.'cases'.DS.'views'.DS.'helpers'.DS);
  140. /**
  141. * Path to the models' test directory.
  142. */
  143. define('MODEL_TESTS', TESTS.'cases'.DS.'models'.DS);
  144. /**
  145. * Path to the lib test directory.
  146. */
  147. define('LIB_TESTS', CAKE_TESTS.'cases'.DS.'lib'.DS);
  148. /**
  149. * Path to the temporary files directory.
  150. */
  151. if (!defined('TMP')) {
  152. define('TMP', APP.'tmp'.DS);
  153. }
  154. /**
  155. * Path to the logs directory.
  156. */
  157. define('LOGS', TMP.'logs'.DS);
  158. /**
  159. * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
  160. */
  161. define('CACHE', TMP.'cache'.DS);
  162. /**
  163. * Path to the vendors directory.
  164. */
  165. if (!defined('VENDORS')) {
  166. define('VENDORS', CAKE_CORE_INCLUDE_PATH.DS.'vendors'.DS);
  167. }
  168. /**
  169. * Web path to the public images directory.
  170. */
  171. if (!defined('IMAGES_URL')) {
  172. define('IMAGES_URL', 'img/');
  173. }
  174. /**
  175. * Web path to the CSS files directory.
  176. */
  177. if (!defined('CSS_URL')) {
  178. define('CSS_URL', 'css/');
  179. }
  180. /**
  181. * Web path to the js files directory.
  182. */
  183. if (!defined('JS_URL')) {
  184. define('JS_URL', 'js/');
  185. }
  186. require LIBS . 'basics.php';
  187. require LIBS . 'Core' . DS .'App.php';
  188. require LIBS . 'Error' . DS . 'exceptions.php';
  189. spl_autoload_register(array('App', 'load'));
  190. App::uses('ErrorHandler', 'Error');
  191. App::uses('Configure', 'Core');
  192. App::uses('Cache', 'Cache');
  193. App::uses('Object', 'Core');
  194. Configure::bootstrap(isset($boot) ? $boot : true);
  195. /**
  196. * Full url prefix
  197. */
  198. if (!defined('FULL_BASE_URL')) {
  199. $s = null;
  200. if (env('HTTPS')) {
  201. $s ='s';
  202. }
  203. $httpHost = env('HTTP_HOST');
  204. if (isset($httpHost)) {
  205. define('FULL_BASE_URL', 'http'.$s.'://'.$httpHost);
  206. }
  207. unset($httpHost, $s);
  208. }