測試過了 沒有問題
我用你的文件一樣正常顯示
你看看是不是其他地方沒弄好吧
- <?php
- /*
- [DISCUZ!] viewthread.php - view thread posts
- This is NOT a freeware, use is subject to license terms
- Version: 4.0.0
- Web: [url]http://www.comsenz.com[/url]
- Copyright: 2001-2005 Comsenz Technology Ltd.
- Last Modified: 2005-3-6 15:38
- */
- define('CURSCRIPT', 'viewthread');
- require_once './include/common.inc.php';
- require_once DISCUZ_ROOT.'./include/forum.func.php';
- require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
- //悬赏提问帖 start
- @require_once DISCUZ_ROOT.'./forumdata/cache/cache_forumdisplay.php';
- //悬赏提问帖 end
- $discuz_action = 3;
- $query = $db->query("SELECT t.*, tm.uid AS moduid, tm.username AS modusername, tm.dateline AS moddateline, tm.action AS modaction
- FROM {$tablepre}threads t LEFT JOIN {$tablepre}threadsmod tm ON t.moderated=1 AND tm.tid=t.tid
- WHERE t.tid='$tid' AND t.displayorder>='0'");
- if(!$thread = $db->fetch_array($query)) {
- showmessage('thread_nonexistence');
- } elseif($thread['moderated']) {
- if($thread['modaction']) {
- include language('modactions');
- $thread['moddateline'] = gmdate("$dateformat $timeformat", $thread['moddateline'] + $timeoffset * 3600);
- $thread['modaction'] = $modactioncode[$thread['modaction']];
- } else {
- $db->query("UPDATE {$tablepre}threads SET moderated='0' WHERE tid='$tid'", 'UNBUFFERED');
- }
- }
- $codecount = 0;
- $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['f'.$fid]) || $thread['lastpost'] > $_DCOOKIE['f'.$fid])) {
- dsetcookie('fid'.$fid, $thread['lastpost'], 3600);
- }
- $navigation = "» <a href="forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."">$forum[name]</a> » $thread[subject]";
- $navtitle = $thread['subject'].' - '.strip_tags($forum['name']).' - ';
- if($forum['type'] == 'sub') {
- $query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
- $fup = $db->fetch_array($query);
- $navigation = "» <a href="forumdisplay.php?fid=$fup[fid]">$fup[name]</a> $navigation";
- $navtitle = $navtitle.' - '.strip_tags($fup['name']);
- }
- if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {
- $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'])) {
- showmessage('forum_nopermission', NULL, 'NOPERM');
- }
- }
- if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
- showmessage('thread_nopermission', NULL, 'NOPERM');
- }
- if($thread['price'] > 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');
- } elseif(!$forum['ismoderator'] && $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';
- exit();
- }
- }
- }
- }
- if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
- header("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
- exit();
- }
- $raterange = $modratelimit && $adminid == 3 && !$forum['ismoderator'] ? array() : $raterange;
- $extra = rawurlencode($extra);
- $allowgetattach = !empty($forum['allowgetattach']) || ($allowgetattach && !$forum['getattachperm']) || forumperm($forum['getattachperm']);
- //get trade thread status (pos. -1)
- $allowposttrade = substr(sprintf('%02b', $forum['allowtrade']), -1, 1);
- //get pay to author status (pos. -2)
- $allowpaytoauthor = substr(sprintf('%02b', $forum['allowtrade']), -2, 1);
- if(empty($action) && $tid) {
- if($discuz_uid && $newpm) {
- require_once DISCUZ_ROOT.'./include/pmprompt.inc.php';
- }
- $highlightstatus = isset($highlight) && str_replace('+', '', $highlight) ? 1 : 0;
- $maxsigrows = $maxsigrows ? 'style="height: '.$maxsigrows.'em"' : '';
- $page = empty($page) || !ispage($page) ? 1 : $page;
- $start_limit = $numpost = ($page - 1) * $ppp;
- if($start_limit > $thread['replies']) {
- $start_limit = $numpost = 0;
- $page = 1;
- }
- $multipage = multi($thread['replies'] + 1, $ppp, $page, "viewthread.php?tid=$tid&extra=$extra".(isset($highlight) ? "&highlight=".rawurlencode($highlight) : ''));
- $polloptions = array();
- if($thread['poll']) {
- $query = $db->query("SELECT pollopts FROM {$tablepre}polls WHERE tid='$tid'");
- if(is_array($pollopts = unserialize($db->result($query, 0)))) {
- foreach($pollopts['options'] as $option) {
- $polloptions[] = array
- (
- 'option' => dhtmlspecialchars(stripslashes($option[0])),
- 'votes' => $option[1],
- 'width' => @round($option[1] * 300 / $pollopts['max']) + 2,
- 'percent' => @sprintf ("%01.2f", $option[1] * 100 / $pollopts['total'])
- );
- }
- $allowvote = $allowvote && (empty($thread['closed']) || $alloweditpoll) && !in_array(($discuz_uid ? $discuz_user : $onlineip), $pollopts['voters']);
- $optiontype = $pollopts['multiple'] ? 'checkbox' : 'radio';
- } else {
- $db->query("UPDATE {$tablepre}threads SET poll='0' WHERE tid='$tid'", 'UNBUFFERED');
- }
- }
- $extcredits_thread = array();
- foreach($extcredits as $key => $value) {
- if($value['showinthread']) {
- $extcredits_thread['extcredits'.$key] = array('title' => $value['title'], 'unit' => $value['unit']);
- }
- }
- $fieldsadd = '';
- if(is_array($_DCACHE['fields_thread'])) {
- foreach($_DCACHE['fields_thread'] as $field) {
- $fieldsadd .= ', mf.field_'.$field['fieldid'];
- }
- }
- $postlist = $attachtags = array();
- $newpostanchor = $postcount = $attachpids = 0;
- $query = $db->query("SELECT p.*, m.uid, m.username, m.groupid, m.regdate, m.lastactivity, m.posts, m.digestposts, m.oltime, m.pageviews, m.credits, m.extcredits1, m.extcredits2, m.extcredits3, m.extcredits4, m.extcredits5, m.extcredits6, m.extcredits7, m.extcredits8, m.email, m.gender, m.showemail,b.mypetname,b.mypet,b.mypetname,b.mypetlevel,b.mypetdead,b.openpk,b.mypethp,b.mypetsp,b.mypetexp,mypetsex,b.mypetsx, m.invisible, m.avatarshowid, mf.nickname, mf.site, mf.icq, mf.qq, mf.yahoo, mf.msn, mf.taobao, mf.alipay, mf.location, mf.medals, mf.avatar, mf.avatarwidth, mf.avatarheight, mf.sightml AS signature, mf.customstatus $fieldsadd FROM {$tablepre}posts p LEFT JOIN {$tablepre}members m ON m.uid=p.authorid LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid LEFT JOIN $tablepre"."mypetdata b ON b.username=p.author WHERE p.tid='$tid' AND p.invisible='0' ORDER BY dateline LIMIT $start_limit, $ppp");
- while($post = $db->fetch_array($query)) {
- //任务精灵 2005-12-14
- if($post['missionid']<>'') {
- $post['hack_mission']=explode('|', $post['missionid']);
- if($post['hack_mission'][0]<>$discuz_uid) $post['missionid']='';
- }
- //任务精灵 end
- if(!$newpostanchor && $post['dateline'] > $lastvisit) {
- $post['newpostanchor'] = '<a name="newpost"></a>';
- $newpostanchor = 1;
- } else {
- $post['newpostanchor'] = '';
- }
- $post['lastpostanchor'] = $numpost == $thread['replies'] ? '<a name="lastpost"></a>' : '';
- $post['number'] = ++$numpost;
- $post['count'] = $postcount++;
- $post['thisbg'] = $thisbg = isset($thisbg) && $thisbg == 'altbg1' ? 'altbg2' : 'altbg1';
- $post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
- $post[petpic]=$post[mypetname];
- $petnowexp=$post[mypetexp];
- $post[mypetlevel] = floor(sqrt(sqrt($petnowexp)));
- $petlevel = $post[mypetlevel] ;
- $post[picdisplay] = intval($post[mypetlevel]/10);
- if ($post[picdisplay]>10){$post[picdisplay]=11;}
- $petnextlvexp = pow($petlevel+1,4);
- if($post['username']) {
- $post['groupid'] = getgroupid($post['authorid'], $_DCACHE['usergroups'][$post['groupid']], $post);
- $post['readaccess'] = $_DCACHE['usergroups'][$post['groupid']]['readaccess'];
- if($userstatusby == 1 || $_DCACHE['usergroups'][$post['groupid']]['byrank'] === 0) {
- $post['authortitle'] = $_DCACHE['usergroups'][$post['groupid']]['grouptitle'];
- $post['stars'] = $_DCACHE['usergroups'][$post['groupid']]['stars'];
- } elseif($userstatusby == 2) {
- foreach($_DCACHE['ranks'] as $rank) {
- if($post['posts'] > $rank['postshigher']) {
- $post['authortitle'] = $rank['ranktitle'];
- $post['stars'] = $rank['stars'];
- break;
- }
- }
- }
- if($allowpaytoauthor) {
- if(!$post['alipay'] && $post['email'] && $post['showemail']) {
- $post['alipay'] = $post['email'];
- }
- } else {
- $post['alipay'] = '';
- }
- $post['authoras'] = addslashes($post['author']);
- $post['regdate'] = gmdate($dateformat, $post['regdate'] + $timeoffset * 3600);
- //--------------背单词语音版--------->
- require_once "./wordlib/libconfig.php";
- require_once "./wordcfg.php";
- $n=count($listkind);
- $opwo="<select onchange=Fword(this.options[this.selectedIndex].value)>";
- $opwo.="<option value=''>选择词库级别</option>";
- foreach($listkind as $key=>$value)
- {
- $opwo.="<option value=$key>$value</option>";
- }
- $opwo.="</select>";
- $woselect=$opwo;
- $post['words']=getword($wordkind,$wordcuttype,$words);
- //--------------背单词语音版--------->
- $post['allowuseblog'] = $_DCACHE['usergroups'][$post['groupid']]['allowuseblog'];
- if($post['medals']) {
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
- foreach($post['medals'] = explode("\t", $post['medals']) as $key => $medalid) {
- if(isset($_DCACHE['medals'][$medalid])) {
- $post['medals'][$key] = $_DCACHE['medals'][$medalid];
- } else {
- unset($post['medals'][$key]);
- }
- }
-
- }
- $post['avatarshow'] = $avatarshowstatus && ($post['avatarshowid'] || $avatarshowdefault) ? avatarshow($post['avatarshowid'], $post['gender']) : '';
- if($_DCACHE['usergroups'][$post['groupid']]['groupavatar']) {
- $post['avatar'] = '<img src="'.$_DCACHE['usergroups'][$post['groupid']]['groupavatar'].'" border="0">';
- } elseif($avatarshowstatus != 2 && $_DCACHE['usergroups'][$post['groupid']]['allowavatar'] && $post['avatar']) {
- $post['avatar'] = '<img src="'.$post['avatar'].'" width="'.$post['avatarwidth'].'" height="'.$post['avatarheight'].'" border="0">';
- } else {
- $post['avatar'] = '<a href="memcp.php?action=profile"><img
- src="images/common/nopic.gif" alt="默认头像" border="0"></a>';
- }
- } else {
- if(!$post['authorid']) {
- $post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')).'.x';
- }
- }
- $post['attachments'] = array();
- if($post['attachment'] && $allowgetattach) {
- $attachpids .= ",$post[pid]";
- $post['attachment'] = 0;
- if(preg_match("/\[attach\](\d+)\[\/attach\]/i", $post['message'])) {
- $attachtags[] = $post['pid'];
- }
- }
- $forum['allowbbcode'] = $forum['allowbbcode'] ? ($_DCACHE['usergroups'][$post['groupid']]['allowcusbbcode'] ? 2 : 1) : 0;
- $post['ratings'] = karmaimg($post['rate'], $post['ratetimes']);
- $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0));
- $post['signature'] = $post['usesig'] ? $post['signature'] : '';
- //帖子显示评分记录开始
- if($post['rate']) {
- $queryr = $db->query("SELECT * FROM {$tablepre}ratelog WHERE pid='$post[pid]' ORDER BY dateline");
- if($db->num_rows($queryr)) {
- if($post['tid'] == $thread['tid']) {
- $post['pft'] = array();
- while($log = $db->fetch_array($queryr)) {
- $log['dateline'] = gmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
- $log['score'] = $log['score'] > 0 ? '+'.$log['score'] : $log['score'];
- $log['reason'] = dhtmlspecialchars($log['reason']);
- $post['pft'][] = $log;
- }
- }
- }
- }
- //帖子显示评分记录结束
- $postlist[$post['pid']] = $post;
- }
- if($attachpids) {
- //图文混排,删除了段内容,替换为下面内容
- $query = $db->query("SELECT aid, pid, displayorder, dateline, readperm, filename, description, filetype, attachment, filesize, downloads
- FROM {$tablepre}attachments WHERE pid IN ($attachpids) ORDER BY displayorder");
- //图文混排结束
- if($db->num_rows($query)) {
- require_once DISCUZ_ROOT.'./include/attachment.func.php';
- while($attach = $db->fetch_array($query)) {
- $extension = strtolower(fileext($attach['filename']));
- $extension == 'torrent' ? $attach['bt'] = 1 : $attach['bt'] = 0;
- $attach['dateline'] = gmdate("$dateformat $timeformat", $attach['dateline'] + $timeoffset * 3600);
- $attach['attachicon'] = attachtype($extension."\t".$attach['filetype']);
- $attach['attachsize'] = sizecount($attach['filesize']);
- //图文混排删除上面内容,加入下面
- $isimage = in_array($extension, array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp'));
- require_once DISCUZ_ROOT.'./include/att_typeid.func.php';
- $attach['$type'] = attachtypeid($attach['filetype']);
- $attach['$idname'] = random(2);
- if ( $isimage && $attachimgpost && !$attach['permid'] ){
- $postlist[$attach['pid']]['attachimg'][$attach[aid]] = $attach;
- }else{
- $postlist[$attach['pid']]['attachments'][$attach[aid]] = $attach;
- }
-
- if ( $attach['permid'] && $isimage && $attachimgpost && !isset($postlist[$attach['pid']]['attachimg'][$attach[aid]]) && ($disablepermscheck || checkperms( $attach['permid'],$attach['readperm'],'attach')==1)){
- $postlist[$attach['pid']]['attachimg'][$attach[aid]] = $attach;
- }
-
- if (isset($postlist[$attach['pid']]['attachimg'][$attach[aid]]) && $forum['allowbbcode'] && $forum['allowimgcode'] && !$post['bbcodeoff']){
- $posmessage = str_replace( "images/common/attachnoperm.gif?{$attach[displayorder]}","$attachurl/$attach[attachment]",$postlist[$attach['pid']]['message']);
-
- if($postlist[$attach['pid']]['message']!=$posmessage){
- $postlist[$attach['pid']]['message']=$posmessage;
- unset($posmessage,$postlist[$attach['pid']]['attachimg'][$attach[aid]]);
- }else{
- unset($posmessage,$postlist[$attach['pid']]['attachments'][$attach[aid]]);
- }
- }//结束
- }
- foreach($attachtags as $pid) {
- $postlist[$pid]['message'] = preg_replace("/\[attach\](\d+)\[\/attach\]/ie", "attachtag($pid, \\1)", $postlist[$pid]['message']);
- }
- } else {
- $db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE pid IN ($attachpids)", 'UNBUFFERED');
- }
- }
- if(empty($postlist)) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- $visitedforums = $visitedforums ? visitedforums() : '';
- $forumselect = $forumjump ? forumselect() : '';
- $usesigcheck = $discuz_uid && $sigstatus ? 'checked' : '';
- $allowpostreply = ((!$thread['closed'] && !checkautoclose()) || $forum['ismoderator']) && ((!$forum['replyperm'] && $allowreply) || ($forum['replyperm'] && forumperm($forum['replyperm'])) || $forum['allowreply']);
- $allowpost = (!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])) || $forum['allowpost'];
- if($delayviewcount) {
- $logfile = DISCUZ_ROOT.'./forumdata/viewcount.log';
- if(substr($timestamp, -2) == '00') {
- require_once DISCUZ_ROOT.'./include/misc.func.php';
- updateviews();
- }
- if(@$fp = fopen($logfile, 'a')) {
- fwrite($fp, "$tid\n");
- fclose($fp);
- } elseif($adminid == 1) {
- showmessage('view_log_invalid');
- }
- } else {
- $db->query("UPDATE {$tablepre}threads SET views=views+1 WHERE tid='$tid'", 'UNBUFFERED');
- }
- include template('viewthread');
- } elseif($action == 'printable' && $tid) {
- require_once DISCUZ_ROOT.'./include/printable.inc.php';
- }
- ?>
复制代码 |