初始化版本
This commit is contained in:
172
review_pictures.php
Normal file
172
review_pictures.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
// 图片审核页面:查看 pictures_pending 中的文件,执行通过/拒绝
|
||||
session_start();
|
||||
|
||||
$ADMIN_PASSWORD = 'my123123';
|
||||
|
||||
// 退出登录
|
||||
if (isset($_GET['logout'])) {
|
||||
unset($_SESSION['admin_ok']);
|
||||
header('Location: review_pictures.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 登录处理
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
|
||||
$pwd = trim($_POST['password'] ?? '');
|
||||
if ($pwd === $ADMIN_PASSWORD) {
|
||||
$_SESSION['admin_ok'] = true;
|
||||
header('Location: review_pictures.php');
|
||||
exit;
|
||||
} else {
|
||||
$login_error = '密码错误,请重试';
|
||||
}
|
||||
}
|
||||
|
||||
// 若未登录,显示登录界面
|
||||
if (empty($_SESSION['admin_ok'])) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>管理员登录 - 图片审核</title>
|
||||
<link rel="stylesheet" href="assets/style.css" />
|
||||
<style>
|
||||
.login-card { max-width: 480px; margin: 60px auto; border:2px solid #e33; border-radius:12px; padding:20px; background:#fff; }
|
||||
.login-card h1 { margin:0 0 12px; font-size:20px; }
|
||||
.login-card .field { display:flex; flex-direction:column; gap:8px; }
|
||||
.login-card input { padding:10px 12px; border:1px solid #ddd; border-radius:8px; }
|
||||
.login-card .btn { background:#e33; color:#fff; border:none; padding:10px 18px; border-radius:22px; cursor:pointer; }
|
||||
.login-card .err { color:#c00; font-size:13px; margin-top:8px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
<header class="menu">
|
||||
<div class="menu__logo">审核登录</div>
|
||||
<nav aria-label="主菜单">
|
||||
<ul class="menu__nav">
|
||||
<li><a class="menu__link" href="index.php">返回首页</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main class="login-card" aria-label="管理员登录">
|
||||
<h1>请输入管理员密码</h1>
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<label for="password">密码</label>
|
||||
<input id="password" name="password" type="password" placeholder="输入管理员密码" required />
|
||||
</div>
|
||||
<div style="margin-top:12px;">
|
||||
<button class="btn" type="submit">登录</button>
|
||||
</div>
|
||||
<?php if (!empty($login_error)): ?>
|
||||
<div class="err"><?php echo htmlspecialchars($login_error); ?></div>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$pendingDir = __DIR__ . '/pictures_pending';
|
||||
$files = [];
|
||||
if (is_dir($pendingDir)) {
|
||||
foreach (scandir($pendingDir) as $f) {
|
||||
if ($f === '.' || $f === '..') continue;
|
||||
if (preg_match('/\.(jpg|jpeg|png|gif|webp)$/i', $f)) {
|
||||
$files[] = $f;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>图片审核</title>
|
||||
<link rel="stylesheet" href="assets/style.css" />
|
||||
<style>
|
||||
.review-page { max-width: 1100px; margin: 24px auto; }
|
||||
.review-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
|
||||
.list { display:grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap:12px; }
|
||||
.card { border:2px solid #e33; border-radius:10px; padding:8px; background:#fff; }
|
||||
.card img { width:100%; height:220px; object-fit:contain; border-radius:6px; background:#fafafa; }
|
||||
.card .meta { font-size: 12px; color:#666; margin-top:6px; }
|
||||
.actions { display:flex; gap:8px; margin-top:8px; }
|
||||
.btn { padding:6px 12px; border:none; border-radius:16px; cursor:pointer; }
|
||||
.btn.approve { background:#2ebd59; color:#fff; }
|
||||
.btn.reject { background:#999; color:#fff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page review-page">
|
||||
<header class="menu">
|
||||
<div class="menu__logo">图片审核</div>
|
||||
<nav aria-label="主菜单">
|
||||
<ul class="menu__nav">
|
||||
<li><a class="menu__link" href="index.php">返回首页</a></li>
|
||||
<li><a class="menu__link" href="review_pictures.php?logout=1">退出登录</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="review-head">
|
||||
<h1 style="margin:0;font-size:18px;">待审核图片(<?php echo count($files); ?>)</h1>
|
||||
</div>
|
||||
<section class="list" id="pendingList">
|
||||
<?php if (!$files): ?>
|
||||
<p>当前无待审核图片。</p>
|
||||
<?php else: foreach ($files as $f):
|
||||
$metaPath = $pendingDir . '/' . $f . '.json';
|
||||
$meta = is_file($metaPath) ? json_decode(@file_get_contents($metaPath), true) : [];
|
||||
?>
|
||||
<div class="card" data-file="<?php echo htmlspecialchars($f); ?>">
|
||||
<img src="<?php echo 'pictures_pending/' . htmlspecialchars($f); ?>" alt="待审核图片" />
|
||||
<div class="meta">
|
||||
<div>文件:<?php echo htmlspecialchars($f); ?></div>
|
||||
<?php if (!empty($meta['original_name'])): ?><div>原名:<?php echo htmlspecialchars($meta['original_name']); ?></div><?php endif; ?>
|
||||
<?php if (!empty($meta['title'])): ?><div>标题:<?php echo htmlspecialchars($meta['title']); ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn approve">通过</button>
|
||||
<button class="btn reject">拒绝</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
const list = document.getElementById('pendingList');
|
||||
function send(action, file, password) {
|
||||
const fd = new FormData();
|
||||
fd.append('action', action);
|
||||
fd.append('file', file);
|
||||
fd.append('password', password);
|
||||
return fetch('api/review_picture_action.php', { method: 'POST', body: fd }).then(r=>r.json());
|
||||
}
|
||||
list?.addEventListener('click', async (e) => {
|
||||
const btn = e.target.closest('button');
|
||||
if (!btn) return;
|
||||
const card = e.target.closest('.card');
|
||||
const file = card?.dataset?.file;
|
||||
if (!file) return;
|
||||
const action = btn.classList.contains('approve') ? 'approve' : 'reject';
|
||||
btn.disabled = true;
|
||||
const res = await send(action, file, '').catch(()=>({ok:false,msg:'请求失败'}));
|
||||
btn.disabled = false;
|
||||
alert(res.msg || '操作完成');
|
||||
if (res.ok) {
|
||||
card.remove();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php ?>
|
||||
|
||||
Reference in New Issue
Block a user