index.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 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. // 定义应用目录
  13. define('APP_PATH', __DIR__ . '/../application/');
  14. // 无路由时可选跳转到后台入口(见 application/extra/public_entry.php)
  15. $__pef = APP_PATH . 'extra/public_entry.php';
  16. if (is_file($__pef)) {
  17. $__pe = include $__pef;
  18. if (is_array($__pe) && !empty($__pe['index_bare_redirect_to_admin'])) {
  19. $__adm = isset($__pe['admin_bootstrap']) ? basename((string)$__pe['admin_bootstrap']) : '';
  20. if ($__adm !== '' && is_file(__DIR__ . '/' . $__adm)) {
  21. $__pi = isset($_SERVER['PATH_INFO']) ? trim((string)$_SERVER['PATH_INFO'], '/') : '';
  22. $__s = isset($_GET['s']) ? trim((string)$_GET['s'], '/') : '';
  23. // 带任意 GET(如 addtabs、sort、offset)多为 index 模块 Ajax,不可 302 到后台,否则表格等请求失败
  24. if ($__pi === '' && $__s === '' && empty($_GET)) {
  25. $__dir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '/'));
  26. if ($__dir === '/' || $__dir === '\\' || $__dir === '.') {
  27. $__dir = '';
  28. }
  29. $__loc = rtrim($__dir, '/') . '/' . $__adm;
  30. header('Location: ' . $__loc, true, 302);
  31. exit;
  32. }
  33. }
  34. }
  35. }
  36. unset($__pef, $__pe, $__adm, $__pi, $__s, $__dir, $__loc);
  37. // 判断是否安装
  38. if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) {
  39. header("location:./install.php");
  40. exit;
  41. }
  42. // 加载框架引导文件
  43. require __DIR__ . '/../thinkphp/start.php';