feat(admin): 替换alert为Swal弹窗并优化样式
refactor: 统一代码缩进和格式化 style: 优化CSS样式和代码可读性
This commit is contained in:
@@ -87,10 +87,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: index.php?success=App 添加成功');
|
echo '<script>Swal.fire("成功", "App 添加成功", "success").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = 'App 添加失败: '. $conn->error;
|
echo '<script>Swal.fire("错误", "App 添加失败: '. $conn->error .'", "error");</script>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$stmt = $conn->prepare('INSERT INTO announcements (title, content, admin_id) VALUES (?, ?, ?)');
|
$stmt = $conn->prepare('INSERT INTO announcements (title, content, admin_id) VALUES (?, ?, ?)');
|
||||||
$stmt->bind_param('ssi', $title, $content, $admin_id);
|
$stmt->bind_param('ssi', $title, $content, $admin_id);
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
header('Location: announcements.php?success=公告发布成功');
|
echo '<script>Swal.fire("成功", "公告发布成功", "success").then(() => { window.location.reload(); });</script>';
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = '公告发布失败: ' . $conn->error;
|
echo '<script>Swal.fire("错误", "公告发布失败: ' . $conn->error . '", "error");</script>';
|
||||||
}
|
}
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
} else {
|
} else {
|
||||||
$error = '标题和内容不能为空';
|
echo '<script>Swal.fire("错误", "标题和内容不能为空", "error");</script>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) {
|
|||||||
|
|
||||||
// 验证App ID
|
// 验证App ID
|
||||||
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||||
header('Location: index.php?error=无效的App ID');
|
echo '<script>Swal.fire("错误", "无效的App ID", "error").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$appId = $_GET['id'];
|
$appId = $_GET['id'];
|
||||||
@@ -33,9 +33,9 @@ if ($stmt->execute() === TRUE) {
|
|||||||
$verStmt->bind_param("i", $appId);
|
$verStmt->bind_param("i", $appId);
|
||||||
$verStmt->execute();
|
$verStmt->execute();
|
||||||
|
|
||||||
header('Location: index.php?success=App 删除成功');
|
echo '<script>Swal.fire("成功", "App 删除成功", "success").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
} else {
|
} else {
|
||||||
header('Location: index.php?error=App 删除失败: '. $conn->error);
|
echo '<script>Swal.fire("错误", "App 删除失败: '. $conn->error .'", "error").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
||||||
@@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) {
|
|||||||
|
|
||||||
// 验证App ID
|
// 验证App ID
|
||||||
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||||
header('Location: index.php?error=无效的App ID');
|
echo '<script>Swal.fire("错误", "无效的App ID", "error").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$appId = $_GET['id'];
|
$appId = $_GET['id'];
|
||||||
@@ -23,7 +23,7 @@ $stmt->bind_param("i", $appId);
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
if ($result->num_rows === 0) {
|
if ($result->num_rows === 0) {
|
||||||
header('Location: index.php?error=App不存在');
|
echo '<script>Swal.fire("错误", "App不存在", "error").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$app = $result->fetch_assoc();
|
$app = $result->fetch_assoc();
|
||||||
@@ -99,10 +99,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
|
|||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: index.php?success=App 更新成功');
|
$updateAppSql = "UPDATE apps SET name = ?, description = ?, age_rating = ?, platforms = ? WHERE id = ?";
|
||||||
|
$updateStmt = $conn->prepare($updateAppSql);
|
||||||
|
$updateStmt->bind_param("ssssi", $name, $description, $ageRating, $newPlatforms, $appId);
|
||||||
|
if ($updateStmt->execute() === TRUE) {
|
||||||
|
echo '<script>Swal.fire("成功", "App 更新成功", "success").then(() => { window.location.href = "index.php"; });</script>';
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = 'App 更新失败: '. $conn->error;
|
echo '<script>Swal.fire("错误", "App 更新失败: '. $conn->error .'", "error");</script>';
|
||||||
|
}
|
||||||
|
$updateStmt->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -391,5 +397,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
|
|||||||
$stmt = $conn->prepare("UPDATE apps SET name=?, description=?, age_rating=?, age_rating_description=?, platforms=?, updated_at=NOW() WHERE id=?");
|
$stmt = $conn->prepare("UPDATE apps SET name=?, description=?, age_rating=?, age_rating_description=?, platforms=?, updated_at=NOW() WHERE id=?");
|
||||||
$stmt->bind_param("sssssi", $name, $description, $age_rating, $_POST['age_rating_description'], $platformsJson, $appId);
|
$stmt->bind_param("sssssi", $name, $description, $age_rating, $_POST['age_rating_description'], $platformsJson, $appId);
|
||||||
|
|
||||||
// ... existing code ...
|
|
||||||
?>
|
?>
|
||||||
@@ -30,7 +30,7 @@ $resultApps = $conn->query($sqlApps);
|
|||||||
|
|
||||||
if (!$resultApps) {
|
if (!$resultApps) {
|
||||||
error_log("Database query failed: " . $conn->error);
|
error_log("Database query failed: " . $conn->error);
|
||||||
echo '<div class="alert alert-danger">获取App列表失败,请联系管理员。</div>';
|
echo '<script>Swal.fire("错误", "获取App列表失败,请联系管理员。", "error");</script>';
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -59,6 +59,7 @@ if (!$resultApps) {
|
|||||||
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||||
<!-- 自定义CSS -->
|
<!-- 自定义CSS -->
|
||||||
<link rel="stylesheet" href="../styles.css">
|
<link rel="stylesheet" href="../styles.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
<!-- Fluent Design 模糊效果 -->
|
<!-- Fluent Design 模糊效果 -->
|
||||||
<style>
|
<style>
|
||||||
.blur-bg {
|
.blur-bg {
|
||||||
@@ -104,13 +105,22 @@ if (!$resultApps) {
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
|
<script>
|
||||||
<?php if (isset($_GET['success'])): ?>
|
<?php if (isset($_GET['success'])): ?>
|
||||||
<div class="alert alert-success"><?php echo $_GET['success']; ?></div>
|
Swal.fire({
|
||||||
|
icon: "success",
|
||||||
|
title: "成功",
|
||||||
|
text: "<?php echo addslashes($_GET['success']); ?>",
|
||||||
|
});
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_GET['error'])): ?>
|
<?php if (isset($_GET['error'])): ?>
|
||||||
<div class="alert alert-danger"><?php echo $_GET['error']; ?></div>
|
Swal.fire({
|
||||||
|
icon: "error",
|
||||||
|
title: "错误",
|
||||||
|
text: "<?php echo addslashes($_GET['error']); ?>",
|
||||||
|
});
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
</script>
|
||||||
<h2>App列表</h2>
|
<h2>App列表</h2>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<a href="manage_tags.php" class="btn btn-info">标签管理</a>
|
<a href="manage_tags.php" class="btn btn-info">标签管理</a>
|
||||||
@@ -135,7 +145,19 @@ if (!$resultApps) {
|
|||||||
<td>
|
<td>
|
||||||
<a href="editapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-primary">编辑</a>
|
<a href="editapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-primary">编辑</a>
|
||||||
<a href="manage_versions.php?app_id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-secondary">版本管理</a>
|
<a href="manage_versions.php?app_id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-secondary">版本管理</a>
|
||||||
<a href="deleteapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('确定要删除吗?');">删除</a>
|
<a href="deleteapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="event.preventDefault(); Swal.fire({
|
||||||
|
title: '确定要删除吗?',
|
||||||
|
text: '删除后将无法恢复!',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#d33',
|
||||||
|
cancelButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: '确定删除'
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
window.location.href = this.href;
|
||||||
|
}
|
||||||
|
});">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endwhile; ?>
|
<?php endwhile; ?>
|
||||||
|
|||||||
162
admin/login.php
162
admin/login.php
@@ -4,37 +4,8 @@ require_once '../config.php';
|
|||||||
// 检查管理员登录状态
|
// 检查管理员登录状态
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// 顶栏样式
|
|
||||||
echo '<style>
|
|
||||||
.navbar.scrolled {
|
|
||||||
background-color: rgba(255, 255, 255, 0.95) !important;
|
|
||||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
</style>';
|
|
||||||
|
|
||||||
// 导航栏
|
|
||||||
echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" href="../index.php">'. APP_STORE_NAME . '</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="../index.php">首页</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="index.php">管理后台</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>';
|
|
||||||
|
|
||||||
// 为内容添加顶部内边距
|
|
||||||
echo '<div style="padding-top: 70px;">';
|
|
||||||
if (!isset($_SESSION['admin'])) {
|
if (!isset($_SESSION['admin'])) {
|
||||||
|
$error = '';
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) {
|
||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
@@ -50,62 +21,89 @@ if (!isset($_SESSION['admin'])) {
|
|||||||
$error = '用户名或密码错误';
|
$error = '用户名或密码错误';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>管理员登录 - <?php echo APP_STORE_NAME; ?></title>
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<!-- 自定义CSS -->
|
||||||
|
<link rel="stylesheet" href="../styles.css">
|
||||||
|
<!-- 顶栏样式 -->
|
||||||
|
<style>
|
||||||
|
.navbar.scrolled {
|
||||||
|
background-color: rgba(255, 255, 255, 0.95) !important;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.blur-bg {
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 导航栏 -->
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="../index.php"><?php echo APP_STORE_NAME; ?></a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="../index.php">首页</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="index.php">管理后台</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
// 显示登录表单
|
<!-- 为内容添加顶部内边距 -->
|
||||||
echo '<!DOCTYPE html>';
|
<div style="padding-top: 70px;">
|
||||||
echo '<html lang="zh-CN">';
|
<div class="container mt-5">
|
||||||
echo '<head>';
|
<div class="row justify-content-center">
|
||||||
echo ' <meta charset="UTF-8">';
|
<div class="col-md-6">
|
||||||
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">';
|
<div class="card blur-bg">
|
||||||
echo ' <title>管理员登录 - '. APP_STORE_NAME . '</title>';
|
<div class="card-header">管理员登录</div>
|
||||||
echo ' <!-- Bootstrap CSS -->';
|
<div class="card-body">
|
||||||
echo ' <link href="../css/bootstrap.min.css" rel="stylesheet">';
|
<?php if (isset($error)): ?>
|
||||||
echo ' <!-- 自定义CSS -->';
|
<script>
|
||||||
echo ' <link rel="stylesheet" href="../styles.css">';
|
|
||||||
echo ' <!-- Fluent Design 模糊效果 -->';
|
|
||||||
echo ' <style>';
|
|
||||||
echo ' .blur-bg {';
|
|
||||||
echo ' backdrop-filter: blur(10px);';
|
|
||||||
echo ' background-color: rgba(255, 255, 255, 0.5);';
|
|
||||||
echo ' }';
|
|
||||||
echo ' </style>';
|
|
||||||
echo '</head>';
|
|
||||||
echo '<body>';
|
|
||||||
echo ' <div class="container mt-5">';
|
|
||||||
echo ' <div class="row justify-content-center">';
|
|
||||||
echo ' <div class="col-md-6">';
|
|
||||||
echo ' <div class="card blur-bg">';
|
|
||||||
echo ' <div class="card-header">管理员登录</div>';
|
|
||||||
echo ' <div class="card-body">';
|
|
||||||
if (isset($error)) {
|
|
||||||
echo '<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>';
|
|
||||||
echo '<script>
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: "error",
|
icon: "error",
|
||||||
title: "错误",
|
title: "错误",
|
||||||
text: "'. addslashes($error) . '",
|
text: "<?php echo addslashes($error); ?>",
|
||||||
});
|
});
|
||||||
</script>';
|
</script>
|
||||||
}
|
<?php endif; ?>
|
||||||
echo ' <form method="post">';
|
<form method="post">
|
||||||
echo ' <div class="mb-3">';
|
<div class="mb-3">
|
||||||
echo ' <label for="username" class="form-label">用户名</label>';
|
<label for="username" class="form-label">用户名</label>
|
||||||
echo ' <input type="text" class="form-control" id="username" name="username" required>';
|
<input type="text" class="form-control" id="username" name="username" required>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' <div class="mb-3">';
|
<div class="mb-3">
|
||||||
echo ' <label for="password" class="form-label">密码</label>';
|
<label for="password" class="form-label">密码</label>
|
||||||
echo ' <input type="password" class="form-control" id="password" name="password" required>';
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' <button type="submit" class="btn btn-primary">登录</button>';
|
<button type="submit" class="btn btn-primary">登录</button>
|
||||||
echo ' </form>';
|
</form>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' </div>';
|
</div>
|
||||||
echo ' <!-- Bootstrap JS Bundle with Popper -->';
|
</div>
|
||||||
echo ' <script src="/js/bootstrap.bundle.js"></script>';
|
<!-- Bootstrap JS Bundle with Popper -->
|
||||||
echo '</body>';
|
<script src="/js/bootstrap.bundle.js"></script>
|
||||||
echo '</html>';
|
</body>
|
||||||
|
</html>
|
||||||
|
<?php
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
require_once '../config.php';
|
require_once '../config.php';
|
||||||
|
|
||||||
// 删除文件
|
// 删除文件
|
||||||
function delete_file($file_path) {
|
function delete_file($file_path) {
|
||||||
if (file_exists($file_path)) {
|
if (file_exists($file_path)) {
|
||||||
return unlink($file_path);
|
return unlink($file_path);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理删除请求
|
// 处理删除请求
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$upload_dirs = [
|
$upload_dirs = [
|
||||||
'../uploads/apps',
|
'../uploads/apps',
|
||||||
'../uploads/images'
|
'../uploads/images'
|
||||||
@@ -47,16 +47,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证管理员权限
|
// 验证管理员权限
|
||||||
if (!isset($_SESSION['admin'])) {
|
if (!isset($_SESSION['admin'])) {
|
||||||
header('Location: login.php');
|
header('Location: login.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取上传文件和图片信息
|
// 获取上传文件和图片信息
|
||||||
function get_uploaded_files_info() {
|
function get_uploaded_files_info() {
|
||||||
$uploaded_files = [];
|
$uploaded_files = [];
|
||||||
|
|
||||||
// 上传目录配置
|
// 上传目录配置
|
||||||
@@ -85,9 +85,9 @@ function get_uploaded_files_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $uploaded_files;
|
return $uploaded_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uploaded_files = get_uploaded_files_info();
|
$uploaded_files = get_uploaded_files_info();
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
@@ -105,7 +105,7 @@ $uploaded_files = get_uploaded_files_info();
|
|||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="index.php">管理员面板</a>
|
<a class="navbar-brand" href="index.php">管理员面板</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
<!-- Font Awesome -->
|
<!-- Font Awesome -->
|
||||||
<link rel="stylesheet" href="/css/all.min.css">
|
<link rel="stylesheet" href="/css/all.min.css">
|
||||||
<style>
|
<style>
|
||||||
body { padding-top: 56px; }
|
body {
|
||||||
|
padding-top: 56px;
|
||||||
|
}
|
||||||
.blur-bg {
|
.blur-bg {
|
||||||
backdrop-filter: blur(10px);
|
backdrop-filter: blur(10px);
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
|
|||||||
72
download.php
72
download.php
@@ -1,54 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
ob_start();
|
ob_start();
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
// 验证版本ID
|
// 验证版本ID
|
||||||
if (!isset($_GET['version_id']) || !is_numeric($_GET['version_id'])) {
|
if (!isset($_GET['version_id']) || !is_numeric($_GET['version_id'])) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
exit('无效的版本ID');
|
exit('无效的版本ID');
|
||||||
}
|
}
|
||||||
$versionId = $_GET['version_id'];
|
$versionId = $_GET['version_id'];
|
||||||
|
|
||||||
// 获取版本信息
|
// 获取版本信息
|
||||||
$version = null;
|
$version = null;
|
||||||
$getVersionSql = "SELECT * FROM app_versions WHERE id = ?";
|
$getVersionSql = "SELECT * FROM app_versions WHERE id = ?";
|
||||||
$stmt = $conn->prepare($getVersionSql);
|
$stmt = $conn->prepare($getVersionSql);
|
||||||
$stmt->bind_param("i", $versionId);
|
$stmt->bind_param("i", $versionId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
if ($result->num_rows !== 1) {
|
if ($result->num_rows !== 1) {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
exit('版本不存在');
|
exit('版本不存在');
|
||||||
}
|
}
|
||||||
$version = $result->fetch_assoc();
|
$version = $result->fetch_assoc();
|
||||||
|
|
||||||
// 获取绝对文件路径
|
// 获取绝对文件路径
|
||||||
$filePath = realpath(__DIR__ . '/' . $version['file_path']);
|
$filePath = realpath(__DIR__ . '/' . $version['file_path']);
|
||||||
|
|
||||||
// 验证文件存在性
|
// 验证文件存在性
|
||||||
if (!$filePath || !file_exists($filePath)) {
|
if (!$filePath || !file_exists($filePath)) {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
exit('文件不存在');
|
exit('文件不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置下载响应头
|
// 设置下载响应头
|
||||||
$fileName = basename($filePath);
|
$fileName = basename($filePath);
|
||||||
$fileSize = filesize($filePath);
|
$fileSize = filesize($filePath);
|
||||||
|
|
||||||
// 清除输出缓冲区并发送 headers
|
// 清除输出缓冲区并发送 headers
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($fileName));
|
header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($fileName));
|
||||||
header('Content-Length: ' . $fileSize);
|
header('Content-Length: ' . $fileSize);
|
||||||
header('Cache-Control: no-cache, must-revalidate');
|
header('Cache-Control: no-cache, must-revalidate');
|
||||||
header('Expires: 0');
|
header('Expires: 0');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
|
|
||||||
// 输出文件内容
|
// 输出文件内容
|
||||||
if (!readfile($filePath)) {
|
if (!readfile($filePath)) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
exit('无法读取文件');
|
exit('无法读取文件');
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
||||||
@@ -6,10 +6,30 @@
|
|||||||
<title>404 - 页面未找到</title>
|
<title>404 - 页面未找到</title>
|
||||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f8f9fa; }
|
body {
|
||||||
.error-container { text-align: center; padding: 2rem; background-color: white; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
|
display: flex;
|
||||||
h1 { font-size: 5rem; margin: 0; color: #6c757d; }
|
justify-content: center;
|
||||||
p { font-size: 1.2rem; margin: 1rem 0; }
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
.error-container {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 5rem;
|
||||||
|
margin: 0;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -6,10 +6,30 @@
|
|||||||
<title>500 - 服务器内部错误</title>
|
<title>500 - 服务器内部错误</title>
|
||||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f8f9fa; }
|
body {
|
||||||
.error-container { text-align: center; padding: 2rem; background-color: white; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
|
display: flex;
|
||||||
h1 { font-size: 5rem; margin: 0; color: #dc3545; }
|
justify-content: center;
|
||||||
p { font-size: 1.2rem; margin: 1rem 0; }
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
.error-container {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 5rem;
|
||||||
|
margin: 0;
|
||||||
|
color: #dc3545;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
32
router.php
32
router.php
@@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
// 路由脚本,用于PHP内置服务器
|
// 路由脚本,用于PHP内置服务器
|
||||||
// 将所有/api开头的请求转发到api.php
|
// 将所有/api开头的请求转发到api.php
|
||||||
|
|
||||||
// 顶栏样式
|
// 顶栏样式
|
||||||
echo '<style>
|
echo '<style>
|
||||||
.navbar.scrolled {
|
.navbar.scrolled {
|
||||||
background-color: rgba(255, 255, 255, 0.95) !important;
|
background-color: rgba(255, 255, 255, 0.95) !important;
|
||||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
</style>';
|
</style>';
|
||||||
|
|
||||||
// 导航栏
|
// 导航栏
|
||||||
echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
|
echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="index.php">'. APP_STORE_NAME . '</a>
|
<a class="navbar-brand" href="index.php">'. APP_STORE_NAME . '</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
@@ -25,14 +25,14 @@ echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>';
|
</nav>';
|
||||||
|
|
||||||
// 为内容添加顶部内边距
|
// 为内容添加顶部内边距
|
||||||
echo '<div style="padding-top: 70px;">';
|
echo '<div style="padding-top: 70px;">';
|
||||||
if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) {
|
if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) {
|
||||||
include 'api.php';
|
include 'api.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 其他请求按正常方式处理
|
// 其他请求按正常方式处理
|
||||||
return false;
|
return false;
|
||||||
Reference in New Issue
Block a user