bootstrap.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * Basic Cake functionality.
  5. *
  6. * Core functions for including other source files, loading models and so forth.
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
  11. * Copyright 2005-2007, Cake Software Foundation, Inc.
  12. * 1785 E. Sahara Avenue, Suite 490-204
  13. * Las Vegas, Nevada 89104
  14. *
  15. * Licensed under The MIT License
  16. * Redistributions of files must retain the above copyright notice.
  17. *
  18. * @filesource
  19. * @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
  20. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  21. * @package cake
  22. * @subpackage cake.cake
  23. * @since CakePHP(tm) v 0.2.9
  24. * @version $Revision$
  25. * @modifiedby $LastChangedBy$
  26. * @lastmodified $Date$
  27. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  28. */
  29. if (!defined('PHP5')) {
  30. define ('PHP5', (phpversion() >= 5));
  31. }
  32. /**
  33. * Configuration, directory layout and standard libraries
  34. */
  35. if (!isset($bootstrap)) {
  36. require CORE_PATH . 'cake' . DS . 'basics.php';
  37. require APP_PATH . 'config' . DS . 'core.php';
  38. require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
  39. }
  40. $TIME_START = getMicrotime();
  41. require LIBS . 'object.php';
  42. require LIBS . 'session.php';
  43. require LIBS . 'security.php';
  44. require LIBS . 'inflector.php';
  45. require LIBS . 'configure.php';
  46. $paths = Configure::getInstance();
  47. Configure::store(null, 'class.paths');
  48. Configure::load('class.paths');
  49. Configure::write('debug', DEBUG);
  50. /**
  51. * Verify that the application's salt has been changed from the default value
  52. */
  53. if (CAKE_SESSION_STRING == 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') {
  54. trigger_error('Please change the value of CAKE_SESSION_STRING in app/config/core.php to a salt value specific to your application', E_USER_NOTICE);
  55. }
  56. /**
  57. * Get the application path and request URL
  58. */
  59. if (empty($uri) && defined('BASE_URL')) {
  60. $uri = setUri();
  61. if ($uri === '/' || $uri === '/index.php' || $uri === '/app/') {
  62. $_GET['url'] = '/';
  63. $url = '/';
  64. } else {
  65. if (strpos($uri, 'index.php') !== false) {
  66. $uri = r('?', '', $uri);
  67. $elements = explode('/index.php', $uri);
  68. } else {
  69. $elements = explode('/?', $uri);
  70. }
  71. if (!empty($elements[1])) {
  72. $_GET['url'] = $elements[1];
  73. $url = $elements[1];
  74. } else {
  75. $_GET['url'] = '/';
  76. $url = '/';
  77. }
  78. }
  79. } else {
  80. if (empty($_GET['url'])) {
  81. $url = null;
  82. } else {
  83. $url = $_GET['url'];
  84. }
  85. }
  86. if (strpos($url, 'ccss/') === 0) {
  87. include WWW_ROOT . DS . 'css.php';
  88. exit();
  89. }
  90. $folders = array('js' => 'text/javascript', 'css' => 'text/css');
  91. $requestPath = explode('/', $url);
  92. if (in_array($requestPath[0], array_keys($folders))) {
  93. if (file_exists(VENDORS . join(DS, $requestPath))) {
  94. header('Content-type: ' . $folders[$requestPath[0]]);
  95. include (VENDORS . join(DS, $requestPath));
  96. exit();
  97. }
  98. }
  99. require CAKE . 'dispatcher.php';
  100. if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
  101. if (empty($uri)) {
  102. $uri = setUri();
  103. }
  104. $filename = CACHE . 'views' . DS . convertSlash($uri) . '.php';
  105. if (file_exists($filename)) {
  106. uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
  107. $v = null;
  108. $view = new View($v);
  109. $view->renderCache($filename, $TIME_START);
  110. } elseif(file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
  111. uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
  112. $v = null;
  113. $view = new View($v);
  114. $view->renderCache(CACHE . 'views' . DS . convertSlash($uri) . '_index.php', $TIME_START);
  115. }
  116. }
  117. ?>