/[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.16 - (show annotations)
Tue Jan 6 15:43:33 2026 UTC (2 months, 1 week ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.15: +2 -2 lines
Error occurred while calculating annotation data.
Return error code

1 <?php
2 if (!isset($_SERVER["argc"]))
3 {
4 echo ("Invalid usage");
5 exit(-1);
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 $text_file_path = "../../var/bbs_top.txt";
14 $menu_file_path = "../../var/bbs_top_menu.conf";
15
16 $buffer_text =
17 " \033[1;34m-----\033[37m=====\033[41;37m 本站十大热门话题 \033[40m=====\033[34m-----\033[m\n\n";
18
19 $buffer_screen = <<<SCREEN
20 #---------------------------------------------------------------------
21 %S_TOP10
22 \033[1;34m-----\033[37m=====\033[41;37m 本站十大热门话题 \033[40m=====\033[34m-----\033[m
23
24 SCREEN;
25
26 $buffer_menu = <<<MENU
27 #---------------------------------------------------------------------
28 %menu M_TOP10
29 title 0, 0, "十大热门话题"
30 screen 2, 0, S_TOP10
31
32 MENU;
33
34 $sql = "SELECT AID, bbs.title AS title, sname,
35 section_config.title AS s_title, username, sub_dt
36 FROM bbs INNER JOIN section_config ON bbs.SID = section_config.SID
37 WHERE section_config.recommend AND TID = 0 AND visible AND view_count >= 10
38 AND (sub_dt >= SUBDATE(NOW(), INTERVAL 7 DAY))
39 ORDER BY excerption DESC, (view_count + reply_count) DESC, transship
40 LIMIT 10";
41
42 $rs = mysqli_query($db_conn, $sql);
43 if ($rs == false)
44 {
45 echo("Query data error: " . mysqli_error($db_conn));
46 exit(-2);
47 }
48
49 $i = 1;
50 while ($row = mysqli_fetch_array($rs))
51 {
52 $title_f = split_line($row["title"], "", 60, 1, "");
53
54 $line_section = sprintf (
55 " \033[1;37m第 \033[31m%2d \033[37m名 版块 : \033[33m%s [%s]%s \033[37m【 \033[32m%s \033[37m】\033[35m%s%s ",
56 $i,
57 $row["s_title"],
58 $row["sname"],
59 str_repeat(" ", 20 - str_length($row["s_title"]) - strlen($row["sname"])),
60 (new DateTimeImmutable($row["sub_dt"]))->format("M d H:i:s"),
61 str_repeat(" ", 16 - strlen($row["username"])),
62 $row["username"]
63 );
64
65 $line_article = sprintf (
66 " \033[1;37m 标题 : \033[44;37m%s%s \033[0;40;37m",
67 $title_f,
68 str_repeat(" ", 60 - str_length($title_f))
69 );
70
71 $buffer_text .= $line_section . "\n " . $line_article . "\n";
72
73 $buffer_screen .= $line_section . "\n\n";
74
75 $row_article = $i * 2 + 2;
76
77 $buffer_menu .= <<<MENU
78 @LOCATE_ARTICLE {$row_article}, 3, 1, 0, "{$row['sname']}|{$row['AID']}", "{$line_article}"
79
80 MENU;
81
82 $i++;
83 }
84 mysqli_free_result($rs);
85
86 mysqli_close($db_conn);
87
88 $buffer_screen .= "%\n";
89 $buffer_menu .= ("%\n" . $buffer_screen);
90
91 file_put_contents($text_file_path, $buffer_text);
92 file_put_contents($menu_file_path, $buffer_menu);

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