category.php
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
require_once __DIR__ . '/core/Session.php';
require_once __DIR__ . '/core/Security.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/Tag.php';
require_once __DIR__ . '/app/models/Comment.php';
require_once __DIR__ . '/app/models/Setting.php';
require_once __DIR__ . '/app/models/Page.php';
Session::start();
$id = (int)($_GET['id'] ?? 0);
$page = max(1, (int)($_GET['page'] ?? 1));
$categoryModel = new Category();
$postModel = new Post();
$tagModel = new Tag();
$commentModel = new Comment();
$settingModel = new Setting();
$category = $categoryModel->find($id);
if (!$category || !$category['status']) {
header('HTTP/1.0 404 Not Found');
include '404.php';
exit;
}
$settings = $settingModel->getAllSettings();
$categories = $categoryModel->getActiveCategories();
$popularTags = $tagModel->getPopularTags(15);
$recentPosts = $postModel->getRecentPosts(5);
$categoryIds = $categoryModel->getChildIds($id);
$result = $postModel->getByCategories($categoryIds, $page, $settings['posts_per_page'] ?? PER_PAGE);
$posts = $result['items'];
$pagination = $result['pagination'];
function getSetting($key, $default = '') {
global $settings;
return $settings[$key] ?? $default;
}
$currentCategoryId = $id;
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo Security::cleanXSS($category['name']); ?> - <?php echo Security::cleanXSS(getSetting('site_title', 'PHP个人博客')); ?></title>
<meta name="description" content="<?php echo Security::cleanXSS($category['description'] ?? $category['name']); ?>">
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<?php include 'views/partials/header.php'; ?>
<main class="site-main">
后面还有 77 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
