admin/posts.php

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
require_once __DIR__ . '/../core/Session.php';
require_once __DIR__ . '/../core/Security.php';
require_once __DIR__ . '/../core/Logger.php';
require_once __DIR__ . '/../core/Pagination.php';
require_once __DIR__ . '/../app/models/Post.php';
require_once __DIR__ . '/../app/models/Category.php';
require_once __DIR__ . '/../app/models/Comment.php';

Session::start();
Session::requireLogin();

$user = Session::getUser();
$postModel = new Post();
$categoryModel = new Category();

$status = $_GET['status'] ?? '';
$search = $_GET['search'] ?? '';
$categoryId = $_GET['category'] ?? '';
$page = max(1, (int)($_GET['page'] ?? 1));

$where = "1=1";
$params = [];

if ($status) {
    $where .= " AND status = ?";
    $params[] = $status;
}

if ($search) {
    $where .= " AND (title LIKE ? OR content LIKE ?)";
    $params[] = "%{$search}%";
    $params[] = "%{$search}%";
}

if ($categoryId) {
    $where .= " AND category_id = ?";
    $params[] = $categoryId;
}

$result = $postModel->paginate($page, PER_PAGE, $where, $params, 'created_at', 'DESC');
$posts = $result['items'];
$pagination = $result['pagination'];

$categories = $categoryModel->getActiveCategories();

$csrfToken = Security::generateCSRFToken();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章管理 - PHP个人博客系统</title>
    <link rel="stylesheet" href="../assets/css/admin.css">
</head>
<body class="admin-page">
    <div class="admin-wrapper">
        <?php include 'views/partials/sidebar.php'; ?>
        
后面还有 119 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。