/[LeafOK_CVS]/lbbs/utils/bin/gen_top.php
ViewVC logotype

Contents of /lbbs/utils/bin/gen_top.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations)
Wed Jul 2 04:17:33 2025 UTC (8 months, 2 weeks ago) by sysadm
Branch: MAIN
Changes since 1.11: +3 -3 lines
Support UTF8 instead of GBK

1 <?php
2 if (!isset($_SERVER["argc"]))
3 {
4 echo ("Invalid usage");
5 exit();
6 }
7
8 chdir(dirname($_SERVER["argv"][0]));
9
10 require_once "../lib/db_open.inc.php";
11 require_once "../lib/str_process.inc.php";
12
13 $cache_path = "../../var/bbs_top.txt";
14
15 $buffer =
16 " \033[1;34m-----\033[37m=====\033[41;37m 本站十大热门话题 \033[40m=====\033[34m-----\033[m\r\n\r\n";
17
18 $sql = "SELECT AID, bbs.title AS title, sname,
19 section_config.title AS s_title, username, sub_dt
20 FROM bbs INNER JOIN section_config ON bbs.SID = section_config.SID
21 WHERE section_config.recommend AND TID = 0 AND visible AND view_count >= 10
22 AND (sub_dt >= SUBDATE(NOW(), INTERVAL 7 DAY))
23 ORDER BY excerption DESC, (view_count + reply_count) DESC, transship
24 LIMIT 10";
25
26 $rs = mysqli_query($db_conn, $sql);
27 if ($rs == false)
28 {
29 echo("Query data error: " . mysqli_error($db_conn));
30 exit();
31 }
32
33 $i = 1;
34 while ($row = mysqli_fetch_array($rs))
35 {
36 $title_f = split_line($row["title"], "", 60, 1, "");
37
38 $buffer .= sprintf (
39 " \033[1;37m第 \033[31m%2d \033[37m名 版块 : \033[33m%s [%s]%s \033[37m【 \033[32m%s \033[37m】\033[35m%s%s \n" .
40 " \033[37m 标题 : \033[44;37m%s%s \033[0;40;37m \n",
41 $i++,
42 $row["s_title"],
43 $row["sname"],
44 str_repeat(" ", 20 - str_length($row["s_title"]) - strlen($row["sname"])),
45 (new DateTimeImmutable($row["sub_dt"]))->format("M d H:i:s"),
46 str_repeat(" ", 16 - strlen($row["username"])),
47 $row["username"],
48 $title_f,
49 str_repeat(" ", 60 - str_length($title_f))
50 );
51 }
52 mysqli_free_result($rs);
53
54 mysqli_close($db_conn);
55
56 file_put_contents($cache_path, $buffer);

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1