| 1 | <?php |
|---|
| 2 | // $Id: viewtopic.php,v 1.6 2006/05/01 02:37:28 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | // Author: Kazumi Ono (AKA onokazu) // |
|---|
| 28 | // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|---|
| 29 | // Project: The XOOPS Project // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | |
|---|
| 32 | include 'header.php'; |
|---|
| 33 | $forum = isset($_GET['forum']) ? intval($_GET['forum']) : 0; |
|---|
| 34 | $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0; |
|---|
| 35 | if ( empty($forum) ) { |
|---|
| 36 | redirect_header(XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/index.php",2,_MD_ERRORFORUM); |
|---|
| 37 | exit(); |
|---|
| 38 | } elseif ( empty($topic_id) ) { |
|---|
| 39 | redirect_header('viewforum.php?forum='.$forum,2,_MD_ERRORTOPIC); |
|---|
| 40 | exit(); |
|---|
| 41 | } |
|---|
| 42 | $topic_time = (isset($_GET['topic_time'])) ? intval($_GET['topic_time']) : 0; |
|---|
| 43 | $post_id = !empty($_GET['post_id']) ? intval($_GET['post_id']) : 0; |
|---|
| 44 | |
|---|
| 45 | //use users preferences |
|---|
| 46 | if (is_object($xoopsUser)) { |
|---|
| 47 | $viewmode = $xoopsUser->getVar('umode'); |
|---|
| 48 | $order = ($xoopsUser->getVar('uorder') == 1) ? 'DESC' : 'ASC'; |
|---|
| 49 | } else { |
|---|
| 50 | $viewmode = 'flat'; |
|---|
| 51 | $order = 'ASC'; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | // newbb does not have nested mode |
|---|
| 55 | if ($viewmode == 'nest') { |
|---|
| 56 | $viewmode = 'thread'; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | // override mode/order if any requested |
|---|
| 60 | if (isset($_GET['viewmode']) && ($_GET['viewmode'] == 'flat' || $_GET['viewmode'] == 'thread')) { |
|---|
| 61 | $viewmode = $_GET['viewmode']; |
|---|
| 62 | } |
|---|
| 63 | if (isset($_GET['order']) && ($_GET['order'] == 'ASC' || $_GET['order'] == 'DESC')) { |
|---|
| 64 | $order = $_GET['order']; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | if ($viewmode != 'flat') { |
|---|
| 68 | $xoopsOption['template_main'] = 'newbb_viewtopic_thread.html'; |
|---|
| 69 | } else { |
|---|
| 70 | $xoopsOption['template_main'] = 'newbb_viewtopic_flat.html'; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | include XOOPS_ROOT_PATH.'/header.php'; |
|---|
| 74 | include_once 'class/class.forumposts.php'; |
|---|
| 75 | |
|---|
| 76 | if ( isset($_GET['move']) && 'next' == $_GET['move'] ) { |
|---|
| 77 | $sql = 'SELECT p.response, t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_time > '.$topic_time.' AND t.forum_id = '.$forum.' ORDER BY t.topic_time ASC LIMIT 1'; |
|---|
| 78 | } elseif ( isset($_GET['move']) && 'prev' == $_GET['move']) { |
|---|
| 79 | $sql = 'SELECT p.response, t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_time < '.$topic_time.' AND t.forum_id = '.$forum.' ORDER BY t.topic_time DESC LIMIT 1'; |
|---|
| 80 | } else { |
|---|
| 81 | $sql = 'SELECT p.response, t.topic_id, p.post_id, p.forum_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = t.topic_last_post_id LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_id = '.$topic_id.' AND t.forum_id = '.$forum; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | if ( !$result = $xoopsDB->query($sql) ) { |
|---|
| 85 | redirect_header('viewforum.php?forum='.$forum,2,_MD_ERROROCCURED); |
|---|
| 86 | exit(); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | if ( !$forumdata = $xoopsDB->fetchArray($result) ) { |
|---|
| 90 | redirect_header('viewforum.php?forum='.$forum,2,_MD_FORUMNOEXIST); |
|---|
| 91 | exit(); |
|---|
| 92 | } |
|---|
| 93 | $xoopsTpl->assign('topic_id', $forumdata['topic_id']); |
|---|
| 94 | $topic_id = $forumdata['topic_id']; |
|---|
| 95 | $xoopsTpl->assign('forum_id', $forumdata['forum_id']); |
|---|
| 96 | $forum = $forumdata['forum_id']; |
|---|
| 97 | $can_post = 0; |
|---|
| 98 | $show_reg = 0; |
|---|
| 99 | if ( $forumdata['forum_type'] == 1 ) { |
|---|
| 100 | // this is a private forum. |
|---|
| 101 | $accesserror = 0; |
|---|
| 102 | if ( $xoopsUser ) { |
|---|
| 103 | if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|---|
| 104 | if ( !check_priv_forum_auth($xoopsUser->getVar('uid'), $forum, false) ) { |
|---|
| 105 | $accesserror = 1; |
|---|
| 106 | } |
|---|
| 107 | } else { |
|---|
| 108 | $isadminormod = 1; |
|---|
| 109 | } |
|---|
| 110 | } else { |
|---|
| 111 | $accesserror = 1; |
|---|
| 112 | } |
|---|
| 113 | if ( $accesserror == 1 ) { |
|---|
| 114 | redirect_header(XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/index.php",2,_MD_NORIGHTTOACCESS); |
|---|
| 115 | exit(); |
|---|
| 116 | } |
|---|
| 117 | $can_post = 1; |
|---|
| 118 | $show_reg = 1; |
|---|
| 119 | } else { |
|---|
| 120 | // this is not a priv forum |
|---|
| 121 | if ( $forumdata['forum_access'] == 1 ) { |
|---|
| 122 | // this is a reg user only forum |
|---|
| 123 | if ( $xoopsUser ) { |
|---|
| 124 | $can_post = 1; |
|---|
| 125 | } else { |
|---|
| 126 | $show_reg = 1; |
|---|
| 127 | } |
|---|
| 128 | } elseif ( $forumdata['forum_access'] == 2 ) { |
|---|
| 129 | // this is an open forum |
|---|
| 130 | $can_post = 1; |
|---|
| 131 | } else { |
|---|
| 132 | // this is an admin/moderator only forum |
|---|
| 133 | if ( $xoopsUser ) { |
|---|
| 134 | if ( $xoopsUser->isAdmin($xoopsModule->mid()) || is_moderator($forum, $xoopsUser->getVar('uid')) ) { |
|---|
| 135 | $can_post = 1; |
|---|
| 136 | $isadminormod = 1; |
|---|
| 137 | } |
|---|
| 138 | } |
|---|
| 139 | } |
|---|
| 140 | } |
|---|
| 141 | include_once 'class/class.util.php'; |
|---|
| 142 | $fix = getFixName($forum); |
|---|
| 143 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 144 | $forumdata['topic_title'] = $myts->makeTboxData4Show($forumdata['topic_title']);$forumdata['forum_name'] = $myts->makeTboxData4Show($forumdata['forum_name']); |
|---|
| 145 | $xoopsTpl->assign(array('fix'=>$fix,'topic_title' => $forumdata['topic_title'], 'forum_name' => $forumdata['forum_name'], 'topic_time' => $forumdata['topic_time'], 'lang_nexttopic' => _MD_NEXTTOPIC, 'lang_prevtopic' => _MD_PREVTOPIC)); |
|---|
| 146 | |
|---|
| 147 | // add image links to admin page if the user viewing this page is a forum admin |
|---|
| 148 | if ( $xoopsUser ) { |
|---|
| 149 | $xoopsTpl->assign('viewer_userid', $xoopsUser->getVar('uid')); |
|---|
| 150 | if ( !empty($isadminormod) || $xoopsUser->isAdmin($xoopsModule->mid()) || is_moderator( $forum, $xoopsUser->getVar('uid')) ) { |
|---|
| 151 | // yup, the user is admin |
|---|
| 152 | // the forum is locked? |
|---|
| 153 | if ( $forumdata['topic_status'] != 1 ) { |
|---|
| 154 | // nope |
|---|
| 155 | $xoopsTpl->assign('topic_lock_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=lock&topic_id='.$topic_id.'&forum='.$forum.'"><img src="'.$bbImage['locktopic'].'" alt="'._MD_LOCKTOPIC.'" /></a>'); |
|---|
| 156 | } else { |
|---|
| 157 | // yup, it is.. |
|---|
| 158 | $xoopsTpl->assign('topic_lock_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=unlock&topic_id='.$topic_id.'&forum='.$forum.'"><img src="'.$bbImage['unlocktopic'].'" alt="'._MD_UNLOCKTOPIC.'" /></a>'); |
|---|
| 159 | } |
|---|
| 160 | $xoopsTpl->assign('topic_move_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=move&topic_id='.$topic_id.'&forum='.$forum.'"><img src="'.$bbImage['movetopic'].'" alt="'._MD_MOVETOPIC.'" /></a>'); |
|---|
| 161 | $xoopsTpl->assign('topic_delete_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=del&topic_id='.$topic_id.'&forum='.$forum.'"><img src="'.$bbImage['deltopic'].'" alt="'._MD_DELETETOPIC.'" /></a>'); |
|---|
| 162 | // is the topic sticky? |
|---|
| 163 | if ( $forumdata['topic_sticky'] != 1 ) { |
|---|
| 164 | // nope, not yet.. |
|---|
| 165 | $xoopsTpl->assign('topic_sticky_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=sticky&topic_id='.$topic_id.'&forum='.$forum.'"><img src="'.$bbImage['sticky'].'" alt="'._MD_STICKYTOPIC.'" /></a>'); |
|---|
| 166 | } else { |
|---|
| 167 | // yup it is sticking.. |
|---|
| 168 | $xoopsTpl->assign('topic_sticky_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=unsticky&topic_id='.$topic_id.'&forum='.$forum.'"><img src="'.$bbImage['unsticky'].'" alt="'._MD_UNSTICKYTOPIC.'" /></a>'); |
|---|
| 169 | } |
|---|
| 170 | // need to set this also |
|---|
| 171 | $xoopsTpl->assign('viewer_is_admin', true); |
|---|
| 172 | } else { |
|---|
| 173 | // nope, the user is not a forum admin.. |
|---|
| 174 | $xoopsTpl->assign('viewer_is_admin', false); |
|---|
| 175 | } |
|---|
| 176 | } else { |
|---|
| 177 | // nope, the user is not a forum admin, not even registered |
|---|
| 178 | $xoopsTpl->assign(array('viewer_is_admin' => false, 'viewer_userid' => 0)); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | function showTree(&$arr, $current=0, $key=0, $prefix='', $foundusers=array()){ |
|---|
| 182 | global $xoopsConfig; |
|---|
| 183 | if ($key != 0) { |
|---|
| 184 | if ( 0 != $arr[$key]['obj']->uid() ) { |
|---|
| 185 | if (!isset($foundusers[$arr[$key]['obj']->uid()])) { |
|---|
| 186 | $eachposter = new XoopsUser($arr[$key]['obj']->uid()); |
|---|
| 187 | $foundusers[$arr[$key]['obj']->uid()] =& $eachposter; |
|---|
| 188 | } else { |
|---|
| 189 | $eachposter =& $foundusers[$arr[$key]['obj']->uid()]; |
|---|
| 190 | } |
|---|
| 191 | $poster_rank = $eachposter->rank(); |
|---|
| 192 | if ( $poster_rank['image'] != '' ) { |
|---|
| 193 | $poster_rank['image'] = '<img src="'.XOOPS_UPLOAD_URL.'/'.$poster_rank['image'].'" alt="" />'; |
|---|
| 194 | } |
|---|
| 195 | if ( $eachposter->isActive() ) { |
|---|
| 196 | $posterarr = array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>'); |
|---|
| 197 | } else { |
|---|
| 198 | $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous']); |
|---|
| 199 | } |
|---|
| 200 | } else { |
|---|
| 201 | $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous']); |
|---|
| 202 | } |
|---|
| 203 | $posticon = $arr[$key]['obj']->icon(); |
|---|
| 204 | if ( isset($posticon) && $posticon != '' ) { |
|---|
| 205 | $post_image = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($posticon).'" alt="" />'; |
|---|
| 206 | } else { |
|---|
| 207 | $post_image = '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />'; |
|---|
| 208 | } |
|---|
| 209 | if ($current != $key) { |
|---|
| 210 | $subject = '<a href="viewtopic.php?viewmode=thread&topic_id='.$arr[$key]['obj']->topic().'&forum='.$arr[$key]['obj']->forum().'&post_id='.$arr[$key]['obj']->postid().'#forumpost'.$arr[$key]['obj']->postid().'">'.$arr[$key]['obj']->subject().'</a>'; |
|---|
| 211 | $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $prefix))); |
|---|
| 212 | } else { |
|---|
| 213 | $subject = '<b>'.$arr[$key]['obj']->subject().'</b>'; |
|---|
| 214 | $thisprefix = substr($prefix, 0, -6)."<b>»</b>"; |
|---|
| 215 | $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $thisprefix))); |
|---|
| 216 | } |
|---|
| 217 | } |
|---|
| 218 | if ( isset($arr[$key]['replies']) && !empty($arr[$key]['replies']) ){ |
|---|
| 219 | $prefix .= " "; |
|---|
| 220 | foreach($arr[$key]['replies'] as $replykey) { |
|---|
| 221 | $current = ( $current == 0 ) ? $replykey : $current; |
|---|
| 222 | showTree($arr, $current, $replykey, $prefix, $foundusers); |
|---|
| 223 | } |
|---|
| 224 | } |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | if ($order == 'DESC') { |
|---|
| 228 | $xoopsTpl->assign(array('order_current' => 'DESC', 'order_other' => 'ASC', 'lang_order_other' => _OLDESTFIRST)); |
|---|
| 229 | } else { |
|---|
| 230 | $xoopsTpl->assign(array('order_current' => 'ASC', 'order_other' => 'DESC', 'lang_order_other' => _NEWESTFIRST)); |
|---|
| 231 | } |
|---|
| 232 | |
|---|
| 233 | // initialize the start number of select query |
|---|
| 234 | $start = !empty($_GET['start']) ? intval($_GET['start']) : 0; |
|---|
| 235 | |
|---|
| 236 | $total_posts = get_total_posts($topic_id, 'topic'); |
|---|
| 237 | if ($total_posts > 50) { |
|---|
| 238 | $viewmode ="flat"; |
|---|
| 239 | // hide link to theaded view |
|---|
| 240 | $xoopsTpl->assign('lang_threaded', "" ); |
|---|
| 241 | $xoopsTpl->assign('lang_flat', _FLAT ); |
|---|
| 242 | } else { |
|---|
| 243 | $xoopsTpl->assign(array('lang_threaded' => _THREADED, 'lang_flat' => _FLAT)); |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | if ( $can_post == 1 ) { |
|---|
| 247 | $xoopsTpl->assign(array('viewer_can_post' => true, 'forum_post_or_register' => "newtopic.php?forum=".$forum)); |
|---|
| 248 | } else { |
|---|
| 249 | $xoopsTpl->assign('viewer_can_post', false); |
|---|
| 250 | if ( $show_reg == 1 ) { |
|---|
| 251 | $xoopsTpl->assign('forum_post_or_register', XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri)); |
|---|
| 252 | } else { |
|---|
| 253 | $xoopsTpl->assign('forum_post_or_register', ''); |
|---|
| 254 | } |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | if ( $viewmode == "thread" ) { |
|---|
| 258 | $start = 0; |
|---|
| 259 | $postsArray = ForumPosts::getAllPosts($topic_id, "ASC", $total_posts, $start); |
|---|
| 260 | $xoopsTpl->assign('topic_viewmode', 'thread'); |
|---|
| 261 | |
|---|
| 262 | $newObjArr = array(); |
|---|
| 263 | foreach ( $postsArray as $eachpost ) { |
|---|
| 264 | $key1 = $eachpost->postid(); |
|---|
| 265 | if ( (!empty($post_id) && $post_id == $key1) || ( empty($post_id) && $eachpost->parent() == 0 ) ) { |
|---|
| 266 | $post_text = $eachpost->text(); |
|---|
| 267 | if ( 0 != $eachpost->uid() ) { |
|---|
| 268 | $eachposter = new XoopsUser($eachpost->uid()); |
|---|
| 269 | $poster_rank = $eachposter->rank(); |
|---|
| 270 | if ( $poster_rank['image'] != "" ) { |
|---|
| 271 | $poster_rank['image'] = "<img src='".XOOPS_UPLOAD_URL."/".$poster_rank['image']."' alt='' />"; |
|---|
| 272 | } |
|---|
| 273 | if ( $eachposter->isActive() ) { |
|---|
| 274 | $poster_status = $eachposter->isOnline() ? _MD_ONLINE : ''; |
|---|
| 275 | $posterarr = array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>', 'poster_avatar' => $eachposter->getVar('user_avatar'), 'poster_from' => $eachposter->getVar('user_from'), 'poster_regdate' => formatTimestamp($eachposter->getVar('user_regdate'), 's'), 'poster_postnum' => $eachposter->getVar('posts'), 'poster_sendpmtext' => sprintf(_SENDPMTO,$eachposter->getVar('uname')), 'poster_rank_title' => $poster_rank['title'], 'poster_rank_image' => $poster_rank['image'], 'poster_status' => $poster_status); |
|---|
| 276 | if ( 1 == $forumdata['allow_sig'] && $eachpost->attachsig() == 1 && $eachposter->attachsig() == 1 ) { |
|---|
| 277 | $myts =& MytextSanitizer::getInstance(); |
|---|
| 278 | $post_text .= "<p><br />----------------<br />". $myts->makeTareaData4Show($eachposter->getVar("user_sig", "N"), 0, 1, 1)."</p>"; |
|---|
| 279 | } |
|---|
| 280 | } else { |
|---|
| 281 | $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => ''); |
|---|
| 282 | } |
|---|
| 283 | } else { |
|---|
| 284 | $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => ''); |
|---|
| 285 | } |
|---|
| 286 | $posticon = $eachpost->icon(); |
|---|
| 287 | if ( isset($posticon) && $posticon != '' ) { |
|---|
| 288 | $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($eachpost->icon()).'" alt="" /></a>'; |
|---|
| 289 | } else { |
|---|
| 290 | $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/icons/posticon.gif" alt="" /></a>'; |
|---|
| 291 | } |
|---|
| 292 | $xoopsTpl->append('topic_posts', array_merge($posterarr, array('fix' => $fix, 'post_response' => $eachpost->response, 'post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip'=> $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text))); |
|---|
| 293 | } |
|---|
| 294 | |
|---|
| 295 | $newObjArr[$key1]['obj'] = $eachpost; |
|---|
| 296 | $key2 = $eachpost->parent(); |
|---|
| 297 | $newObjArr[$key2]['replies'][] = $key1; |
|---|
| 298 | $newObjArr[$key2]['leaf'] = $key1; |
|---|
| 299 | } |
|---|
| 300 | showTree($newObjArr, $post_id); |
|---|
| 301 | $xoopsTpl->assign(array('lang_subject' => _MD_SUBJECT, 'lang_date' => _MD_DATE)); |
|---|
| 302 | } else { |
|---|
| 303 | $xoopsTpl->assign(array('topic_viewmode' => 'flat', 'lang_top' => _MD_TOP, 'lang_subject' => _MD_SUBJECT, 'lang_bottom' => _MD_BOTTOM)); |
|---|
| 304 | $postsArray = ForumPosts::getAllPosts($topic_id, $order, $forumdata['posts_per_page'], $start, $post_id); |
|---|
| 305 | $foundusers = array(); |
|---|
| 306 | foreach ( $postsArray as $eachpost ) { |
|---|
| 307 | $post_text = $eachpost->text(); |
|---|
| 308 | if ( 0 != $eachpost->uid() ) { |
|---|
| 309 | if (!isset($foundusers['user'.$eachpost->uid()])) { |
|---|
| 310 | $eachposter = new XoopsUser($eachpost->uid()); |
|---|
| 311 | $foundusers['user'.$eachpost->uid()] =& $eachposter; |
|---|
| 312 | } else { |
|---|
| 313 | $eachposter =& $foundusers['user'.$eachpost->uid()]; |
|---|
| 314 | } |
|---|
| 315 | $poster_rank = $eachposter->rank(); |
|---|
| 316 | if ( $poster_rank['image'] != '' ) { |
|---|
| 317 | $poster_rank['image'] = '<img src="'.XOOPS_UPLOAD_URL.'/'.$poster_rank['image'].'" alt="" />'; |
|---|
| 318 | } |
|---|
| 319 | if ( $eachposter->isActive() ) { |
|---|
| 320 | $poster_status = $eachposter->isOnline() ? _MD_ONLINE : ''; |
|---|
| 321 | $posterarr = array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>', 'poster_avatar' => $eachposter->getVar('user_avatar'), 'poster_from' => $eachposter->getVar('user_from'), 'poster_regdate' => formatTimestamp($eachposter->getVar('user_regdate'), 's'), 'poster_postnum' => $eachposter->getVar('posts'), 'poster_sendpmtext' => sprintf(_SENDPMTO,$eachposter->getVar('uname')), 'poster_rank_title' => $poster_rank['title'], 'poster_rank_image' => $poster_rank['image'], 'poster_status' => $poster_status); |
|---|
| 322 | if ( 1 == $forumdata['allow_sig'] && $eachpost->attachsig() == 1 && $eachposter->attachsig() == 1 ) { |
|---|
| 323 | $myts =& MytextSanitizer::getInstance(); |
|---|
| 324 | $post_text .= '<p><br />----------------<br />'. $myts->makeTareaData4Show($eachposter->getVar('user_sig', 'N'), 0, 1, 1).'</p>'; |
|---|
| 325 | } |
|---|
| 326 | } else { |
|---|
| 327 | $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => ''); |
|---|
| 328 | } |
|---|
| 329 | } else { |
|---|
| 330 | $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => ''); |
|---|
| 331 | } |
|---|
| 332 | $posticon = $eachpost->icon(); |
|---|
| 333 | if ( isset($posticon) && $posticon != '' ) { |
|---|
| 334 | $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($eachpost->icon()).'" alt="" /></a>'; |
|---|
| 335 | } else { |
|---|
| 336 | $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" /></a>'; |
|---|
| 337 | } |
|---|
| 338 | |
|---|
| 339 | $xoopsTpl->append('topic_posts', array_merge($posterarr, array('fix' => $fix, 'post_response' => $eachpost->response, 'post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip'=> $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text))); |
|---|
| 340 | unset($eachposter); |
|---|
| 341 | } |
|---|
| 342 | if ( $total_posts > $forumdata['posts_per_page'] ) { |
|---|
| 343 | include XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|---|
| 344 | $nav = new XoopsPageNav($total_posts, $forumdata['posts_per_page'], $start, "start", 'topic_id='.$topic_id.'&forum='.$forum.'&viewmode='.$viewmode.'&order='.$order); |
|---|
| 345 | $xoopsTpl->assign('forum_page_nav', $nav->renderNav(4)); |
|---|
| 346 | } else { |
|---|
| 347 | $xoopsTpl->assign('forum_page_nav', ''); |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | // ¥«¥Æ¥´¥ê̾¼èÆÀ |
|---|
| 351 | $sql = "SELECT c.cat_id, c.cat_title FROM ".$xoopsDB->prefix("bb_categories")." c, ".$xoopsDB->prefix("bb_forums")." f WHERE c.cat_id = f.cat_id AND forum_id = $forum"; |
|---|
| 352 | |
|---|
| 353 | if ( !$result = $xoopsDB->query($sql) ) { |
|---|
| 354 | //redirect_header('index.php',2,_MD_ERROROCCURED); |
|---|
| 355 | //exit(); |
|---|
| 356 | } |
|---|
| 357 | $arrCat = $xoopsDB->fetchArray($result); |
|---|
| 358 | $xoopsTpl->assign('arrCat', $arrCat); |
|---|
| 359 | |
|---|
| 360 | // Âбþ¾õ¶· |
|---|
| 361 | $xoopsTpl->assign('arrResponse', $arrResponse); |
|---|
| 362 | |
|---|
| 363 | // create jump box |
|---|
| 364 | $xoopsTpl->assign(array('forum_jumpbox' => make_jumpbox($forum), 'lang_forum_index' => sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']), 'lang_from' => _MD_FROM, 'lang_joined' => _MD_JOINED, 'lang_posts' => _MD_POSTS, 'lang_poster' => _MD_POSTER, 'lang_thread' => _MD_THREAD, 'lang_edit' => _EDIT, 'lang_delete' => _DELETE, 'lang_reply' => _REPLY, 'lang_postedon' => _MD_POSTEDON, 'lang_response' => _MD_RESPONSE . ": ")); |
|---|
| 365 | |
|---|
| 366 | // Read in cookie of 'lastread' times |
|---|
| 367 | $topic_lastread = newbb_get_topics_viewed(); |
|---|
| 368 | // if cookie is not set for this topic, update view count and set cookie |
|---|
| 369 | if ( empty($topic_lastread[$topic_id]) ) { |
|---|
| 370 | $sql = 'UPDATE '.$xoopsDB->prefix('bb_topics').' SET topic_views = topic_views + 1 WHERE topic_id ='. $topic_id; |
|---|
| 371 | $xoopsDB->queryF($sql); |
|---|
| 372 | } |
|---|
| 373 | // Update cookie |
|---|
| 374 | newbb_add_topics_viewed($topic_lastread, $topic_id, time(), $bbCookie['path'], $bbCookie['domain'], $bbCookie['secure']); |
|---|
| 375 | include XOOPS_ROOT_PATH.'/footer.php'; |
|---|
| 376 | |
|---|
| 377 | ?> |
|---|