-
Notifications
You must be signed in to change notification settings - Fork 2
/
bbshot.php
104 lines (92 loc) · 2.38 KB
/
bbshot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* display the top 5 hot threads in board
* @author: windinsn May 28.2004
*/
require ('www2-funcs.php');
login_init();
if (!defined('BBS_NEWPOSTSTAT'))
exit ();
define('BBS_STAT_HOT',1);
define('BOARD_HOT_THREADS',5);
if (isset($_GET["board"]))
$board = $_GET["board"];
else
exit ();
$brdarr = array();
$normalboard = bbs_safe_getboard(0, $board, $brdarr);
if (is_null($normalboard)) die;
$board = $brdarr["NAME"];
if ($brdarr["FLAG"]&BBS_BOARD_GROUP)
exit ();
if ($normalboard) {
if (update_cache_header(60))
exit ();
} else die;
include ('db.php'); // include the database class
if (!($db = new BbsDb)) {
html_error_quit($db->err);
}
/**
* get hot threads of a borad
* bbs_get_hot_threads(string board)
* @author: windinsn
*/
function bbs_get_hot_threads($board,$num,&$threads,&$err)
{
global $db;
$brdarr = array();
$bid = bbs_getboard($board,$brdarr);
if (!$bid) {
$err = '°æÃæ '.$board.' ²»´æÔÚ';
return false;
}
$board = $brdarr['NAME'];
$tt = date('Ymd')."000000";
$sql = 'SELECT threadid,userid,title,time AS created,MAX(time) AS changed,count(DISTINCT userid) AS count FROM postlog WHERE time>='.$tt.
' AND bname = \''.addslashes($board).'\' GROUP BY threadid ORDER BY count DESC , id DESC LIMIT 0 , '.(intval($num)*2).';';
if (!$db->query($sql,1)) {
$err = $db->err;
return false;
}
$threads = array();
$n = 0;
for ($i = 0 ; $i < $db->nums ; $i ++ ) {
$title = $db->arrays[$i]['title'];
$gid = $db->arrays[$i]['threadid'];
$articles = array ();
if (bbs_get_records_from_id($board, $gid, 0, $articles) <= 0) continue;
if (substr($title,0,4)=='Re: ')
$title = substr($title,4);
$threads[] = array(
'gid' => $gid,
'userid' => $db->arrays[$i]['userid'],
'created' => $db->arrays[$i]['created'],
'changed' => $db->arrays[$i]['changed'],
'count' => $db->arrays[$i]['count'],
'title' => $title
);
$n++;
if ($n == $num) break;
}
return true;
}
$threads = array();
$err = '';
if (!bbs_get_hot_threads($board,BOARD_HOT_THREADS,$threads,$err))
exit ();
page_header("ÈÈÃÅ»°Ìâ", FALSE);
?>
<body><script type="text/javascript"><!--
parent.setHots([<?php
if (sizeof($threads)>0) {
foreach ($threads as $thread) {
?>
[<?php echo $thread['gid']; ?>, '<?php echo htmlspecialchars($thread['title'], ENT_QUOTES); ?> ', <?php echo $thread['count']; ?>],
<?php
}
}
?>
0]);
//-->
</script></body></html>