index.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. if ($__pi === '' && $__s === '' && (!isset($_GET['to']) || (string)$_GET['to'] !== 'frontend')) {
  24. $__dir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '/'));
  25. if ($__dir === '/' || $__dir === '\\' || $__dir === '.') {
  26. $__dir = '';
  27. }
  28. $__loc = rtrim($__dir, '/') . '/' . $__adm;
  29. header('Location: ' . $__loc, true, 302);
  30. exit;
  31. }
  32. }
  33. }
  34. }
  35. unset($__pef, $__pe, $__adm, $__pi, $__s, $__dir, $__loc);
  36. // 判断是否安装
  37. if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) {
  38. header("location:./install.php");
  39. exit;
  40. }
  41. // 加载框架引导文件
  42. require __DIR__ . '/../thinkphp/start.php';