源代码: admin-index1.php
<?php
include __DIR__ . "/../password.php";
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../Assets/helpers.php";
require_once __DIR__ . "/helpers.php";
function renderPendingRow($item, $counter)
{
$itemId = htmlspecialchars($item["id"]);
$domain = htmlspecialchars($item["domain"]);
$description = htmlspecialchars($item["description"]);
$master = htmlspecialchars($item["master"]);
$email = htmlspecialchars($item["email"]);
// 向下兼容
$join_date = htmlspecialchars($item["join_date"] ?? '', ENT_QUOTES, 'UTF-8');
return <<<HTML
<tr id="item-$itemId">
<td>$counter</td>
<td>$itemId</td>
<td>$domain</td>
<td>$description</td>
<td>$master</td>
<td>$email</td>
<td>$join_date</td>
<td>
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-teal" onclick="handleAction('$itemId', 'pass')">通过(速度有亿些慢)</button>
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-red" onclick="handleAction('$itemId', 'fail')">阻止</button>
</td>
</tr>
HTML;
}
if (!empty($_GET["password"]) && $_GET["password"] == $password) {
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入MDUI的CSS -->
<link rel="stylesheet" href="/Assets/css/mdui.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>等待审核の后台</title>
<link rel="stylesheet" href="/Assets/css/mdui.min.css">
<link href="https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
<script>
NProgress.configure({
minimum: 0.08,
showSpinner: true,
parent: '#item-list'
})
window.addEventListener('load', () => {
NProgress.done();
});
document.addEventListener('readystatechange', () => {
if (document.readyState === 'interactive') {
NProgress.start();
} else if (document.readyState === 'complete') {
NProgress.done();
}
});
</script>
<div class="mdui-container mdui-typo">
<h1 class="mdui-typo-display-1">
等待审核の后台
<a no-pjax href="index2.php?password=<?php echo htmlspecialchars($_GET["password"]); ?>">前往 - 列表</a>
|
<a no-pjax href="index3.php?password=<?php echo htmlspecialchars($_GET["password"]); ?>">前往 - 编辑公告</a>
</h1>
<div class="mdui-divider"></div>
<div id="item-list">
<?php
// 显示所有待审核数据
$data = json_decode(file_get_contents(__DIR__ . "/../Assets/data/json/pending.json"), true);
// 分页设置
$totalItems = count($data);
$itemsPerPage = 10; // 每页显示的项目数量
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$totalPages = ceil($totalItems / $itemsPerPage);
// 计算当前页显示的项目
$startIndex = ($currentPage - 1) * $itemsPerPage;
$currentPageData = array_slice($data, $startIndex, $itemsPerPage);
if (!empty($currentPageData)) {
// 如果有待审核数据,则显示这些数据
echo <<<HTML
<div class="mdui-table-fluid">
<table class="mdui-table mdui-table-hoverable">
<thead>
<tr><th>#</th><th>ID</th><th>域名</th><th>介绍</th><th>站长</th><th>邮箱</th><th>加入时间</th><th>操作</th></tr>
</thead>
<tbody>
HTML;
$counter = $startIndex + 1;
foreach ($currentPageData as $item) {
echo renderPendingRow($item, $counter);
$counter++;
}
echo '</tbody>';
echo '</table>';
echo '</div>';
// 分页导航
echo '<div class="mdui-m-y-4 mdui-center">';
if ($currentPage > 1) {
$prevPage = $currentPage - 1;
echo "<a href=\"?page=$prevPage&password={$password}\" class=\"mdui-btn mdui-btn-raised mdui-ripple\">上一页</a>";
}
if ($currentPage < $totalPages) {
$nextPage = $currentPage + 1;
echo "<a href=\"?page=$nextPage&password={$password}\" class=\"mdui-btn mdui-btn-raised mdui-ripple\">下一页</a>";
}
echo '</div>';
} else {
// 如果没有待审核数据,则显示提示信息
echo '<div class="mdui-m-y-4 mdui-center">';
echo '<h3 class="mdui-typo-display-2 mdui-text-color-grey-500">暂无待审核项目</h3>';
echo '</div>';
}
?>
</div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/mdui/1.0.2/js/mdui.min.js"></script>
<script>
function handleAction(id, action) {
$.ajax({
url: 'index1-action.php?password=<?php echo htmlspecialchars($_GET["password"]); ?>',
type: 'POST',
data: {
id: id,
action: action,
},
success: function(response) {
if (response.status === 'success') {
// 添加渐隐动画并在完成后删除元素
$('#item-' + id).fadeOut(500, function() {
$(this).remove();
});
mdui.snackbar({
message: `${action} ${id} 成功`,
position: "left-bottom",
});
} else {
alert('操作失败: ' + response);
}
},
error: function() {
alert('请求失败,请稍后再试。');
}
});
}
</script>
</head>
</html>
<?php
} else {
http_response_code(404);
}
这个网站由wusheng233制作,生成了静态页面