tag.php

(开头部分) 4KB

这里只显示每个文件的开头 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/Setting.php';
require_once __DIR__ . '/app/models/Page.php';

Session::start();

$id = (int)($_GET['id'] ?? 0);
$page = max(1, (int)($_GET['page'] ?? 1));

$tagModel = new Tag();
$postModel = new Post();
$categoryModel = new Category();
$settingModel = new Setting();

$tag = $tagModel->find($id);

if (!$tag) {
    header('HTTP/1.0 404 Not Found');
    include '404.php';
    exit;
}

$settings = $settingModel->getAllSettings();
$categories = $categoryModel->getActiveCategories();
$popularTags = $tagModel->getPopularTags(15);

$result = $postModel->getByTag($id, $page, $settings['posts_per_page'] ?? PER_PAGE);
$posts = $result['items'];
$pagination = $result['pagination'];

function getSetting($key, $default = '') {
    global $settings;
    return $settings[$key] ?? $default;
}
?>
<!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($tag['name']); ?> - <?php echo Security::cleanXSS(getSetting('site_title', 'PHP个人博客')); ?></title>
    <link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
    <?php include 'views/partials/header.php'; ?>
    
    <main class="site-main">
        <div class="container">
            <div class="main-content">
                <div class="archive-header">
                    <h1>#<?php echo Security::cleanXSS($tag['name']); ?></h1>
                    <?php if ($tag['description']): ?>
                    <p class="archive-description"><?php echo Security::cleanXSS($tag['description']); ?></p>
                    <?php endif; ?>
后面还有 58 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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