📄 forumdisplay.php
字号:
$query = $db->query("SELECT uid, groupid, username, invisible, lastactivity, action FROM {$tablepre}sessions WHERE $guestwhere fid='$fid' AND invisible='0'");
if($db->num_rows($query)) {
$whosonlinestatus = 1;
while($online = $db->fetch_array($query)) {
if($online['uid']) {
$online['icon'] = isset($_DCACHE['onlinelist'][$online['groupid']]) ? $_DCACHE['onlinelist'][$online['groupid']] : $_DCACHE['onlinelist'][0];
} else {
$online['icon'] = $_DCACHE['onlinelist'][7];
$online['username'] = $_DCACHE['onlinelist']['guest'];
}
$online['action'] = $actioncode[$online['action']];
$online['lastactivity'] = gmdate($timeformat, $online['lastactivity'] + ($timeoffset * 3600));
$whosonline[] = $online;
}
}
unset($online);
}
} else {
$whosonlinestatus = 0;
}
if(empty($filter)) {
$threadcount = $forum['threads'];
} else {
$threadcount = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid' $filteradd AND displayorder>='0'");
}
$thisgid = $forum['type'] == 'forum' ? $forum['fup'] : $_DCACHE['forums'][$forum['fup']]['fup'];
if($globalstick && $forum['allowglobalstick']) {
$stickytids = $_DCACHE['globalstick']['global']['tids'].(empty($_DCACHE['globalstick']['categories'][$thisgid]['count']) ? '' : ','.$_DCACHE['globalstick']['categories'][$thisgid]['tids']);
$stickycount = $_DCACHE['globalstick']['global']['count'] + $_DCACHE['globalstick']['categories'][$thisgid]['count'];
} else {
$stickycount = $stickytids = 0;
}
$filterbool = !empty($filter) && in_array($filter, array('digest', 'type', 'activity', 'poll', 'trade', 'reward', 'debate', 'video'));
$threadcount += $filterbool ? 0 : $stickycount;
$multipage = multi($threadcount, $tpp, $page, "forumdisplay.php?fid=$fid$forumdisplayadd", $threadmaxpages);
$extra = rawurlencode("page=$page$forumdisplayadd");
$separatepos = 0;
$threadlist = array();
$colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
$displayorderadd = !$filterbool && $stickycount ? 't.displayorder IN (0, 1)' : 't.displayorder IN (0, 1, 2, 3)';
if(($start_limit && $start_limit > $stickycount) || !$stickycount || $filterbool) {
$querysticky = '';
$query = $sdb->query("SELECT t.* FROM {$tablepre}threads t
WHERE t.fid='$fid' $filteradd AND $displayorderadd
ORDER BY t.displayorder DESC, t.$orderby $ascdesc
LIMIT ".($filterbool ? $start_limit : $start_limit - $stickycount).", $tpp");
} else {
$querysticky = $sdb->query("SELECT t.* FROM {$tablepre}threads t
WHERE t.tid IN ($stickytids) AND t.displayorder IN (2, 3)
ORDER BY displayorder DESC, $orderby $ascdesc
LIMIT $start_limit, ".($stickycount - $start_limit < $tpp ? $stickycount - $start_limit : $tpp));
if($tpp - $stickycount + $start_limit > 0) {
$query = $sdb->query("SELECT t.* FROM {$tablepre}threads t
WHERE t.fid='$fid' $filteradd AND $displayorderadd
ORDER BY displayorder DESC, $orderby $ascdesc
LIMIT ".($tpp - $stickycount + $start_limit));
} else {
$query = '';
}
}
if($page < 4 && !(empty($_DCACHE['floatthreads']['categories'][$thisgid]) && empty($_DCACHE['floatthreads']['forums'][$fid]))) {
$queryfloat = $sdb->query("SELECT t.* FROM {$tablepre}threads t
WHERE t.tid IN (".(!empty($_DCACHE['floatthreads']['categories'][$thisgid]) ? $_DCACHE['floatthreads']['categories'][$thisgid] : 0).','.(!empty($_DCACHE['floatthreads']['forums'][$fid]) ? $_DCACHE['floatthreads']['forums'][$fid] : 0).") AND t.displayorder IN (4, 5)
ORDER BY displayorder DESC");
} else {
$queryfloat = '';
}
$ppp = $forum['threadcaches'] && !$discuz_uid ? $_DCACHE['settings']['postperpage'] : $ppp;
while(($querysticky && $thread = $sdb->fetch_array($querysticky)) || ($query && $thread = $sdb->fetch_array($query)) || ($queryfloat && $thread = $sdb->fetch_array($queryfloat))) {
$thread['icon'] = isset($_DCACHE['icons'][$thread['iconid']]) ? '<img src="images/icons/'.$_DCACHE['icons'][$thread['iconid']].'" alt="Icon'.$thread['iconid'].'" class="icon" />' : ' ';
$thread['lastposterenc'] = rawurlencode($thread['lastposter']);
$thread['typeid'] = $thread['typeid'] && !empty($forum['threadtypes']['prefix']) && isset($forum['threadtypes']['types'][$thread['typeid']]) ?
'<em>[<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">'.$forum['threadtypes']['types'][$thread['typeid']].'</a>]</em>' : '';
$thread['sortid'] = $thread['sortid'] && !empty($forum['threadsorts']['prefix']) && isset($forum['threadsorts']['types'][$thread['sortid']]) ?
'<em>[<a href="forumdisplay.php?fid='.$fid.'&filter=sort&sortid='.$thread['sortid'].'">'.$forum['threadsorts']['types'][$thread['sortid']].'</a>]</em>' : '';
$thread['multipage'] = '';
$topicposts = $thread['special'] ? $thread['replies'] : $thread['replies'] + 1;
$thread['special'] == 3 && $thread['price'] < 0 && $thread['replies']--;
if($topicposts > $ppp) {
$pagelinks = '';
$thread['pages'] = ceil($topicposts / $ppp);
for($i = 2; $i <= 6 && $i <= $thread['pages']; $i++) {
$pagelinks .= "<a href=\"viewthread.php?tid=$thread[tid]&extra=$extra&page=$i\">$i</a> ";
}
if($thread['pages'] > 6) {
$pagelinks .= " .. <a href=\"viewthread.php?tid=$thread[tid]&extra=$extra&page=$thread[pages]\">$thread[pages]</a> ";
}
$thread['multipage'] = '... '.$pagelinks;
}
if($thread['highlight']) {
$string = sprintf('%02d', $thread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$thread['highlight'] = ' style="';
$thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$thread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
$thread['highlight'] .= '"';
} else {
$thread['highlight'] = '';
}
$thread['moved'] = 0;
if($thread['closed'] || ($forum['autoclose'] && $timestamp - $thread[$closedby] > $forum['autoclose'])) {
$thread['new'] = 0;
if($thread['closed'] > 1) {
$thread['moved'] = $thread['tid'];
$thread['tid'] = $thread['closed'];
$thread['replies'] = '-';
$thread['views'] = '-';
}
$thread['folder'] = 'lock';
} else {
$thread['folder'] = 'common';
if($lastvisit < $thread['lastpost'] && (empty($_DCOOKIE['oldtopics']) || strpos($_DCOOKIE['oldtopics'], 'D'.$thread['tid'].'D') === FALSE)) {
$thread['new'] = 1;
$thread['folder'] = 'new';
} else {
$thread['new'] = 0;
}
if($thread['replies'] > $thread['views']) {
$thread['views'] = $thread['replies'];
}
if($thread['replies'] >= $hottopic) {
$thread['folder'] = 'hot';
}
}
$thread['dateline'] = gmdate($dateformat, $thread['dateline'] + $timeoffset * 3600);
$thread['lastpost'] = dgmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
if(in_array($thread['displayorder'], array(1, 2, 3))) {
$thread['id'] = 'stickthread_'.$thread['tid'];
$separatepos++;
} elseif(in_array($thread['displayorder'], array(4, 5))) {
$thread['id'] = 'floatthread_'.$thread['tid'];
} else {
$thread['id'] = 'normalthread_'.$thread['tid'];
}
$threadlist[] = $thread;
}
$separatepos = $separatepos ? $separatepos + 1 : ($announcement ? 1 : 0);
$visitedforums = $visitedforums ? visitedforums() : '';
$forummenu = '';
$usesigcheck = $discuz_uid && $sigstatus ? 'checked="checked"' : '';
$allowpost = (!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])) || ($forum['allowpost'] == 1 && $allowpost);
$fastpost = $fastpost && !$forum['allowspecialonly'];
$allowpost = $forum['allowpost'] != -1 ? $allowpost : false;
$addfeedcheck = $customaddfeed & 1 ? 'checked="checked"': '';
$showpoll = $showtrade = $showreward = $showactivity = $showdebate = $showvideo = 0;
if($forum['allowpostspecial']) {
$showpoll = $forum['allowpostspecial'] & 1;
$showtrade = $forum['allowpostspecial'] & 2;
$showreward = isset($extcredits[$creditstransextra[2]]) && ($forum['allowpostspecial'] & 4);
$showactivity = $forum['allowpostspecial'] & 8;
$showdebate = $forum['allowpostspecial'] & 16;
$showvideo = ($forum['allowpostspecial'] & 32) && $videoopen;
}
if($allowpost) {
$allowpostpoll = $allowpostpoll && $showpoll;
$allowposttrade = $allowposttrade && $showtrade;
$allowpostreward = $allowpostreward && $showreward;
$allowpostactivity = $allowpostactivity && $showactivity;
$allowpostdebate = $allowpostdebate && $showdebate;
$allowpostvideo = $allowpostvideo && $showvideo;
}
if($forumjump) {
$forummenu = forumselect(FALSE, 1);
}
include template('forumdisplay');
function arrayslice($array, $offset, $length) {
if(empty($array) || !is_array($array)) return array();
if(PHP_VERSION >= '5.0.2') {
return array_slice($array, $offset, $length, TRUE);
} else {
$array = array_chunk($array, $length, TRUE);
return $array[$offset / $length];
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -