--- lbbs/utils/bin/gen_top.php 2025/04/28 03:31:00 1.8 +++ lbbs/utils/bin/gen_top.php 2025/12/19 06:30:40 1.15 @@ -1,50 +1,92 @@ -= 10 + AND (sub_dt >= SUBDATE(NOW(), INTERVAL 7 DAY)) + ORDER BY excerption DESC, (view_count + reply_count) DESC, transship + LIMIT 10"; - $buffer = - " \033[1;34m-----\033[37m=====\033[41;37m վʮŻ \033[40m=====\033[34m-----\033[m\r\n\r\n"; - - $db_conn = include "./db_open.inc.php"; - - $rs = mysql_query( - " select bbs.title, sname, username, sub_dt". - " from bbs inner join section_config on". - " bbs.SID=section_config.SID 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) - or die ("Query data error"); + $rs = mysqli_query($db_conn, $sql); + if ($rs == false) + { + echo("Query data error: " . mysqli_error($db_conn)); + exit(); + } $i = 1; - while ($row=mysql_fetch_array($rs)) + while ($row = mysqli_fetch_array($rs)) { - $buffer .= sprintf ( - " \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". - " \033[37m : \033[44;37m%s%s \033[0;40;37m\r\n", - $i++, $row["sname"], str_repeat(" ", 20 - strlen($row["sname"])), - strftime("%b %d %H:%M:%S", strtotime($row["sub_dt"])), + $title_f = split_line($row["title"], "", 60, 1, ""); + + $line_section = sprintf ( + " \033[1;37m第 \033[31m%2d \033[37m名 版块 : \033[33m%s [%s]%s \033[37m【 \033[32m%s \033[37m】\033[35m%s%s ", + $i, + $row["s_title"], + $row["sname"], + str_repeat(" ", 20 - str_length($row["s_title"]) - strlen($row["sname"])), + (new DateTimeImmutable($row["sub_dt"]))->format("M d H:i:s"), str_repeat(" ", 16 - strlen($row["username"])), - $row["username"], substr($row["title"],0,60), - str_repeat(" ", 60 - strlen($row["title"]) >=0 ? 60 - strlen($row["title"]) : 0) + $row["username"] ); - } - mysql_free_result($rs); + $line_article = sprintf ( + " \033[1;37m 标题 : \033[44;37m%s%s \033[0;40;37m", + $title_f, + str_repeat(" ", 60 - str_length($title_f)) + ); - mysql_close($db_conn); + $buffer_text .= $line_section . "\n " . $line_article . "\n"; - if (($fp=fopen($cache_path,"w"))) - { - fwrite($fp,$buffer); - fclose($fp); + $buffer_screen .= $line_section . "\n\n"; + + $row_article = $i * 2 + 2; + + $buffer_menu .= << + file_put_contents($text_file_path, $buffer_text); + file_put_contents($menu_file_path, $buffer_menu);