mirror of
https://github.com/UISNBLOON/TrackICP.git
synced 2025-11-19 22:35:50 +08:00
Compare commits
3 commits
7dc603fd42
...
c67f0eabfe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c67f0eabfe | ||
|
|
24b4dd868c | ||
|
|
bc57760643 |
13 changed files with 3563 additions and 2938 deletions
|
|
@ -1,416 +1,425 @@
|
||||||
<?php
|
<?php
|
||||||
// 加载配置
|
session_start();
|
||||||
$config = include '../config.php';
|
require_once '../auth_check.php';
|
||||||
|
checkAdminAuth();
|
||||||
// 数据库连接函数
|
$csrf_token = generateCSRFToken();
|
||||||
function getDatabaseConnection() {
|
|
||||||
global $config;
|
// 加载配置
|
||||||
try {
|
$config = include '../config.php';
|
||||||
if ($config['database_type'] === 'mysql') {
|
|
||||||
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
// 数据库连接函数
|
||||||
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
function getDatabaseConnection() {
|
||||||
} else if ($config['database_type'] === 'sqlite') {
|
global $config;
|
||||||
$dsn = "sqlite:{$config['database_config']['path']}";
|
try {
|
||||||
return new PDO($dsn);
|
if ($config['database_type'] === 'mysql') {
|
||||||
}
|
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
||||||
} catch (PDOException $e) {
|
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
||||||
die('数据库连接失败: ' . $e->getMessage());
|
} else if ($config['database_type'] === 'sqlite') {
|
||||||
}
|
$dsn = "sqlite:{$config['database_config']['path']}";
|
||||||
}
|
return new PDO($dsn);
|
||||||
|
}
|
||||||
// 连接数据库
|
} catch (PDOException $e) {
|
||||||
$pdo = getDatabaseConnection();
|
die('数据库连接失败: ' . $e->getMessage());
|
||||||
|
}
|
||||||
// 从数据库获取网站信息
|
}
|
||||||
$stmt = $pdo->query("SELECT name, description FROM site_info LIMIT 1");
|
|
||||||
$siteInfo = $stmt->fetch(PDO::FETCH_ASSOC);
|
// 连接数据库
|
||||||
|
$pdo = getDatabaseConnection();
|
||||||
// 如果找不到网站信息,使用配置文件中的默认值
|
|
||||||
if (!$siteInfo) {
|
// 从数据库获取网站信息
|
||||||
$siteInfo = [
|
$stmt = $pdo->query("SELECT name, description FROM site_info LIMIT 1");
|
||||||
'name' => $config['site_name'] ?? '二次元网站备案系统',
|
$siteInfo = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
'description' => $config['site_description'] ?? '管理和审核网站备案申请'
|
|
||||||
];
|
// 如果找不到网站信息,使用配置文件中的默认值
|
||||||
}
|
if (!$siteInfo) {
|
||||||
|
$siteInfo = [
|
||||||
// 处理表单提交
|
'name' => $config['site_name'] ?? '二次元网站备案系统',
|
||||||
$success = '';
|
'description' => $config['site_description'] ?? '管理和审核网站备案申请'
|
||||||
$errors = [];
|
];
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
}
|
||||||
// 验证表单数据
|
|
||||||
$data = [];
|
// 处理表单提交
|
||||||
|
$success = '';
|
||||||
// 验证网站名称
|
$errors = [];
|
||||||
if (empty($_POST['website_name'])) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$errors[] = '网站名称不能为空';
|
// 验证CSRF令牌
|
||||||
} else {
|
verifyCSRFToken($_POST['csrf_token'] ?? '');
|
||||||
$data['website_name'] = trim($_POST['website_name']);
|
|
||||||
}
|
// 验证表单数据
|
||||||
|
$data = [];
|
||||||
// 验证网站类型
|
|
||||||
if (empty($_POST['website_category'])) {
|
// 验证网站名称
|
||||||
$errors[] = '请选择网站类型';
|
if (empty($_POST['website_name'])) {
|
||||||
} else {
|
$errors[] = '网站名称不能为空';
|
||||||
$data['website_category'] = $_POST['website_category'];
|
} else {
|
||||||
}
|
$data['website_name'] = trim($_POST['website_name']);
|
||||||
|
}
|
||||||
// 验证网站负责人
|
|
||||||
if (empty($_POST['contact_person'])) {
|
// 验证网站类型
|
||||||
$errors[] = '网站负责人不能为空';
|
if (empty($_POST['website_category'])) {
|
||||||
} else {
|
$errors[] = '请选择网站类型';
|
||||||
$data['contact_person'] = trim($_POST['contact_person']);
|
} else {
|
||||||
}
|
$data['website_category'] = $_POST['website_category'];
|
||||||
|
}
|
||||||
// 验证联系电话
|
|
||||||
if (empty($_POST['contact_phone'])) {
|
// 验证网站负责人
|
||||||
$errors[] = '联系电话不能为空';
|
if (empty($_POST['contact_person'])) {
|
||||||
} else {
|
$errors[] = '网站负责人不能为空';
|
||||||
$data['contact_phone'] = trim($_POST['contact_phone']);
|
} else {
|
||||||
}
|
$data['contact_person'] = trim($_POST['contact_person']);
|
||||||
|
}
|
||||||
// 验证联系邮箱
|
|
||||||
if (empty($_POST['contact_email'])) {
|
// 验证联系电话
|
||||||
$errors[] = '联系邮箱不能为空';
|
if (empty($_POST['contact_phone'])) {
|
||||||
} elseif (!filter_var($_POST['contact_email'], FILTER_VALIDATE_EMAIL)) {
|
$errors[] = '联系电话不能为空';
|
||||||
$errors[] = '请输入有效的邮箱地址';
|
} else {
|
||||||
} else {
|
$data['contact_phone'] = trim($_POST['contact_phone']);
|
||||||
$data['contact_email'] = trim($_POST['contact_email']);
|
}
|
||||||
}
|
|
||||||
|
// 验证联系邮箱
|
||||||
// 验证网站地址
|
if (empty($_POST['contact_email'])) {
|
||||||
if (empty($_POST['website_url'])) {
|
$errors[] = '联系邮箱不能为空';
|
||||||
$errors[] = '网站地址不能为空';
|
} elseif (!filter_var($_POST['contact_email'], FILTER_VALIDATE_EMAIL)) {
|
||||||
} else {
|
$errors[] = '请输入有效的邮箱地址';
|
||||||
// 移除可能的http://或https://前缀
|
} else {
|
||||||
$website = trim($_POST['website_url']);
|
$data['contact_email'] = trim($_POST['contact_email']);
|
||||||
$website = preg_replace('#^https?://#', '', $website);
|
}
|
||||||
$data['website_url'] = $website;
|
|
||||||
}
|
// 验证网站地址
|
||||||
|
if (empty($_POST['website_url'])) {
|
||||||
// 验证网站描述
|
$errors[] = '网站地址不能为空';
|
||||||
if (empty($_POST['website_description'])) {
|
} else {
|
||||||
$errors[] = '网站描述不能为空';
|
// 移除可能的http://或https://前缀
|
||||||
} else {
|
$website = trim($_POST['website_url']);
|
||||||
$data['website_description'] = trim($_POST['website_description']);
|
$website = preg_replace('#^https?://#', '', $website);
|
||||||
}
|
$data['website_url'] = $website;
|
||||||
|
}
|
||||||
// 验证状态
|
|
||||||
if (empty($_POST['status'])) {
|
// 验证网站描述
|
||||||
$errors[] = '请选择状态';
|
if (empty($_POST['website_description'])) {
|
||||||
} else {
|
$errors[] = '网站描述不能为空';
|
||||||
$data['status'] = $_POST['status'];
|
} else {
|
||||||
}
|
$data['website_description'] = trim($_POST['website_description']);
|
||||||
|
}
|
||||||
// 如果没有错误,保存数据
|
|
||||||
if (empty($errors)) {
|
// 验证状态
|
||||||
// 生成唯一备案编号 (ICP-年月日-6位ID)
|
if (empty($_POST['status'])) {
|
||||||
// 生成8位数字备案编号
|
$errors[] = '请选择状态';
|
||||||
$data['registration_number'] = str_pad(rand(10000000, 99999999), 8, '0', STR_PAD_LEFT);
|
} else {
|
||||||
$data['created_at'] = date('Y-m-d H:i:s');
|
$data['status'] = $_POST['status'];
|
||||||
|
}
|
||||||
if ($data['status'] === 'approved' || $data['status'] === 'rejected') {
|
|
||||||
$data['processed_at'] = $data['created_at'];
|
// 如果没有错误,保存数据
|
||||||
}
|
if (empty($errors)) {
|
||||||
|
// 生成8位数字备案编号
|
||||||
// 初始化reason字段
|
$data['registration_number'] = str_pad(rand(10000000, 99999999), 8, '0', STR_PAD_LEFT);
|
||||||
$data['reason'] = $_POST['reason'] ?? '';
|
$data['created_at'] = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
try {
|
if ($data['status'] === 'approved' || $data['status'] === 'rejected') {
|
||||||
// 插入数据到数据库
|
$data['processed_at'] = $data['created_at'];
|
||||||
$stmt = $pdo->prepare("INSERT INTO registrations (website_name, website_category, contact_person, contact_phone, contact_email, website_url, website_description, status, created_at, processed_at, registration_number, reason) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
}
|
||||||
$stmt->execute([
|
|
||||||
$data['website_name'],
|
// 初始化reason字段
|
||||||
$data['website_category'],
|
$data['reason'] = $_POST['reason'] ?? '';
|
||||||
$data['contact_person'],
|
|
||||||
$data['contact_phone'],
|
try {
|
||||||
$data['contact_email'],
|
// 插入数据到数据库
|
||||||
$data['website_url'],
|
$stmt = $pdo->prepare("INSERT INTO registrations (website_name, website_category, contact_person, contact_phone, contact_email, website_url, website_description, status, created_at, processed_at, registration_number, reason) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$data['website_description'],
|
$stmt->execute([
|
||||||
$data['status'],
|
$data['website_name'],
|
||||||
$data['created_at'],
|
$data['website_category'],
|
||||||
$data['processed_at'] ?? null,
|
$data['contact_person'],
|
||||||
$data['registration_number'],
|
$data['contact_phone'],
|
||||||
$data['reason']
|
$data['contact_email'],
|
||||||
]);
|
$data['website_url'],
|
||||||
|
$data['website_description'],
|
||||||
$success = '备案信息添加成功!备案编号: 初ICP备' . $data['registration_number'] . '备';
|
$data['status'],
|
||||||
} catch (PDOException $e) {
|
$data['created_at'],
|
||||||
$errors[] = '添加备案信息失败: ' . $e->getMessage();
|
$data['processed_at'] ?? null,
|
||||||
}
|
$data['registration_number'],
|
||||||
}
|
$data['reason']
|
||||||
}
|
]);
|
||||||
?>
|
|
||||||
<html lang="zh-CN">
|
$success = '备案信息添加成功!备案编号: 初ICP备' . $data['registration_number'] . '备';
|
||||||
<head>
|
} catch (PDOException $e) {
|
||||||
<meta charset="UTF-8">
|
$errors[] = '添加备案信息失败: ' . $e->getMessage();
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
}
|
||||||
<title>添加备案信息 - <?php echo $siteInfo['name']; ?></title>
|
}
|
||||||
<style>
|
}
|
||||||
* {
|
?>
|
||||||
margin: 0;
|
<html lang="zh-CN">
|
||||||
padding: 0;
|
<head>
|
||||||
box-sizing: border-box;
|
<meta charset="UTF-8">
|
||||||
}
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
body {
|
<title>添加备案信息 - <?php echo $siteInfo['name']; ?></title>
|
||||||
background-color: #f0f2f5;
|
<style>
|
||||||
color: #333;
|
* {
|
||||||
line-height: 1.6;
|
margin: 0;
|
||||||
}
|
padding: 0;
|
||||||
.container {
|
box-sizing: border-box;
|
||||||
max-width: 800px;
|
}
|
||||||
margin: 0 auto;
|
body {
|
||||||
padding: 20px;
|
background-color: #f0f2f5;
|
||||||
}
|
color: #333;
|
||||||
.header-frosted {
|
line-height: 1.6;
|
||||||
position: fixed;
|
}
|
||||||
top: 0;
|
.container {
|
||||||
left: 0;
|
max-width: 800px;
|
||||||
right: 0;
|
margin: 0 auto;
|
||||||
background: rgba(255, 255, 255, 0.7);
|
padding: 20px;
|
||||||
backdrop-filter: blur(10px);
|
}
|
||||||
-webkit-backdrop-filter: blur(10px);
|
.header-frosted {
|
||||||
color: #333;
|
position: fixed;
|
||||||
padding: 15px 20px;
|
top: 0;
|
||||||
display: flex;
|
left: 0;
|
||||||
justify-content: space-between;
|
right: 0;
|
||||||
align-items: center;
|
background: rgba(255, 255, 255, 0.7);
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
backdrop-filter: blur(10px);
|
||||||
z-index: 1000;
|
-webkit-backdrop-filter: blur(10px);
|
||||||
}
|
color: #333;
|
||||||
.header-nav {
|
padding: 15px 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 20px;
|
justify-content: space-between;
|
||||||
}
|
align-items: center;
|
||||||
.header-nav span {
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
cursor: pointer;
|
z-index: 1000;
|
||||||
color: #7873f5;
|
}
|
||||||
font-weight: bold;
|
.header-nav {
|
||||||
transition: color 0.3s ease;
|
display: flex;
|
||||||
}
|
gap: 20px;
|
||||||
.header-nav span:hover {
|
}
|
||||||
color: #605acf;
|
.header-nav span {
|
||||||
}
|
cursor: pointer;
|
||||||
header {
|
color: #7873f5;
|
||||||
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
font-weight: bold;
|
||||||
color: white;
|
transition: color 0.3s ease;
|
||||||
padding: 80px 0 40px;
|
}
|
||||||
text-align: center;
|
.header-nav span:hover {
|
||||||
border-radius: 10px;
|
color: #605acf;
|
||||||
margin-bottom: 30px;
|
}
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
header {
|
||||||
margin-top: 60px;
|
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
||||||
}
|
color: white;
|
||||||
h1 {
|
padding: 80px 0 40px;
|
||||||
font-size: 2rem;
|
text-align: center;
|
||||||
margin-bottom: 10px;
|
border-radius: 10px;
|
||||||
}
|
margin-bottom: 30px;
|
||||||
.card {
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
background: white;
|
margin-top: 60px;
|
||||||
border-radius: 10px;
|
}
|
||||||
padding: 30px;
|
h1 {
|
||||||
margin-bottom: 30px;
|
font-size: 2rem;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
h2 {
|
.card {
|
||||||
color: #7873f5;
|
background: white;
|
||||||
margin-bottom: 20px;
|
border-radius: 10px;
|
||||||
padding-bottom: 10px;
|
padding: 30px;
|
||||||
border-bottom: 2px solid #f0f0f0;
|
margin-bottom: 30px;
|
||||||
}
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
.form-group {
|
}
|
||||||
margin-bottom: 20px;
|
h2 {
|
||||||
}
|
color: #7873f5;
|
||||||
label {
|
margin-bottom: 20px;
|
||||||
display: block;
|
padding-bottom: 10px;
|
||||||
margin-bottom: 8px;
|
border-bottom: 2px solid #f0f0f0;
|
||||||
font-weight: bold;
|
}
|
||||||
color: #555;
|
.form-group {
|
||||||
}
|
margin-bottom: 20px;
|
||||||
input[type="text"],
|
}
|
||||||
input[type="email"],
|
label {
|
||||||
textarea,
|
display: block;
|
||||||
select {
|
margin-bottom: 8px;
|
||||||
width: 100%;
|
font-weight: bold;
|
||||||
padding: 12px;
|
color: #555;
|
||||||
border: 1px solid #ddd;
|
}
|
||||||
border-radius: 6px;
|
input[type="text"],
|
||||||
font-size: 1rem;
|
input[type="email"],
|
||||||
transition: border 0.3s ease;
|
textarea,
|
||||||
}
|
select {
|
||||||
input[type="text"]:focus,
|
width: 100%;
|
||||||
input[type="email"]:focus,
|
padding: 12px;
|
||||||
textarea:focus,
|
border: 1px solid #ddd;
|
||||||
select:focus {
|
border-radius: 6px;
|
||||||
border-color: #7873f5;
|
font-size: 1rem;
|
||||||
outline: none;
|
transition: border 0.3s ease;
|
||||||
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
}
|
||||||
}
|
input[type="text"]:focus,
|
||||||
textarea {
|
input[type="email"]:focus,
|
||||||
height: 150px;
|
textarea:focus,
|
||||||
resize: vertical;
|
select:focus {
|
||||||
}
|
border-color: #7873f5;
|
||||||
.btn {
|
outline: none;
|
||||||
display: inline-block;
|
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
||||||
background: #7873f5;
|
}
|
||||||
color: white;
|
textarea {
|
||||||
padding: 12px 25px;
|
height: 150px;
|
||||||
border-radius: 30px;
|
resize: vertical;
|
||||||
text-decoration: none;
|
}
|
||||||
font-weight: bold;
|
.btn {
|
||||||
transition: background 0.3s ease;
|
display: inline-block;
|
||||||
border: none;
|
background: #7873f5;
|
||||||
cursor: pointer;
|
color: white;
|
||||||
font-size: 1rem;
|
padding: 12px 25px;
|
||||||
}
|
border-radius: 30px;
|
||||||
.btn:hover {
|
text-decoration: none;
|
||||||
background: #605acf;
|
font-weight: bold;
|
||||||
}
|
transition: background 0.3s ease;
|
||||||
.btn-container {
|
border: none;
|
||||||
text-align: center;
|
cursor: pointer;
|
||||||
margin-top: 30px;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
.back-link {
|
.btn:hover {
|
||||||
display: inline-block;
|
background: #605acf;
|
||||||
margin-top: 15px;
|
}
|
||||||
color: #7873f5;
|
.btn-container {
|
||||||
text-decoration: none;
|
text-align: center;
|
||||||
}
|
margin-top: 30px;
|
||||||
.back-link:hover {
|
}
|
||||||
text-decoration: underline;
|
.back-link {
|
||||||
}
|
display: inline-block;
|
||||||
.error {
|
margin-top: 15px;
|
||||||
color: #e74c3c;
|
color: #7873f5;
|
||||||
font-size: 0.9rem;
|
text-decoration: none;
|
||||||
margin-top: 5px;
|
}
|
||||||
}
|
.back-link:hover {
|
||||||
.success {
|
text-decoration: underline;
|
||||||
color: #2ecc71;
|
}
|
||||||
padding: 15px;
|
.error {
|
||||||
background: #f1f9f1;
|
color: #e74c3c;
|
||||||
border-radius: 6px;
|
font-size: 0.9rem;
|
||||||
margin-bottom: 20px;
|
margin-top: 5px;
|
||||||
border-left: 4px solid #2ecc71;
|
}
|
||||||
}
|
.success {
|
||||||
.logout-btn {
|
color: #2ecc71;
|
||||||
background: #e74c3c;
|
padding: 15px;
|
||||||
color: white;
|
background: #f1f9f1;
|
||||||
border: none;
|
border-radius: 6px;
|
||||||
padding: 8px 15px;
|
margin-bottom: 20px;
|
||||||
border-radius: 30px;
|
border-left: 4px solid #2ecc71;
|
||||||
cursor: pointer;
|
}
|
||||||
font-weight: bold;
|
.logout-btn {
|
||||||
transition: background 0.3s ease;
|
background: #e74c3c;
|
||||||
}
|
color: white;
|
||||||
.logout-btn:hover {
|
border: none;
|
||||||
background: #c0392b;
|
padding: 8px 15px;
|
||||||
}
|
border-radius: 30px;
|
||||||
</style>
|
cursor: pointer;
|
||||||
</head>
|
font-weight: bold;
|
||||||
<body>
|
transition: background 0.3s ease;
|
||||||
<div class="header-frosted">
|
}
|
||||||
<h3><?php echo $siteInfo['name']; ?> - 管理员面板</h3>
|
.logout-btn:hover {
|
||||||
<div class="header-nav">
|
background: #c0392b;
|
||||||
<span onclick="window.location.href='admin_dashboard.php'">控制面板</span>
|
}
|
||||||
<span onclick="window.location.href='admin_dashboard.php?view=all'">所有备案</span>
|
</style>
|
||||||
<span onclick="window.location.href='admin_dashboard.php?view=pending'">待审核备案</span>
|
</head>
|
||||||
<span onclick="window.location.href='add_registration.php'">添加备案</span>
|
<body>
|
||||||
<span onclick="window.location.href='settings.php'">系统设置</span>
|
<div class="header-frosted">
|
||||||
<button class="logout-btn" onclick="window.location.href='admin_login.php?action=logout'">退出登录</button>
|
<h3><?php echo $siteInfo['name']; ?> - 管理员面板</h3>
|
||||||
</div>
|
<div class="header-nav">
|
||||||
</div>
|
<span onclick="window.location.href='admin_dashboard.php'">控制面板</span>
|
||||||
<div class="container">
|
<span onclick="window.location.href='admin_dashboard.php?view=all'">所有备案</span>
|
||||||
<header>
|
<span onclick="window.location.href='admin_dashboard.php?view=pending'">待审核备案</span>
|
||||||
<h1><?php echo $siteInfo['name']; ?> - 添加备案信息</h1>
|
<span onclick="window.location.href='add_registration.php'">添加备案</span>
|
||||||
<p>直接添加新的备案信息</p>
|
<span onclick="window.location.href='settings.php'">系统设置</span>
|
||||||
</header>
|
<button class="logout-btn" onclick="window.location.href='admin_login.php?action=logout'">退出登录</button>
|
||||||
|
</div>
|
||||||
<div class="card">
|
</div>
|
||||||
<h2>添加备案信息</h2>
|
<div class="container">
|
||||||
|
<header>
|
||||||
<?php if ($success): ?>
|
<h1><?php echo $siteInfo['name']; ?> - 添加备案信息</h1>
|
||||||
<div class="success"><?php echo $success; ?></div>
|
<p>直接添加新的备案信息</p>
|
||||||
<?php endif; ?>
|
</header>
|
||||||
|
|
||||||
<?php if (!empty($errors)): ?>
|
<div class="card">
|
||||||
<?php foreach ($errors as $error): ?>
|
<h2>添加备案信息</h2>
|
||||||
<div class="error"><?php echo $error; ?></div>
|
|
||||||
<?php endforeach; ?>
|
<?php if ($success): ?>
|
||||||
<?php endif; ?>
|
<div class="success"><?php echo $success; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
<form method="post" enctype="multipart/form-data">
|
|
||||||
<div class="form-group">
|
<?php if (!empty($errors)): ?>
|
||||||
<label for="website_name">网站名称 *</label>
|
<?php foreach ($errors as $error): ?>
|
||||||
<input type="text" id="website_name" name="website_name" required placeholder="请输入网站的名称">
|
<div class="error"><?php echo $error; ?></div>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
<div class="form-group">
|
|
||||||
<label for="website_category">网站类型 *</label>
|
<form method="post" enctype="multipart/form-data">
|
||||||
<select id="website_category" name="website_category" required>
|
<input type="hidden" name="csrf_token" value="<?php echo $csrf_token; ?>">
|
||||||
<option value="">请选择</option>
|
|
||||||
<option value="anime">动漫网站</option>
|
<div class="form-group">
|
||||||
<option value="game">游戏网站</option>
|
<label for="website_name">网站名称 *</label>
|
||||||
<option value="blog">个人博客</option>
|
<input type="text" id="website_name" name="website_name" required placeholder="请输入网站的名称">
|
||||||
<option value="other">其他类型</option>
|
</div>
|
||||||
</select>
|
|
||||||
</div>
|
<div class="form-group">
|
||||||
|
<label for="website_category">网站类型 *</label>
|
||||||
<div class="form-group">
|
<select id="website_category" name="website_category" required>
|
||||||
<label for="contact_person">网站负责人 *</label>
|
<option value="">请选择</option>
|
||||||
<input type="text" id="contact_person" name="contact_person" required placeholder="请输入网站负责人姓名">
|
<option value="anime">动漫网站</option>
|
||||||
</div>
|
<option value="game">游戏网站</option>
|
||||||
|
<option value="blog">个人博客</option>
|
||||||
<div class="form-group">
|
<option value="other">其他类型</option>
|
||||||
<label for="contact_phone">联系电话 *</label>
|
</select>
|
||||||
<input type="text" id="contact_phone" name="contact_phone" required placeholder="请输入联系电话">
|
</div>
|
||||||
</div>
|
|
||||||
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label for="contact_person">网站负责人 *</label>
|
||||||
<label for="contact_email">联系邮箱 *</label>
|
<input type="text" id="contact_person" name="contact_person" required placeholder="请输入网站负责人姓名">
|
||||||
<input type="email" id="contact_email" name="contact_email" required placeholder="请输入联系邮箱">
|
</div>
|
||||||
</div>
|
|
||||||
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label for="contact_phone">联系电话 *</label>
|
||||||
<label for="website_url">网站地址 *</label>
|
<input type="text" id="contact_phone" name="contact_phone" required placeholder="请输入联系电话">
|
||||||
<input type="text" id="website_url" name="website_url" required placeholder="请输入网站域名,不带http://">
|
</div>
|
||||||
</div>
|
|
||||||
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label for="contact_email">联系邮箱 *</label>
|
||||||
<label for="website_description">网站描述 *</label>
|
<input type="email" id="contact_email" name="contact_email" required placeholder="请输入联系邮箱">
|
||||||
<textarea id="website_description" name="website_description" required placeholder="请简要描述网站内容"></textarea>
|
</div>
|
||||||
</div>
|
|
||||||
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label for="website_url">网站地址 *</label>
|
||||||
<label for="status">状态 *</label>
|
<input type="text" id="website_url" name="website_url" required placeholder="请输入网站域名,不带http://">
|
||||||
<select id="status" name="status" required>
|
</div>
|
||||||
<option value="pending">待审核</option>
|
|
||||||
<option value="approved">已通过</option>
|
<div class="form-group">
|
||||||
<option value="rejected">已拒绝</option>
|
<label for="website_description">网站描述 *</label>
|
||||||
</select>
|
<textarea id="website_description" name="website_description" required placeholder="请简要描述网站内容"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" id="reason_group" style="display: none;">
|
<div class="form-group">
|
||||||
<label for="reason">处理说明 *</label>
|
<label for="status">状态 *</label>
|
||||||
<textarea id="reason" name="reason" placeholder="请输入审核通过或拒绝的原因"></textarea>
|
<select id="status" name="status" required>
|
||||||
</div>
|
<option value="pending">待审核</option>
|
||||||
|
<option value="approved">已通过</option>
|
||||||
<script>
|
<option value="rejected">已拒绝</option>
|
||||||
// 当状态改变时,显示或隐藏处理说明字段
|
</select>
|
||||||
document.getElementById('status').addEventListener('change', function() {
|
</div>
|
||||||
var reasonGroup = document.getElementById('reason_group');
|
|
||||||
if (this.value === 'approved' || this.value === 'rejected') {
|
<div class="form-group" id="reason_group" style="display: none;">
|
||||||
reasonGroup.style.display = 'block';
|
<label for="reason">处理说明 *</label>
|
||||||
} else {
|
<textarea id="reason" name="reason" placeholder="请输入审核通过或拒绝的原因"></textarea>
|
||||||
reasonGroup.style.display = 'none';
|
</div>
|
||||||
}
|
|
||||||
});
|
<script>
|
||||||
</script>
|
// 当状态改变时,显示或隐藏处理说明字段
|
||||||
|
document.getElementById('status').addEventListener('change', function() {
|
||||||
<div class="btn-container">
|
var reasonGroup = document.getElementById('reason_group');
|
||||||
<button type="submit" class="btn">添加备案</button>
|
if (this.value === 'approved' || this.value === 'rejected') {
|
||||||
<a href="admin_dashboard.php" class="back-link">返回控制面板</a>
|
reasonGroup.style.display = 'block';
|
||||||
</div>
|
} else {
|
||||||
</form>
|
reasonGroup.style.display = 'none';
|
||||||
</div>
|
}
|
||||||
</div>
|
});
|
||||||
</body>
|
</script>
|
||||||
|
|
||||||
|
<div class="btn-container">
|
||||||
|
<button type="submit" class="btn">添加备案</button>
|
||||||
|
<a href="admin_dashboard.php" class="back-link">返回控制面板</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,161 +1,227 @@
|
||||||
<?php
|
<?php
|
||||||
// 加载配置
|
session_start();
|
||||||
$config = include '../config.php';
|
|
||||||
|
// 加载配置
|
||||||
// 数据库连接函数
|
$config = include '../config.php';
|
||||||
function getDatabaseConnection() {
|
|
||||||
global $config;
|
// 数据库连接函数
|
||||||
try {
|
function getDatabaseConnection() {
|
||||||
if ($config['database_type'] === 'mysql') {
|
global $config;
|
||||||
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
try {
|
||||||
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
if ($config['database_type'] === 'mysql') {
|
||||||
} else if ($config['database_type'] === 'sqlite') {
|
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
||||||
$dsn = "sqlite:{$config['database_config']['path']}";
|
$pdo = new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
||||||
return new PDO($dsn);
|
} else if ($config['database_type'] === 'sqlite') {
|
||||||
}
|
$dsn = "sqlite:{$config['database_config']['path']}";
|
||||||
} catch (PDOException $e) {
|
$pdo = new PDO($dsn);
|
||||||
die('数据库连接失败: ' . $e->getMessage());
|
}
|
||||||
}
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
}
|
return $pdo;
|
||||||
|
} catch (PDOException $e) {
|
||||||
// 处理注销请求
|
die('数据库连接失败');
|
||||||
if (isset($_GET['action']) && $_GET['action'] === 'logout') {
|
}
|
||||||
setcookie('admin_logged_in', '', time() - 3600, '/');
|
}
|
||||||
header('Location: admin_login.php');
|
|
||||||
exit;
|
// 处理注销请求
|
||||||
}
|
if (isset($_GET['action']) && $_GET['action'] === 'logout') {
|
||||||
|
session_unset();
|
||||||
// 检查是否已登录
|
session_destroy();
|
||||||
if (isset($_COOKIE['admin_logged_in']) && $_COOKIE['admin_logged_in'] === 'true') {
|
header('Location: admin_login.php');
|
||||||
header('Location: admin_dashboard.php');
|
exit;
|
||||||
exit;
|
}
|
||||||
}
|
|
||||||
|
// 检查是否已登录
|
||||||
$error = '';
|
if (isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true) {
|
||||||
// 处理登录请求
|
header('Location: admin_dashboard.php');
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
exit;
|
||||||
$username = $_POST['username'] ?? '';
|
}
|
||||||
$password = $_POST['password'] ?? '';
|
|
||||||
|
// 防止暴力破解:记录失败次数
|
||||||
// 连接数据库
|
if (!isset($_SESSION['login_attempts'])) {
|
||||||
$pdo = getDatabaseConnection();
|
$_SESSION['login_attempts'] = 0;
|
||||||
|
$_SESSION['last_attempt'] = time();
|
||||||
// 查询管理员信息
|
}
|
||||||
$stmt = $pdo->prepare("SELECT password_hash FROM admins WHERE username = ?");
|
|
||||||
$stmt->execute([$username]);
|
// 重置计数器(5分钟后)
|
||||||
$admin = $stmt->fetch(PDO::FETCH_ASSOC);
|
if (time() - $_SESSION['last_attempt'] > 300) {
|
||||||
|
$_SESSION['login_attempts'] = 0;
|
||||||
// 验证密码
|
}
|
||||||
if ($admin && password_verify($password, $admin['password_hash'])) {
|
|
||||||
// 设置登录cookie,有效期1小时
|
$error = '';
|
||||||
setcookie('admin_logged_in', 'true', time() + 3600, '/');
|
|
||||||
header('Location: admin_dashboard.php');
|
// 处理登录请求
|
||||||
exit;
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
} else {
|
// 检查是否超过最大尝试次数(5次)
|
||||||
$error = '用户名或密码错误';
|
if ($_SESSION['login_attempts'] >= 5) {
|
||||||
}
|
$error = '登录尝试次数过多,请5分钟后重试';
|
||||||
}
|
} else {
|
||||||
?>
|
// 验证CSRF令牌
|
||||||
<!DOCTYPE html>
|
if (!isset($_POST['csrf_token']) || $_POST['csrf_token'] !== $_SESSION['csrf_token']) {
|
||||||
<html lang="zh-CN">
|
$error = '安全验证失败,请重新登录';
|
||||||
<head>
|
} else {
|
||||||
<meta charset="UTF-8">
|
$username = $_POST['username'] ?? '';
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
$password = $_POST['password'] ?? '';
|
||||||
<title>管理员登录 - 二次元网站备案系统</title>
|
|
||||||
<style>
|
// 输入验证
|
||||||
* {
|
if (empty($username) || empty($password)) {
|
||||||
margin: 0;
|
$error = '用户名和密码不能为空';
|
||||||
padding: 0;
|
} else {
|
||||||
box-sizing: border-box;
|
// 连接数据库
|
||||||
}
|
$pdo = getDatabaseConnection();
|
||||||
body {
|
|
||||||
background-color: #f0f2f5;
|
// 查询管理员信息
|
||||||
color: #333;
|
$stmt = $pdo->prepare("SELECT id, password_hash FROM admins WHERE username = ?");
|
||||||
line-height: 1.6;
|
$stmt->execute([$username]);
|
||||||
display: flex;
|
$admin = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
// 验证密码
|
||||||
height: 100vh;
|
if ($admin && password_verify($password, $admin['password_hash'])) {
|
||||||
}
|
// 登录成功,重置尝试次数
|
||||||
.login-container {
|
$_SESSION['login_attempts'] = 0;
|
||||||
background: white;
|
|
||||||
border-radius: 10px;
|
// 设置会话变量
|
||||||
padding: 40px;
|
$_SESSION['admin_logged_in'] = true;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
$_SESSION['admin_id'] = $admin['id'];
|
||||||
width: 100%;
|
$_SESSION['admin_username'] = $username;
|
||||||
max-width: 400px;
|
$_SESSION['last_activity'] = time();
|
||||||
}
|
|
||||||
h1 {
|
// 重新生成会话ID
|
||||||
color: #7873f5;
|
session_regenerate_id(true);
|
||||||
margin-bottom: 30px;
|
|
||||||
text-align: center;
|
header('Location: admin_dashboard.php');
|
||||||
}
|
exit;
|
||||||
.form-group {
|
} else {
|
||||||
margin-bottom: 20px;
|
$_SESSION['login_attempts']++;
|
||||||
}
|
$_SESSION['last_attempt'] = time();
|
||||||
label {
|
$error = '用户名或密码错误';
|
||||||
display: block;
|
}
|
||||||
margin-bottom: 8px;
|
}
|
||||||
font-weight: bold;
|
}
|
||||||
color: #555;
|
}
|
||||||
}
|
}
|
||||||
input[type="text"],
|
|
||||||
input[type="password"] {
|
// 生成CSRF令牌
|
||||||
width: 100%;
|
if (!isset($_SESSION['csrf_token'])) {
|
||||||
padding: 12px;
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||||
border: 1px solid #ddd;
|
}
|
||||||
border-radius: 6px;
|
?>
|
||||||
font-size: 1rem;
|
<!DOCTYPE html>
|
||||||
transition: border 0.3s ease;
|
<html lang="zh-CN">
|
||||||
}
|
<head>
|
||||||
input[type="text"]:focus,
|
<meta charset="UTF-8">
|
||||||
input[type="password"]:focus {
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
border-color: #7873f5;
|
<title>管理员登录 - 二次元网站备案系统</title>
|
||||||
outline: none;
|
<style>
|
||||||
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
* {
|
||||||
}
|
margin: 0;
|
||||||
.btn {
|
padding: 0;
|
||||||
display: inline-block;
|
box-sizing: border-box;
|
||||||
background: #7873f5;
|
}
|
||||||
color: white;
|
body {
|
||||||
padding: 12px 25px;
|
background-color: #f0f2f5;
|
||||||
border-radius: 30px;
|
color: #333;
|
||||||
text-decoration: none;
|
line-height: 1.6;
|
||||||
font-weight: bold;
|
display: flex;
|
||||||
transition: background 0.3s ease;
|
justify-content: center;
|
||||||
border: none;
|
align-items: center;
|
||||||
cursor: pointer;
|
height: 100vh;
|
||||||
font-size: 1rem;
|
}
|
||||||
width: 100%;
|
.login-container {
|
||||||
}
|
background: white;
|
||||||
.btn:hover {
|
border-radius: 10px;
|
||||||
background: #605acf;
|
padding: 40px;
|
||||||
}
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
.error {
|
width: 100%;
|
||||||
color: #e74c3c;
|
max-width: 400px;
|
||||||
font-size: 0.9rem;
|
}
|
||||||
margin-top: 15px;
|
h1 {
|
||||||
text-align: center;
|
color: #7873f5;
|
||||||
}
|
margin-bottom: 30px;
|
||||||
</style>
|
text-align: center;
|
||||||
</head>
|
}
|
||||||
<body>
|
.form-group {
|
||||||
<div class="login-container">
|
margin-bottom: 20px;
|
||||||
<h1>管理员登录</h1>
|
}
|
||||||
<form method="post" class="login-form">
|
label {
|
||||||
<div class="form-group">
|
display: block;
|
||||||
<label for="username">用户名</label>
|
margin-bottom: 8px;
|
||||||
<input type="text" id="username" name="username" required placeholder="请输入管理员用户名">
|
font-weight: bold;
|
||||||
</div>
|
color: #555;
|
||||||
<div class="form-group">
|
}
|
||||||
<label for="password">密码</label>
|
input[type="text"],
|
||||||
<input type="password" id="password" name="password" required placeholder="请输入管理员密码">
|
input[type="password"] {
|
||||||
</div>
|
width: 100%;
|
||||||
<button type="submit" class="btn">登录</button>
|
padding: 12px;
|
||||||
<?php if (!empty($error)): ?>
|
border: 1px solid #ddd;
|
||||||
<div class="error"><?php echo $error; ?></div>
|
border-radius: 6px;
|
||||||
<?php endif; ?>
|
font-size: 1rem;
|
||||||
</form>
|
transition: border 0.3s ease;
|
||||||
</div>
|
}
|
||||||
</body>
|
input[type="text"]:focus,
|
||||||
|
input[type="password"]:focus {
|
||||||
|
border-color: #7873f5;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
background: #7873f5;
|
||||||
|
color: white;
|
||||||
|
padding: 12px 25px;
|
||||||
|
border-radius: 30px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: background 0.3s ease;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.btn:hover {
|
||||||
|
background: #605acf;
|
||||||
|
}
|
||||||
|
.error {
|
||||||
|
color: #e74c3c;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-top: 15px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
color: #666;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
margin-top: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="login-container">
|
||||||
|
<h1>管理员登录</h1>
|
||||||
|
<form method="post" class="login-form">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username">用户名</label>
|
||||||
|
<input type="text" id="username" name="username" required placeholder="请输入管理员用户名" autocomplete="username">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">密码</label>
|
||||||
|
<input type="password" id="password" name="password" required placeholder="请输入管理员密码" autocomplete="current-password">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn">登录</button>
|
||||||
|
|
||||||
|
<?php if (!empty($error)): ?>
|
||||||
|
<div class="error"><?php echo htmlspecialchars($error); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($_SESSION['login_attempts'] >= 3): ?>
|
||||||
|
<div class="info">
|
||||||
|
剩余尝试次数: <?php echo 5 - $_SESSION['login_attempts']; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -1,63 +1,62 @@
|
||||||
<?php
|
<?php
|
||||||
// 管理员审核通过备案申请
|
session_start();
|
||||||
|
require_once '../auth_check.php';
|
||||||
// 检查是否已登录
|
checkAdminAuth();
|
||||||
if (!isset($_COOKIE['admin_logged_in']) || $_COOKIE['admin_logged_in'] !== 'true') {
|
|
||||||
header('Location: admin_login.php');
|
// 检查是否提供了申请ID
|
||||||
exit;
|
if (!isset($_POST['registration_id'])) {
|
||||||
}
|
die('缺少备案申请ID');
|
||||||
|
}
|
||||||
// 检查是否提供了申请ID
|
|
||||||
if (!isset($_POST['registration_id'])) {
|
$registrationId = $_POST['registration_id'];
|
||||||
die('缺少备案申请ID');
|
$reason = $_POST['reason'] ?? '审核通过';
|
||||||
}
|
|
||||||
|
// 正确加载配置
|
||||||
$registrationId = $_POST['registration_id'];
|
$config = include '../config.php';
|
||||||
$reason = $_POST['reason'] ?? '审核通过';
|
if (!$config || !is_array($config)) {
|
||||||
|
die('配置文件加载失败');
|
||||||
// 加载配置
|
}
|
||||||
$config = include '../config.php';
|
|
||||||
|
// 初始化数据库连接
|
||||||
// 初始化数据库连接
|
require_once '../db_init.php';
|
||||||
require_once '../db_init.php';
|
require_once '../email_utils.php';
|
||||||
require_once '../email_utils.php';
|
|
||||||
|
// 更新备案申请状态为通过
|
||||||
// 更新备案申请状态为通过
|
try {
|
||||||
try {
|
// 开始事务
|
||||||
// 开始事务
|
$pdo->beginTransaction();
|
||||||
$pdo->beginTransaction();
|
|
||||||
|
// 获取备案信息
|
||||||
// 获取备案信息
|
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE id = ?");
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE id = ?");
|
$stmt->execute([$registrationId]);
|
||||||
$stmt->execute([$registrationId]);
|
$registration = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$registration = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
if (!$registration) {
|
||||||
if (!$registration) {
|
die('未找到该备案申请');
|
||||||
die('未找到该备案申请');
|
}
|
||||||
}
|
|
||||||
|
// 更新状态
|
||||||
// 更新状态
|
$stmt = $pdo->prepare("UPDATE registrations SET status = 'approved', processed_at = NOW(), reason = ? WHERE id = ?");
|
||||||
$stmt = $pdo->prepare("UPDATE registrations SET status = 'approved', processed_at = NOW(), reason = ? WHERE id = ?");
|
$stmt->execute([$reason, $registrationId]);
|
||||||
$stmt->execute([$reason, $registrationId]);
|
|
||||||
|
// 提交事务
|
||||||
// 提交事务
|
$pdo->commit();
|
||||||
$pdo->commit();
|
|
||||||
|
// 发送邮件通知
|
||||||
// 发送邮件通知
|
try {
|
||||||
try {
|
$emailUtils = new EmailUtils($pdo);
|
||||||
$emailUtils = new EmailUtils($pdo);
|
$emailUtils->sendApprovalEmail($registration);
|
||||||
$emailUtils->sendApprovalEmail($registration);
|
} catch (Exception $e) {
|
||||||
} catch (Exception $e) {
|
// 邮件发送失败,记录日志但不影响主流程
|
||||||
// 邮件发送失败,记录日志但不影响主流程
|
error_log('发送审核通过邮件失败: ' . $e->getMessage());
|
||||||
error_log('发送审核通过邮件失败: ' . $e->getMessage());
|
}
|
||||||
}
|
|
||||||
|
// 重定向回管理员面板
|
||||||
// 重定向回管理员面板
|
header('Location: admin_dashboard.php?success=1&message=备案申请已成功通过');
|
||||||
header('Location: admin_dashboard.php?success=1&message=备案申请已成功通过');
|
exit;
|
||||||
exit;
|
} catch (PDOException $e) {
|
||||||
} catch (PDOException $e) {
|
// 回滚事务
|
||||||
// 回滚事务
|
$pdo->rollBack();
|
||||||
$pdo->rollBack();
|
die('更新备案申请状态失败: ' . $e->getMessage());
|
||||||
die('更新备案申请状态失败: ' . $e->getMessage());
|
}
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -1,287 +1,309 @@
|
||||||
<?php
|
<?php
|
||||||
// 管理管理员账户脚本
|
session_start();
|
||||||
// 使用方法: 访问此文件并按照提示操作
|
require_once '../auth_check.php';
|
||||||
|
checkAdminAuth();
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', 1);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
// 加载配置
|
|
||||||
$config = include '../config.php';
|
// 正确加载配置
|
||||||
|
$config = include '../config.php';
|
||||||
// 数据库连接函数
|
if (!$config || !is_array($config)) {
|
||||||
function getDatabaseConnection() {
|
die('配置文件加载失败');
|
||||||
global $config;
|
}
|
||||||
try {
|
|
||||||
if ($config['database_type'] === 'mysql') {
|
// 数据库连接函数
|
||||||
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
function getDatabaseConnection() {
|
||||||
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
global $config;
|
||||||
} else if ($config['database_type'] === 'sqlite') {
|
try {
|
||||||
$dsn = "sqlite:{$config['database_config']['path']}";
|
if ($config['database_type'] === 'mysql') {
|
||||||
return new PDO($dsn);
|
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
||||||
}
|
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
||||||
} catch (PDOException $e) {
|
} else if ($config['database_type'] === 'sqlite') {
|
||||||
die('数据库连接失败: ' . $e->getMessage());
|
$dsn = "sqlite:{$config['database_config']['path']}";
|
||||||
}
|
return new PDO($dsn);
|
||||||
}
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
// 连接数据库
|
die('数据库连接失败: ' . $e->getMessage());
|
||||||
$pdo = getDatabaseConnection();
|
}
|
||||||
|
}
|
||||||
// 获取所有管理员账户
|
|
||||||
function getAllAdmins($pdo) {
|
// 连接数据库
|
||||||
$stmt = $pdo->query("SELECT id, username, created_at FROM admins");
|
$pdo = getDatabaseConnection();
|
||||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
}
|
// 获取所有管理员账户
|
||||||
|
function getAllAdmins($pdo) {
|
||||||
// 检查用户名是否已存在
|
$stmt = $pdo->query("SELECT id, username, created_at FROM admins");
|
||||||
function checkUsernameExists($pdo, $username) {
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM admins WHERE username = ?");
|
}
|
||||||
$stmt->execute([$username]);
|
|
||||||
return $stmt->fetchColumn() > 0;
|
// 检查用户名是否已存在
|
||||||
}
|
function checkUsernameExists($pdo, $username) {
|
||||||
|
$stmt = $pdo->prepare("SELECT COUNT(*) FROM admins WHERE username = ?");
|
||||||
// 添加新管理员
|
$stmt->execute([$username]);
|
||||||
function addAdmin($pdo, $username, $password) {
|
return $stmt->fetchColumn() > 0;
|
||||||
if (checkUsernameExists($pdo, $username)) {
|
}
|
||||||
return ['success' => false, 'message' => '用户名已存在'];
|
|
||||||
}
|
// 添加新管理员
|
||||||
|
function addAdmin($pdo, $username, $password) {
|
||||||
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
if (checkUsernameExists($pdo, $username)) {
|
||||||
try {
|
return ['success' => false, 'message' => '用户名已存在'];
|
||||||
$stmt = $pdo->prepare("INSERT INTO admins (username, password_hash) VALUES (?, ?)");
|
}
|
||||||
$stmt->execute([$username, $password_hash]);
|
|
||||||
return ['success' => true, 'message' => '管理员添加成功'];
|
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||||
} catch (PDOException $e) {
|
try {
|
||||||
return ['success' => false, 'message' => '添加失败: ' . $e->getMessage()];
|
$stmt = $pdo->prepare("INSERT INTO admins (username, password_hash) VALUES (?, ?)");
|
||||||
}
|
$stmt->execute([$username, $password_hash]);
|
||||||
}
|
return ['success' => true, 'message' => '管理员添加成功'];
|
||||||
|
} catch (PDOException $e) {
|
||||||
// 删除管理员
|
return ['success' => false, 'message' => '添加失败: ' . $e->getMessage()];
|
||||||
function deleteAdmin($pdo, $id) {
|
}
|
||||||
try {
|
}
|
||||||
$stmt = $pdo->prepare("DELETE FROM admins WHERE id = ?");
|
|
||||||
$stmt->execute([$id]);
|
// 删除管理员
|
||||||
return ['success' => true, 'message' => '管理员删除成功'];
|
function deleteAdmin($pdo, $id) {
|
||||||
} catch (PDOException $e) {
|
try {
|
||||||
return ['success' => false, 'message' => '删除失败: ' . $e->getMessage()];
|
$stmt = $pdo->prepare("DELETE FROM admins WHERE id = ?");
|
||||||
}
|
$stmt->execute([$id]);
|
||||||
}
|
return ['success' => true, 'message' => '管理员删除成功'];
|
||||||
|
} catch (PDOException $e) {
|
||||||
// 处理表单提交
|
return ['success' => false, 'message' => '删除失败: ' . $e->getMessage()];
|
||||||
$message = '';
|
}
|
||||||
$success = false;
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
// 处理表单提交
|
||||||
if (isset($_POST['action'])) {
|
$message = '';
|
||||||
switch ($_POST['action']) {
|
$success = false;
|
||||||
case 'add':
|
|
||||||
$username = trim($_POST['username']);
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$password = trim($_POST['password']);
|
// 验证CSRF令牌
|
||||||
$confirm_password = trim($_POST['confirm_password']);
|
if (!isset($_POST['csrf_token']) || $_POST['csrf_token'] !== $_SESSION['csrf_token']) {
|
||||||
|
$message = '安全验证失败';
|
||||||
if (empty($username) || empty($password)) {
|
} else {
|
||||||
$message = '用户名和密码不能为空';
|
if (isset($_POST['action'])) {
|
||||||
} elseif ($password !== $confirm_password) {
|
switch ($_POST['action']) {
|
||||||
$message = '两次输入的密码不一致';
|
case 'add':
|
||||||
} elseif (strlen($password) < 6) {
|
$username = trim($_POST['username']);
|
||||||
$message = '密码长度不能少于6位';
|
$password = trim($_POST['password']);
|
||||||
} else {
|
$confirm_password = trim($_POST['confirm_password']);
|
||||||
$result = addAdmin($pdo, $username, $password);
|
|
||||||
$success = $result['success'];
|
if (empty($username) || empty($password)) {
|
||||||
$message = $result['message'];
|
$message = '用户名和密码不能为空';
|
||||||
}
|
} elseif ($password !== $confirm_password) {
|
||||||
break;
|
$message = '两次输入的密码不一致';
|
||||||
|
} elseif (strlen($password) < 6) {
|
||||||
case 'delete':
|
$message = '密码长度不能少于6位';
|
||||||
$id = (int)$_POST['id'];
|
} else {
|
||||||
$result = deleteAdmin($pdo, $id);
|
$result = addAdmin($pdo, $username, $password);
|
||||||
$success = $result['success'];
|
$success = $result['success'];
|
||||||
$message = $result['message'];
|
$message = $result['message'];
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
}
|
case 'delete':
|
||||||
|
$id = (int)$_POST['id'];
|
||||||
// 获取所有管理员
|
// 防止删除自己
|
||||||
$admins = getAllAdmins($pdo);
|
if ($id == $_SESSION['admin_id']) {
|
||||||
|
$message = '不能删除当前登录的管理员账户';
|
||||||
?>
|
} else {
|
||||||
<!DOCTYPE html>
|
$result = deleteAdmin($pdo, $id);
|
||||||
<html lang="zh-CN">
|
$success = $result['success'];
|
||||||
<head>
|
$message = $result['message'];
|
||||||
<meta charset="UTF-8">
|
}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
break;
|
||||||
<title>管理员账户管理</title>
|
}
|
||||||
<style>
|
}
|
||||||
* {
|
}
|
||||||
margin: 0;
|
}
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
// 生成CSRF令牌
|
||||||
font-family: 'ZD', sans-serif;
|
$csrf_token = generateCSRFToken();
|
||||||
}
|
|
||||||
body {
|
// 获取所有管理员
|
||||||
background-color: #f0f2f5;
|
$admins = getAllAdmins($pdo);
|
||||||
color: #333;
|
?>
|
||||||
line-height: 1.6;
|
<!DOCTYPE html>
|
||||||
padding: 20px;
|
<html lang="zh-CN">
|
||||||
}
|
<head>
|
||||||
.container {
|
<meta charset="UTF-8">
|
||||||
max-width: 800px;
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
margin: 0 auto;
|
<title>管理员账户管理</title>
|
||||||
background-color: #fff;
|
<style>
|
||||||
border-radius: 10px;
|
* {
|
||||||
padding: 30px;
|
margin: 0;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
padding: 0;
|
||||||
}
|
box-sizing: border-box;
|
||||||
h1 {
|
font-family: 'ZD', sans-serif;
|
||||||
color: #7873f5;
|
}
|
||||||
margin-bottom: 20px;
|
body {
|
||||||
text-align: center;
|
background-color: #f0f2f5;
|
||||||
}
|
color: #333;
|
||||||
table {
|
line-height: 1.6;
|
||||||
width: 100%;
|
padding: 20px;
|
||||||
border-collapse: collapse;
|
}
|
||||||
margin-bottom: 30px;
|
.container {
|
||||||
}
|
max-width: 800px;
|
||||||
th, td {
|
margin: 0 auto;
|
||||||
padding: 12px 15px;
|
background-color: #fff;
|
||||||
text-align: left;
|
border-radius: 10px;
|
||||||
border-bottom: 1px solid #ddd;
|
padding: 30px;
|
||||||
}
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
th {
|
}
|
||||||
background-color: #f8f9fa;
|
h1 {
|
||||||
font-weight: bold;
|
color: #7873f5;
|
||||||
}
|
margin-bottom: 20px;
|
||||||
tr:hover {
|
text-align: center;
|
||||||
background-color: #f5f5f5;
|
}
|
||||||
}
|
table {
|
||||||
.btn {
|
width: 100%;
|
||||||
display: inline-block;
|
border-collapse: collapse;
|
||||||
background: #7873f5;
|
margin-bottom: 30px;
|
||||||
color: white;
|
}
|
||||||
padding: 8px 15px;
|
th, td {
|
||||||
border-radius: 4px;
|
padding: 12px 15px;
|
||||||
text-decoration: none;
|
text-align: left;
|
||||||
font-weight: bold;
|
border-bottom: 1px solid #ddd;
|
||||||
transition: background 0.3s ease;
|
}
|
||||||
border: none;
|
th {
|
||||||
cursor: pointer;
|
background-color: #f8f9fa;
|
||||||
font-size: 0.9rem;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.btn:hover {
|
tr:hover {
|
||||||
background: #605acf;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
.btn-danger {
|
.btn {
|
||||||
background: #e74c3c;
|
display: inline-block;
|
||||||
}
|
background: #7873f5;
|
||||||
.btn-danger:hover {
|
color: white;
|
||||||
background: #c0392b;
|
padding: 8px 15px;
|
||||||
}
|
border-radius: 4px;
|
||||||
.form-group {
|
text-decoration: none;
|
||||||
margin-bottom: 20px;
|
font-weight: bold;
|
||||||
}
|
transition: background 0.3s ease;
|
||||||
label {
|
border: none;
|
||||||
display: block;
|
cursor: pointer;
|
||||||
margin-bottom: 8px;
|
font-size: 0.9rem;
|
||||||
font-weight: bold;
|
}
|
||||||
color: #555;
|
.btn:hover {
|
||||||
}
|
background: #605acf;
|
||||||
input[type="text"],
|
}
|
||||||
input[type="password"] {
|
.btn-danger {
|
||||||
width: 100%;
|
background: #e74c3c;
|
||||||
padding: 12px;
|
}
|
||||||
border: 1px solid #ddd;
|
.btn-danger:hover {
|
||||||
border-radius: 6px;
|
background: #c0392b;
|
||||||
font-size: 1rem;
|
}
|
||||||
}
|
.form-group {
|
||||||
.message {
|
margin-bottom: 20px;
|
||||||
padding: 15px;
|
}
|
||||||
margin-bottom: 20px;
|
label {
|
||||||
border-radius: 4px;
|
display: block;
|
||||||
font-weight: bold;
|
margin-bottom: 8px;
|
||||||
}
|
font-weight: bold;
|
||||||
.success {
|
color: #555;
|
||||||
background-color: #d4edda;
|
}
|
||||||
color: #155724;
|
input[type="text"],
|
||||||
border: 1px solid #c3e6cb;
|
input[type="password"] {
|
||||||
}
|
width: 100%;
|
||||||
.error {
|
padding: 12px;
|
||||||
background-color: #f8d7da;
|
border: 1px solid #ddd;
|
||||||
color: #721c24;
|
border-radius: 6px;
|
||||||
border: 1px solid #f5c6cb;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
.card {
|
.message {
|
||||||
background: white;
|
padding: 15px;
|
||||||
border-radius: 10px;
|
margin-bottom: 20px;
|
||||||
padding: 20px;
|
border-radius: 4px;
|
||||||
margin-bottom: 30px;
|
font-weight: bold;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
}
|
||||||
}
|
.success {
|
||||||
</style>
|
background-color: #d4edda;
|
||||||
</head>
|
color: #155724;
|
||||||
<body>
|
border: 1px solid #c3e6cb;
|
||||||
<div class="container">
|
}
|
||||||
<h1>管理员账户管理</h1>
|
.error {
|
||||||
|
background-color: #f8d7da;
|
||||||
<?php if (!empty($message)): ?>
|
color: #721c24;
|
||||||
<div class="message <?php echo $success ? 'success' : 'error'; ?>">
|
border: 1px solid #f5c6cb;
|
||||||
<?php echo $message; ?>
|
}
|
||||||
</div>
|
.card {
|
||||||
<?php endif; ?>
|
background: white;
|
||||||
|
border-radius: 10px;
|
||||||
<div class="card">
|
padding: 20px;
|
||||||
<h2>当前管理员账户</h2>
|
margin-bottom: 30px;
|
||||||
<table>
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
<thead>
|
}
|
||||||
<tr>
|
</style>
|
||||||
<th>ID</th>
|
</head>
|
||||||
<th>用户名</th>
|
<body>
|
||||||
<th>创建时间</th>
|
<div class="container">
|
||||||
<th>操作</th>
|
<h1>管理员账户管理</h1>
|
||||||
</tr>
|
|
||||||
</thead>
|
<?php if (!empty($message)): ?>
|
||||||
<tbody>
|
<div class="message <?php echo $success ? 'success' : 'error'; ?>">
|
||||||
<?php foreach ($admins as $admin): ?>
|
<?php echo $message; ?>
|
||||||
<tr>
|
</div>
|
||||||
<td><?php echo $admin['id']; ?></td>
|
<?php endif; ?>
|
||||||
<td><?php echo $admin['username']; ?></td>
|
|
||||||
<td><?php echo $admin['created_at']; ?></td>
|
<div class="card">
|
||||||
<td>
|
<h2>当前管理员账户</h2>
|
||||||
<form method="post" style="display: inline;">
|
<table>
|
||||||
<input type="hidden" name="action" value="delete">
|
<thead>
|
||||||
<input type="hidden" name="id" value="<?php echo $admin['id']; ?>">
|
<tr>
|
||||||
<button type="submit" class="btn btn-danger" onclick="return confirm('确定要删除这个管理员账户吗?');">删除</button>
|
<th>ID</th>
|
||||||
</form>
|
<th>用户名</th>
|
||||||
</td>
|
<th>创建时间</th>
|
||||||
</tr>
|
<th>操作</th>
|
||||||
<?php endforeach; ?>
|
</tr>
|
||||||
</tbody>
|
</thead>
|
||||||
</table>
|
<tbody>
|
||||||
</div>
|
<?php foreach ($admins as $admin): ?>
|
||||||
|
<tr>
|
||||||
<div class="card">
|
<td><?php echo $admin['id']; ?></td>
|
||||||
<h2>添加新管理员</h2>
|
<td><?php echo htmlspecialchars($admin['username']); ?></td>
|
||||||
<form method="post">
|
<td><?php echo $admin['created_at']; ?></td>
|
||||||
<input type="hidden" name="action" value="add">
|
<td>
|
||||||
<div class="form-group">
|
<?php if ($admin['id'] != $_SESSION['admin_id']): ?>
|
||||||
<label for="username">用户名</label>
|
<form method="post" style="display: inline;">
|
||||||
<input type="text" id="username" name="username" required placeholder="输入新管理员用户名">
|
<input type="hidden" name="csrf_token" value="<?php echo $csrf_token; ?>">
|
||||||
</div>
|
<input type="hidden" name="action" value="delete">
|
||||||
<div class="form-group">
|
<input type="hidden" name="id" value="<?php echo $admin['id']; ?>">
|
||||||
<label for="password">密码</label>
|
<button type="submit" class="btn btn-danger" onclick="return confirm('确定要删除这个管理员账户吗?');">删除</button>
|
||||||
<input type="password" id="password" name="password" required placeholder="输入密码(至少6位)">
|
</form>
|
||||||
</div>
|
<?php else: ?>
|
||||||
<div class="form-group">
|
<span style="color: #999;">当前账户</span>
|
||||||
<label for="confirm_password">确认密码</label>
|
<?php endif; ?>
|
||||||
<input type="password" id="confirm_password" name="confirm_password" required placeholder="再次输入密码">
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
<button type="submit" class="btn">添加管理员</button>
|
<?php endforeach; ?>
|
||||||
</form>
|
</tbody>
|
||||||
</div>
|
</table>
|
||||||
|
</div>
|
||||||
<div style="text-align: center; margin-top: 30px;">
|
|
||||||
<a href="admin_dashboard.php" class="btn">返回管理面板</a>
|
<div class="card">
|
||||||
</div>
|
<h2>添加新管理员</h2>
|
||||||
</div>
|
<form method="post">
|
||||||
</body>
|
<input type="hidden" name="csrf_token" value="<?php echo $csrf_token; ?>">
|
||||||
|
<input type="hidden" name="action" value="add">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username">用户名</label>
|
||||||
|
<input type="text" id="username" name="username" required placeholder="输入新管理员用户名">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">密码</label>
|
||||||
|
<input type="password" id="password" name="password" required placeholder="输入密码(至少6位)">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="confirm_password">确认密码</label>
|
||||||
|
<input type="password" id="confirm_password" name="confirm_password" required placeholder="再次输入密码">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn">添加管理员</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="text-align: center; margin-top: 30px;">
|
||||||
|
<a href="admin_dashboard.php" class="btn">返回管理面板</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
131
admin/reject.php
131
admin/reject.php
|
|
@ -1,67 +1,66 @@
|
||||||
<?php
|
<?php
|
||||||
// 管理员拒绝备案申请
|
session_start();
|
||||||
|
require_once '../auth_check.php';
|
||||||
// 检查是否已登录
|
checkAdminAuth();
|
||||||
if (!isset($_COOKIE['admin_logged_in']) || $_COOKIE['admin_logged_in'] !== 'true') {
|
|
||||||
header('Location: admin_login.php');
|
// 检查是否提供了申请ID
|
||||||
exit;
|
if (!isset($_POST['registration_id'])) {
|
||||||
}
|
die('缺少备案申请ID');
|
||||||
|
}
|
||||||
// 检查是否提供了申请ID
|
|
||||||
if (!isset($_POST['registration_id'])) {
|
$registrationId = $_POST['registration_id'];
|
||||||
die('缺少备案申请ID');
|
$reason = $_POST['reason'] ?? '';
|
||||||
}
|
|
||||||
|
if (empty($reason)) {
|
||||||
$registrationId = $_POST['registration_id'];
|
die('请提供拒绝原因');
|
||||||
$reason = $_POST['reason'] ?? '';
|
}
|
||||||
|
|
||||||
if (empty($reason)) {
|
// 正确加载配置
|
||||||
die('请提供拒绝原因');
|
$config = include '../config.php';
|
||||||
}
|
if (!$config || !is_array($config)) {
|
||||||
|
die('配置文件加载失败');
|
||||||
// 加载配置
|
}
|
||||||
$config = include '../config.php';
|
|
||||||
|
// 初始化数据库连接
|
||||||
// 初始化数据库连接
|
require_once '../db_init.php';
|
||||||
require_once '../db_init.php';
|
require_once '../email_utils.php';
|
||||||
require_once '../email_utils.php';
|
|
||||||
|
// 更新备案申请状态为拒绝
|
||||||
// 更新备案申请状态为拒绝
|
try {
|
||||||
try {
|
// 开始事务
|
||||||
// 开始事务
|
$pdo->beginTransaction();
|
||||||
$pdo->beginTransaction();
|
|
||||||
|
// 获取备案信息
|
||||||
// 获取备案信息
|
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE id = ?");
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE id = ?");
|
$stmt->execute([$registrationId]);
|
||||||
$stmt->execute([$registrationId]);
|
$registration = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$registration = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
if (!$registration) {
|
||||||
if (!$registration) {
|
die('未找到该备案申请');
|
||||||
die('未找到该备案申请');
|
}
|
||||||
}
|
|
||||||
|
// 更新状态
|
||||||
// 更新状态
|
$stmt = $pdo->prepare("UPDATE registrations SET status = 'rejected', processed_at = NOW(), reason = ? WHERE id = ?");
|
||||||
$stmt = $pdo->prepare("UPDATE registrations SET status = 'rejected', processed_at = NOW(), reason = ? WHERE id = ?");
|
$stmt->execute([$reason, $registrationId]);
|
||||||
$stmt->execute([$reason, $registrationId]);
|
|
||||||
|
// 提交事务
|
||||||
// 提交事务
|
$pdo->commit();
|
||||||
$pdo->commit();
|
|
||||||
|
// 发送邮件通知
|
||||||
// 发送邮件通知
|
try {
|
||||||
try {
|
$emailUtils = new EmailUtils($pdo);
|
||||||
$emailUtils = new EmailUtils($config);
|
$emailUtils->sendRejectionEmail($registration);
|
||||||
$emailUtils->sendRejectionEmail($registration);
|
} catch (Exception $e) {
|
||||||
} catch (Exception $e) {
|
// 邮件发送失败,记录日志但不影响主流程
|
||||||
// 邮件发送失败,记录日志但不影响主流程
|
error_log('发送拒绝通知邮件失败: ' . $e->getMessage());
|
||||||
error_log('发送拒绝通知邮件失败: ' . $e->getMessage());
|
}
|
||||||
}
|
|
||||||
|
// 重定向回管理员面板
|
||||||
// 重定向回管理员面板
|
header('Location: admin_dashboard.php?success=1&message=备案申请已拒绝');
|
||||||
header('Location: admin_dashboard.php?success=1&message=备案申请已拒绝');
|
exit;
|
||||||
exit;
|
} catch (PDOException $e) {
|
||||||
} catch (PDOException $e) {
|
// 回滚事务
|
||||||
// 回滚事务
|
$pdo->rollBack();
|
||||||
$pdo->rollBack();
|
die('更新备案申请状态失败: ' . $e->getMessage());
|
||||||
die('更新备案申请状态失败: ' . $e->getMessage());
|
}
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
476
admin/settings.php
Normal file
476
admin/settings.php
Normal file
|
|
@ -0,0 +1,476 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once '../auth_check.php';
|
||||||
|
checkAdminAuth();
|
||||||
|
$csrf_token = generateCSRFToken();
|
||||||
|
|
||||||
|
// 加载配置
|
||||||
|
$config = include '../config.php';
|
||||||
|
|
||||||
|
// 数据库连接函数
|
||||||
|
function getDatabaseConnection() {
|
||||||
|
global $config;
|
||||||
|
try {
|
||||||
|
if ($config['database_type'] === 'mysql') {
|
||||||
|
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
||||||
|
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
||||||
|
} else if ($config['database_type'] === 'sqlite') {
|
||||||
|
$dsn = "sqlite:{$config['database_config']['path']}";
|
||||||
|
return new PDO($dsn);
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die('数据库连接失败: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 连接数据库
|
||||||
|
$pdo = getDatabaseConnection();
|
||||||
|
|
||||||
|
// 从数据库获取网站信息
|
||||||
|
$stmt = $pdo->query("SELECT name, description FROM site_info LIMIT 1");
|
||||||
|
$siteInfo = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// 如果找不到网站信息,使用配置文件中的默认值
|
||||||
|
if (!$siteInfo) {
|
||||||
|
$siteInfo = [
|
||||||
|
'name' => $config['site_name'] ?? '二次元网站备案系统',
|
||||||
|
'description' => $config['site_description'] ?? '管理和审核网站备案申请'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从数据库获取邮件配置
|
||||||
|
$stmt = $pdo->query("SELECT * FROM email_config LIMIT 1");
|
||||||
|
$emailConfig = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// 如果找不到邮件配置,使用默认值
|
||||||
|
if (!$emailConfig) {
|
||||||
|
$emailConfig = [
|
||||||
|
'smtp_host' => '',
|
||||||
|
'smtp_port' => 465,
|
||||||
|
'smtp_username' => '',
|
||||||
|
'smtp_password' => '',
|
||||||
|
'smtp_encryption' => 'ssl',
|
||||||
|
'from_email' => '',
|
||||||
|
'from_name' => $siteInfo['name']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理表单提交
|
||||||
|
$success = '';
|
||||||
|
$errors = [];
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
// 验证CSRF令牌
|
||||||
|
verifyCSRFToken($_POST['csrf_token'] ?? '');
|
||||||
|
|
||||||
|
// 处理站点设置
|
||||||
|
$siteName = trim($_POST['site_name']);
|
||||||
|
$siteDescription = trim($_POST['site_description']);
|
||||||
|
|
||||||
|
// 处理邮件设置
|
||||||
|
$smtpHost = trim($_POST['smtp_host']);
|
||||||
|
$smtpPort = (int)$_POST['smtp_port'];
|
||||||
|
$smtpUsername = trim($_POST['smtp_username']);
|
||||||
|
$smtpPassword = trim($_POST['smtp_password']);
|
||||||
|
$smtpEncryption = $_POST['smtp_encryption'];
|
||||||
|
$fromEmail = trim($_POST['from_email']);
|
||||||
|
$fromName = trim($_POST['from_name']);
|
||||||
|
|
||||||
|
// 验证必填字段
|
||||||
|
if (empty($siteName)) {
|
||||||
|
$errors[] = '站点名称不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($smtpHost) || empty($smtpUsername) || empty($smtpPassword) || empty($fromEmail)) {
|
||||||
|
$errors[] = '邮件配置的必填字段不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
try {
|
||||||
|
// 开始事务
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
|
||||||
|
// 更新站点信息
|
||||||
|
if ($siteInfo) {
|
||||||
|
$stmt = $pdo->prepare("UPDATE site_info SET name = ?, description = ?");
|
||||||
|
$stmt->execute([$siteName, $siteDescription]);
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO site_info (name, description) VALUES (?, ?)");
|
||||||
|
$stmt->execute([$siteName, $siteDescription]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新邮件配置
|
||||||
|
if ($emailConfig) {
|
||||||
|
$stmt = $pdo->prepare("UPDATE email_config SET smtp_host = ?, smtp_port = ?, smtp_username = ?, smtp_password = ?, smtp_encryption = ?, from_email = ?, from_name = ?");
|
||||||
|
$stmt->execute([$smtpHost, $smtpPort, $smtpUsername, $smtpPassword, $smtpEncryption, $fromEmail, $fromName]);
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO email_config (smtp_host, smtp_port, smtp_username, smtp_password, smtp_encryption, from_email, from_name) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
$stmt->execute([$smtpHost, $smtpPort, $smtpUsername, $smtpPassword, $smtpEncryption, $fromEmail, $fromName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交事务
|
||||||
|
$pdo->commit();
|
||||||
|
|
||||||
|
$success = '设置已成功保存';
|
||||||
|
|
||||||
|
// 更新本地变量以反映更改
|
||||||
|
$siteInfo['name'] = $siteName;
|
||||||
|
$siteInfo['description'] = $siteDescription;
|
||||||
|
$emailConfig = [
|
||||||
|
'smtp_host' => $smtpHost,
|
||||||
|
'smtp_port' => $smtpPort,
|
||||||
|
'smtp_username' => $smtpUsername,
|
||||||
|
'smtp_password' => $smtpPassword,
|
||||||
|
'smtp_encryption' => $smtpEncryption,
|
||||||
|
'from_email' => $fromEmail,
|
||||||
|
'from_name' => $fromName
|
||||||
|
];
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// 回滚事务
|
||||||
|
$pdo->rollBack();
|
||||||
|
$errors[] = '保存设置失败: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保email_config表存在
|
||||||
|
function ensureEmailConfigTableExists($pdo) {
|
||||||
|
try {
|
||||||
|
// 根据数据库类型选择自增关键字
|
||||||
|
global $config;
|
||||||
|
$auto_increment = ($config['database_type'] === 'mysql') ? 'AUTO_INCREMENT' : 'AUTOINCREMENT';
|
||||||
|
$int_type = ($config['database_type'] === 'mysql') ? 'INT' : 'INTEGER';
|
||||||
|
|
||||||
|
$pdo->exec("CREATE TABLE IF NOT EXISTS email_config (
|
||||||
|
id $int_type PRIMARY KEY $auto_increment,
|
||||||
|
smtp_host VARCHAR(255) NOT NULL,
|
||||||
|
smtp_port INTEGER NOT NULL,
|
||||||
|
smtp_username VARCHAR(255) NOT NULL,
|
||||||
|
smtp_password VARCHAR(255) NOT NULL,
|
||||||
|
smtp_encryption VARCHAR(10) NOT NULL,
|
||||||
|
from_email VARCHAR(255) NOT NULL,
|
||||||
|
from_name VARCHAR(255) NOT NULL,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)");
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die('创建email_config表失败: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保表存在
|
||||||
|
ensureEmailConfigTableExists($pdo);
|
||||||
|
?>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>系统设置 - <?php echo $siteInfo['name']; ?></title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: #f0f2f5;
|
||||||
|
color: #333;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.header-frosted {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background: rgba(255, 255, 255, 0.7);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10px);
|
||||||
|
color: #333;
|
||||||
|
padding: 15px 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
.header-nav {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
.header-nav span {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #7873f5;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: color 0.3s ease;
|
||||||
|
}
|
||||||
|
.header-nav span:hover {
|
||||||
|
color: #605acf;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
||||||
|
color: white;
|
||||||
|
padding: 80px 0 40px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
|
margin-top: 60px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 30px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color: #7873f5;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 2px solid #f0f0f0;
|
||||||
|
}
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
input[type="text"],
|
||||||
|
input[type="email"],
|
||||||
|
input[type="password"],
|
||||||
|
textarea,
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
transition: border 0.3s ease;
|
||||||
|
}
|
||||||
|
input[type="text"]:focus,
|
||||||
|
input[type="email"]:focus,
|
||||||
|
input[type="password"]:focus,
|
||||||
|
textarea:focus,
|
||||||
|
select:focus {
|
||||||
|
border-color: #7873f5;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
height: 150px;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
background: #7873f5;
|
||||||
|
color: white;
|
||||||
|
padding: 12px 25px;
|
||||||
|
border-radius: 30px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: background 0.3s ease;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
.btn:hover {
|
||||||
|
background: #605acf;
|
||||||
|
}
|
||||||
|
.btn-container {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
.back-link {
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 15px;
|
||||||
|
color: #7873f5;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.back-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.error {
|
||||||
|
color: #e74c3c;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
.success {
|
||||||
|
color: #2ecc71;
|
||||||
|
padding: 15px;
|
||||||
|
background: #f1f9f1;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-left: 4px solid #2ecc71;
|
||||||
|
}
|
||||||
|
.logout-btn {
|
||||||
|
background: #e74c3c;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 8px 15px;
|
||||||
|
border-radius: 30px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: background 0.3s ease;
|
||||||
|
}
|
||||||
|
.logout-btn:hover {
|
||||||
|
background: #c0392b;
|
||||||
|
}
|
||||||
|
.tab-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.tab {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background: #f0f0f0;
|
||||||
|
border-radius: 5px 5px 0 0;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #777;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
.tab.active {
|
||||||
|
background: white;
|
||||||
|
color: #7873f5;
|
||||||
|
border-top: 2px solid #7873f5;
|
||||||
|
}
|
||||||
|
.tab-content {
|
||||||
|
display: none;
|
||||||
|
background: white;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 0 5px 5px 5px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.tab-content.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// 选项卡切换
|
||||||
|
const tabs = document.querySelectorAll('.tab');
|
||||||
|
tabs.forEach(tab => {
|
||||||
|
tab.addEventListener('click', function() {
|
||||||
|
// 移除所有active类
|
||||||
|
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
||||||
|
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
|
||||||
|
|
||||||
|
// 添加active类到当前选项卡
|
||||||
|
this.classList.add('active');
|
||||||
|
const target = this.getAttribute('data-target');
|
||||||
|
document.getElementById(target).classList.add('active');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header-frosted">
|
||||||
|
<h3><?php echo $siteInfo['name']; ?> - 管理员面板</h3>
|
||||||
|
<div class="header-nav">
|
||||||
|
<span onclick="window.location.href='admin_dashboard.php'">控制面板</span>
|
||||||
|
<span onclick="window.location.href='admin_dashboard.php?view=all'">所有备案</span>
|
||||||
|
<span onclick="window.location.href='admin_dashboard.php?view=pending'">待审核备案</span>
|
||||||
|
<span onclick="window.location.href='add_registration.php'">添加备案</span>
|
||||||
|
<span onclick="window.location.href='settings.php'">系统设置</span>
|
||||||
|
<button class="logout-btn" onclick="window.location.href='admin_login.php?action=logout'">退出登录</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<header>
|
||||||
|
<h1><?php echo $siteInfo['name']; ?> - 系统设置</h1>
|
||||||
|
<p>配置站点信息和邮件设置</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h2>系统设置</h2>
|
||||||
|
|
||||||
|
<?php if ($success): ?>
|
||||||
|
<div class="success"><?php echo $success; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (!empty($errors)): ?>
|
||||||
|
<?php foreach ($errors as $error): ?>
|
||||||
|
<div class="error"><?php echo $error; ?></div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="tab-container">
|
||||||
|
<div class="tab active" data-target="site-settings">站点设置</div>
|
||||||
|
<div class="tab" data-target="email-settings">邮件设置</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo $csrf_token; ?>">
|
||||||
|
|
||||||
|
<div id="site-settings" class="tab-content active">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="site_name">站点名称 *</label>
|
||||||
|
<input type="text" id="site_name" name="site_name" required value="<?php echo htmlspecialchars($siteInfo['name']); ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="site_description">站点描述</label>
|
||||||
|
<textarea id="site_description" name="site_description"><?php echo htmlspecialchars($siteInfo['description']); ?></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="email-settings" class="tab-content">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="smtp_host">SMTP 服务器 *</label>
|
||||||
|
<input type="text" id="smtp_host" name="smtp_host" required value="<?php echo htmlspecialchars($emailConfig['smtp_host']); ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="smtp_port">SMTP 端口 *</label>
|
||||||
|
<input type="text" id="smtp_port" name="smtp_port" required value="<?php echo htmlspecialchars($emailConfig['smtp_port']); ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="smtp_encryption">加密方式 *</label>
|
||||||
|
<select id="smtp_encryption" name="smtp_encryption" required>
|
||||||
|
<option value="ssl" <?php echo $emailConfig['smtp_encryption'] === 'ssl' ? 'selected' : ''; ?>>SSL</option>
|
||||||
|
<option value="tls" <?php echo $emailConfig['smtp_encryption'] === 'tls' ? 'selected' : ''; ?>>TLS</option>
|
||||||
|
<option value="none" <?php echo $emailConfig['smtp_encryption'] === 'none' ? 'selected' : ''; ?>>无</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="smtp_username">SMTP 用户名 *</label>
|
||||||
|
<input type="text" id="smtp_username" name="smtp_username" required value="<?php echo htmlspecialchars($emailConfig['smtp_username']); ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="smtp_password">SMTP 密码 *</label>
|
||||||
|
<input type="password" id="smtp_password" name="smtp_password" required value="<?php echo htmlspecialchars($emailConfig['smtp_password']); ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="from_email">发件人邮箱 *</label>
|
||||||
|
<input type="email" id="from_email" name="from_email" required value="<?php echo htmlspecialchars($emailConfig['from_email']); ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="from_name">发件人名称 *</label>
|
||||||
|
<input type="text" id="from_name" name="from_name" required value="<?php echo htmlspecialchars($emailConfig['from_name']); ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-container">
|
||||||
|
<button type="submit" class="btn">保存设置</button>
|
||||||
|
<a href="admin_dashboard.php" class="back-link">返回控制面板</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
44
auth_check.php
Normal file
44
auth_check.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
// 统一身份验证和安全检查模块
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// 验证管理员登录状态
|
||||||
|
function checkAdminAuth() {
|
||||||
|
// 检查 session 而不是 cookie
|
||||||
|
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
|
||||||
|
header('Location: /admin/admin_login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查会话超时(1小时)
|
||||||
|
if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > 3600)) {
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
header('Location: /admin/admin_login.php?timeout=1');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION['last_activity'] = time();
|
||||||
|
|
||||||
|
// 重新生成会话ID以防止会话固定攻击
|
||||||
|
if (!isset($_SESSION['regenerated'])) {
|
||||||
|
session_regenerate_id(true);
|
||||||
|
$_SESSION['regenerated'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成CSRF令牌
|
||||||
|
function generateCSRFToken() {
|
||||||
|
if (!isset($_SESSION['csrf_token'])) {
|
||||||
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||||
|
}
|
||||||
|
return $_SESSION['csrf_token'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证CSRF令牌
|
||||||
|
function verifyCSRFToken($token) {
|
||||||
|
if (!isset($_SESSION['csrf_token']) || $token !== $_SESSION['csrf_token']) {
|
||||||
|
die('CSRF token validation failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
182
db_init.php
182
db_init.php
|
|
@ -1,104 +1,80 @@
|
||||||
<?php
|
<?php
|
||||||
// 数据库初始化脚本
|
// 数据库初始化脚本
|
||||||
// 这个脚本用于创建必要的数据库表结构
|
// 安全检查:如果系统已安装,禁止访问
|
||||||
|
if (file_exists('.installed')) {
|
||||||
// 加载配置
|
die('系统已安装。数据库初始化已被禁用。');
|
||||||
$config = include 'config.php';
|
}
|
||||||
|
|
||||||
// 数据库连接函数
|
// 正确加载配置
|
||||||
function getDatabaseConnection() {
|
$config = include 'config.php';
|
||||||
global $config;
|
if (!$config || !is_array($config)) {
|
||||||
try {
|
die('配置文件加载失败');
|
||||||
if ($config['database_type'] === 'mysql') {
|
}
|
||||||
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
|
||||||
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
// 数据库连接函数
|
||||||
} else if ($config['database_type'] === 'sqlite') {
|
function getDatabaseConnection() {
|
||||||
$dsn = "sqlite:{$config['database_config']['path']}";
|
global $config;
|
||||||
return new PDO($dsn);
|
try {
|
||||||
}
|
if ($config['database_type'] === 'mysql') {
|
||||||
} catch (PDOException $e) {
|
$dsn = "mysql:host={$config['database_config']['host']};port={$config['database_config']['port']};dbname={$config['database_config']['name']};charset=utf8mb4";
|
||||||
die('数据库连接失败: ' . $e->getMessage());
|
return new PDO($dsn, $config['database_config']['user'], $config['database_config']['password']);
|
||||||
}
|
} else if ($config['database_type'] === 'sqlite') {
|
||||||
}
|
$dsn = "sqlite:{$config['database_config']['path']}";
|
||||||
|
return new PDO($dsn);
|
||||||
// 连接数据库
|
}
|
||||||
$pdo = getDatabaseConnection();
|
} catch (PDOException $e) {
|
||||||
|
die('数据库连接失败: ' . $e->getMessage());
|
||||||
// 创建表的SQL语句
|
}
|
||||||
// 根据数据库类型选择合适的自增语法
|
}
|
||||||
$autoIncrement = $config['database_type'] === 'mysql' ? 'AUTO_INCREMENT' : 'AUTOINCREMENT';
|
|
||||||
|
// 连接数据库
|
||||||
$queries = [
|
$pdo = getDatabaseConnection();
|
||||||
// 创建管理员表
|
|
||||||
"CREATE TABLE IF NOT EXISTS admins (
|
// 根据数据库类型选择合适的自增语法
|
||||||
id INTEGER PRIMARY KEY $autoIncrement,
|
$autoIncrement = $config['database_type'] === 'mysql' ? 'AUTO_INCREMENT' : 'AUTOINCREMENT';
|
||||||
username VARCHAR(50) NOT NULL UNIQUE,
|
|
||||||
password_hash VARCHAR(255) NOT NULL,
|
$queries = [
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
// 创建管理员表
|
||||||
)",
|
"CREATE TABLE IF NOT EXISTS admins (
|
||||||
|
id INTEGER PRIMARY KEY $autoIncrement,
|
||||||
// 创建网站信息表
|
username VARCHAR(50) NOT NULL UNIQUE,
|
||||||
"CREATE TABLE IF NOT EXISTS site_info (
|
password_hash VARCHAR(255) NOT NULL,
|
||||||
id INTEGER PRIMARY KEY $autoIncrement,
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
name VARCHAR(100) NOT NULL,
|
)",
|
||||||
description TEXT,
|
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
// 创建网站信息表
|
||||||
)",
|
"CREATE TABLE IF NOT EXISTS site_info (
|
||||||
|
id INTEGER PRIMARY KEY $autoIncrement,
|
||||||
// 创建备案申请表
|
name VARCHAR(100) NOT NULL,
|
||||||
"CREATE TABLE IF NOT EXISTS registrations (
|
description TEXT,
|
||||||
id INTEGER PRIMARY KEY $autoIncrement,
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
website_name VARCHAR(255) NOT NULL,
|
)",
|
||||||
website_url VARCHAR(255) NOT NULL,
|
|
||||||
contact_person VARCHAR(100) NOT NULL,
|
// 创建备案申请表
|
||||||
contact_email VARCHAR(255) NOT NULL,
|
"CREATE TABLE IF NOT EXISTS registrations (
|
||||||
contact_phone VARCHAR(255) NOT NULL,
|
id INTEGER PRIMARY KEY $autoIncrement,
|
||||||
website_category VARCHAR(100) NOT NULL,
|
website_name VARCHAR(255) NOT NULL,
|
||||||
website_description TEXT NOT NULL,
|
website_url VARCHAR(255) NOT NULL,
|
||||||
status VARCHAR(20) DEFAULT 'pending',
|
contact_person VARCHAR(100) NOT NULL,
|
||||||
reason TEXT,
|
contact_email VARCHAR(255) NOT NULL,
|
||||||
registration_number VARCHAR(50),
|
contact_phone VARCHAR(255) NOT NULL,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
website_category VARCHAR(100) NOT NULL,
|
||||||
processed_at TIMESTAMP
|
website_description TEXT NOT NULL,
|
||||||
)"
|
status VARCHAR(20) DEFAULT 'pending',
|
||||||
];
|
reason TEXT,
|
||||||
|
registration_number VARCHAR(50),
|
||||||
// 执行SQL语句
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
try {
|
processed_at TIMESTAMP
|
||||||
foreach ($queries as $query) {
|
)"
|
||||||
$pdo->exec($query);
|
];
|
||||||
}
|
|
||||||
|
// 执行SQL语句
|
||||||
// 初始化管理员账户
|
try {
|
||||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM admins");
|
foreach ($queries as $query) {
|
||||||
$stmt->execute();
|
$pdo->exec($query);
|
||||||
$count = $stmt->fetchColumn();
|
}
|
||||||
|
echo "数据库表结构初始化完成<br>";
|
||||||
if ($count === 0) {
|
} catch (PDOException $e) {
|
||||||
// 创建默认管理员账户
|
die('创建表结构失败: ' . $e->getMessage());
|
||||||
$username = $config['admin']['username'];
|
}
|
||||||
$password = $config['admin']['password'];
|
|
||||||
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
|
|
||||||
|
|
||||||
$stmt = $pdo->prepare("INSERT INTO admins (username, password_hash) VALUES (?, ?)");
|
|
||||||
$stmt->execute([$username, $passwordHash]);
|
|
||||||
|
|
||||||
echo "管理员账户已创建!用户名: $username, 密码: $password <br>";
|
|
||||||
echo "请登录后立即修改密码!<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化网站信息
|
|
||||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM site_info");
|
|
||||||
$stmt->execute();
|
|
||||||
$count = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if ($count === 0) {
|
|
||||||
$stmt = $pdo->prepare("INSERT INTO site_info (name, description) VALUES (?, ?)");
|
|
||||||
$stmt->execute([$config['site_name'], $config['site_description']]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 表结构初始化完成
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
die('创建表结构失败: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
358
index.php
358
index.php
|
|
@ -1,184 +1,176 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<?php
|
<?php
|
||||||
// 检查是否已安装
|
// 检查是否已安装
|
||||||
if (!file_exists('config.php')) {
|
if (!file_exists('config.php')) {
|
||||||
// 调试信息
|
header('Location: install.php');
|
||||||
error_log('index.php: config.php不存在,重定向到install.php');
|
exit;
|
||||||
header('Location: install.php');
|
}
|
||||||
exit;
|
|
||||||
}
|
// 正确加载配置
|
||||||
|
$config = include 'config.php';
|
||||||
// 加载配置
|
if (!$config || !is_array($config)) {
|
||||||
$config = include 'config.php';
|
die('配置文件加载失败');
|
||||||
?>
|
}
|
||||||
<?php include 'common_header.php'; ?>
|
?>
|
||||||
|
<?php include 'common_header.php'; ?>
|
||||||
<div class="container">
|
|
||||||
<style>
|
<div class="container">
|
||||||
* {
|
<style>
|
||||||
margin: 0;
|
* {
|
||||||
padding: 0;
|
margin: 0;
|
||||||
box-sizing: border-box;
|
padding: 0;
|
||||||
}
|
box-sizing: border-box;
|
||||||
body {
|
}
|
||||||
background-image: url('img/Camera_XHS_17522965447511000g0082k8vvumgii0505o57.jpg');
|
body {
|
||||||
background-size: cover;
|
background-image: url('img/Camera_XHS_17522965447511000g0082k8vvumgii0505o57.jpg');
|
||||||
background-position: center;
|
background-size: cover;
|
||||||
background-attachment: fixed;
|
background-position: center;
|
||||||
color: #333;
|
background-attachment: fixed;
|
||||||
line-height: 1.6;
|
color: #333;
|
||||||
background-color: #f0f2f5;
|
line-height: 1.6;
|
||||||
}
|
background-color: #f0f2f5;
|
||||||
/* 页眉样式已移至common_header.php */
|
}
|
||||||
.container {
|
.container {
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
margin-top: 90px; /* 为固定的页眉留出空间 */
|
margin-top: 90px;
|
||||||
}
|
}
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 2.5rem;
|
font-size: 2.5rem;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
color: white;
|
color: white;
|
||||||
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
.subtitle {
|
.subtitle {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
color: white;
|
color: white;
|
||||||
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
|
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
.card {
|
.card {
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||||
}
|
}
|
||||||
|
.form-group {
|
||||||
.form-group {
|
margin-bottom: 20px;
|
||||||
margin-bottom: 20px;
|
}
|
||||||
}
|
label {
|
||||||
|
display: block;
|
||||||
label {
|
margin-bottom: 8px;
|
||||||
display: block;
|
font-weight: bold;
|
||||||
margin-bottom: 8px;
|
color: #555;
|
||||||
font-weight: bold;
|
}
|
||||||
color: #555;
|
input[type="text"],
|
||||||
}
|
select {
|
||||||
|
width: 100%;
|
||||||
input[type="text"],
|
padding: 12px;
|
||||||
select {
|
border: 1px solid #ddd;
|
||||||
width: 100%;
|
border-radius: 6px;
|
||||||
padding: 12px;
|
font-size: 1rem;
|
||||||
border: 1px solid #ddd;
|
transition: border 0.3s ease;
|
||||||
border-radius: 6px;
|
}
|
||||||
font-size: 1rem;
|
input[type="text"]:focus,
|
||||||
transition: border 0.3s ease;
|
select:focus {
|
||||||
}
|
border-color: #7873f5;
|
||||||
|
outline: none;
|
||||||
input[type="text"]:focus,
|
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
||||||
select:focus {
|
}
|
||||||
border-color: #7873f5;
|
.btn-container {
|
||||||
outline: none;
|
text-align: center;
|
||||||
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
.card:hover {
|
||||||
.btn-container {
|
transform: translateY(-5px);
|
||||||
text-align: center;
|
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
||||||
margin-top: 30px;
|
}
|
||||||
}
|
h2 {
|
||||||
.card:hover {
|
color: #7873f5;
|
||||||
transform: translateY(-5px);
|
margin-bottom: 20px;
|
||||||
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
padding-bottom: 10px;
|
||||||
}
|
border-bottom: 2px solid #f0f0f0;
|
||||||
h2 {
|
}
|
||||||
color: #7873f5;
|
.btn {
|
||||||
margin-bottom: 20px;
|
display: inline-block;
|
||||||
padding-bottom: 10px;
|
background: #7873f5;
|
||||||
border-bottom: 2px solid #f0f0f0;
|
color: white;
|
||||||
}
|
padding: 12px 25px;
|
||||||
.btn {
|
border-radius: 30px;
|
||||||
display: inline-block;
|
text-decoration: none;
|
||||||
background: #7873f5;
|
font-weight: bold;
|
||||||
color: white;
|
transition: background 0.3s ease;
|
||||||
padding: 12px 25px;
|
border: none;
|
||||||
border-radius: 30px;
|
cursor: pointer;
|
||||||
text-decoration: none;
|
font-size: 1rem;
|
||||||
font-weight: bold;
|
}
|
||||||
transition: background 0.3s ease;
|
.btn:hover {
|
||||||
border: none;
|
background: #605acf;
|
||||||
cursor: pointer;
|
}
|
||||||
font-size: 1rem;
|
.features {
|
||||||
}
|
display: flex;
|
||||||
.btn:hover {
|
flex-wrap: wrap;
|
||||||
background: #605acf;
|
gap: 20px;
|
||||||
}
|
margin-top: 30px;
|
||||||
.features {
|
}
|
||||||
display: flex;
|
.feature-item {
|
||||||
flex-wrap: wrap;
|
flex: 1 1 300px;
|
||||||
gap: 20px;
|
background: #f9f9ff;
|
||||||
margin-top: 30px;
|
padding: 20px;
|
||||||
}
|
border-radius: 8px;
|
||||||
.feature-item {
|
border-left: 4px solid #7873f5;
|
||||||
flex: 1 1 300px;
|
}
|
||||||
background: #f9f9ff;
|
.feature-item h3 {
|
||||||
padding: 20px;
|
color: #7873f5;
|
||||||
border-radius: 8px;
|
margin-bottom: 10px;
|
||||||
border-left: 4px solid #7873f5;
|
}
|
||||||
}
|
footer {
|
||||||
.feature-item h3 {
|
text-align: center;
|
||||||
color: #7873f5;
|
padding: 20px;
|
||||||
margin-bottom: 10px;
|
color: #777;
|
||||||
}
|
margin-top: 20px;
|
||||||
footer {
|
}
|
||||||
text-align: center;
|
@media (max-width: 768px) {
|
||||||
padding: 20px;
|
h1 {
|
||||||
color: #777;
|
font-size: 2rem;
|
||||||
margin-top: 20px;
|
}
|
||||||
}
|
.container {
|
||||||
@media (max-width: 768px) {
|
padding: 15px;
|
||||||
h1 {
|
}
|
||||||
font-size: 2rem;
|
#randomImage {
|
||||||
}
|
max-height: 200px;
|
||||||
.container {
|
}
|
||||||
padding: 15px;
|
}
|
||||||
}
|
</style>
|
||||||
#randomImage {
|
</head>
|
||||||
max-height: 200px;
|
<body>
|
||||||
}
|
<div class="container">
|
||||||
}
|
<div class="card">
|
||||||
</style>
|
<h2>备案查询</h2>
|
||||||
</head>
|
<p style="margin-bottom: 20px;">输入备案编号或网站地址查询备案信息</p>
|
||||||
<body>
|
|
||||||
|
<form method="get" action="search.php">
|
||||||
<div class="container">
|
<div class="form-group">
|
||||||
<div class="card">
|
<label for="search_type">查询类型</label>
|
||||||
<h2>备案查询</h2>
|
<select id="search_type" name="search_type">
|
||||||
<p style="margin-bottom: 20px;">输入备案编号或网站地址查询备案信息</p>
|
<option value="registration_number">备案编号</option>
|
||||||
|
<option value="website">网站地址</option>
|
||||||
<form method="get" action="search.php">
|
</select>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="search_type">查询类型</label>
|
|
||||||
<select id="search_type" name="search_type">
|
<div class="form-group">
|
||||||
<option value="registration_number">备案编号</option>
|
<label for="search_query">查询内容</label>
|
||||||
<option value="website">网站地址</option>
|
<input type="text" id="search_query" name="search_query" placeholder="请输入查询内容" value="<?php if (isset($_GET['search_query'])) echo htmlspecialchars($_GET['search_query']); ?>">
|
||||||
</select>
|
</div>
|
||||||
</div>
|
|
||||||
|
<div class="btn-container">
|
||||||
<div class="form-group">
|
<button type="submit" class="btn">查询</button>
|
||||||
<label for="search_query">查询内容</label>
|
</div>
|
||||||
<input type="text" id="search_query" name="search_query" placeholder="请输入查询内容" value="<?php if (isset($_GET['search_query'])) echo htmlspecialchars($_GET['search_query']); ?>">
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="btn-container">
|
</body>
|
||||||
<button type="submit" class="btn">查询</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 页脚已删除 -->
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
1024
install.php
1024
install.php
File diff suppressed because it is too large
Load diff
624
register.php
624
register.php
|
|
@ -1,314 +1,312 @@
|
||||||
<?php
|
<?php
|
||||||
// 检查是否已安装
|
// 检查是否已安装
|
||||||
if (!file_exists('config.php')) {
|
if (!file_exists('config.php')) {
|
||||||
header('Location: install.php');
|
header('Location: install.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载配置
|
// 正确加载配置
|
||||||
$config = include 'config.php';
|
$config = include 'config.php';
|
||||||
|
if (!$config || !is_array($config)) {
|
||||||
// 初始化数据库连接
|
die('配置文件加载失败');
|
||||||
require_once 'db_init.php';
|
}
|
||||||
|
|
||||||
// 处理表单提交
|
// 初始化数据库连接
|
||||||
$success = '';
|
require_once 'db_init.php';
|
||||||
$errors = [];
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
// 处理表单提交
|
||||||
// 验证表单数据
|
$success = '';
|
||||||
$data = [];
|
$errors = [];
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// 验证网站名称
|
// 验证表单数据
|
||||||
if (empty($_POST['website_name'])) {
|
$data = [];
|
||||||
$errors[] = '网站名称不能为空';
|
|
||||||
} else {
|
// 验证网站名称
|
||||||
$data['website_name'] = trim($_POST['website_name']);
|
if (empty($_POST['website_name'])) {
|
||||||
}
|
$errors[] = '网站名称不能为空';
|
||||||
|
} else {
|
||||||
// 验证网站类型
|
$data['website_name'] = trim($_POST['website_name']);
|
||||||
if (empty($_POST['website_category'])) {
|
}
|
||||||
$errors[] = '请选择网站类型';
|
|
||||||
} else {
|
// 验证网站类型
|
||||||
$data['website_category'] = $_POST['website_category'];
|
if (empty($_POST['website_category'])) {
|
||||||
}
|
$errors[] = '请选择网站类型';
|
||||||
|
} else {
|
||||||
// 验证网站负责人
|
$data['website_category'] = $_POST['website_category'];
|
||||||
if (empty($_POST['contact_person'])) {
|
}
|
||||||
$errors[] = '网站负责人不能为空';
|
|
||||||
} else {
|
// 验证网站负责人
|
||||||
$data['contact_person'] = trim($_POST['contact_person']);
|
if (empty($_POST['contact_person'])) {
|
||||||
}
|
$errors[] = '网站负责人不能为空';
|
||||||
|
} else {
|
||||||
// 验证联系电话
|
$data['contact_person'] = trim($_POST['contact_person']);
|
||||||
if (empty($_POST['contact_phone'])) {
|
}
|
||||||
$errors[] = '联系电话不能为空';
|
|
||||||
} else {
|
// 验证联系电话
|
||||||
$data['contact_phone'] = trim($_POST['contact_phone']);
|
if (empty($_POST['contact_phone'])) {
|
||||||
}
|
$errors[] = '联系电话不能为空';
|
||||||
|
} else {
|
||||||
// 验证联系邮箱
|
$data['contact_phone'] = trim($_POST['contact_phone']);
|
||||||
if (empty($_POST['contact_email'])) {
|
}
|
||||||
$errors[] = '联系邮箱不能为空';
|
|
||||||
} elseif (!filter_var($_POST['contact_email'], FILTER_VALIDATE_EMAIL)) {
|
// 验证联系邮箱
|
||||||
$errors[] = '请输入有效的邮箱地址';
|
if (empty($_POST['contact_email'])) {
|
||||||
} else {
|
$errors[] = '联系邮箱不能为空';
|
||||||
$data['contact_email'] = trim($_POST['contact_email']);
|
} elseif (!filter_var($_POST['contact_email'], FILTER_VALIDATE_EMAIL)) {
|
||||||
}
|
$errors[] = '请输入有效的邮箱地址';
|
||||||
|
} else {
|
||||||
// 验证网站地址
|
$data['contact_email'] = trim($_POST['contact_email']);
|
||||||
if (empty($_POST['website_url'])) {
|
}
|
||||||
$errors[] = '网站地址不能为空';
|
|
||||||
} else {
|
// 验证网站地址
|
||||||
$website = trim($_POST['website_url']);
|
if (empty($_POST['website_url'])) {
|
||||||
$website = preg_replace('#^https?://#', '', $website); // 统一格式
|
$errors[] = '网站地址不能为空';
|
||||||
$data['website_url'] = $website;
|
} else {
|
||||||
}
|
$website = trim($_POST['website_url']);
|
||||||
|
$website = preg_replace('#^https?://#', '', $website);
|
||||||
// 验证网站描述
|
$data['website_url'] = $website;
|
||||||
if (empty($_POST['website_description'])) {
|
}
|
||||||
$errors[] = '网站描述不能为空';
|
|
||||||
} else {
|
// 验证网站描述
|
||||||
$data['website_description'] = trim($_POST['website_description']);
|
if (empty($_POST['website_description'])) {
|
||||||
}
|
$errors[] = '网站描述不能为空';
|
||||||
|
} else {
|
||||||
// 如果没有错误,保存数据
|
$data['website_description'] = trim($_POST['website_description']);
|
||||||
if (empty($errors)) {
|
}
|
||||||
// 生成唯一备案编号 (ICP-年月日-6位ID)
|
|
||||||
// 生成8位数字备案编号
|
// 如果没有错误,保存数据
|
||||||
$data['registration_number'] = str_pad(rand(10000000, 99999999), 8, '0', STR_PAD_LEFT);
|
if (empty($errors)) {
|
||||||
$data['created_at'] = date('Y-m-d H:i:s');
|
// 生成8位数字备案编号
|
||||||
$data['status'] = 'pending'; // 默认为待审核
|
$data['registration_number'] = str_pad(rand(10000000, 99999999), 8, '0', STR_PAD_LEFT);
|
||||||
$data['reason'] = '';
|
$data['created_at'] = date('Y-m-d H:i:s');
|
||||||
|
$data['status'] = 'pending';
|
||||||
try {
|
$data['reason'] = '';
|
||||||
// 插入数据到数据库
|
|
||||||
$stmt = $pdo->prepare("INSERT INTO registrations (website_name, website_url, contact_person, contact_email, contact_phone, website_category, website_description, status, reason, registration_number, created_at, processed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
try {
|
||||||
$stmt->execute([
|
// 插入数据到数据库
|
||||||
$data['website_name'],
|
$stmt = $pdo->prepare("INSERT INTO registrations (website_name, website_url, contact_person, contact_email, contact_phone, website_category, website_description, status, reason, registration_number, created_at, processed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$data['website_url'],
|
$stmt->execute([
|
||||||
$data['contact_person'],
|
$data['website_name'],
|
||||||
$data['contact_email'],
|
$data['website_url'],
|
||||||
$data['contact_phone'],
|
$data['contact_person'],
|
||||||
$data['website_category'],
|
$data['contact_email'],
|
||||||
$data['website_description'],
|
$data['contact_phone'],
|
||||||
$data['status'],
|
$data['website_category'],
|
||||||
$data['reason'],
|
$data['website_description'],
|
||||||
$data['registration_number'],
|
$data['status'],
|
||||||
$data['created_at'],
|
$data['reason'],
|
||||||
null
|
$data['registration_number'],
|
||||||
]);
|
$data['created_at'],
|
||||||
|
null
|
||||||
$success = '备案信息添加成功!备案编号: 初ICP备' . $data['registration_number'] . '备';
|
]);
|
||||||
} catch (PDOException $e) {
|
|
||||||
$errors[] = '添加备案信息失败: ' . $e->getMessage();
|
$success = '备案信息添加成功!备案编号: 初ICP备' . $data['registration_number'] . '备';
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
}
|
$errors[] = '添加备案信息失败: ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 从数据库获取网站信息
|
}
|
||||||
$stmt = $pdo->query("SELECT name, description FROM site_info LIMIT 1");
|
|
||||||
$siteInfo = $stmt->fetch(PDO::FETCH_ASSOC);
|
// 从数据库获取网站信息
|
||||||
|
$stmt = $pdo->query("SELECT name, description FROM site_info LIMIT 1");
|
||||||
// 如果找不到网站信息,使用配置文件中的默认值
|
$siteInfo = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
if (!$siteInfo) {
|
|
||||||
$siteInfo = [
|
// 如果找不到网站信息,使用配置文件中的默认值
|
||||||
'name' => $config['site_name'] ?? '网站备案系统',
|
if (!$siteInfo) {
|
||||||
'description' => $config['site_description'] ?? 'ICP备案管理平台'
|
$siteInfo = [
|
||||||
];
|
'name' => $config['site_name'] ?? '网站备案系统',
|
||||||
}
|
'description' => $config['site_description'] ?? 'ICP备案管理平台'
|
||||||
?>
|
];
|
||||||
<?php include 'common_header.php'; ?>
|
}
|
||||||
|
?>
|
||||||
<style>
|
<?php include 'common_header.php'; ?>
|
||||||
.container {
|
|
||||||
max-width: 800px;
|
<style>
|
||||||
margin: 0 auto;
|
.container {
|
||||||
padding: 20px;
|
max-width: 800px;
|
||||||
margin-top: 20px;
|
margin: 0 auto;
|
||||||
}
|
padding: 20px;
|
||||||
.header-content {
|
margin-top: 20px;
|
||||||
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
}
|
||||||
color: white;
|
.header-content {
|
||||||
padding: 40px 0;
|
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
||||||
text-align: center;
|
color: white;
|
||||||
border-radius: 10px;
|
padding: 40px 0;
|
||||||
margin-bottom: 30px;
|
text-align: center;
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
border-radius: 10px;
|
||||||
}
|
margin-bottom: 30px;
|
||||||
h1 {
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
font-size: 2.5rem;
|
}
|
||||||
margin-bottom: 10px;
|
h1 {
|
||||||
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
font-size: 2.5rem;
|
||||||
}
|
margin-bottom: 10px;
|
||||||
.subtitle {
|
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
||||||
font-size: 1.2rem;
|
}
|
||||||
opacity: 0.9;
|
.subtitle {
|
||||||
}
|
font-size: 1.2rem;
|
||||||
.card {
|
opacity: 0.9;
|
||||||
background: white;
|
}
|
||||||
border-radius: 10px;
|
.card {
|
||||||
padding: 30px;
|
background: white;
|
||||||
margin-bottom: 30px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
padding: 30px;
|
||||||
}
|
margin-bottom: 30px;
|
||||||
h2 {
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
color: #7873f5;
|
}
|
||||||
margin-bottom: 20px;
|
h2 {
|
||||||
padding-bottom: 10px;
|
color: #7873f5;
|
||||||
border-bottom: 2px solid #f0f0f0;
|
margin-bottom: 20px;
|
||||||
}
|
padding-bottom: 10px;
|
||||||
.form-group {
|
border-bottom: 2px solid #f0f0f0;
|
||||||
margin-bottom: 20px;
|
}
|
||||||
}
|
.form-group {
|
||||||
label {
|
margin-bottom: 20px;
|
||||||
display: block;
|
}
|
||||||
margin-bottom: 8px;
|
label {
|
||||||
font-weight: bold;
|
display: block;
|
||||||
color: #555;
|
margin-bottom: 8px;
|
||||||
}
|
font-weight: bold;
|
||||||
input[type="text"],
|
color: #555;
|
||||||
input[type="email"],
|
}
|
||||||
textarea,
|
input[type="text"],
|
||||||
select {
|
input[type="email"],
|
||||||
width: 100%;
|
textarea,
|
||||||
padding: 12px;
|
select {
|
||||||
border: 1px solid #ddd;
|
width: 100%;
|
||||||
border-radius: 6px;
|
padding: 12px;
|
||||||
font-size: 1rem;
|
border: 1px solid #ddd;
|
||||||
transition: border 0.3s ease;
|
border-radius: 6px;
|
||||||
}
|
font-size: 1rem;
|
||||||
input[type="text"]:focus,
|
transition: border 0.3s ease;
|
||||||
input[type="email"]:focus,
|
}
|
||||||
textarea:focus,
|
input[type="text"]:focus,
|
||||||
select:focus {
|
input[type="email"]:focus,
|
||||||
border-color: #7873f5;
|
textarea:focus,
|
||||||
outline: none;
|
select:focus {
|
||||||
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
border-color: #7873f5;
|
||||||
}
|
outline: none;
|
||||||
textarea {
|
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
||||||
height: 150px;
|
}
|
||||||
resize: vertical;
|
textarea {
|
||||||
}
|
height: 150px;
|
||||||
.btn {
|
resize: vertical;
|
||||||
display: inline-block;
|
}
|
||||||
background: #7873f5;
|
.btn {
|
||||||
color: white;
|
display: inline-block;
|
||||||
padding: 12px 25px;
|
background: #7873f5;
|
||||||
border-radius: 30px;
|
color: white;
|
||||||
text-decoration: none;
|
padding: 12px 25px;
|
||||||
font-weight: bold;
|
border-radius: 30px;
|
||||||
transition: background 0.3s ease;
|
text-decoration: none;
|
||||||
border: none;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
transition: background 0.3s ease;
|
||||||
font-size: 1rem;
|
border: none;
|
||||||
}
|
cursor: pointer;
|
||||||
.btn:hover {
|
font-size: 1rem;
|
||||||
background: #605acf;
|
}
|
||||||
}
|
.btn:hover {
|
||||||
.btn-container {
|
background: #605acf;
|
||||||
text-align: center;
|
}
|
||||||
margin-top: 30px;
|
.btn-container {
|
||||||
}
|
text-align: center;
|
||||||
.back-link {
|
margin-top: 30px;
|
||||||
display: inline-block;
|
}
|
||||||
margin-top: 15px;
|
.back-link {
|
||||||
color: #7873f5;
|
display: inline-block;
|
||||||
text-decoration: none;
|
margin-top: 15px;
|
||||||
}
|
color: #7873f5;
|
||||||
.back-link:hover {
|
text-decoration: none;
|
||||||
text-decoration: underline;
|
}
|
||||||
}
|
.back-link:hover {
|
||||||
.error {
|
text-decoration: underline;
|
||||||
color: #e74c3c;
|
}
|
||||||
font-size: 0.9rem;
|
.error {
|
||||||
margin-top: 5px;
|
color: #e74c3c;
|
||||||
}
|
font-size: 0.9rem;
|
||||||
.success {
|
margin-top: 5px;
|
||||||
color: #2ecc71;
|
}
|
||||||
padding: 15px;
|
.success {
|
||||||
background: #f1f9f1;
|
color: #2ecc71;
|
||||||
border-radius: 6px;
|
padding: 15px;
|
||||||
margin-bottom: 20px;
|
background: #f1f9f1;
|
||||||
border-left: 4px solid #2ecc71;
|
border-radius: 6px;
|
||||||
}
|
margin-bottom: 20px;
|
||||||
@media (max-width: 768px) {
|
border-left: 4px solid #2ecc71;
|
||||||
#randomImage {
|
}
|
||||||
max-height: 200px;
|
@media (max-width: 768px) {
|
||||||
}
|
#randomImage {
|
||||||
}
|
max-height: 200px;
|
||||||
</style>
|
}
|
||||||
</head>
|
}
|
||||||
<body>
|
</style>
|
||||||
<div class="header-content">
|
</head>
|
||||||
<h1>网站备案申请</h1>
|
<body>
|
||||||
<p class="subtitle">填写以下信息完成网站备案申请</p>
|
<div class="header-content">
|
||||||
</div>
|
<h1>网站备案申请</h1>
|
||||||
|
<p class="subtitle">填写以下信息完成网站备案申请</p>
|
||||||
<div class="card">
|
</div>
|
||||||
<h2>网站备案申请</h2>
|
|
||||||
|
<div class="card">
|
||||||
<?php if ($success): ?>
|
<h2>网站备案申请</h2>
|
||||||
<div class="success"><?php echo $success; ?></div>
|
|
||||||
<?php endif; ?>
|
<?php if ($success): ?>
|
||||||
|
<div class="success"><?php echo $success; ?></div>
|
||||||
<?php if (!empty($errors)): ?>
|
<?php endif; ?>
|
||||||
<?php foreach ($errors as $error): ?>
|
|
||||||
<div class="error"><?php echo $error; ?></div>
|
<?php if (!empty($errors)): ?>
|
||||||
<?php endforeach; ?>
|
<?php foreach ($errors as $error): ?>
|
||||||
<?php endif; ?>
|
<div class="error"><?php echo $error; ?></div>
|
||||||
|
<?php endforeach; ?>
|
||||||
<form method="post">
|
<?php endif; ?>
|
||||||
<div class="form-group">
|
|
||||||
<label for="website_name">网站名称 *</label>
|
<form method="post">
|
||||||
<input type="text" id="website_name" name="website_name" required placeholder="请输入网站的名称">
|
<div class="form-group">
|
||||||
</div>
|
<label for="website_name">网站名称 *</label>
|
||||||
|
<input type="text" id="website_name" name="website_name" required placeholder="请输入网站的名称">
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="website_category">网站类型 *</label>
|
|
||||||
<select id="website_category" name="website_category" required>
|
<div class="form-group">
|
||||||
<option value="">请选择</option>
|
<label for="website_category">网站类型 *</label>
|
||||||
<option value="anime">动漫网站</option>
|
<select id="website_category" name="website_category" required>
|
||||||
<option value="game">游戏网站</option>
|
<option value="">请选择</option>
|
||||||
<option value="blog">个人博客</option>
|
<option value="anime">动漫网站</option>
|
||||||
<option value="other">其他类型</option>
|
<option value="game">游戏网站</option>
|
||||||
</select>
|
<option value="blog">个人博客</option>
|
||||||
</div>
|
<option value="other">其他类型</option>
|
||||||
|
</select>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="contact_person">网站负责人 *</label>
|
|
||||||
<input type="text" id="contact_person" name="contact_person" required placeholder="请输入网站负责人姓名">
|
<div class="form-group">
|
||||||
</div>
|
<label for="contact_person">网站负责人 *</label>
|
||||||
|
<input type="text" id="contact_person" name="contact_person" required placeholder="请输入网站负责人姓名">
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="contact_phone">联系电话 *</label>
|
|
||||||
<input type="text" id="contact_phone" name="contact_phone" required placeholder="请输入联系电话">
|
<div class="form-group">
|
||||||
</div>
|
<label for="contact_phone">联系电话 *</label>
|
||||||
|
<input type="text" id="contact_phone" name="contact_phone" required placeholder="请输入联系电话">
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="contact_email">联系邮箱 *</label>
|
|
||||||
<input type="email" id="contact_email" name="contact_email" required placeholder="请输入联系邮箱">
|
<div class="form-group">
|
||||||
</div>
|
<label for="contact_email">联系邮箱 *</label>
|
||||||
|
<input type="email" id="contact_email" name="contact_email" required placeholder="请输入联系邮箱">
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="website_url">网站地址 *</label>
|
|
||||||
<input type="text" id="website_url" name="website_url" required placeholder="请输入网站域名,不带http://">
|
<div class="form-group">
|
||||||
</div>
|
<label for="website_url">网站地址 *</label>
|
||||||
|
<input type="text" id="website_url" name="website_url" required placeholder="请输入网站域名,不带http://">
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="website_description">网站描述 *</label>
|
|
||||||
<textarea id="website_description" name="website_description" required placeholder="请简要描述网站内容"></textarea>
|
<div class="form-group">
|
||||||
</div>
|
<label for="website_description">网站描述 *</label>
|
||||||
|
<textarea id="website_description" name="website_description" required placeholder="请简要描述网站内容"></textarea>
|
||||||
<div class="btn-container">
|
</div>
|
||||||
<button type="submit" class="btn">提交备案</button>
|
|
||||||
<a href="index.php" class="back-link">返回首页</a>
|
<div class="btn-container">
|
||||||
</div>
|
<button type="submit" class="btn">提交备案</button>
|
||||||
</form>
|
<a href="index.php" class="back-link">返回首页</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
|
</div>
|
||||||
<!-- common_footer.php 文件不存在,已移除引用 -->
|
</div>
|
||||||
|
</body>
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
515
search.php
515
search.php
|
|
@ -1,258 +1,257 @@
|
||||||
<?php
|
<?php
|
||||||
// 检查是否已安装
|
// 检查是否已安装
|
||||||
if (!file_exists('config.php')) {
|
if (!file_exists('config.php')) {
|
||||||
header('Location: install.php');
|
header('Location: install.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载配置
|
// 正确加载配置
|
||||||
$config = include 'config.php';
|
$config = include 'config.php';
|
||||||
?>
|
if (!$config || !is_array($config)) {
|
||||||
<?php include 'common_header.php'; ?>
|
die('配置文件加载失败');
|
||||||
|
}
|
||||||
<div class="container">
|
?>
|
||||||
<style>
|
<?php include 'common_header.php'; ?>
|
||||||
* {
|
|
||||||
margin: 0;
|
<div class="container">
|
||||||
padding: 0;
|
<style>
|
||||||
box-sizing: border-box;
|
* {
|
||||||
}
|
margin: 0;
|
||||||
body {
|
padding: 0;
|
||||||
background-color: #f0f2f5;
|
box-sizing: border-box;
|
||||||
color: #333;
|
}
|
||||||
line-height: 1.6;
|
body {
|
||||||
}
|
background-color: #f0f2f5;
|
||||||
.container {
|
color: #333;
|
||||||
max-width: 800px;
|
line-height: 1.6;
|
||||||
margin: 0 auto;
|
}
|
||||||
padding: 20px;
|
.container {
|
||||||
margin-top: 20px;
|
max-width: 800px;
|
||||||
}
|
margin: 0 auto;
|
||||||
.header-content {
|
padding: 20px;
|
||||||
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
margin-top: 20px;
|
||||||
color: white;
|
}
|
||||||
padding: 20px 0;
|
.header-content {
|
||||||
text-align: center;
|
background: linear-gradient(135deg, #ff6ec7, #7873f5);
|
||||||
border-radius: 10px;
|
color: white;
|
||||||
margin-bottom: 30px;
|
padding: 20px 0;
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
text-align: center;
|
||||||
}
|
border-radius: 10px;
|
||||||
h1 {
|
margin-bottom: 30px;
|
||||||
font-size: 1.8rem;
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
margin-bottom: 10px;
|
}
|
||||||
}
|
h1 {
|
||||||
.card {
|
font-size: 1.8rem;
|
||||||
background: white;
|
margin-bottom: 10px;
|
||||||
border-radius: 10px;
|
}
|
||||||
padding: 30px;
|
.card {
|
||||||
margin-bottom: 30px;
|
background: white;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
border-radius: 10px;
|
||||||
}
|
padding: 30px;
|
||||||
h2 {
|
margin-bottom: 30px;
|
||||||
color: #7873f5;
|
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||||
margin-bottom: 20px;
|
}
|
||||||
padding-bottom: 10px;
|
h2 {
|
||||||
border-bottom: 2px solid #f0f0f0;
|
color: #7873f5;
|
||||||
}
|
margin-bottom: 20px;
|
||||||
.form-group {
|
padding-bottom: 10px;
|
||||||
margin-bottom: 20px;
|
border-bottom: 2px solid #f0f0f0;
|
||||||
}
|
}
|
||||||
label {
|
.form-group {
|
||||||
display: block;
|
margin-bottom: 20px;
|
||||||
margin-bottom: 8px;
|
}
|
||||||
font-weight: bold;
|
label {
|
||||||
color: #555;
|
display: block;
|
||||||
}
|
margin-bottom: 8px;
|
||||||
input[type="text"],
|
font-weight: bold;
|
||||||
select {
|
color: #555;
|
||||||
width: 100%;
|
}
|
||||||
padding: 12px;
|
input[type="text"],
|
||||||
border: 1px solid #ddd;
|
select {
|
||||||
border-radius: 6px;
|
width: 100%;
|
||||||
font-size: 1rem;
|
padding: 12px;
|
||||||
transition: border 0.3s ease;
|
border: 1px solid #ddd;
|
||||||
}
|
border-radius: 6px;
|
||||||
input[type="text"]:focus,
|
font-size: 1rem;
|
||||||
select:focus {
|
transition: border 0.3s ease;
|
||||||
border-color: #7873f5;
|
}
|
||||||
outline: none;
|
input[type="text"]:focus,
|
||||||
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
select:focus {
|
||||||
}
|
border-color: #7873f5;
|
||||||
.btn {
|
outline: none;
|
||||||
display: inline-block;
|
box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.2);
|
||||||
background: #7873f5;
|
}
|
||||||
color: white;
|
.btn {
|
||||||
padding: 12px 25px;
|
display: inline-block;
|
||||||
border-radius: 30px;
|
background: #7873f5;
|
||||||
text-decoration: none;
|
color: white;
|
||||||
font-weight: bold;
|
padding: 12px 25px;
|
||||||
transition: background 0.3s ease;
|
border-radius: 30px;
|
||||||
border: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
font-weight: bold;
|
||||||
font-size: 1rem;
|
transition: background 0.3s ease;
|
||||||
}
|
border: none;
|
||||||
.btn:hover {
|
cursor: pointer;
|
||||||
background: #605acf;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
.btn-container {
|
.btn:hover {
|
||||||
text-align: center;
|
background: #605acf;
|
||||||
margin-top: 30px;
|
}
|
||||||
}
|
.btn-container {
|
||||||
.back-link {
|
text-align: center;
|
||||||
display: inline-block;
|
margin-top: 30px;
|
||||||
margin-top: 15px;
|
}
|
||||||
color: #7873f5;
|
.back-link {
|
||||||
text-decoration: none;
|
display: inline-block;
|
||||||
}
|
margin-top: 15px;
|
||||||
.back-link:hover {
|
color: #7873f5;
|
||||||
text-decoration: underline;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
.error {
|
.back-link:hover {
|
||||||
color: #e74c3c;
|
text-decoration: underline;
|
||||||
font-size: 0.9rem;
|
}
|
||||||
margin-top: 5px;
|
.error {
|
||||||
}
|
color: #e74c3c;
|
||||||
.search-results {
|
font-size: 0.9rem;
|
||||||
margin-top: 30px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
.result-item {
|
.search-results {
|
||||||
background: #f9f9ff;
|
margin-top: 30px;
|
||||||
padding: 20px;
|
}
|
||||||
border-radius: 8px;
|
.result-item {
|
||||||
margin-bottom: 20px;
|
background: #f9f9ff;
|
||||||
border-left: 4px solid #7873f5;
|
padding: 20px;
|
||||||
}
|
border-radius: 8px;
|
||||||
.result-item h3 {
|
margin-bottom: 20px;
|
||||||
color: #7873f5;
|
border-left: 4px solid #7873f5;
|
||||||
margin-bottom: 10px;
|
}
|
||||||
}
|
.result-item h3 {
|
||||||
.result-item p {
|
color: #7873f5;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.result-label {
|
.result-item p {
|
||||||
font-weight: bold;
|
margin-bottom: 8px;
|
||||||
color: #555;
|
}
|
||||||
}
|
.result-label {
|
||||||
.no-results {
|
font-weight: bold;
|
||||||
text-align: center;
|
color: #555;
|
||||||
padding: 30px;
|
}
|
||||||
color: #777;
|
.no-results {
|
||||||
}
|
text-align: center;
|
||||||
@media (max-width: 768px) {
|
padding: 30px;
|
||||||
#randomImage {
|
color: #777;
|
||||||
max-height: 200px;
|
}
|
||||||
}
|
@media (max-width: 768px) {
|
||||||
}
|
#randomImage {
|
||||||
</style>
|
max-height: 200px;
|
||||||
<div class="header-content">
|
}
|
||||||
<h1>网站备案查询</h1>
|
}
|
||||||
<p>输入备案编号或网站地址查询备案信息</p>
|
</style>
|
||||||
</div>
|
<div class="header-content">
|
||||||
|
<h1>网站备案查询</h1>
|
||||||
<div class="card">
|
<p>输入备案编号或网站地址查询备案信息</p>
|
||||||
<h2>查询备案信息</h2>
|
</div>
|
||||||
|
|
||||||
<form method="get">
|
<div class="card">
|
||||||
<div class="form-group">
|
<h2>查询备案信息</h2>
|
||||||
<label for="search_type">查询类型</label>
|
|
||||||
<select id="search_type" name="search_type">
|
<form method="get">
|
||||||
<option value="registration_number" <?php if (isset($_GET['search_type']) && $_GET['search_type'] == 'registration_number') echo 'selected'; ?>>备案编号</option>
|
<div class="form-group">
|
||||||
<option value="website" <?php if (isset($_GET['search_type']) && $_GET['search_type'] == 'website') echo 'selected'; ?>>网站地址</option>
|
<label for="search_type">查询类型</label>
|
||||||
</select>
|
<select id="search_type" name="search_type">
|
||||||
</div>
|
<option value="registration_number" <?php if (isset($_GET['search_type']) && $_GET['search_type'] == 'registration_number') echo 'selected'; ?>>备案编号</option>
|
||||||
|
<option value="website" <?php if (isset($_GET['search_type']) && $_GET['search_type'] == 'website') echo 'selected'; ?>>网站地址</option>
|
||||||
<div class="form-group">
|
</select>
|
||||||
<label for="search_query">查询内容</label>
|
</div>
|
||||||
<input type="text" id="search_query" name="search_query" placeholder="请输入查询内容" value="<?php if (isset($_GET['search_query'])) echo htmlspecialchars($_GET['search_query']); ?>">
|
|
||||||
</div>
|
<div class="form-group">
|
||||||
|
<label for="search_query">查询内容</label>
|
||||||
<div class="btn-container">
|
<input type="text" id="search_query" name="search_query" placeholder="请输入查询内容" value="<?php if (isset($_GET['search_query'])) echo htmlspecialchars($_GET['search_query']); ?>">
|
||||||
<button type="submit" class="btn">查询</button>
|
</div>
|
||||||
</div>
|
|
||||||
<span class="back-link">返回首页</span>
|
<div class="btn-container">
|
||||||
</form>
|
<button type="submit" class="btn">查询</button>
|
||||||
|
<a href="index.php" class="back-link">返回首页</a>
|
||||||
<div class="search-results">
|
</div>
|
||||||
<?php
|
</form>
|
||||||
// 加载配置
|
|
||||||
$config = include 'config.php';
|
<div class="search-results">
|
||||||
|
<?php
|
||||||
// 设置默认配置值
|
// 设置默认配置值
|
||||||
$site_name = $config['site_name'] ?? '网站备案系统';
|
$site_name = $config['site_name'] ?? '网站备案系统';
|
||||||
$site_description = $config['site_description'] ?? 'ICP备案管理平台';
|
$site_description = $config['site_description'] ?? 'ICP备案管理平台';
|
||||||
|
|
||||||
// 初始化数据库连接
|
// 初始化数据库连接
|
||||||
require_once 'db_init.php';
|
require_once 'db_init.php';
|
||||||
|
|
||||||
// 处理查询请求
|
// 处理查询请求
|
||||||
if (isset($_GET['search_query']) && !empty($_GET['search_query'])) {
|
if (isset($_GET['search_query']) && !empty($_GET['search_query'])) {
|
||||||
$search_type = $_GET['search_type'];
|
$search_type = $_GET['search_type'];
|
||||||
$search_query = trim($_GET['search_query']);
|
$search_query = trim($_GET['search_query']);
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
// 检查数据库连接
|
// 检查数据库连接
|
||||||
if (isset($pdo) && $pdo) {
|
if (isset($pdo) && $pdo) {
|
||||||
try {
|
try {
|
||||||
// 准备SQL查询
|
// 准备SQL查询
|
||||||
if ($search_type === 'registration_number') {
|
if ($search_type === 'registration_number') {
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE registration_number LIKE :query");
|
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE registration_number LIKE :query");
|
||||||
$stmt->execute(['query' => '%' . $search_query . '%']);
|
$stmt->execute(['query' => '%' . $search_query . '%']);
|
||||||
} elseif ($search_type === 'website') {
|
} elseif ($search_type === 'website') {
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE website_url LIKE :query");
|
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE website_url LIKE :query");
|
||||||
$stmt->execute(['query' => '%' . $search_query . '%']);
|
$stmt->execute(['query' => '%' . $search_query . '%']);
|
||||||
} elseif ($search_type === 'email') {
|
} elseif ($search_type === 'email') {
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE contact_email LIKE :query");
|
$stmt = $pdo->prepare("SELECT * FROM registrations WHERE contact_email LIKE :query");
|
||||||
$stmt->execute(['query' => '%' . $search_query . '%']);
|
$stmt->execute(['query' => '%' . $search_query . '%']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
echo '<div class="error">查询失败: ' . $e->getMessage() . '</div>';
|
echo '<div class="error">查询失败: ' . $e->getMessage() . '</div>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo '<div class="error">数据库连接失败,请检查配置文件。</div>';
|
echo '<div class="error">数据库连接失败,请检查配置文件。</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示查询结果
|
// 显示查询结果
|
||||||
if (!empty($results)) {
|
if (!empty($results)) {
|
||||||
echo '<h3>查询结果 (共 ' . count($results) . ' 条)</h3>';
|
echo '<h3>查询结果 (共 ' . count($results) . ' 条)</h3>';
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
echo '<div class="result-item">';
|
echo '<div class="result-item">';
|
||||||
echo '<h3>' . htmlspecialchars($result['website_name']) . '</h3>';
|
echo '<h3>' . htmlspecialchars($result['website_name']) . '</h3>';
|
||||||
echo '<p><span class="result-label">备案编号:</span>初ICP备' . htmlspecialchars($result['registration_number']) . '备</p>';
|
echo '<p><span class="result-label">备案编号:</span>初ICP备' . htmlspecialchars($result['registration_number']) . '备</p>';
|
||||||
|
|
||||||
// 显示网站类型
|
// 显示网站类型
|
||||||
$categoryMap = [
|
$categoryMap = [
|
||||||
'anime' => '动漫网站',
|
'anime' => '动漫网站',
|
||||||
'game' => '游戏网站',
|
'game' => '游戏网站',
|
||||||
'blog' => '个人博客',
|
'blog' => '个人博客',
|
||||||
'other' => '其他类型'
|
'other' => '其他类型'
|
||||||
];
|
];
|
||||||
echo '<p><span class="result-label">网站类型:</span>' . htmlspecialchars($categoryMap[$result['website_category']] ?? '未知类型') . '</p>';
|
echo '<p><span class="result-label">网站类型:</span>' . htmlspecialchars($categoryMap[$result['website_category']] ?? '未知类型') . '</p>';
|
||||||
|
|
||||||
echo '<p><span class="result-label">网站负责人:</span>' . htmlspecialchars($result['contact_person']) . '</p>';
|
echo '<p><span class="result-label">网站负责人:</span>' . htmlspecialchars($result['contact_person']) . '</p>';
|
||||||
echo '<p><span class="result-label">联系电话:</span>' . htmlspecialchars($result['contact_phone']) . '</p>';
|
echo '<p><span class="result-label">联系电话:</span>' . htmlspecialchars($result['contact_phone']) . '</p>';
|
||||||
echo '<p><span class="result-label">联系邮箱:</span>' . htmlspecialchars($result['contact_email']) . '</p>';
|
echo '<p><span class="result-label">联系邮箱:</span>' . htmlspecialchars($result['contact_email']) . '</p>';
|
||||||
echo '<p><span class="result-label">网站地址:</span><a href="http://' . htmlspecialchars($result['website_url']) . '" target="_blank">' . htmlspecialchars($result['website_url']) . '</a></p>';
|
echo '<p><span class="result-label">网站地址:</span><a href="http://' . htmlspecialchars($result['website_url']) . '" target="_blank">' . htmlspecialchars($result['website_url']) . '</a></p>';
|
||||||
echo '<p><span class="result-label">提交日期:</span>' . htmlspecialchars($result['created_at']) . '</p>';
|
echo '<p><span class="result-label">提交日期:</span>' . htmlspecialchars($result['created_at']) . '</p>';
|
||||||
echo '<p><span class="result-label">处理日期:</span>' . htmlspecialchars($result['processed_at'] ?? '未处理') . '</p>';
|
echo '<p><span class="result-label">处理日期:</span>' . htmlspecialchars($result['processed_at'] ?? '未处理') . '</p>';
|
||||||
echo '<p><span class="result-label">状态:</span>' . ($result['status'] === 'pending' ? '待审核' : ($result['status'] === 'approved' ? '已通过' : '已拒绝')) . '</p>';
|
echo '<p><span class="result-label">状态:</span>' . ($result['status'] === 'pending' ? '待审核' : ($result['status'] === 'approved' ? '已通过' : '已拒绝')) . '</p>';
|
||||||
echo '<p><span class="result-label">网站描述:</span>' . nl2br(htmlspecialchars($result['website_description'])) . '</p>';
|
echo '<p><span class="result-label">网站描述:</span>' . nl2br(htmlspecialchars($result['website_description'])) . '</p>';
|
||||||
if (!empty($result['reason'])) {
|
if (!empty($result['reason'])) {
|
||||||
echo '<p><span class="result-label">处理说明:</span>' . nl2br(htmlspecialchars($result['reason'])) . '</p>';
|
echo '<p><span class="result-label">处理说明:</span>' . nl2br(htmlspecialchars($result['reason'])) . '</p>';
|
||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo '<div class="no-results">';
|
echo '<div class="no-results">';
|
||||||
echo '<p>没有找到符合条件的备案信息</p>';
|
echo '<p>没有找到符合条件的备案信息</p>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue