diff --git a/admin/admins.php b/admin/admins.php
new file mode 100644
index 0000000..da9ecb0
--- /dev/null
+++ b/admin/admins.php
@@ -0,0 +1,120 @@
+prepare("DELETE FROM admin_users WHERE id = ?");
+ $stmt->execute([$id]);
+ header('Location: admins.php?msg=deleted');
+ exit;
+}
+
+// Handle Save
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $username = $_POST['username'];
+ $nickname = $_POST['nickname'];
+ $password = $_POST['password'];
+
+ if ($id) {
+ if (!empty($password)) {
+ $stmt = $pdo->prepare("UPDATE admin_users SET username=?, nickname=?, password=? WHERE id=?");
+ $stmt->execute([$username, $nickname, password_hash($password, PASSWORD_DEFAULT), $id]);
+ } else {
+ $stmt = $pdo->prepare("UPDATE admin_users SET username=?, nickname=? WHERE id=?");
+ $stmt->execute([$username, $nickname, $id]);
+ }
+ } else {
+ $stmt = $pdo->prepare("INSERT INTO admin_users (username, nickname, password) VALUES (?, ?, ?)");
+ $stmt->execute([$username, $nickname, password_hash($password, PASSWORD_DEFAULT)]);
+ }
+ header('Location: admins.php?msg=saved');
+ exit;
+}
+
+// Fetch list
+$admins = $pdo->query("SELECT * FROM admin_users ORDER BY id DESC")->fetchAll();
+
+// Fetch for edit
+$item = null;
+if ($action === 'edit' && $id) {
+ $stmt = $pdo->prepare("SELECT * FROM admin_users WHERE id = ?");
+ $stmt->execute([$id]);
+ $item = $stmt->fetch();
+}
+?>
+
+
+
+
+
+
+
+
+
+ | ID |
+ 用户名 |
+ 昵称 |
+ 创建时间 |
+ 操作 |
+
+
+
+
+
+ | = $a['id'] ?> |
+ = htmlspecialchars($a['username']) ?> |
+ = htmlspecialchars($a['nickname']) ?> |
+ = $a['created_at'] ?> |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/auth.php b/admin/auth.php
new file mode 100644
index 0000000..a3bc7b7
--- /dev/null
+++ b/admin/auth.php
@@ -0,0 +1,40 @@
+prepare("SELECT * FROM admin_users WHERE username = ?");
+ $stmt->execute([$username]);
+ $user = $stmt->fetch();
+
+ if ($user && password_verify($password, $user['password'])) {
+ $_SESSION['admin_user'] = [
+ 'id' => $user['id'],
+ 'username' => $user['username'],
+ 'nickname' => $user['nickname'],
+ 'avatar' => $user['avatar']
+ ];
+ // Update last login
+ $stmt = $pdo->prepare("UPDATE admin_users SET last_login = NOW() WHERE id = ?");
+ $stmt->execute([$user['id']]);
+ return true;
+ }
+ return false;
+}
+
+function logout() {
+ unset($_SESSION['admin_user']);
+ session_destroy();
+}
diff --git a/admin/cases.php b/admin/cases.php
new file mode 100644
index 0000000..3c5ca76
--- /dev/null
+++ b/admin/cases.php
@@ -0,0 +1,192 @@
+prepare("DELETE FROM cases WHERE id = ?");
+ $stmt->execute([$id]);
+ header('Location: cases.php?msg=deleted');
+ exit;
+}
+
+// Handle Save (Add/Edit)
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $data = [
+ 'title' => $_POST['title'],
+ 'slug' => $_POST['slug'] ?: strtolower(preg_replace('/[^A-Za-z0-9-]+/', '-', $_POST['title'])),
+ 'tag' => $_POST['tag'],
+ 'category' => $_POST['category'],
+ 'img' => $_POST['img'],
+ 'description' => $_POST['description'],
+ 'content' => $_POST['content'],
+ 'challenge' => $_POST['challenge'],
+ 'solution' => $_POST['solution'],
+ 'result_stability' => $_POST['result_stability'],
+ 'result_throughput' => $_POST['result_throughput'],
+ 'result_cost' => $_POST['result_cost'],
+ 'tech' => $_POST['tech'],
+ 'is_featured' => isset($_POST['is_featured']) ? 1 : 0,
+ 'sort_order' => (int)$_POST['sort_order']
+ ];
+
+ if ($id) {
+ $sql = "UPDATE cases SET title=:title, slug=:slug, tag=:tag, category=:category, img=:img, description=:description, content=:content, challenge=:challenge, solution=:solution, result_stability=:result_stability, result_throughput=:result_throughput, result_cost=:result_cost, tech=:tech, is_featured=:is_featured, sort_order=:sort_order WHERE id=:id";
+ $data['id'] = $id;
+ } else {
+ $sql = "INSERT INTO cases (title, slug, tag, category, img, description, content, challenge, solution, result_stability, result_throughput, result_cost, tech, is_featured, sort_order) VALUES (:title, :slug, :tag, :category, :img, :description, :content, :challenge, :solution, :result_stability, :result_throughput, :result_cost, :tech, :is_featured, :sort_order)";
+ }
+
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute($data);
+ header('Location: cases.php?msg=saved');
+ exit;
+}
+
+// Fetch cases for list
+$cases = $pdo->query("SELECT * FROM cases ORDER BY sort_order ASC, created_at DESC")->fetchAll();
+
+// Fetch case for edit
+$case = null;
+if ($action === 'edit' && $id) {
+ $stmt = $pdo->prepare("SELECT * FROM cases WHERE id = ?");
+ $stmt->execute([$id]);
+ $case = $stmt->fetch();
+}
+?>
+
+
+
+
+
+
+
+
+
+ | 预览 |
+ 标题 / 分类 |
+ 标签 |
+ 精选 |
+ 排序 |
+ 操作 |
+
+
+
+
+
+  ?>) |
+
+ = htmlspecialchars($c['title']) ?>
+ = htmlspecialchars($c['category']) ?>
+ |
+ = htmlspecialchars($c['tag']) ?> |
+
+
+ 是
+
+ 否
+
+ |
+ = $c['sort_order'] ?> |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/footer.php b/admin/footer.php
new file mode 100644
index 0000000..b1762b9
--- /dev/null
+++ b/admin/footer.php
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+