bootstrap.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 . 'cache.php';
  43. require LIBS . 'session.php';
  44. require LIBS . 'security.php';
  45. require LIBS . 'inflector.php';
  46. require LIBS . 'configure.php';
  47. $paths = Configure::getInstance();
  48. if(isset($cakeCache)) {
  49. $cache = 'File';
  50. $settings = array();
  51. if(isset($cakeCache[0])) {
  52. $cache = $cakeCache[0];
  53. }
  54. if(isset($cakeCache[1])) {
  55. $settings = $cakeCache[1];
  56. }
  57. Cache::engine($cache, $settings);
  58. } else {
  59. Cache::engine();
  60. }
  61. Configure::store(null, 'class.paths');
  62. Configure::load('class.paths');
  63. Configure::write('debug', DEBUG);
  64. /**
  65. * Check for IIS Server
  66. */
  67. if (!defined('SERVER_IIS') && php_sapi_name() == 'isapi') {
  68. define('SERVER_IIS', true);
  69. }
  70. /**
  71. * Get the application path and request URL
  72. */
  73. if (empty($uri) && defined('BASE_URL')) {
  74. $uri = setUri();
  75. if ($uri === '/' || $uri === '/index.php' || $uri === '/'.APP_DIR.'/') {
  76. $_GET['url'] = '/';
  77. $url = '/';
  78. } else {
  79. if (strpos($uri, 'index.php') !== false) {
  80. $uri = r('?', '', $uri);
  81. $elements = explode('/index.php', $uri);
  82. } elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) {
  83. $elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri));
  84. } else {
  85. $elements = array();
  86. }
  87. if (!empty($elements[1])) {
  88. $_GET['url'] = $elements[1];
  89. $url = $elements[1];
  90. } else {
  91. $url = $_GET['url'] = '/';
  92. }
  93. if (strpos($url, '/') === 0 && $url != '/') {
  94. $url = $_GET['url'] = substr($url, 1);
  95. }
  96. }
  97. } else {
  98. if (empty($_GET['url'])) {
  99. $url = null;
  100. } else {
  101. $url = $_GET['url'];
  102. }
  103. }
  104. if (strpos($url, 'ccss/') === 0) {
  105. include WWW_ROOT . DS . 'css.php';
  106. exit();
  107. }
  108. $folders = array('js' => 'text/javascript', 'css' => 'text/css');
  109. $requestPath = explode('/', $url);
  110. if (in_array($requestPath[0], array_keys($folders))) {
  111. if (file_exists(VENDORS . join(DS, $requestPath))) {
  112. header('Content-type: ' . $folders[$requestPath[0]]);
  113. include (VENDORS . join(DS, $requestPath));
  114. exit();
  115. }
  116. }
  117. require CAKE . 'dispatcher.php';
  118. if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
  119. if (empty($uri)) {
  120. $uri = setUri();
  121. }
  122. $filename = CACHE . 'views' . DS . convertSlash($uri) . '.php';
  123. if (file_exists($filename)) {
  124. uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
  125. $v = null;
  126. $view = new View($v);
  127. $view->renderCache($filename, $TIME_START);
  128. } elseif(file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
  129. uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
  130. $v = null;
  131. $view = new View($v);
  132. $view->renderCache(CACHE . 'views' . DS . convertSlash($uri) . '_index.php', $TIME_START);
  133. }
  134. }
  135. ?>