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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.11 by sysadm, Sun May 4 00:25:34 2025 UTC Revision 1.16 by sysadm, Tue Jan 6 15:43:33 2026 UTC
# Line 2  Line 2 
2          if (!isset($_SERVER["argc"]))          if (!isset($_SERVER["argc"]))
3          {          {
4                  echo ("Invalid usage");                  echo ("Invalid usage");
5                  exit();                  exit(-1);
6          }          }
7    
8          chdir(dirname($_SERVER["argv"][0]));          chdir(dirname($_SERVER["argv"][0]));
# Line 10  Line 10 
10          require_once "../lib/db_open.inc.php";          require_once "../lib/db_open.inc.php";
11          require_once "../lib/str_process.inc.php";          require_once "../lib/str_process.inc.php";
12    
13          $cache_path = "../../var/bbs_top.txt";          $text_file_path = "../../var/bbs_top.txt";
14            $menu_file_path = "../../var/bbs_top_menu.conf";
15    
16          $buffer =          $buffer_text =
17                  "               \033[1;34m-----\033[37m=====\033[41;37m 本站十大热门话题 \033[40m=====\033[34m-----\033[m\r\n\r\n";                  "                     \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,          $sql = "SELECT AID, bbs.title AS title, sname,
35                          section_config.title AS s_title, username, sub_dt                          section_config.title AS s_title, username, sub_dt
# Line 27  Line 43 
43          if ($rs == false)          if ($rs == false)
44          {          {
45                  echo("Query data error: " . mysqli_error($db_conn));                  echo("Query data error: " . mysqli_error($db_conn));
46                  exit();                  exit(-2);
47          }          }
48    
49          $i = 1;          $i = 1;
# Line 35  Line 51 
51          {          {
52                  $title_f = split_line($row["title"], "", 60, 1, "");                  $title_f = split_line($row["title"], "", 60, 1, "");
53    
54                  $buffer .= sprintf (                  $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 \n" .                          " \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                          " \033[37m         标题 : \033[44;37m%s%s  \033[0;40;37m \n",                          $i,
                         $i++,  
57                          $row["s_title"],                          $row["s_title"],
58                          $row["sname"],                          $row["sname"],
59                          str_repeat(" ", 20 - str_length($row["s_title"]) - strlen($row["sname"])),                          str_repeat(" ", 20 - str_length($row["s_title"]) - strlen($row["sname"])),
60                          (new DateTimeImmutable($row["sub_dt"]))->format("M d H:i:s"),                          (new DateTimeImmutable($row["sub_dt"]))->format("M d H:i:s"),
61                          str_repeat(" ", 16 - strlen($row["username"])),                          str_repeat(" ", 16 - strlen($row["username"])),
62                          $row["username"],                          $row["username"]
63                            );
64    
65                    $line_article = sprintf (
66                            " \033[1;37m       鏍囬 : \033[44;37m%s%s  \033[0;40;37m",
67                          $title_f,                          $title_f,
68                          str_repeat(" ", 60 - str_length($title_f))                          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);          mysqli_free_result($rs);
85    
86          mysqli_close($db_conn);          mysqli_close($db_conn);
87    
88          file_put_contents($cache_path, $buffer);          $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);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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