仰望星辰工作室

better-staridc-MNBT

better-staridc-MNBT/ user/notice.php 1.3 KB · 47 行 原始文件
Z zfhsh first commit 1 天前
1<?php
2include("../MPHX/common.php");
3@header('Content-Type: text/html; charset=UTF-8');
4$title = 'MNBT通知日志';
5mnbt_user_require_login();
6include_once("../MPHX/monitor.function.php");
7monitor_ensure_tables($DB);
8
9$type = trim($_GET['type'] ?? '');
10$level = trim($_GET['level'] ?? '');
11$read = trim($_GET['read'] ?? '');
12$keyword = trim($_GET['keyword'] ?? '');
13$page = max(1, intval($_GET['page'] ?? 1));
14$page_size = intval($_GET['page_size'] ?? 15);
15if (!in_array($page_size, [10, 15, 25, 50, 100], true)) {
16 $page_size = 15;
17}
18
19$where = " WHERE user=?";
20$params = [$yhc['user']];
21if ($type !== '') {
22 $where .= " AND type=?";
23 $params[] = $type;
24}
25if ($level !== '') {
26 $where .= " AND level=?";
27 $params[] = $level;
28}
29if ($read === 'true' || $read === 'false') {
30 $where .= " AND is_read=?";
31 $params[] = $read;
32}
33if ($keyword !== '') {
34 $where .= " AND (title LIKE ? OR content LIKE ?)";
35 $like = '%' . $keyword . '%';
36 $params[] = $like;
37 $params[] = $like;
38}
39
40$total = (int)$DB->count_prepare("SELECT count(*) FROM MN_notice_log {$where}", $params);
41$total_pages = max(1, (int)ceil($total / $page_size));
42if ($page > $total_pages) {
43 $page = $total_pages;
44}
45$offset = ($page - 1) * $page_size;
46$logs = $DB->get_all_prepare("SELECT * FROM MN_notice_log {$where} ORDER BY id DESC LIMIT {$offset},{$page_size}", $params) ?: [];
47mnbt_render('notice');