📄 viewthread.php
字号:
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: viewthread.php 13764 2008-05-19 03:14:01Z heyond $
*/
if(!defined('CURSCRIPT')) {
define('CURSCRIPT', 'viewthread');
}
define('SQL_ADD_THREAD', ' t.dateline, t.special, t.lastpost AS lastthreadpost, ');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/forum.func.php';
$page = max($page, 1);
if($cachethreadlife && $forum['threadcaches'] && !$discuz_uid && $page == 1 && !$forum['special']) {
viewthread_loadcache();
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$discuz_action = 3;
$thread = $db->fetch_first("SELECT * FROM {$tablepre}threads t WHERE tid='$tid' AND displayorder>='0'");
if(!$thread) {
showmessage('thread_nonexistence');
}
$oldtopics = isset($_DCOOKIE['oldtopics']) ? $_DCOOKIE['oldtopics'] : 'D';
if(strpos($oldtopics, 'D'.$tid.'D') === FALSE) {
$oldtopics = 'D'.$tid.$oldtopics;
if(strlen($oldtopics) > 3072) {
$oldtopics = preg_replace("((D\d+)+D).*$", "\\1", substr($oldtopics, 0, 3072));
}
dsetcookie('oldtopics', $oldtopics, 3600);
}
if($lastvisit < $thread['lastpost'] && (!isset($_DCOOKIE['fid'.$fid]) || $thread['lastpost'] > $_DCOOKIE['fid'.$fid])) {
dsetcookie('fid'.$fid, $thread['lastpost'], 3600);
}
$thisgid = 0;
$thread['subjectenc'] = rawurlencode($thread['subject']);
$fromuid = $creditspolicy['promotion_visit'] && $discuz_uid ? '&fromuid='.$discuz_uid : '';
$navigation = ' » <a href="forumdisplay.php?fid='.$fid.($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '').'">'.$forum['name'].'</a> » '.$thread['subject'];
if($thread['digest'] == '-2') {
$campaign = $db->fetch_first("SELECT id, type, status, url, autoupdate, lastupdated FROM {$tablepre}campaigns WHERE tid='$tid'");
if(!$campaign || $campaign['status'] != 2) {
showmessage('thread_nonexistence');
}
$insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'");
$insenz = $insenz ? unserialize($insenz) : array();
if(empty($insenz['authkey'])) {
showmessage('thread_nonexistence');
}
require_once DISCUZ_ROOT.'./include/insenz.func.php';
$member = $db->fetch_first("SELECT regdate FROM {$tablepre}members WHERE uid='$discuz_uid'");
$iframeurl = $campaign[url]."siteid=$insenz[siteid]&cid=$campaign[id]&s=".urlencode(insenz_authcode("sitename=$bbname&siteurl=$boardurl&username=$discuz_userss&uid=$discuz_uid&email=$email&grouptitle=$grouptitle®date=$member[regdate]&ppp=$ppp&tid=$tid", 'ENCODE', $insenz['authkey'])).'&'.$_SERVER['QUERY_STRING'];
$update = $campaign['autoupdate'] && ($timestamp - $campaign['lastupdated']) < 600 ? FALSE : TRUE;
include template('viewthread_iframe');
exit;
}
$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);
if($forum['type'] == 'sub') {
$fup = $db->fetch_first("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$navigation = '» <a href="forumdisplay.php?fid='.$fup['fid'].'">'.$fup['name'].'</a> '.$navigation;
$navtitle = $navtitle.' - '.strip_tags($fup['name']);
}
$navtitle .= ' - ';
$forum['typemodels'] = $forum['typemodels'] ? unserialize($forum['typemodels']) : array();
$threadtype = isset($forum['threadtypes']['types'][$thread['typeid']]) ? 1 : 0;
$typetemplate = $tagscript = '';
$optiondata = $optionlist = array();
if($thread['typeid'] && $threadtype) {
if($forum['threadtypes']['special'][$thread['typeid']]) {
if(@include_once DISCUZ_ROOT.'./forumdata/cache/threadtype_'.$thread['typeid'].'.php') {
$query = $db->query("SELECT optionid, value FROM {$tablepre}typeoptionvars WHERE tid='$tid'");
while($option = $db->fetch_array($query)) {
$optiondata[$option['optionid']] = $option['value'];
}
foreach($_DTYPE as $optionid => $option) {
$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
if($_DTYPE[$optionid]['type'] == 'checkbox') {
$optionlist[$option['identifier']]['value'] = '';
foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].' ';
}
} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
} elseif($_DTYPE[$optionid]['type'] == 'image') {
$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" $maxwidth $maxheight border=\"0\"></a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'url') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
} else {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
}
}
$typetemplate = $_DTYPETEMPLATE ? preg_replace(array("/\[(.+?)value\]/ies", "/{(.+?)}/ies"), array("showoption('\\1', 'value')", "showoption('\\1', 'title')"), $_DTYPETEMPLATE) : '';
}
}
$thread['subject'] = ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">['.$forum['threadtypes']['types'][$thread['typeid']].']</a>' : '['.$forum['threadtypes']['types'][$thread['typeid']].']').' '.$thread['subject'];
}
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
$navtitle = '';
showmessage('forum_nopermission', NULL, 'NOPERM');
}
} elseif($forum['allowview'] == -1) {
$navtitle = '';
showmessage('forum_access_view_disallow');
}
if($forum['formulaperm']) {
formulaperm($forum['formulaperm']);
}
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
dheader("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
}
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
$threadpay = FALSE;
if($thread['price'] > 0 && $thread['special'] == 0) {
if($maxchargespan && $timestamp - $thread['dateline'] >= $maxchargespan * 3600) {
$db->query("UPDATE {$tablepre}threads SET price='0' WHERE tid='$tid'");
$thread['price'] = 0;
} else {
if(!$discuz_uid) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
$exemptvalue = $forum['ismoderator'] ? 128 : 16;
if(!($exempt & $exemptvalue) && $thread['authorid'] != $discuz_uid) {
$query = $db->query("SELECT tid FROM {$tablepre}paymentlog WHERE tid='$tid' AND uid='$discuz_uid'");
if(!$db->num_rows($query)) {
require_once DISCUZ_ROOT.'./include/threadpay.inc.php';
$threadpay = TRUE;
}
}
}
}
$forum['modrecommend'] = $forum['modrecommend'] ? unserialize($forum['modrecommend']) : array();
$raterange = $modratelimit && $adminid == 3 && !$forum['ismoderator'] ? array() : $raterange;
$extra = rawurlencode($extra);
$allowgetattach = !empty($forum['allowgetattach']) || ($allowgetattach && !$forum['getattachperm']) || forumperm($forum['getattachperm']);
$postlist = $attachtags = $attachlist = array();
$attachpids = $announcepm = 0;
$smile = isset($_DCOOKIE['smile']) ? explode('D', $_DCOOKIE['smile']) : array();
$stypeid = intval(!empty($stypeid) ? $stypeid : ($smile[3] != $styleid ? STYPEID : $smile[0]));
$stypeid = isset($_DCACHE['smileytypes'][$stypeid]) ? $stypeid : (isset($_DCACHE['smileytypes'][STYPEID]) ? STYPEID : key($_DCACHE['smileytypes']));
$smilies = $_DCACHE['smilies_display'][$stypeid];
$scrollt = intval(!empty($scrollt) ? $scrollt : $smile[2]);
$sm_page = (!isset($_GET['stypeid']) || $_GET['stypeid'] == $smile[0] ? $smile[1] : 1);
$spp = $smcols * $smrows;
$sm_multipage = multi(count($smilies), $spp, $sm_page, 'post.php?action=smilies&stypeid='.$stypeid.'&inajax=1&scrollt='.$scrollt, 0, 10, FALSE, TRUE);
$smilies = arrayslice($smilies, $spp * ($sm_page - 1), $spp);
dsetcookie('smile', $stypeid.'D'.$sm_page.'D'.$scrollt.'D'.$styleid, 86400 * 365);
if(empty($action) && $tid) {
$thisgid = $forum['type'] == 'forum' ? $forum['fup'] : $_DCACHE['forums'][$forum['fup']]['fup'];
$lastmod = $thread['moderated'] ? viewthread_lastmod() : array();
$showsettings = str_pad(decbin($showsettings), 3, '0', STR_PAD_LEFT);
$customshow = $discuz_uid ? str_pad(base_convert($customshow, 10, 3), 3, '0', STR_PAD_LEFT) : '222';
$showsignatures = $customshow{0} == 2 ? $showsettings{0} : $customshow{0};
$showavatars = $customshow{1} == 2 ? $showsettings{1} : $customshow{1};
$showimages = $customshow{2} == 2 ? $showsettings{2} : $customshow{2};
$highlightstatus = isset($highlight) && str_replace('+', '', $highlight) ? 1 : 0;
$usesigcheck = $discuz_uid && $sigstatus ? 'checked="checked"' : '';
$allowpostreply = ($forum['allowreply'] != -1) && ((!$thread['closed'] && !checkautoclose()) || $forum['ismoderator']) && ((!$forum['replyperm'] && $allowreply) || ($forum['replyperm'] && forumperm($forum['replyperm'])) || $forum['allowreply']);
$allowpost = $forum['allowpost'] != -1 && ((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])) || $forum['allowpost']);
$addfeedcheck = $customaddfeed & 4 ? 'checked="checked"': '';
if($allowpost) {
$allowpostpoll = $allowpostpoll && ($forum['allowpostspecial'] & 1);
$allowposttrade = $allowposttrade && ($forum['allowpostspecial'] & 2);
$allowpostreward = $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
$allowpostactivity = $allowpostactivity && ($forum['allowpostspecial'] & 8);
$allowpostdebate = $allowpostdebate && ($forum['allowpostspecial'] & 16);
$allowpostvideo = $allowpostvideo && ($forum['allowpostspecial'] & 32) && $videoopen;
} else {
$allowpostpoll = $allowposttrade = $allowpostreward = $allowpostactivity = $allowpostdebate = $allowpostvideo = FALSE;
}
$visitedforums = $visitedforums ? visitedforums() : '';
$forumselect = $forummenu = '';
$forumselect = $forummenu = '';
if($forumjump) {
if($jsmenu[1]) {
$forummenu = forumselect(FALSE, 1);
} else {
$forumselect = forumselect(FALSE, 1);
}
}
$relatedthreadlist = array();
$relatedthreadupdate = $tagupdate = FALSE;
$relatedkeywords = $tradekeywords = $metakeywords = $firstpid = '';
$randnum = $qihoo['relate']['webnum'] ? rand(1, 1000) : '';
$statsdata = !empty($statsdata) ? dhtmlspecialchars($statsdata) : '';
if($qihoo['relate']['bbsnum'] || $insenz['topicrelatedad'] || ($insenz['traderelatedad'] && $thread['special'] == 2)) {
$site = site();
$query = $db->query("SELECT type, expiration, keywords, relatedthreads FROM {$tablepre}relatedthreads WHERE tid='$tid'");
if($db->num_rows($query)) {
while($related = $db->fetch_array($query)) {
if($related['expiration'] <= $timestamp) {
$relatedthreadupdate = TRUE;
$qihoo_up = 1;
} elseif($qihoo['relate']['bbsnum'] && $related['type'] == 'general') {
$relatedthreadlist = unserialize($related['relatedthreads']);
if($related['keywords']) {
$keywords = str_replace("\t", ' ', $related['keywords']);
$searchkeywords = rawurlencode($keywords);
$statskeywords = urlencode($keywords);
$statsurl = urlencode($boardurl.'viewthread.php?tid='.$tid);
foreach(explode("\t", $related['keywords']) as $keyword) {
$relatedkeywords .= $keyword ? '<a href="http://www.qihoo.com/wenda.php?kw='.rawurlencode($keyword).'&do=search&noq=q" target="_blank">'.$keyword.'</a> ' : '';
$metakeywords .= $keyword ? $keyword.',' : '';
}
}
} elseif($related['type'] == 'trade') {
$tradekeywords = explode("\t", $related['keywords']);
$tradekeywords = $tradekeywords[array_rand($tradekeywords)];
}
}
} else {
$relatedthreadupdate = TRUE;
$qihoo_up = 0;
}
$relatedthreadupdate && $verifykey = md5($authkey.$tid.$thread['subjectenc'].$charset.$site);
}
$relatedthreads = array();
if(!empty($relatedthreadlist)) {
if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'relatedthreads') === FALSE) {
$relatedthreads['img'] = 'collapsed_no.gif';
$relatedthreads['style'] = '';
} else {
$relatedthreads['img'] = 'collapsed_yes.gif';
$relatedthreads['style'] = 'display: none';
}
}
$threadtag = array();
if($tagstatus) {
$query = $db->query("SELECT tagname FROM {$tablepre}threadtags WHERE tid='$tid'");
$thread['tags'] = '';
while($tags = $db->fetch_array($query)) {
$metakeywords .= $tags['tagname'].',';
$thread['tags'] .= '<a href="tag.php?name='.rawurlencode($tags['tagname']).'" target="_blank">'.$tags['tagname'].'</a> ';
}
if($tagstatus == 2 && !$thread['tags'] || $relatedthreadupdate) {
$tagupdate = TRUE;
}
$relatedthreadupdate && $thread['tagsenc'] = rawurlencode(strip_tags($thread['tags']));
}
viewthread_updateviews();
@extract($_DCACHE['custominfo']);
$infosidestatus['posts'] = $infosidestatus[1] && isset($infosidestatus['f'.$fid]['posts']) ? $infosidestatus['f'.$fid]['posts'] : $infosidestatus['posts'];
$infoside = $infosidestatus[1] && $thread['replies'] > $infosidestatus['posts'];
if($thread['special'] > 0) {
$thread['starttime'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
$thread['remaintime'] = '';
if(!empty($do) && $do == 'viewspecialpost') {
include_once DISCUZ_ROOT.'./include/viewthread_special.inc.php';
} else {
switch($thread['special']) {
case 1: include_once DISCUZ_ROOT.'./include/viewthread_poll.inc.php'; break;
case 2: include_once DISCUZ_ROOT.'./include/viewthread_trade.inc.php'; break;
case 3: include_once DISCUZ_ROOT.'./include/viewthread_reward.inc.php'; break;
case 4: include_once DISCUZ_ROOT.'./include/viewthread_activity.inc.php'; break;
case 5: include_once DISCUZ_ROOT.'./include/viewthread_debate.inc.php'; break;
case 6: include_once DISCUZ_ROOT.'./include/viewthread_video.inc.php'; break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -