/[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.1 by sysadm, Fri Oct 22 17:45:36 2004 UTC Revision 1.14 by sysadm, Mon Oct 13 07:14:48 2025 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/php  <?php
 <?  
2          if (!isset($_SERVER["argc"]))          if (!isset($_SERVER["argc"]))
3                  $_SERVER["argc"] = 0;          {
4                    echo ("Invalid usage");
5                    exit();
6            }
7    
8          if (isset($_SERVER["argv"][0]))          chdir(dirname($_SERVER["argv"][0]));
                 chdir(substr($_SERVER["argv"][0],0,strrpos($_SERVER["argv"][0],"/")));  
9    
10          $cache_path = "../../data/bbs_top.txt";          require_once "../lib/db_open.inc.php";
11            require_once "../lib/str_process.inc.php";
12    
13          $buffer =          $text_file_path = "../../var/bbs_top.txt";
14                  "                -----===== 全国十大热门话题 =====-----\r\n\r\n";          $menu_file_path = "../../var/bbs_top_menu.conf";
   
         $db_conn = include "./db_open.inc.php";  
           
         $rs = mysql_query(  
                 " select bbs.title, sname, username".  
                 " from bbs inner join section_config on".  
                 " bbs.SID=section_config.SID inner join user_list on".  
                 " user_list.UID=bbs.UID where section_config.recommend".  
                 " and bbs.TID=0 and bbs.visible and bbs.view_count>=10".  
                 " and (bbs.sub_dt >= subdate(now(),interval '7' day))".  
                 " order by bbs.excerption desc,bbs.view_count+bbs.reply_count desc,".  
                 "bbs.transship limit 10",$db_conn);  
15    
16          i = 1;          $buffer_text =
17                    "                     \033[1;34m-----\033[37m=====\033[41;37m 鏈珯鍗佸ぇ鐑棬璇濋 \033[40m=====\033[34m-----\033[m\r\n\r\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          while ($row=mysql_fetch_array($rs))          $rs = mysqli_query($db_conn, $sql);
43            if ($rs == false)
44          {          {
45                  sprintf ($temp,                  echo("Query data error: " . mysqli_error($db_conn));
46                          "第 %2d 名 版块 : [%s]%s%s%s\r\n".                  exit();
                         "         标题 : %s%s\r\n",  
                         i++, $row["sname"], str_repeat(" ", 36 - strlen($row["sname"])),  
                         $row["username"], str_repeat(" ", 28 - strlen($row["username"]))  
                         );  
                 $buffer.=$temp;  
47          }          }
           
         mysql_free_result($rs);  
48    
49          mysql_close($db_conn);          $i = 1;
50            while ($row = mysqli_fetch_array($rs))
         if (($fp=fopen($cache_path,"w")))  
51          {          {
52                  fwrite($fp,$buffer);                  $title_f = split_line($row["title"], "", 60, 1, "");
53                  fclose($fp);  
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          return 0;  
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);


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

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