index.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. if (version_compare(PHP_VERSION, '7.4.0', '<'))
  14. die('require PHP > 7.4.0 !');
  15. // 检测PHP环境 允许前端跨域请求
  16. header("Access-Control-Allow-Origin:*");
  17. // 响应类型
  18. header('Access-Control-Allow-Methods:GET, POST, PUT, DELETE');
  19. // 响应头设置
  20. header('Access-Control-Allow-Headers:x-requested-with, content-type');
  21. if (!file_exists('./install.lock')) {
  22. header('location: ./install.php');
  23. exit();
  24. }
  25. $query_string = $_SERVER['REQUEST_URI'];
  26. if(!empty($query_string))
  27. {
  28. $file_ext = substr($query_string, -3);
  29. $array = [ 'jpg', 'png', 'css', '.js', 'txt', 'doc', 'ocx', 'peg' ];
  30. if (in_array($file_ext, $array)) {
  31. exit();
  32. }
  33. $query_string_array = explode('/', $query_string);
  34. $app_name = $query_string_array[1] ?? '';
  35. switch ($app_name) {
  36. case 'h5':
  37. echo file_get_contents('./h5/index.html');exit();
  38. case 'web':
  39. echo file_get_contents('./web/index.html');exit();
  40. case 'mshop':
  41. echo file_get_contents('./mshop/index.html');exit();
  42. case 'cashregister':
  43. echo file_get_contents('./cashregister/index.html');exit();
  44. }
  45. }
  46. require __DIR__ . '/vendor/autoload.php';
  47. // 执行HTTP应用并响应
  48. $http = (new App())->http;
  49. $response = $http->run();
  50. $response->send();
  51. $http->end($response);