/[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.5 by sysadm, Sun Mar 13 09:06:27 2005 UTC Revision 1.14 by sysadm, Mon Oct 13 07:14:48 2025 UTC
# Line 1  Line 1 
1  #!/usr/local/php/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            chdir(dirname($_SERVER["argv"][0]));
9    
10          if (isset($_SERVER["argv"][0]))          require_once "../lib/db_open.inc.php";
11                  chdir(substr($_SERVER["argv"][0],0,strrpos($_SERVER["argv"][0],"/")));          require_once "../lib/str_process.inc.php";
12    
13          $cache_path = "../../data/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\r\n\r\n";
18    
19          $db_conn = include "./db_open.inc.php";          $buffer_screen = <<<SCREEN
20            #---------------------------------------------------------------------
21          $rs = mysql_query(  %S_TOP10
22                  " select bbs.title, sname, username, sub_dt".                       \033[1;34m-----\033[37m=====\033[41;37m 鏈珯鍗佸ぇ鐑棬璇濋 \033[40m=====\033[34m-----\033[m
23                  " from bbs inner join section_config on".  
24                  " bbs.SID=section_config.SID where section_config.recommend".  SCREEN;
25                  " and bbs.TID=0 and bbs.visible and bbs.view_count>=10".  
26                  " and (bbs.sub_dt >= subdate(now(),interval '7' day))".          $buffer_menu = <<<MENU
27                  " order by bbs.excerption desc,bbs.view_count+bbs.reply_count desc,".  #---------------------------------------------------------------------
28                  "bbs.transship limit 10",$db_conn)  %menu M_TOP10
29                  or die ("Query data error");  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();
47            }
48    
49          $i = 1;          $i = 1;
50          while ($row=mysql_fetch_array($rs))          while ($row = mysqli_fetch_array($rs))
51          {          {
52                  $buffer .= sprintf (                  $title_f = split_line($row["title"], "", 60, 1, "");
53                          " \033[1;37m第 \033[31m%2d \033[37m名 版块 : \033[33m%s%s \033[37m【\033[32m%s \033[37m】    \033[35m%s%s \r\n".  
54                          " \033[37m     标题 : \033[44;37m%s%s \033[0;40;37m\r\n",                  $line_section = sprintf (
55                          $i++, $row["sname"], str_repeat(" ", 20 - strlen($row["sname"])),                          " \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                          strftime("%b %d %H:%M:%S", strtotime($row["sub_dt"])),                          $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"])),                          str_repeat(" ", 16 - strlen($row["username"])),
62                          $row["username"], substr($row["title"],0,60),                          $row["username"]
63                          str_repeat(" ", 60 - strlen($row["title"]))                          );
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                          );                          );
         }  
           
         mysql_free_result($rs);  
70    
71          mysql_close($db_conn);                  $buffer_text .= $line_section . "\n  " . $line_article . "\n";
72    
73          if (($fp=fopen($cache_path,"w")))                  $buffer_screen .= $line_section . "\n\n";
74          {  
75                  fwrite($fp,$buffer);                  $row_article = $i * 2 + 2;
76                  fclose($fp);  
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