search.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/Setting.php';
require_once __DIR__ . '/app/models/Page.php';
Session::start();
$keyword = trim($_GET['q'] ?? '');
$page = max(1, (int)($_GET['page'] ?? 1));
$postModel = new Post();
$categoryModel = new Category();
$tagModel = new Tag();
$settingModel = new Setting();
$settings = $settingModel->getAllSettings();
$categories = $categoryModel->getActiveCategories();
$popularTags = $tagModel->getPopularTags(15);
$posts = [];
$pagination = null;
if ($keyword) {
$result = $postModel->search($keyword, $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($keyword); ?> - <?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($keyword); ?>"</h1>
<?php if ($pagination): ?>
<p class="archive-count">找到 <?php echo $pagination->getTotal(); ?> 篇相关文章</p>
<?php endif; ?>
</div>
<?php if (empty($keyword)): ?>
后面还有 67 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
