| [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', 'forumdisplay.php'); 29 30 require 'header.php'; 31 32 loadtemplates( 33 'forumdisplay', 34 'forumdisplay_admin', 35 'forumdisplay_sortby', 36 'forumdisplay_multipage', 37 'forumdisplay_multipage_admin', 38 'forumdisplay_newpoll', 39 'forumdisplay_newtopic', 40 'forumdisplay_nothreads', 41 'forumdisplay_password', 42 'forumdisplay_subforum', 43 'forumdisplay_subforum_lastpost', 44 'forumdisplay_subforum_nolastpost', 45 'forumdisplay_subforums', 46 'forumdisplay_thread', 47 'forumdisplay_thread_admin', 48 'forumdisplay_thread_lastpost' 49 ); 50 51 smcwcache(); 52 53 eval('$css = "'.template('css').'";'); 54 eval($lang['hottopiceval']); 55 56 $fid = getInt('fid'); 57 58 $forum = getForum($fid); 59 60 if (($forum['type'] != 'forum' && $forum['type'] != 'sub') || $forum['status'] != 'on') { 61 header('HTTP/1.0 404 Not Found'); 62 error($lang['textnoforum']); 63 } 64 65 $perms = checkForumPermissions($forum); 66 if (!$perms[X_PERMS_VIEW]) { 67 if (X_GUEST) { 68 redirect("{$full_url}misc.php?action=login", 0); 69 exit; 70 } else { 71 error($lang['privforummsg']); 72 } 73 } else if (!$perms[X_PERMS_PASSWORD]) { 74 handlePasswordDialog($fid); 75 } 76 77 $fup = array(); 78 if ($forum['type'] == 'sub') { 79 $fup = getForum($forum['fup']); 80 // prevent access to subforum when upper forum can't be viewed. 81 $fupPerms = checkForumPermissions($fup); 82 if (!$fupPerms[X_PERMS_VIEW]) { 83 if (X_GUEST) { 84 redirect("{$full_url}misc.php?action=login", 0); 85 exit; 86 } else { 87 error($lang['privforummsg']); 88 } 89 } else if (!$fupPerms[X_PERMS_PASSWORD]) { 90 handlePasswordDialog($fup['fid']); 91 } else if ($fup['fup'] > 0) { 92 $fupup = getForum($fup['fup']); 93 nav('<a href="index.php?gid='.$fup['fup'].'">'.fnameOut($fupup['name']).'</a>'); 94 unset($fupup); 95 } 96 nav('<a href="forumdisplay.php?fid='.$fup['fid'].'">'.fnameOut($fup['name']).'</a>'); 97 unset($fup); 98 } else if ($forum['fup'] > 0) { // 'forum' in a 'group' 99 $fup = getForum($forum['fup']); 100 nav('<a href="index.php?gid='.$fup['fid'].'">'.fnameOut($fup['name']).'</a>'); 101 unset($fup); 102 } 103 nav(fnameOut($forum['name'])); 104 105 if ($SETTINGS['subject_in_title'] == 'on') { 106 $threadSubject = '- '.fnameOut($forum['name']); 107 } 108 109 // Search-link 110 $searchlink = makeSearchLink($forum['fid']); 111 112 validateTpp(); 113 validatePpp(); 114 115 $threadcount = $db->result($db->query("SELECT COUNT(tid) FROM ".X_PREFIX."threads WHERE fid=$fid"), 0); 116 117 // Perform automatic maintenance 118 if ($forum['type'] == 'sub' And $forum['threads'] != $threadcount) { 119 updateforumcount($fid); 120 } 121 122 $mpage = multipage($threadcount, $tpp, 'forumdisplay.php?fid='.$fid); 123 124 eval('$header = "'.template('header').'";'); 125 126 if ($perms[X_PERMS_POLL]) { 127 eval('$newpolllink = "'.template('forumdisplay_newpoll').'";'); 128 } else { 129 $newpolllink = ''; 130 } 131 132 if ($perms[X_PERMS_THREAD]) { 133 eval('$newtopiclink = "'.template('forumdisplay_newtopic').'";'); 134 } else { 135 $newtopiclink = ''; 136 } 137 138 $index_subforums = array(); 139 $subforums = ''; 140 if ($forum['type'] == 'forum') { 141 $forumlist = ''; 142 $permitted = permittedForums(forumCache(), 'forum'); 143 foreach($permitted as $sub) { 144 if ($sub['type'] == 'sub' And $sub['fup'] == $fid) { 145 $forumlist .= forum($sub, "forumdisplay_subforum", $index_subforums); 146 } 147 } 148 if ($forumlist != '') { 149 eval('$subforums .= "'.template('forumdisplay_subforums').'";'); 150 } 151 } 152 153 $t_extension = get_extension($lang['toppedprefix']); 154 switch($t_extension) { 155 case 'gif': 156 case 'jpg': 157 case 'jpeg': 158 case 'png': 159 $lang['toppedprefix'] = '<img src="'.$imgdir.'/'.$lang['toppedprefix'].'" alt="'.$lang['toppedpost'].'" border="0" />'; 160 break; 161 } 162 163 $p_extension = get_extension($lang['pollprefix']); 164 switch($p_extension) { 165 case 'gif': 166 case 'jpg': 167 case 'jpeg': 168 case 'png': 169 $lang['pollprefix'] = '<img src="'.$imgdir.'/'.$lang['pollprefix'].'" alt="'.$lang['postpoll'].'" border="0" />'; 170 break; 171 } 172 173 $cusdate = formInt('cusdate'); 174 if ($cusdate) { 175 $cusdate = $onlinetime - $cusdate; 176 $cusdate = "AND (substring_index(lastpost, '|',1)+1) >= '$cusdate'"; 177 } else { 178 $cusdate = ''; 179 } 180 181 $ascdesc = postedVar('ascdesc', '', FALSE, FALSE); 182 if (strtolower($ascdesc) != 'asc') { 183 $ascdesc = "desc"; 184 } 185 186 $forumdisplay_thread = 'forumdisplay_thread'; 187 188 $status1 = modcheck($self['username'], $forum['moderator']); 189 190 if ($status1 == 'Moderator') { 191 $forumdisplay_thread = 'forumdisplay_thread_admin'; 192 } 193 194 $topicsnum = 0; 195 $threadlist = ''; 196 $threadsInFid = array(); 197 if ($SETTINGS['dotfolders'] == 'on' && X_MEMBER) { 198 $query = $db->query("SELECT tid FROM ".X_PREFIX."posts WHERE author='$xmbuser' AND fid='$fid'"); 199 while($row = $db->fetch_array($query)) { 200 array_push($threadsInFid, $row['tid']); 201 } 202 $db->free_result($query); 203 } 204 205 $querytop = $db->query("SELECT t.*, m.uid FROM ".X_PREFIX."threads AS t LEFT JOIN ".X_PREFIX."members AS m ON t.author=m.username WHERE t.fid='$fid' $cusdate ORDER BY topped $ascdesc, lastpost $ascdesc LIMIT {$mpage['start']}, $tpp"); 206 while($thread = $db->fetch_array($querytop)) { 207 if ($thread['icon'] != '' && file_exists($smdir.'/'.$thread['icon'])) { 208 $thread['icon'] = '<img src="'.$smdir.'/'.$thread['icon'].'" alt="'.$thread['icon'].'" border="0" />'; 209 } else { 210 $thread['icon'] = ''; 211 } 212 213 if ($thread['topped'] == 1) { 214 $topimage = '<img src="'.$admdir.'/untop.gif" alt="'.$lang['textuntopthread'].'" border="0" />'; 215 } else { 216 $topimage = '<img src="'.$admdir.'/top.gif" alt="'.$lang['alttopthread'].'" border="0" />'; 217 } 218 219 $thread['subject'] = shortenString(rawHTMLsubject(stripslashes($thread['subject'])), 125, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...'); 220 221 if ($thread['author'] == $lang['textanonymous'] Or is_null($thread['uid'])) { 222 $authorlink = $thread['author']; 223 } else { 224 $authorlink = '<a href="member.php?action=viewpro&member='.recodeOut($thread['author']).'">'.$thread['author'].'</a>'; 225 } 226 227 $prefix = ''; 228 229 $lastpost = explode('|', $thread['lastpost']); 230 $dalast = trim($lastpost[0]); 231 232 if ($lastpost[1] != 'Anonymous') { 233 $lastpost[1] = '<a href="member.php?action=viewpro&member='.recodeOut(trim($lastpost[1])).'">'.trim($lastpost[1]).'</a>'; 234 } else { 235 $lastpost[1] = $lang['textanonymous']; 236 } 237 238 $lastPid = isset($lastpost[2]) ? $lastpost[2] : 0; 239 240 if ($thread['replies'] >= $SETTINGS['hottopic']) { 241 $folder = 'hot_folder.gif'; 242 } else { 243 $folder = 'folder.gif'; 244 } 245 246 $oldtopics = isset($oldtopics) ? $oldtopics : ''; 247 248 if (($oT = strpos($oldtopics, '|'.$lastPid.'|')) === false && $thread['replies'] >= $SETTINGS['hottopic'] && $lastvisit < $dalast) { 249 $folder = "hot_red_folder.gif"; 250 } else if ($lastvisit < $dalast && $oT === false) { 251 $folder = "red_folder.gif"; 252 } 253 254 if ($SETTINGS['dotfolders'] == 'on' && X_MEMBER && (count($threadsInFid) > 0) && in_array($thread['tid'], $threadsInFid)) { 255 $folder = 'dot_'.$folder; 256 } 257 258 $folder = '<img src="'.$imgdir.'/'.$folder.'" alt="'.$lang['altfolder'].'" border="0" />'; 259 260 if ($thread['closed'] == 'yes') { 261 $folder = '<img src="'.$imgdir.'/lock_folder.gif" alt="'.$lang['altclosedtopic'].'" border="0" />'; 262 } 263 264 $lastreplydate = gmdate($dateformat, $lastpost[0] + ($timeoffset * 3600) + ($addtime * 3600)); 265 $lastreplytime = gmdate($timecode, $lastpost[0] + ($timeoffset * 3600) + ($addtime * 3600)); 266 267 $lastpost = $lastreplydate.' '.$lang['textat'].' '.$lastreplytime.'<br />'.$lang['textby'].' '.$lastpost[1]; 268 269 $moved = explode('|', $thread['closed']); 270 if ($moved[0] == 'moved') { 271 $prefix = $lang['moved'].' '; 272 $thread['realtid'] = $thread['tid']; 273 $thread['tid'] = $moved[1]; 274 $thread['replies'] = "-"; 275 $thread['views'] = "-"; 276 $folder = '<img src="'.$imgdir.'/lock_folder.gif" alt="'.$lang['altclosedtopic'].'" border="0" />'; 277 $query = $db->query("SELECT COUNT(pid) FROM ".X_PREFIX."posts WHERE tid='$thread[tid]'"); 278 $postnum = 0; 279 if ($query !== false) { 280 $postnum = $db->result($query, 0); 281 } 282 } else { 283 $thread['realtid'] = $thread['tid']; 284 } 285 286 eval('$lastpostrow = "'.template('forumdisplay_thread_lastpost').'";'); 287 288 if ($thread['pollopts'] == 1) { 289 $prefix = $lang['pollprefix'].' '; 290 } 291 292 if ($thread['topped'] == 1) { 293 $prefix = $lang['toppedprefix'].' '.$prefix; 294 } 295 296 $mpurl = 'viewthread.php?tid='.$thread['tid']; 297 $multipage2 = multi(1, quickpage($thread['replies']+1, $ppp), $mpurl, FALSE); 298 if (strlen($multipage2) != 0) { 299 $multipage2 = "(<small>$multipage2</small>)"; 300 } 301 unset($mpurl); 302 303 eval('$threadlist .= "'.template($forumdisplay_thread).'";'); 304 305 $prefix = ''; 306 $topicsnum++; 307 } 308 $db->free_result($querytop); 309 310 if ($topicsnum == 0) { 311 eval('$threadlist = "'.template('forumdisplay_nothreads').'";'); 312 } 313 314 $check1 = $check5 = ''; 315 $check15 = $check30 = ''; 316 $check60 = $check100 = ''; 317 $checkyear = $checkall = ''; 318 switch($cusdate) { 319 case 86400: 320 $check1 = $selHTML; 321 break; 322 case 432000: 323 $check5 = $selHTML; 324 break; 325 case 1296000: 326 $check15 = $selHTML; 327 break; 328 case 2592000: 329 $check30 = $selHTML; 330 break; 331 case 5184000: 332 $check60 = $selHTML; 333 break; 334 case 8640000: 335 $check100 = $selHTML; 336 break; 337 case 31536000: 338 $checkyear = $selHTML; 339 break; 340 default: 341 $checkall = $selHTML; 342 break; 343 } 344 345 $query = $db->query("SELECT COUNT(tid) FROM ".X_PREFIX."threads WHERE fid='$fid'"); 346 $topicsnum = $db->result($query, 0); 347 $db->free_result($query); 348 349 eval('$sortby = "'.template('forumdisplay_sortby').'";'); 350 351 $multipage =& $mpage['html']; 352 if (strlen($mpage['html']) != 0) { 353 if ($status1 == 'Moderator') { 354 eval('$multipage = "'.template('forumdisplay_multipage_admin').'";'); 355 } else { 356 eval('$multipage = "'.template('forumdisplay_multipage').'";'); 357 } 358 } 359 360 if ($status1 == 'Moderator') { 361 if (X_ADMIN) { 362 $fadminlink = '<a href="cp.php?action=forum&fdetails='.$forum['fid'].'" title="'.$lang['alteditsettings'].'"><img src="'.$admdir.'/editforumsets.gif" border="0" /></a>'; 363 } else { 364 $fadminlink = ''; 365 } 366 eval('$forumdisplay = "'.template('forumdisplay_admin').'";'); 367 } else { 368 eval('$forumdisplay = "'.template('forumdisplay').'";'); 369 } 370 371 end_time(); 372 eval('$footer = "'.template('footer').'";'); 373 echo $header, $forumdisplay, $footer; 374 ?>
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 |