liuhairui před 3 dny
rodič
revize
1f206f3cf8
1 změnil soubory, kde provedl 23 přidání a 0 odebrání
  1. 23 0
      public/index.php

+ 23 - 0
public/index.php

@@ -13,6 +13,29 @@
 // 定义应用目录
 define('APP_PATH', __DIR__ . '/../application/');
 
+// 无路由时可选跳转到后台入口(见 application/extra/public_entry.php)
+$__pef = APP_PATH . 'extra/public_entry.php';
+if (is_file($__pef)) {
+    $__pe = include $__pef;
+    if (is_array($__pe) && !empty($__pe['index_bare_redirect_to_admin'])) {
+        $__adm = isset($__pe['admin_bootstrap']) ? basename((string)$__pe['admin_bootstrap']) : '';
+        if ($__adm !== '' && is_file(__DIR__ . '/' . $__adm)) {
+            $__pi = isset($_SERVER['PATH_INFO']) ? trim((string)$_SERVER['PATH_INFO'], '/') : '';
+            $__s = isset($_GET['s']) ? trim((string)$_GET['s'], '/') : '';
+            if ($__pi === '' && $__s === '' && (!isset($_GET['to']) || (string)$_GET['to'] !== 'frontend')) {
+                $__dir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '/'));
+                if ($__dir === '/' || $__dir === '\\' || $__dir === '.') {
+                    $__dir = '';
+                }
+                $__loc = rtrim($__dir, '/') . '/' . $__adm;
+                header('Location: ' . $__loc, true, 302);
+                exit;
+            }
+        }
+    }
+}
+unset($__pef, $__pe, $__adm, $__pi, $__s, $__dir, $__loc);
+
 // 判断是否安装
 if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) {
     header("location:./install.php");