| 1 |
<? |
<?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"; |
$cache_path = "../../var/bbs_top.txt"; |
| 14 |
|
|
| 15 |
$buffer = |
$buffer = |
| 16 |
" \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"; |
| 17 |
|
|
| 18 |
$db_conn = include "./db_open.inc.php"; |
$sql = "SELECT AID, bbs.title AS title, sname, username, sub_dt |
| 19 |
|
FROM bbs INNER JOIN section_config ON bbs.SID = section_config.SID |
| 20 |
|
WHERE section_config.recommend AND TID = 0 AND visible AND view_count >= 10 |
| 21 |
|
AND (sub_dt >= SUBDATE(NOW(), INTERVAL 7 DAY)) |
| 22 |
|
ORDER BY excerption DESC, (view_count + reply_count) DESC, transship |
| 23 |
|
LIMIT 10"; |
| 24 |
|
|
| 25 |
$rs = mysql_query( |
$rs = mysqli_query($db_conn, $sql); |
| 26 |
" select bbs.title, sname, username, sub_dt". |
if ($rs == false) |
| 27 |
" from bbs inner join section_config on". |
{ |
| 28 |
" bbs.SID=section_config.SID where section_config.recommend". |
echo("Query data error: " . mysqli_error($db_conn)); |
| 29 |
" and bbs.TID=0 and bbs.visible and bbs.view_count>=10". |
exit(); |
| 30 |
" 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"); |
|
| 31 |
|
|
| 32 |
$i = 1; |
$i = 1; |
| 33 |
while ($row=mysql_fetch_array($rs)) |
while ($row = mysqli_fetch_array($rs)) |
| 34 |
{ |
{ |
| 35 |
|
$title_f = split_line($row["title"], "", 60, 1, ""); |
| 36 |
|
|
| 37 |
$buffer .= sprintf ( |
$buffer .= sprintf ( |
| 38 |
" \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[1;37m第 \033[31m%2d \033[37m名 版块 : \033[33m%s%s \033[37m【 \033[32m%s \033[37m】 \033[35m%s%s \n" . |
| 39 |
" \033[37m 标题 : \033[44;37m%s%s \033[0;40;37m\r\n", |
" \033[37m 标题 : \033[44;37m%s%s \033[0;40;37m\n", |
| 40 |
$i++, $row["sname"], str_repeat(" ", 20 - strlen($row["sname"])), |
$i++, |
| 41 |
strftime("%b %d %H:%M:%S", strtotime($row["sub_dt"])), |
$row["sname"], |
| 42 |
|
str_repeat(" ", 20 - strlen($row["sname"])), |
| 43 |
|
(new DateTimeImmutable($row["sub_dt"]))->format("M d H:i:s"), |
| 44 |
str_repeat(" ", 16 - strlen($row["username"])), |
str_repeat(" ", 16 - strlen($row["username"])), |
| 45 |
$row["username"], substr($row["title"],0,60), |
$row["username"], |
| 46 |
str_repeat(" ", 60 - strlen($row["title"]) >=0 ? 60 - strlen($row["title"]) : 0) |
$title_f, |
| 47 |
|
str_repeat(" ", 60 - str_length($title_f)) |
| 48 |
); |
); |
| 49 |
} |
} |
| 50 |
|
mysqli_free_result($rs); |
| 51 |
|
|
| 52 |
mysql_free_result($rs); |
mysqli_close($db_conn); |
|
|
|
|
mysql_close($db_conn); |
|
|
|
|
|
if (($fp=fopen($cache_path,"w"))) |
|
|
{ |
|
|
fwrite($fp,$buffer); |
|
|
fclose($fp); |
|
|
} |
|
| 53 |
|
|
| 54 |
return 0; |
file_put_contents($cache_path, $buffer); |
|
?> |
|