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;
|
||||
} 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->bind_param('ssi', $title, $content, $admin_id);
|
||||
if ($stmt->execute()) {
|
||||
header('Location: announcements.php?success=公告发布成功');
|
||||
echo '<script>Swal.fire("成功", "公告发布成功", "success").then(() => { window.location.reload(); });</script>';
|
||||
exit;
|
||||
} else {
|
||||
$error = '公告发布失败: ' . $conn->error;
|
||||
echo '<script>Swal.fire("错误", "公告发布失败: ' . $conn->error . '", "error");</script>';
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
$error = '标题和内容不能为空';
|
||||
echo '<script>Swal.fire("错误", "标题和内容不能为空", "error");</script>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) {
|
||||
|
||||
// 验证App 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;
|
||||
}
|
||||
$appId = $_GET['id'];
|
||||
@@ -33,9 +33,9 @@ if ($stmt->execute() === TRUE) {
|
||||
$verStmt->bind_param("i", $appId);
|
||||
$verStmt->execute();
|
||||
|
||||
header('Location: index.php?success=App 删除成功');
|
||||
echo '<script>Swal.fire("成功", "App 删除成功", "success").then(() => { window.location.href = "index.php"; });</script>';
|
||||
} 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;
|
||||
?>
|
||||
@@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) {
|
||||
|
||||
// 验证App 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;
|
||||
}
|
||||
$appId = $_GET['id'];
|
||||
@@ -23,7 +23,7 @@ $stmt->bind_param("i", $appId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
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;
|
||||
}
|
||||
$app = $result->fetch_assoc();
|
||||
@@ -99,11 +99,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
header('Location: index.php?success=App 更新成功');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'App 更新失败: '. $conn->error;
|
||||
}
|
||||
$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;
|
||||
} else {
|
||||
echo '<script>Swal.fire("错误", "App 更新失败: '. $conn->error .'", "error");</script>';
|
||||
}
|
||||
$updateStmt->close();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -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->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) {
|
||||
error_log("Database query failed: " . $conn->error);
|
||||
echo '<div class="alert alert-danger">获取App列表失败,请联系管理员。</div>';
|
||||
echo '<script>Swal.fire("错误", "获取App列表失败,请联系管理员。", "error");</script>';
|
||||
} else {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -59,6 +59,7 @@ if (!$resultApps) {
|
||||
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- 自定义CSS -->
|
||||
<link rel="stylesheet" href="../styles.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<!-- Fluent Design 模糊效果 -->
|
||||
<style>
|
||||
.blur-bg {
|
||||
@@ -104,13 +105,22 @@ if (!$resultApps) {
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<script>
|
||||
<?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 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; ?>
|
||||
|
||||
</script>
|
||||
<h2>App列表</h2>
|
||||
<div class="mb-3">
|
||||
<a href="manage_tags.php" class="btn btn-info">标签管理</a>
|
||||
@@ -135,7 +145,19 @@ if (!$resultApps) {
|
||||
<td>
|
||||
<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="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>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
|
||||
172
admin/login.php
172
admin/login.php
@@ -4,37 +4,8 @@ require_once '../config.php';
|
||||
// 检查管理员登录状态
|
||||
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'])) {
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
@@ -50,62 +21,89 @@ if (!isset($_SESSION['admin'])) {
|
||||
$error = '用户名或密码错误';
|
||||
}
|
||||
}
|
||||
|
||||
// 显示登录表单
|
||||
echo '<!DOCTYPE html>';
|
||||
echo '<html lang="zh-CN">';
|
||||
echo '<head>';
|
||||
echo ' <meta charset="UTF-8">';
|
||||
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">';
|
||||
echo ' <title>管理员登录 - '. APP_STORE_NAME . '</title>';
|
||||
echo ' <!-- Bootstrap CSS -->';
|
||||
echo ' <link href="../css/bootstrap.min.css" rel="stylesheet">';
|
||||
echo ' <!-- 自定义CSS -->';
|
||||
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({
|
||||
icon: "error",
|
||||
title: "错误",
|
||||
text: "'. addslashes($error) . '",
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
echo ' <form method="post">';
|
||||
echo ' <div class="mb-3">';
|
||||
echo ' <label for="username" class="form-label">用户名</label>';
|
||||
echo ' <input type="text" class="form-control" id="username" name="username" required>';
|
||||
echo ' </div>';
|
||||
echo ' <div class="mb-3">';
|
||||
echo ' <label for="password" class="form-label">密码</label>';
|
||||
echo ' <input type="password" class="form-control" id="password" name="password" required>';
|
||||
echo ' </div>';
|
||||
echo ' <button type="submit" class="btn btn-primary">登录</button>';
|
||||
echo ' </form>';
|
||||
echo ' </div>';
|
||||
echo ' </div>';
|
||||
echo ' </div>';
|
||||
echo ' </div>';
|
||||
echo ' </div>';
|
||||
echo ' <!-- Bootstrap JS Bundle with Popper -->';
|
||||
echo ' <script src="/js/bootstrap.bundle.js"></script>';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
?>
|
||||
<!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>
|
||||
|
||||
<!-- 为内容添加顶部内边距 -->
|
||||
<div style="padding-top: 70px;">
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card blur-bg">
|
||||
<div class="card-header">管理员登录</div>
|
||||
<div class="card-body">
|
||||
<?php if (isset($error)): ?>
|
||||
<script>
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "错误",
|
||||
text: "<?php echo addslashes($error); ?>",
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<form method="post">
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">用户名</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">密码</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">登录</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bootstrap JS Bundle with Popper -->
|
||||
<script src="/js/bootstrap.bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
@@ -1,24 +1,70 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once '../config.php';
|
||||
session_start();
|
||||
require_once '../config.php';
|
||||
|
||||
// 删除文件
|
||||
function delete_file($file_path) {
|
||||
if (file_exists($file_path)) {
|
||||
return unlink($file_path);
|
||||
// 删除文件
|
||||
function delete_file($file_path) {
|
||||
if (file_exists($file_path)) {
|
||||
return unlink($file_path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 处理删除请求
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$upload_dirs = [
|
||||
'../uploads/apps',
|
||||
'../uploads/images'
|
||||
];
|
||||
|
||||
// 全量删除
|
||||
if (isset($_POST['delete_all'])) {
|
||||
// 处理删除请求
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$upload_dirs = [
|
||||
'../uploads/apps',
|
||||
'../uploads/images'
|
||||
];
|
||||
|
||||
// 全量删除
|
||||
if (isset($_POST['delete_all'])) {
|
||||
foreach ($upload_dirs as $dir) {
|
||||
if (is_dir($dir)) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $file) {
|
||||
if ($file !== '.' && $file !== '..') {
|
||||
$file_path = $dir . '/' . $file;
|
||||
if (is_file($file_path)) {
|
||||
delete_file($file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 单个删除
|
||||
if (isset($_POST['delete_files'])) {
|
||||
foreach ($_POST['delete_files'] as $file_info) {
|
||||
list($type, $filename) = explode('|', $file_info);
|
||||
$dir = $type === '图片' ? '../uploads/images' : '../uploads/apps';
|
||||
$file_path = $dir . '/' . $filename;
|
||||
delete_file($file_path);
|
||||
}
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// 验证管理员权限
|
||||
if (!isset($_SESSION['admin'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 获取上传文件和图片信息
|
||||
function get_uploaded_files_info() {
|
||||
$uploaded_files = [];
|
||||
|
||||
// 上传目录配置
|
||||
$upload_dirs = [
|
||||
'../uploads/apps',
|
||||
'../uploads/images'
|
||||
];
|
||||
|
||||
foreach ($upload_dirs as $dir) {
|
||||
if (is_dir($dir)) {
|
||||
$files = scandir($dir);
|
||||
@@ -26,68 +72,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if ($file !== '.' && $file !== '..') {
|
||||
$file_path = $dir . '/' . $file;
|
||||
if (is_file($file_path)) {
|
||||
delete_file($file_path);
|
||||
$file_size = filesize($file_path);
|
||||
$uploaded_files[] = [
|
||||
'name' => $file,
|
||||
'size' => $file_size,
|
||||
'type' => strpos($dir, 'images') !== false ? '图片' : '文件'
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 单个删除
|
||||
if (isset($_POST['delete_files'])) {
|
||||
foreach ($_POST['delete_files'] as $file_info) {
|
||||
list($type, $filename) = explode('|', $file_info);
|
||||
$dir = $type === '图片' ? '../uploads/images' : '../uploads/apps';
|
||||
$file_path = $dir . '/' . $filename;
|
||||
delete_file($file_path);
|
||||
}
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// 验证管理员权限
|
||||
if (!isset($_SESSION['admin'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 获取上传文件和图片信息
|
||||
function get_uploaded_files_info() {
|
||||
$uploaded_files = [];
|
||||
|
||||
// 上传目录配置
|
||||
$upload_dirs = [
|
||||
'../uploads/apps',
|
||||
'../uploads/images'
|
||||
];
|
||||
|
||||
foreach ($upload_dirs as $dir) {
|
||||
if (is_dir($dir)) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $file) {
|
||||
if ($file !== '.' && $file !== '..') {
|
||||
$file_path = $dir . '/' . $file;
|
||||
if (is_file($file_path)) {
|
||||
$file_size = filesize($file_path);
|
||||
$uploaded_files[] = [
|
||||
'name' => $file,
|
||||
'size' => $file_size,
|
||||
'type' => strpos($dir, 'images') !== false ? '图片' : '文件'
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $uploaded_files;
|
||||
}
|
||||
|
||||
return $uploaded_files;
|
||||
}
|
||||
|
||||
$uploaded_files = get_uploaded_files_info();
|
||||
$uploaded_files = get_uploaded_files_info();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
@@ -105,7 +105,7 @@ $uploaded_files = get_uploaded_files_info();
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container">
|
||||
<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>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="/css/all.min.css">
|
||||
<style>
|
||||
body { padding-top: 56px; }
|
||||
body {
|
||||
padding-top: 56px;
|
||||
}
|
||||
.blur-bg {
|
||||
backdrop-filter: blur(10px);
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
|
||||
88
download.php
88
download.php
@@ -1,54 +1,54 @@
|
||||
<?php
|
||||
ob_start();
|
||||
require_once 'config.php';
|
||||
ob_start();
|
||||
require_once 'config.php';
|
||||
|
||||
// 验证版本ID
|
||||
if (!isset($_GET['version_id']) || !is_numeric($_GET['version_id'])) {
|
||||
http_response_code(400);
|
||||
exit('无效的版本ID');
|
||||
}
|
||||
$versionId = $_GET['version_id'];
|
||||
// 验证版本ID
|
||||
if (!isset($_GET['version_id']) || !is_numeric($_GET['version_id'])) {
|
||||
http_response_code(400);
|
||||
exit('无效的版本ID');
|
||||
}
|
||||
$versionId = $_GET['version_id'];
|
||||
|
||||
// 获取版本信息
|
||||
$version = null;
|
||||
$getVersionSql = "SELECT * FROM app_versions WHERE id = ?";
|
||||
$stmt = $conn->prepare($getVersionSql);
|
||||
$stmt->bind_param("i", $versionId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows !== 1) {
|
||||
http_response_code(404);
|
||||
exit('版本不存在');
|
||||
}
|
||||
$version = $result->fetch_assoc();
|
||||
// 获取版本信息
|
||||
$version = null;
|
||||
$getVersionSql = "SELECT * FROM app_versions WHERE id = ?";
|
||||
$stmt = $conn->prepare($getVersionSql);
|
||||
$stmt->bind_param("i", $versionId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows !== 1) {
|
||||
http_response_code(404);
|
||||
exit('版本不存在');
|
||||
}
|
||||
$version = $result->fetch_assoc();
|
||||
|
||||
// 获取绝对文件路径
|
||||
$filePath = realpath(__DIR__ . '/' . $version['file_path']);
|
||||
// 获取绝对文件路径
|
||||
$filePath = realpath(__DIR__ . '/' . $version['file_path']);
|
||||
|
||||
// 验证文件存在性
|
||||
if (!$filePath || !file_exists($filePath)) {
|
||||
http_response_code(404);
|
||||
exit('文件不存在');
|
||||
}
|
||||
// 验证文件存在性
|
||||
if (!$filePath || !file_exists($filePath)) {
|
||||
http_response_code(404);
|
||||
exit('文件不存在');
|
||||
}
|
||||
|
||||
// 设置下载响应头
|
||||
$fileName = basename($filePath);
|
||||
$fileSize = filesize($filePath);
|
||||
// 设置下载响应头
|
||||
$fileName = basename($filePath);
|
||||
$fileSize = filesize($filePath);
|
||||
|
||||
// 清除输出缓冲区并发送 headers
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($fileName));
|
||||
header('Content-Length: ' . $fileSize);
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: 0');
|
||||
header('Pragma: public');
|
||||
// 清除输出缓冲区并发送 headers
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($fileName));
|
||||
header('Content-Length: ' . $fileSize);
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: 0');
|
||||
header('Pragma: public');
|
||||
|
||||
// 输出文件内容
|
||||
if (!readfile($filePath)) {
|
||||
http_response_code(500);
|
||||
exit('无法读取文件');
|
||||
}
|
||||
// 输出文件内容
|
||||
if (!readfile($filePath)) {
|
||||
http_response_code(500);
|
||||
exit('无法读取文件');
|
||||
}
|
||||
|
||||
exit;
|
||||
exit;
|
||||
?>
|
||||
@@ -6,10 +6,30 @@
|
||||
<title>404 - 页面未找到</title>
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body { display: flex; justify-content: center; 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; }
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
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>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -6,10 +6,30 @@
|
||||
<title>500 - 服务器内部错误</title>
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body { display: flex; justify-content: center; 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; }
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
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>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
64
router.php
64
router.php
@@ -1,38 +1,38 @@
|
||||
<?php
|
||||
// 路由脚本,用于PHP内置服务器
|
||||
// 将所有/api开头的请求转发到api.php
|
||||
// 路由脚本,用于PHP内置服务器
|
||||
// 将所有/api开头的请求转发到api.php
|
||||
|
||||
// 顶栏样式
|
||||
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 '<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>
|
||||
</ul>
|
||||
// 导航栏
|
||||
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>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>';
|
||||
</nav>';
|
||||
|
||||
// 为内容添加顶部内边距
|
||||
echo '<div style="padding-top: 70px;">';
|
||||
if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) {
|
||||
include 'api.php';
|
||||
exit;
|
||||
}
|
||||
// 为内容添加顶部内边距
|
||||
echo '<div style="padding-top: 70px;">';
|
||||
if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) {
|
||||
include 'api.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// 其他请求按正常方式处理
|
||||
return false;
|
||||
// 其他请求按正常方式处理
|
||||
return false;
|
||||
Reference in New Issue
Block a user