plugins.php3.6 KB
<?php
require 'config.php';
$page_title = "插件管理";
// 处理状态切换
if (isset($_GET['toggle'])) {
$id = $_GET['toggle'];
$pdo->exec("UPDATE plugins SET is_active = IF(is_active=1, 0, 1) WHERE id = $id");
header('Location: plugins.php'); exit;
}
$stmt = $pdo->query("SELECT * FROM plugins ORDER BY id ASC");
$plugins = $stmt->fetchAll(PDO::FETCH_ASSOC);
ob_start();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>评论管理</title>
<style>
</style>
</head>
<body>
<div class="overlay" id="overlay"></div>
<!-- 侧边栏 -->
<?php require_once __DIR__ . '/views/sidebar.php'; ?>
<!-- 主内容区 -->
<div class="main-wrapper">
<?php require_once __DIR__ . '/views/header.php'; ?>
<main class="content-area">
<div class="page-header">
<h1 class="page-title">数据概览</h1>
<button class="btn-primary"><a href="post_edit.php">+ 撰写新文章</a></button>
</div>
<!-- 数据表格 -->
<!-- 提示信息 -->
<?php if (!empty($_GET['msg'])): ?>
<p style="color:green;font-weight:bold;margin-bottom:15px;">操作成功!</p>
<?php endif; ?>
<!-- 数据表格 -->
<div class="card" style="padding: 0; overflow: hidden;">
<div class="table-wrapper">
<table>
<thead>
<tr>
<th style="width: 40px;"><input type="checkbox" class="table-checkbox"></th>
<th style="width: 60px;">ID</th>
<th>插件标识 (Key)</th>
<th>状态</th>
<th style="width: 120px;">操作</th>
</tr>
</thead>
<tbody>
<?php if (!empty($plugins)): ?>
<?php foreach ($plugins as $plugin): ?>
<tr>
<td><input type="checkbox" class="table-checkbox"></td>
<td><?php echo $plugin['id']; ?></td>
<td>
<div class="article-cat"><code><?php echo htmlspecialchars($plugin['plugin_key']); ?></code></div>
</td>
<td>
<!-- 状态标签:使用新的 status-badge 样式 -->
<?php if ($plugin['is_active']): ?>
<span class="status-badge status-pub">已启用</span>
<?php else: ?>
<span class="status-badge status-draft">已停用</span>
<?php endif; ?>
</td>
<td>
<!-- 启用/停用按钮 -->
<a href="?toggle=<?php echo $plugin['id']; ?>" class="action-btn" title="<?php echo $plugin['is_active'] ? '停用' : '启用'; ?>">
<?php echo $plugin['is_active'] ? '🚫' : '✅'; ?>
</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" style="text-align:center; color:#999; padding:30px 0;">暂无插件数据。</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</main>
</div>
<?php require_once __DIR__ . '/views/footer.php'; ?>
</body>
</html>