Init 1.0 codes
This commit is contained in:
89
admin/debug_redirect.php
Normal file
89
admin/debug_redirect.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// 设置错误报告级别以查看详细错误
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// 记录重定向链
|
||||
session_start();
|
||||
if (!isset($_SESSION['redirect_chain'])) {
|
||||
$_SESSION['redirect_chain'] = [];
|
||||
}
|
||||
|
||||
// 获取当前文件名
|
||||
$current_file = basename($_SERVER['PHP_SELF']);
|
||||
|
||||
// 添加到重定向链
|
||||
if (!in_array($current_file, $_SESSION['redirect_chain'])) {
|
||||
$_SESSION['redirect_chain'][] = $current_file;
|
||||
}
|
||||
|
||||
// 如果重定向链太长,说明存在循环重定向
|
||||
if (count($_SESSION['redirect_chain']) > 5) {
|
||||
echo '<!DOCTYPE html><html><head><title>循环重定向检测</title></head><body>';
|
||||
echo '<h1>检测到循环重定向!</h1>';
|
||||
echo '<p>重定向链:' . implode(' -> ', $_SESSION['redirect_chain']) . '</p>';
|
||||
echo '<p>请查看以下详细信息来排查问题:</p>';
|
||||
|
||||
// 输出会话信息
|
||||
echo '<h2>会话信息</h2>';
|
||||
echo '<pre>';
|
||||
print_r($_SESSION);
|
||||
echo '</pre>';
|
||||
|
||||
// 尝试加载配置文件
|
||||
echo '<h2>配置文件检测</h2>';
|
||||
if (file_exists('../config.php')) {
|
||||
echo 'config.php 文件存在<br>';
|
||||
// 尝试加载配置但捕获错误
|
||||
try {
|
||||
require_once '../config.php';
|
||||
echo '配置文件加载成功<br>';
|
||||
|
||||
// 检查管理员账户配置
|
||||
echo '<h3>管理员账户配置</h3>';
|
||||
if (isset($admin_accounts) && is_array($admin_accounts)) {
|
||||
echo '找到 ' . count($admin_accounts) . ' 个管理员账户<br>';
|
||||
foreach ($admin_accounts as $account) {
|
||||
echo '用户名: ' . $account['username'] . ', 权限: ' . $account['permission'] . '<br>';
|
||||
}
|
||||
} else {
|
||||
echo '未找到管理员账户配置<br>';
|
||||
}
|
||||
|
||||
// 检查数据库连接
|
||||
echo '<h3>数据库连接</h3>';
|
||||
if (isset($conn) && $conn instanceof mysqli) {
|
||||
echo '数据库连接对象存在<br>';
|
||||
if ($conn->ping()) {
|
||||
echo '数据库连接成功<br>';
|
||||
} else {
|
||||
echo '数据库连接失败: ' . $conn->error . '<br>';
|
||||
}
|
||||
} else {
|
||||
echo '数据库连接对象不存在<br>';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo '配置文件加载错误: ' . $e->getMessage() . '<br>';
|
||||
}
|
||||
} else {
|
||||
echo 'config.php 文件不存在<br>';
|
||||
}
|
||||
|
||||
// 重置重定向链
|
||||
echo '<h2>修复选项</h2>';
|
||||
echo '<a href="?reset=1">重置重定向链</a>';
|
||||
|
||||
if (isset($_GET['reset']) && $_GET['reset'] == 1) {
|
||||
unset($_SESSION['redirect_chain']);
|
||||
echo '<script>alert("重定向链已重置"); window.location.href = "login.php";</script>';
|
||||
}
|
||||
|
||||
echo '</body></html>';
|
||||
exit;
|
||||
}
|
||||
|
||||
// 正常情况:重定向到登录页面进行测试
|
||||
echo '<!DOCTYPE html><html><head><title>重定向调试</title></head><body>';
|
||||
echo '<p>正在重定向到登录页面进行测试...</p>';
|
||||
echo '<script>setTimeout(function(){ window.location.href = "login.php"; }, 1000);</script>';
|
||||
echo '</body></html>';
|
||||
Reference in New Issue
Block a user