| 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\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, |
$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 |
| 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); |