index.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // [ 应用入口文件 ]
  12. namespace think;
  13. $server = isset($_REQUEST['server']) || isset($_SERVER['HTTP_SERVER']) || substr($_SERVER['REQUEST_URI'], 1, 9) == 'index.php' || $_SERVER['REQUEST_METHOD'] == 'OPTIONS';
  14. if (!$server) {
  15. /*
  16. * 用户访问前端
  17. * 不在tp加载后判断,为了安全的使用 exit()(常驻内存运行时不走本文件)
  18. */
  19. $rootPath = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
  20. // 安装检测-s
  21. if (!is_file($rootPath . 'install.lock') && is_file($rootPath . 'install' . DIRECTORY_SEPARATOR . 'index.html')) {
  22. header("location:" . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR);
  23. exit();
  24. }
  25. // 安装检测-e
  26. // 检测是否已编译前端(如果存在 index.html,则访问)-s
  27. if (is_file($rootPath . 'index.html')) {
  28. header("location:" . DIRECTORY_SEPARATOR . 'index.html');
  29. exit();
  30. }
  31. // 检测是否已编译前端-e
  32. }
  33. require __DIR__ . '/../vendor/autoload.php';
  34. // 执行HTTP应用并响应
  35. $http = (new App())->http;
  36. $response = $http->run();
  37. $response->send();
  38. $http->end($response);