| [Top level directory] [Classes] [Functions] [Constants] [Variables] |
XMB Open Source Forum Software - PHP Cross Reference |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * eXtreme Message Board 4 * XMB 1.9.11 5 * 6 * Developed And Maintained By The XMB Group 7 * Copyright (c) 2001-2010, The XMB Group 8 * http://www.xmbforum.com 9 * 10 * Sponsored By iEntry, Inc. 11 * http://www.ientry.com 12 * 13 * This program is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU General Public License 15 * as published by the Free Software Foundation; either version 2 16 * of the License, or (at your option) any later version. 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, see <http://www.gnu.org/licenses/>. 25 * 26 **/ 27 28 define('X_SCRIPT', 'viewthread.php'); 29 30 require 'header.php'; 31 32 validatePpp(); 33 34 $pid = getInt('pid'); 35 $tid = getInt('tid'); 36 $fid = getInt('fid'); 37 $goto = postedVar('goto', '', FALSE, FALSE, FALSE, 'g'); 38 $action = postedVar('action', '', FALSE, FALSE, FALSE, 'g'); 39 40 if ($goto == 'lastpost') { 41 if ($pid > 0) { 42 $query = $db->query("SELECT tid, dateline FROM ".X_PREFIX."posts WHERE pid=$pid"); 43 if ($db->num_rows($query) == 1) { 44 $post = $db->fetch_array($query); 45 $tid = $post['tid']; 46 47 $query = $db->query("SELECT COUNT(pid) as postcount FROM ".X_PREFIX."posts WHERE tid=$tid AND dateline <= {$post['dateline']}"); 48 $posts = $db->result($query, 0); 49 $db->free_result($query); 50 } else { 51 header('HTTP/1.0 404 Not Found'); 52 eval('$css = "'.template('css').'";'); 53 error($lang['textnothread']); 54 } 55 } else if ($tid > 0) { 56 $query = $db->query("SELECT COUNT(pid) FROM ".X_PREFIX."posts WHERE tid=$tid"); 57 $posts = $db->result($query, 0); 58 $db->free_result($query); 59 60 if ($posts == 0) { 61 header('HTTP/1.0 404 Not Found'); 62 eval('$css = "'.template('css').'";'); 63 error($lang['textnothread']); 64 } 65 66 $query = $db->query("SELECT pid FROM ".X_PREFIX."posts WHERE tid=$tid ORDER BY dateline DESC, pid DESC LIMIT 0, 1"); 67 $pid = $db->result($query, 0); 68 $db->free_result($query); 69 } else if ($fid > 0) { 70 $pid = 0; 71 $tid = 0; 72 $query = $db->query("SELECT pid, tid, dateline FROM ".X_PREFIX."posts WHERE fid=$fid ORDER BY dateline DESC, pid DESC LIMIT 0, 1"); 73 if ($db->num_rows($query) == 1) { 74 $posts = $db->fetch_array($query); 75 $db->free_result($query); 76 77 $pid = $posts['pid']; 78 $tid = $posts['tid']; 79 } 80 81 $query = $db->query("SELECT p.pid, p.tid, p.dateline FROM ".X_PREFIX."posts p LEFT JOIN ".X_PREFIX."forums f USING (fid) WHERE f.fup=$fid ORDER BY p.dateline DESC, p.pid DESC LIMIT 0, 1"); 82 if ($db->num_rows($query) == 1) { 83 $fupPosts = $db->fetch_array($query); 84 $db->free_result($query); 85 86 if ($pid == 0) { 87 $pid = $fupPosts['pid']; 88 $tid = $fupPosts['tid']; 89 } elseif ($fupPosts['dateline'] > $posts['dateline']) { 90 $pid = $fupPosts['pid']; 91 $tid = $fupPosts['tid']; 92 } 93 } 94 95 if ($pid == 0) { 96 header('HTTP/1.0 404 Not Found'); 97 eval('$css = "'.template('css').'";'); 98 error($lang['textnothread']); 99 } 100 101 $query = $db->query("SELECT COUNT(pid) FROM ".X_PREFIX."posts WHERE tid=$tid"); 102 $posts = $db->result($query, 0); 103 $db->free_result($query); 104 } else { 105 header('HTTP/1.0 404 Not Found'); 106 eval('$css = "'.template('css').'";'); 107 error($lang['textnothread']); 108 } 109 $page = quickpage($posts, $ppp); 110 if ($page == 1) { 111 $page = ''; 112 } else { 113 $page = "&page=$page"; 114 } 115 redirect("{$full_url}viewthread.php?tid=$tid$page#pid$pid", 0); 116 117 } else if ($goto == 'search') { 118 $tidtest = $db->query("SELECT dateline FROM ".X_PREFIX."posts WHERE tid = $tid AND pid = $pid"); 119 if ($db->num_rows($tidtest) == 1) { 120 $post = $db->fetch_array($tidtest); 121 $posts = $db->result($db->query("SELECT COUNT(pid) FROM ".X_PREFIX."posts WHERE tid = $tid AND dateline <= {$post['dateline']}"), 0); 122 $page = quickpage(($posts), $ppp); 123 if ($page == 1) { 124 $page = ''; 125 } else { 126 $page = "&page=$page"; 127 } 128 redirect("{$full_url}viewthread.php?tid=$tid$page#pid$pid", 0); 129 } else { 130 header('HTTP/1.0 404 Not Found'); 131 eval('$css = "'.template('css').'";'); 132 error($lang['textnothread']); 133 } 134 } 135 136 loadtemplates( 137 'functions_bbcode_quickreply', 138 'functions_smilieinsert', 139 'functions_smilieinsert_smilie', 140 'viewthread_reply', 141 'viewthread_quickreply', 142 'viewthread_quickreply_captcha', 143 'viewthread', 144 'viewthread_modlog', 145 'viewthread_modoptions', 146 'viewthread_newpoll', 147 'viewthread_newtopic', 148 'viewthread_poll_options_view', 149 'viewthread_poll_options', 150 'viewthread_poll_submitbutton', 151 'viewthread_poll', 152 'viewthread_post', 153 'viewthread_post_email', 154 'viewthread_post_site', 155 'viewthread_post_icq', 156 'viewthread_post_aim', 157 'viewthread_post_msn', 158 'viewthread_post_yahoo', 159 'viewthread_post_search', 160 'viewthread_post_profile', 161 'viewthread_post_u2u', 162 'viewthread_post_ip', 163 'viewthread_post_repquote', 164 'viewthread_post_report', 165 'viewthread_post_edit', 166 'viewthread_post_attachmentthumb', 167 'viewthread_post_attachmentimage', 168 'viewthread_post_attachment', 169 'viewthread_post_sig', 170 'viewthread_post_nosig', 171 'viewthread_printable', 172 'viewthread_printable_row', 173 'viewthread_multipage' 174 ); 175 176 smcwcache(); 177 178 eval('$css = "'.template('css').'";'); 179 180 $posts = ''; 181 182 $query = $db->query("SELECT t.fid, t.subject, t.closed, t.topped, t.lastpost, t.replies, COUNT(pid) AS postcount FROM ".X_PREFIX."threads AS t LEFT JOIN ".X_PREFIX."posts USING (tid) WHERE t.tid=$tid GROUP BY t.tid"); 183 if ($db->num_rows($query) != 1) { 184 $db->free_result($query); 185 header('HTTP/1.0 404 Not Found'); 186 error($lang['textnothread']); 187 } 188 189 $thread = $db->fetch_array($query); 190 $db->free_result($query); 191 192 $thislast = explode('|', $thread['lastpost']); 193 194 // Perform automatic maintenance 195 if ($thread['replies'] != $thread['postcount'] - 1) { 196 updatethreadcount($tid); 197 } 198 199 if (strpos($thread['closed'], '|') !== false) { 200 $moved = explode('|', $thread['closed']); 201 if ($moved[0] == 'moved') { 202 header('HTTP/1.0 301 Moved Permanently'); 203 header('Location: '.$full_url.'viewthread.php?tid='.$moved[1]); 204 exit(); 205 } 206 } 207 208 $thread['subject'] = shortenString(rawHTMLsubject(stripslashes($thread['subject'])), 125, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...'); 209 210 $lastPid = isset($thislast[2]) ? $thislast[2] : 0; 211 $expire = $onlinetime + X_ONLINE_TIMER; 212 if (!isset($oldtopics)) { 213 put_cookie('oldtopics', '|'.$lastPid.'|', $expire, $cookiepath, $cookiedomain, null, X_SET_HEADER); 214 } else if (false === strpos($oldtopics, '|'.$lastPid.'|')) { 215 $oldtopics .= $lastPid.'|'; 216 put_cookie('oldtopics', $oldtopics, $expire, $cookiepath, $cookiedomain, null, X_SET_HEADER); 217 } 218 219 $fid = $thread['fid']; 220 $forum = getForum($fid); 221 222 if (($forum['type'] != 'forum' && $forum['type'] != 'sub') || $forum['status'] != 'on') { 223 header('HTTP/1.0 404 Not Found'); 224 error($lang['textnoforum']); 225 } 226 227 $perms = checkForumPermissions($forum); 228 if (!$perms[X_PERMS_VIEW]) { 229 if (X_GUEST) { 230 redirect("{$full_url}misc.php?action=login", 0); 231 exit; 232 } else { 233 error($lang['privforummsg']); 234 } 235 } else if (!$perms[X_PERMS_PASSWORD]) { 236 handlePasswordDialog($fid); 237 } 238 239 $fup = array(); 240 if ($forum['type'] == 'sub') { 241 $fup = getForum($forum['fup']); 242 // prevent access to subforum when upper forum can't be viewed. 243 $fupPerms = checkForumPermissions($fup); 244 if (!$fupPerms[X_PERMS_VIEW]) { 245 if (X_GUEST) { 246 redirect("{$full_url}misc.php?action=login", 0); 247 exit; 248 } else { 249 error($lang['privforummsg']); 250 } 251 } else if (!$fupPerms[X_PERMS_PASSWORD]) { 252 handlePasswordDialog($fup['fid']); 253 } else if ($fup['fup'] > 0) { 254 $fupup = getForum($fup['fup']); 255 nav('<a href="index.php?gid='.$fup['fup'].'">'.fnameOut($fupup['name']).'</a>'); 256 unset($fupup); 257 } 258 nav('<a href="forumdisplay.php?fid='.$fup['fid'].'">'.fnameOut($fup['name']).'</a>'); 259 unset($fup); 260 } else if ($forum['fup'] > 0) { // 'forum' in a 'group' 261 $fup = getForum($forum['fup']); 262 nav('<a href="index.php?gid='.$fup['fid'].'">'.fnameOut($fup['name']).'</a>'); 263 unset($fup); 264 } 265 nav('<a href="forumdisplay.php?fid='.$fid.'">'.fnameOut($forum['name']).'</a>'); 266 nav($thread['subject']); 267 268 if ($SETTINGS['subject_in_title'] == 'on') { 269 $threadSubject = '- '.$thread['subject']; 270 } 271 272 // Search-link 273 $searchlink = makeSearchLink($forum['fid']); 274 275 $allowimgcode = ($forum['allowimgcode'] == 'yes') ? $lang['texton']:$lang['textoff']; 276 $allowhtml = ($forum['allowhtml'] == 'yes') ? $lang['texton']:$lang['textoff']; 277 $allowsmilies = ($forum['allowsmilies'] == 'yes') ? $lang['texton']:$lang['textoff']; 278 $allowbbcode = ($forum['allowbbcode'] == 'yes') ? $lang['texton']:$lang['textoff']; 279 280 $replylink = $quickreply = ''; 281 282 $status1 = modcheck($self['username'], $forum['moderator']); 283 284 if ($action == '') { 285 $mpage = multipage($thread['postcount'], $ppp, 'viewthread.php?tid='.$tid); 286 $multipage =& $mpage['html']; 287 if (strlen($mpage['html']) != 0) { 288 eval('$multipage = "'.template('viewthread_multipage').'";'); 289 } 290 291 eval('$header = "'.template('header').'";'); 292 293 if ($perms[X_PERMS_REPLY] And ($thread['closed'] == '' Or X_SADMIN)) { 294 eval('$replylink = "'.template('viewthread_reply').'";'); 295 if ($SETTINGS['quickreply_status'] == 'on') { 296 $usesigcheck = ''; 297 if (X_MEMBER) { 298 if ($self['sig'] != '') { 299 $usesigcheck = 'checked="checked"'; 300 } 301 } 302 303 $captchapostcheck = ''; 304 if (X_GUEST && $SETTINGS['captcha_status'] == 'on' && $SETTINGS['captcha_post_status'] == 'on' && !DEBUG) { 305 require ROOT.'include/captcha.inc.php'; 306 $Captcha = new Captcha(250, 50); 307 if ($Captcha->bCompatible !== false) { 308 $imghash = $Captcha->GenerateCode(); 309 if ($SETTINGS['captcha_code_casesensitive'] == 'off') { 310 $lang['captchacaseon'] = ''; 311 } 312 eval('$captchapostcheck = "'.template('viewthread_quickreply_captcha').'";'); 313 } 314 } 315 316 if ($SETTINGS['smileyinsert'] == 'on' And $forum['allowsmilies'] == 'yes' And $smiliesnum > 0) { 317 eval('$quickbbcode = "'.template('functions_bbcode_quickreply').'";'); 318 319 $smilies = '<div align="center"><hr /><table border="0"><tr>'; 320 $smilies .= smilieinsert('quick'); 321 $smilies .= '</tr></table>'; 322 $smilies .= "<a href=\"misc.php?action=smilies\" onclick=\"Popup(this.href, 'Window', 200, 250); return false;\">{$lang['moresmilies']}</a>"; 323 $smilies .= "</div></td>"; 324 } else { 325 $quickbbcode = ''; 326 $smilies = ''; 327 } 328 329 eval('$quickreply = "'.template('viewthread_quickreply').'";'); 330 } 331 } 332 333 if ($thread['closed'] == '') { 334 $closeopen = $lang['textclosethread']; 335 } else { 336 $closeopen = $lang['textopenthread']; 337 } 338 339 if (X_GUEST) { 340 $memcplink = ''; 341 } else { 342 $memcplink = " | <a href=\"memcp.php?action=subscriptions&subadd=$tid\">{$lang['textsubscribe']}</a> | <a href=\"memcp.php?action=favorites&favadd=$tid\">{$lang['textaddfav']}</a>"; 343 } 344 345 if ($perms[X_PERMS_THREAD]) { 346 eval('$newtopiclink = "'.template('viewthread_newtopic').'";'); 347 } else { 348 $newtopiclink = ''; 349 } 350 351 if ($perms[X_PERMS_POLL]) { 352 eval('$newpolllink = "'.template('viewthread_newpoll').'";'); 353 } else { 354 $newpolllink = ''; 355 } 356 357 $topuntop = ($thread['topped'] == 1) ? $lang['textuntopthread'] : $lang['texttopthread']; 358 359 $specialrank = array(); 360 $rankposts = array(); 361 $queryranks = $db->query("SELECT id, title, posts, stars, allowavatars, avatarrank FROM ".X_PREFIX."ranks"); 362 while($query = $db->fetch_row($queryranks)) { 363 $title = $query[1]; 364 $rposts= $query[2]; 365 if ($title == 'Super Administrator' || $title == 'Administrator' || $title == 'Super Moderator' || $title == 'Moderator') { 366 $specialrank[$title] = "$query[0],$query[1],$query[2],$query[3],$query[4],$query[5]"; 367 } else { 368 $rankposts[$rposts] = "$query[0],$query[1],$query[2],$query[3],$query[4],$query[5]"; 369 } 370 } 371 $db->free_result($queryranks); 372 373 $db->query("UPDATE ".X_PREFIX."threads SET views=views+1 WHERE tid='$tid'"); 374 375 $pollhtml = $poll = ''; 376 $vote_id = $voted = 0; 377 378 $query = $db->query("SELECT vote_id FROM ".X_PREFIX."vote_desc WHERE topic_id='$tid'"); 379 if ($query) { 380 $vote_id = $db->fetch_array($query); 381 $vote_id = (int) $vote_id['vote_id']; 382 } 383 $db->free_result($query); 384 385 if ($vote_id > 0 && $perms[X_PERMS_POLL]) { 386 if (X_MEMBER) { 387 $query = $db->query("SELECT COUNT(vote_id) AS cVotes FROM ".X_PREFIX."vote_voters WHERE vote_id='$vote_id' AND vote_user_id=".intval($self['uid'])); 388 if ($query) { 389 $voted = $db->fetch_array($query); 390 $voted = (int) $voted['cVotes']; 391 } 392 $db->free_result($query); 393 } 394 395 $viewresults = (isset($viewresults) && $viewresults == 'yes') ? 'yes' : ''; 396 if ($voted >= 1 || $thread['closed'] == 'yes' || X_GUEST || $viewresults) { 397 if ($viewresults) { 398 $results = '- [<a href="viewthread.php?tid='.$tid.'"><font color="'.$cattext.'">'.$lang['backtovote'].'</font></a>]'; 399 } else { 400 $results = ''; 401 } 402 403 $num_votes = 0; 404 $query = $db->query("SELECT vote_result, vote_option_text FROM ".X_PREFIX."vote_results WHERE vote_id='$vote_id'"); 405 while($result = $db->fetch_array($query)) { 406 $num_votes += $result['vote_result']; 407 $pollentry = array(); 408 $pollentry['name'] = postify($result['vote_option_text'], 'no', 'no', 'yes', 'no', 'yes', 'yes'); 409 $pollentry['votes'] = $result['vote_result']; 410 $poll[] = $pollentry; 411 } 412 $db->free_result($query); 413 414 reset($poll); 415 foreach($poll as $num=>$array) { 416 $pollimgnum = 0; 417 $pollbar = ''; 418 if ($array['votes'] > 0) { 419 $orig = round($array['votes']/$num_votes*100, 2); 420 $percentage = round($orig, 2); 421 $percentage .= '%'; 422 $poll_length = (int) $orig; 423 if ($poll_length > 97) { 424 $poll_length = 97; 425 } 426 $pollbar = '<img src="'.$imgdir.'/pollbar.gif" height="10" width="'.$poll_length.'%" alt="'.$lang['altpollpercentage'].'" title="'.$lang['altpollpercentage'].'" border="0" />'; 427 } else { 428 $percentage = '0%'; 429 } 430 eval('$pollhtml .= "'.template('viewthread_poll_options_view').'";'); 431 $buttoncode = ''; 432 } 433 } else { 434 $results = '- [<a href="viewthread.php?tid='.$tid.'&viewresults=yes"><font color="'.$cattext.'">'.$lang['viewresults'].'</font></a>]'; 435 $query = $db->query("SELECT vote_option_id, vote_option_text FROM ".X_PREFIX."vote_results WHERE vote_id='$vote_id'"); 436 while($result = $db->fetch_array($query)) { 437 $poll['id'] = (int) $result['vote_option_id']; 438 $poll['name'] = $result['vote_option_text']; 439 eval('$pollhtml .= "'.template('viewthread_poll_options').'";'); 440 } 441 $db->free_result($query); 442 eval('$buttoncode = "'.template('viewthread_poll_submitbutton').'";'); 443 } 444 eval('$poll = "'.template('viewthread_poll').'";'); 445 } 446 447 $startdate = '0'; 448 $enddate = '0'; 449 $sql = "SELECT dateline " 450 . "FROM ".X_PREFIX."posts " 451 . "WHERE tid=$tid " 452 . "ORDER BY dateline ASC, pid ASC " 453 . "LIMIT {$mpage['start']}, ".($ppp + 1); 454 $query1 = $db->query($sql); 455 $rowcount = $db->num_rows($query1); 456 if ($rowcount > 0) { 457 $row = $db->fetch_array($query1); 458 $startdate = $row['dateline']; 459 if ($rowcount <= $ppp) { 460 $enddate = $onlinetime; 461 } else { 462 $db->data_seek($query1, $rowcount - 1); 463 $row = $db->fetch_array($query1); 464 $enddate = $row['dateline']; 465 } 466 } 467 $db->free_result($query1); 468 469 $thisbg = $altbg2; 470 $sql = "SELECT p.*, m.* " 471 . "FROM " 472 . "( " 473 . " ( " 474 . " SELECT 'post' AS type, fid, tid, author, subject, dateline, pid, message, icon, usesig, useip, bbcodeoff, smileyoff " 475 . " FROM ".X_PREFIX."posts " 476 . " WHERE tid=$tid " 477 . " ORDER BY dateline ASC, pid ASC " 478 . " LIMIT {$mpage['start']}, $ppp " 479 . " ) " 480 . " UNION ALL " 481 . " ( " 482 . " SELECT 'modlog' AS type, fid, tid, username AS author, action AS subject, date AS dateline, '', '', '', '', '', '', '' " 483 . " FROM ".X_PREFIX."logs " 484 . " WHERE tid=$tid AND date >= $startdate AND date < $enddate " 485 . " ) " 486 . ") AS p " 487 . "LEFT JOIN ".X_PREFIX."members m ON m.username=p.author " 488 . "ORDER BY p.dateline ASC, p.type DESC, p.pid ASC "; 489 $querypost = $db->query($sql); 490 491 if ($forum['attachstatus'] == 'on') { 492 require ('include/attach.inc.php'); 493 $queryattach = $db->query("SELECT a.aid, a.pid, a.filename, a.filetype, a.filesize, a.downloads, a.img_size, thumbs.aid AS thumbid, thumbs.filename AS thumbname, thumbs.img_size AS thumbsize FROM ".X_PREFIX."attachments AS a LEFT JOIN ".X_PREFIX."attachments AS thumbs ON a.aid=thumbs.parentid INNER JOIN ".X_PREFIX."posts AS p ON a.pid=p.pid WHERE p.tid=$tid AND a.parentid=0"); 494 } 495 496 $tmoffset = ($timeoffset * 3600) + ($addtime * 3600); 497 while($post = $db->fetch_array($querypost)) { 498 // Perform automatic maintenance 499 if ($post['type'] == 'post' And $post['fid'] != $thread['fid']) { 500 $db->query('UPDATE '.X_PREFIX.'posts SET fid='.$thread['fid'].' WHERE pid='.$post['pid']); 501 } 502 503 $post['avatar'] = str_replace("script:", "sc ript:", $post['avatar']); 504 505 if ($onlinetime - (int)$post['lastvisit'] <= X_ONLINE_TIMER) { 506 if ($post['invisible'] == 1) { 507 if (!X_ADMIN) { 508 $onlinenow = $lang['memberisoff']; 509 } else { 510 $onlinenow = $lang['memberison'].' ('.$lang['hidden'].')'; 511 } 512 } else { 513 $onlinenow = $lang['memberison']; 514 } 515 } else { 516 $onlinenow = $lang['memberisoff']; 517 } 518 519 $date = gmdate($dateformat, $post['dateline'] + $tmoffset); 520 $time = gmdate($timecode, $post['dateline'] + $tmoffset); 521 522 $poston = $lang['textposton'].' '.$date.' '.$lang['textat'].' '.$time; 523 524 if ($post['icon'] != '' && file_exists($smdir.'/'.$post['icon'])) { 525 $post['icon'] = '<img src="'.$smdir.'/'.$post['icon'].'" alt="'.$post['icon'].'" border="0" />'; 526 } else { 527 $post['icon'] = '<img src="'.$imgdir.'/default_icon.gif" alt="[*]" border="0" />'; 528 } 529 530 if ($post['author'] != 'Anonymous' && $post['username']) { 531 if (X_MEMBER && $post['showemail'] == 'yes') { 532 eval('$email = "'.template('viewthread_post_email').'";'); 533 } else { 534 $email = ''; 535 } 536 537 if ($post['site'] == '') { 538 $site = ''; 539 } else { 540 $post['site'] = str_replace("http://", "", $post['site']); 541 $post['site'] = "http://$post[site]"; 542 eval('$site = "'.template('viewthread_post_site').'";'); 543 } 544 545 $encodename = recodeOut($post['author']); 546 $profilelink = "<a href=\"./member.php?action=viewpro&member=$encodename\">{$post['author']}</a>"; 547 548 $icq = ''; 549 if ($post['icq'] != '' && $post['icq'] > 0) { 550 eval('$icq = "'.template('viewthread_post_icq').'";'); 551 } 552 553 $aim = ''; 554 if ($post['aim'] != '') { 555 $post['aim'] = recodeOut($post['aim']); 556 eval('$aim = "'.template('viewthread_post_aim').'";'); 557 } 558 559 $msn = ''; 560 if ($post['msn'] != '') { 561 $post['msn'] = recodeOut($post['msn']); 562 eval('$msn = "'.template('viewthread_post_msn').'";'); 563 } 564 565 $yahoo = ''; 566 if ($post['yahoo'] != '') { 567 $post['yahoo'] = recodeOut($post['yahoo']); 568 eval('$yahoo = "'.template('viewthread_post_yahoo').'";'); 569 } 570 571 if (X_GUEST && $SETTINGS['captcha_status'] == 'on' && $SETTINGS['captcha_search_status'] == 'on' && !DEBUG) { 572 $search = ''; 573 } else { 574 eval('$search = "'.template('viewthread_post_search').'";'); 575 } 576 577 eval('$profile = "'.template('viewthread_post_profile').'";'); 578 if (X_GUEST) { 579 $u2u = ''; 580 } else { 581 eval('$u2u = "'.template('viewthread_post_u2u').'";'); 582 } 583 584 $showtitle = $post['status']; 585 $rank = array(); 586 if ($post['status'] == 'Administrator' || $post['status'] == 'Super Administrator' || $post['status'] == 'Super Moderator' || $post['status'] == 'Moderator') { 587 $sr = $post['status']; 588 $rankinfo = explode(",", $specialrank[$sr]); 589 $rank['allowavatars'] = $rankinfo[4]; 590 $rank['title'] = $lang[$status_translate[$status_enum[$sr]]]; 591 $rank['stars'] = $rankinfo[3]; 592 $rank['avatarrank'] = $rankinfo[5]; 593 } else if ($post['status'] == 'Banned') { 594 $rank['allowavatars'] = 'no'; 595 $rank['title'] = $lang['textbanned']; 596 $rank['stars'] = 0; 597 $rank['avatarrank'] = ''; 598 } else { 599 $last_max = -1; 600 foreach($rankposts as $key => $rankstuff) { 601 if ($post['postnum'] >= $key && $key > $last_max) { 602 $last_max = $key; 603 $rankinfo = explode(",", $rankstuff); 604 $rank['allowavatars'] = $rankinfo[4]; 605 $rank['title'] = $rankinfo[1]; 606 $rank['stars'] = $rankinfo[3]; 607 $rank['avatarrank'] = $rankinfo[5]; 608 } 609 } 610 } 611 612 $allowavatars = $rank['allowavatars']; 613 $stars = str_repeat('<img src="'.$imgdir.'/star.gif" alt="*" border="0" />', $rank['stars']) . '<br />'; 614 $showtitle = ($post['customstatus'] != '') ? $post['customstatus'].'<br />' : $rank['title'].'<br />'; 615 616 if ($allowavatars == 'no') { 617 $post['avatar'] = ''; 618 } 619 620 if ($rank['avatarrank'] != '') { 621 $rank['avatar'] = '<img src="'.$rank['avatarrank'].'" alt="'.$lang['altavatar'].'" border="0" /><br />'; 622 } 623 624 $tharegdate = gmdate($dateformat, $post['regdate'] + $tmoffset); 625 626 $avatar = ''; 627 if ($SETTINGS['avastatus'] == 'on' || $SETTINGS['avastatus'] == 'list') { 628 if ($post['avatar'] != '' && $allowavatars != "no") { 629 $avatar = '<img src="'.$post['avatar'].'" alt="'.$lang['altavatar'].'" border="0" />'; 630 } 631 } 632 633 if ($post['mood'] != '') { 634 $mood = '<strong>'.$lang['mood'].'</strong> '.postify($post['mood'], 'no', 'no', 'yes', 'no', 'yes', 'no', true, 'yes'); 635 } else { 636 $mood = ''; 637 } 638 639 if ($post['location'] != '') { 640 $post['location'] = censor($post['location']); 641 $location = '<br />'.$lang['textlocation'].' '.$post['location']; 642 } else { 643 $location = ''; 644 } 645 } else { 646 $post['author'] = ($post['author'] == 'Anonymous') ? $lang['textanonymous'] : $post['author']; 647 $showtitle = $lang['textunregistered'].'<br />'; 648 $stars = ''; 649 $avatar = ''; 650 $rank['avatar'] = ''; 651 $post['postnum'] = 'N/A'; 652 $tharegdate = 'N/A'; 653 $email = ''; 654 $site = ''; 655 $icq = ''; 656 $msn = ''; 657 $aim = ''; 658 $yahoo = ''; 659 $profile = ''; 660 $search = ''; 661 $u2u = ''; 662 $location = ''; 663 $mood = ''; 664 $encodename = ''; 665 $profilelink = $post['author']; 666 } 667 668 $ip = ''; 669 if (X_ADMIN) { 670 eval('$ip = "'.template('viewthread_post_ip').'";'); 671 } 672 673 $repquote = ''; 674 if ($perms[X_PERMS_REPLY] && $thread['closed'] != 'yes') { 675 eval("\$repquote = \"".template('viewthread_post_repquote')."\";"); 676 } 677 678 $reportlink = ''; 679 if (X_MEMBER && $post['author'] != $xmbuser && $SETTINGS['reportpost'] == 'on') { 680 eval('$reportlink = "'.template('viewthread_post_report').'";'); 681 } 682 683 $edit = ''; 684 if (modcheckPost($self['username'], $forum['moderator'], $post['status']) == 'Moderator' || ($thread['closed'] != 'yes' && $post['author'] == $xmbuser)) { 685 eval('$edit = "'.template('viewthread_post_edit').'";'); 686 } 687 688 $bbcodeoff = $post['bbcodeoff']; 689 $smileyoff = $post['smileyoff']; 690 $post['message'] = postify(stripslashes($post['message']), $smileyoff, $bbcodeoff, $forum['allowsmilies'], $forum['allowhtml'], $forum['allowbbcode'], $forum['allowimgcode']); 691 692 if ($forum['attachstatus'] == 'on' And $db->num_rows($queryattach) > 0) { 693 $files = array(); 694 $db->data_seek($queryattach, 0); 695 while($attach = $db->fetch_array($queryattach)) { 696 if ($attach['pid'] == $post['pid']) { 697 $files[] = $attach; 698 } 699 } 700 if (count($files) > 0) { 701 bbcodeFileTags($post['message'], $files, $post['pid'], ($forum['allowbbcode'] == 'yes' And $bbcodeoff == 'no')); 702 } 703 } 704 705 if ($post['usesig'] == 'yes') { 706 $post['sig'] = postify($post['sig'], 'no', 'no', $forum['allowsmilies'], $SETTINGS['sightml'], $SETTINGS['sigbbcode'], $forum['allowimgcode'], false); 707 eval("\$post['message'] .= \"".template('viewthread_post_sig')."\";"); 708 } else { 709 eval("\$post['message'] .= \"".template('viewthread_post_nosig')."\";"); 710 } 711 712 if (!isset($rank['avatar'])) { 713 $rank['avatar'] = ''; 714 } 715 716 if ($post['type'] == 'post') { 717 718 if ($post['subject'] != '') { 719 $linktitle = rawHTMLsubject(stripslashes($post['subject'])); 720 $post['subject'] = $linktitle.'<br />'; 721 } else { 722 $linktitle = $thread['subject']; 723 } 724 725 eval('$posts .= "'.template('viewthread_post').'";'); 726 727 } else { 728 729 $poston = $date.' '.$lang['textat'].' '.$time; 730 $post['message'] = $lang["modlog_{$post['subject']}"].'<br />'.$poston; 731 eval('$posts .= "'.template('viewthread_modlog').'";'); 732 733 } 734 735 if ($thisbg == $altbg2) { 736 $thisbg = $altbg1; 737 } else { 738 $thisbg = $altbg2; 739 } 740 } 741 $db->free_result($querypost); 742 743 $modoptions = ''; 744 if ('Moderator' == $status1) { 745 eval('$modoptions = "'.template('viewthread_modoptions').'";'); 746 } 747 eval('$viewthread = "'.template('viewthread').'";'); 748 end_time(); 749 eval('$footer = "'.template('footer').'";'); 750 echo $header, $viewthread, $footer; 751 } else if ($action == 'attachment') { 752 // Validate action 753 if (!($forum['attachstatus'] == 'on' And $pid > 0 And $tid > 0)) { 754 header('HTTP/1.0 404 Not Found'); 755 error($lang['textnothread']); 756 } 757 758 // Validate PID and TID 759 $query = $db->query("SELECT aid, filename FROM ".X_PREFIX."attachments AS a INNER JOIN ".X_PREFIX."posts AS p USING (pid) WHERE a.pid=$pid AND a.parentid=0 AND p.tid=$tid ORDER BY aid LIMIT 1"); 760 if ($db->num_rows($query) != 1) { 761 header('HTTP/1.0 404 Not Found'); 762 error($lang['textnothread']); 763 } 764 765 // Redirect to new URL 766 $file = $db->fetch_array($query); 767 $db->free_result($query); 768 require ('include/attach.inc.php'); 769 $url = getAttachmentURL($file['aid'], $pid, $file['filename'], FALSE); 770 header('HTTP/1.0 301 Moved Permanently'); 771 header('Location: '.$url); 772 } else if ($action == 'printable') { 773 $threadlink = "viewthread.php?tid=$tid"; 774 775 $querypost = $db->query("SELECT * FROM ".X_PREFIX."posts WHERE tid='$tid' ORDER BY dateline ASC, pid ASC"); 776 if ($forum['attachstatus'] == 'on') { 777 require ('include/attach.inc.php'); 778 $queryattach = $db->query("SELECT a.aid, a.pid, a.filename, a.filetype, a.filesize, a.downloads, a.img_size, thumbs.aid AS thumbid, thumbs.filename AS thumbname, thumbs.img_size AS thumbsize FROM ".X_PREFIX."attachments AS a LEFT JOIN ".X_PREFIX."attachments AS thumbs ON a.aid=thumbs.parentid INNER JOIN ".X_PREFIX."posts AS p ON a.pid=p.pid WHERE p.tid=$tid AND a.parentid=0"); 779 } 780 781 $counter = 0; 782 $posts = ''; 783 $tmoffset = ($timeoffset * 3600) + ($addtime * 3600); 784 while($post = $db->fetch_array($querypost)) { 785 $date = gmdate($dateformat, $post['dateline'] + $tmoffset); 786 $time = gmdate($timecode, $post['dateline'] + $tmoffset); 787 $poston = "$date $lang[textat] $time"; 788 $bbcodeoff = $post['bbcodeoff']; 789 $smileyoff = $post['smileyoff']; 790 if ($counter == 0) { 791 $subject = ''; 792 } else { 793 $subject = rawHTMLsubject(stripslashes($post['subject'])); 794 } 795 $post['message'] = postify(stripslashes($post['message']), $smileyoff, $bbcodeoff, $forum['allowsmilies'], $forum['allowhtml'], $forum['allowbbcode'], $forum['allowimgcode']); 796 if ($forum['attachstatus'] == 'on' And $db->num_rows($queryattach) > 0) { 797 $files = array(); 798 $db->data_seek($queryattach, 0); 799 while($attach = $db->fetch_array($queryattach)) { 800 if ($attach['pid'] == $post['pid']) { 801 $files[] = $attach; 802 } 803 } 804 if (count($files) > 0) { 805 bbcodeFileTags($post['message'], $files, $post['pid'], ($forum['allowbbcode'] == 'yes' And $bbcodeoff == 'no')); 806 } 807 } 808 eval('$posts .= "'.template('viewthread_printable_row').'";'); 809 $counter++; 810 } 811 $db->free_result($querypost); 812 eval('echo "'.template('viewthread_printable').'";'); 813 } else { 814 header('HTTP/1.0 404 Not Found'); 815 error($lang['textnoaction']); 816 } 817 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Jan 26 20:11:23 2010 | Home | Forum | Download | SVN | Bug Tracker | Documentation | Cross-referenced by PHPXref 0.7 |