boot.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | utf-8
  5. |--------------------------------------------------------------------------
  6. */
  7. header('Content-Type: text/html; charset=utf-8');
  8. /*
  9. |--------------------------------------------------------------------------
  10. | default hostname
  11. |--------------------------------------------------------------------------
  12. */
  13. if(!isset($_SERVER['MAZEPHP_SERVER']))
  14. {
  15. $_SERVER['MAZEPHP_SERVER'] = 'localhost';
  16. }
  17. /*
  18. |--------------------------------------------------------------------------
  19. | date rpc
  20. |--------------------------------------------------------------------------
  21. */
  22. date_default_timezone_set("PRC");
  23. /*
  24. |--------------------------------------------------------------------------
  25. | start time
  26. |--------------------------------------------------------------------------
  27. */
  28. define('MAZE_START', microtime());
  29. /*
  30. |--------------------------------------------------------------------------
  31. | maze time
  32. |--------------------------------------------------------------------------
  33. */
  34. define('MAZE_TIME', $_SERVER['REQUEST_TIME']);
  35. /*
  36. |--------------------------------------------------------------------------
  37. | maze path
  38. |--------------------------------------------------------------------------
  39. */
  40. define('MAZE_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
  41. /*
  42. |--------------------------------------------------------------------------
  43. | maze project host
  44. |--------------------------------------------------------------------------
  45. */
  46. if(isset($_SERVER['HTTP_HOST']))
  47. {
  48. define('MAZE_PROJECT_HOST', 'http://' . $_SERVER['HTTP_HOST'] . ($_SERVER['SCRIPT_NAME'] ? substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], 'index.php')) : DIRECTORY_SEPARATOR));
  49. }
  50. else
  51. {
  52. define('MAZE_PROJECT_HOST', '');
  53. }
  54. /*
  55. |--------------------------------------------------------------------------
  56. | autoload
  57. |--------------------------------------------------------------------------
  58. */
  59. require __DIR__ . '/vendor/autoload.php';
  60. /*
  61. |--------------------------------------------------------------------------
  62. | load base config
  63. |--------------------------------------------------------------------------
  64. */
  65. Maze\Config\Load::get('base');
  66. /*
  67. |--------------------------------------------------------------------------
  68. | maze project name
  69. |--------------------------------------------------------------------------
  70. */
  71. if(!defined('MAZE_PROJECT_NAME'))
  72. {
  73. $temp = explode(Maze\Config\Load::$global['base']['path'], MAZE_PROJECT_PATH);
  74. define('MAZE_PROJECT_NAME', chop(str_replace(DIRECTORY_SEPARATOR, '_', end($temp)), '_'));
  75. }
  76. /*
  77. |--------------------------------------------------------------------------
  78. | maze header cache
  79. |--------------------------------------------------------------------------
  80. */
  81. if(isset(Maze\Config\Load::$global['base']['header-cache']) && Maze\Config\Load::$global['base']['header-cache'] == true)
  82. {
  83. header("Expires: -1");
  84. header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  85. header("Pragma: no-cache");
  86. }
  87. /*
  88. |--------------------------------------------------------------------------
  89. | load host config
  90. |--------------------------------------------------------------------------
  91. */
  92. Maze\Config\Load::get('host');
  93. /*
  94. |--------------------------------------------------------------------------
  95. | load debug config
  96. |--------------------------------------------------------------------------
  97. */
  98. Maze\Config\Load::get('debug');
  99. if(Maze\Config\Load::$global['debug']['error'])
  100. {
  101. /*
  102. |----------------------------------------------------------------------
  103. | error
  104. |----------------------------------------------------------------------
  105. */
  106. ini_set('display_errors', true);
  107. }
  108. /*
  109. |--------------------------------------------------------------------------
  110. | project register
  111. |--------------------------------------------------------------------------
  112. */
  113. Maze\Config\Project::register();
  114. /*
  115. |--------------------------------------------------------------------------
  116. | route
  117. |--------------------------------------------------------------------------
  118. */
  119. $route = new Maze\Routing\Route;
  120. /*
  121. |--------------------------------------------------------------------------
  122. | route run and out
  123. |--------------------------------------------------------------------------
  124. */
  125. if(!defined('MAZE_DAEMON'))
  126. {
  127. $route->runing()->output();
  128. }
  129. /*
  130. |--------------------------------------------------------------------------
  131. | user cron
  132. |--------------------------------------------------------------------------
  133. */
  134. if(isset(Maze\Config\Load::$global['base']['cron']) && Maze\Config\Load::$global['base']['cron'] == true && MAZE_TIME%2 == 0)
  135. {
  136. Maze::load('manage/project.cron');
  137. }