本帖最后由 caoxuming 于 2010-02-03 22:25 编辑
//热门话题
$cachefile = S_ROOT.'./data/cache_network_thread.txt';
if(check_network_cache('thread')) {
$threadlist = unserialize(sreadfile($cachefile));
} else {
$sqlarr = mk_network_sql('thread',
array('tid', 'uid'),
array('hot','viewnum','replynum'),
array('dateline','lastpost'),
array('dateline','viewnum','replynum','hot')
);
extract($sqlarr);
//显示数量
$shownum = 10;
$threadlist = array();
$query = $_SGLOBAL['db']->query("SELECT main.*, m.tagname
FROM ".tname('thread')." main
LEFT JOIN ".tname('mtag')." m ON m.tagid=main.tagid
WHERE ".implode(' AND ', $wherearr)."
ORDER BY main.{$order} $sc LIMIT 0,$shownum");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$value['tagname'] = getstr($value['tagname'], 20);
$value['subject'] = getstr($value['subject'], 50);
$threadlist[] = $value;
}
if($_SGLOBAL['network']['thread']['cache']) {
swritefile($cachefile, serialize($threadlist));
}
}
foreach($threadlist as $key => $value) {
realname_set($value['uid'], $value['username']);
$threadlist[$key] = $value;
} |