bootstrap.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. * Check for IIS Server
  52. */
  53. if (!defined('SERVER_IIS') && php_sapi_name() == 'isapi') {
  54. define('SERVER_IIS', true);
  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. } elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) {
  69. $elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri));
  70. } else {
  71. $elements = array();
  72. }
  73. if (!empty($elements[1])) {
  74. $_GET['url'] = $elements[1];
  75. $url = $elements[1];
  76. } else {
  77. $url = $_GET['url'] = '/';
  78. }
  79. if (strpos($url, '/') === 0 && $url != '/') {
  80. $url = $_GET['url'] = substr($url, 1);
  81. }
  82. }
  83. } else {
  84. if (empty($_GET['url'])) {
  85. $url = null;
  86. } else {
  87. $url = $_GET['url'];
  88. }
  89. }
  90. if (strpos($url, 'ccss/') === 0) {
  91. include WWW_ROOT . DS . 'css.php';
  92. exit();
  93. }
  94. $folders = array('js' => 'text/javascript', 'css' => 'text/css');
  95. $requestPath = explode('/', $url);
  96. if (in_array($requestPath[0], array_keys($folders))) {
  97. if (file_exists(VENDORS . join(DS, $requestPath))) {
  98. header('Content-type: ' . $folders[$requestPath[0]]);
  99. include (VENDORS . join(DS, $requestPath));
  100. exit();
  101. }
  102. }
  103. require CAKE . 'dispatcher.php';
  104. if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
  105. if (empty($uri)) {
  106. $uri = setUri();
  107. }
  108. $filename = CACHE . 'views' . DS . convertSlash($uri) . '.php';
  109. if (file_exists($filename)) {
  110. uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
  111. $v = null;
  112. $view = new View($v);
  113. $view->renderCache($filename, $TIME_START);
  114. } elseif(file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
  115. uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
  116. $v = null;
  117. $view = new View($v);
  118. $view->renderCache(CACHE . 'views' . DS . convertSlash($uri) . '_index.php', $TIME_START);
  119. }
  120. }
  121. ?>