boot.php 4.3 KB

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