| [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', 'index.php'); 29 30 require 'header.php'; 31 32 loadtemplates( 33 'index', 34 'index_category', 35 'index_category_hr', 36 'index_category_spacer', 37 'index_forum', 38 'index_forum_lastpost', 39 'index_forum_nolastpost', 40 'index_noforum', 41 'index_ticker', 42 'index_stats', 43 'index_welcome_guest', 44 'index_welcome_member', 45 'index_whosonline', 46 'index_whosonline_today' 47 ); 48 49 eval('$css = "'.template('css').'";'); 50 51 $ticker = ''; 52 if ($SETTINGS['tickerstatus'] == 'on') { 53 $contents = ''; 54 $news = explode("\n", str_replace(array("\r\n", "\r"), array("\n"), $SETTINGS['tickercontents'])); 55 $counter = 0; 56 for($i=0;$i<count($news);$i++) { 57 if (strlen(trim($news[$i])) == 0) { 58 continue; 59 } 60 61 $news[$i] = str_replace('\"', '"', addslashes(postify($news[$i], 'no', 'no', 'yes', 'yes', 'yes', 'yes', false, 'yes', 'no'))); 62 $contents .= "\tcontents[$counter]='{$news[$i]}';\n"; 63 $counter++; 64 } 65 eval('$ticker = "'.template('index_ticker').'";'); 66 } 67 68 if (onSubmit('gid')) { 69 $gid = getInt('gid'); 70 $SETTINGS['tickerstatus'] = 'off'; 71 $SETTINGS['whosonlinestatus'] = 'off'; 72 $SETTINGS['index_stats'] = 'off'; 73 $cat = getForum($gid); 74 if ($cat === FALSE) { 75 header('HTTP/1.0 404 Not Found'); 76 error($lang['textnocat']); 77 } elseif ($cat['type'] != 'group' Or $cat['status'] != 'on') { 78 header('HTTP/1.0 404 Not Found'); 79 error($lang['textnocat']); 80 } 81 setCanonicalLink("index.php?gid=$gid"); 82 nav(fnameOut($cat['name'])); 83 if ($SETTINGS['subject_in_title'] == 'on') { 84 $threadSubject = '- '.fnameOut($cat['name']); 85 } 86 } else { 87 $gid = 0; 88 setCanonicalLink('./'); 89 } 90 91 eval('$header = "'.template('header').'";'); 92 93 $statsbar = ''; 94 if ($SETTINGS['index_stats'] == 'on') { 95 $query = $db->query("SELECT username FROM ".X_PREFIX."members WHERE lastvisit!=0 ORDER BY regdate DESC LIMIT 1"); 96 $lastmember = $db->fetch_array($query); 97 $db->free_result($query); 98 99 $query = $db->query("SELECT COUNT(uid) FROM ".X_PREFIX."members UNION ALL SELECT COUNT(tid) FROM ".X_PREFIX."threads UNION ALL SELECT COUNT(pid) FROM ".X_PREFIX."posts"); 100 $members = $db->result($query, 0); 101 if ($members == false) { 102 $members = 0; 103 } 104 105 $threads = $db->result($query, 1); 106 if ($threads == false) { 107 $threads = 0; 108 } 109 110 $posts = $db->result($query, 2); 111 if ($posts == false) { 112 $posts = 0; 113 } 114 $db->free_result($query); 115 116 $memhtml = '<a href="member.php?action=viewpro&member='.recodeOut($lastmember['username']).'"><strong>'.$lastmember['username'].'</strong></a>.'; 117 eval($lang['evalindexstats']); 118 eval('$statsbar = "'.template('index_stats').'";'); 119 } 120 121 if ($gid == 0) { 122 if (X_MEMBER) { 123 eval('$welcome = "'.template('index_welcome_member').'";'); 124 } else { 125 eval('$welcome = "'.template('index_welcome_guest').'";'); 126 } 127 128 $whosonline = $whosonlinetoday = ''; 129 if ($SETTINGS['whosonlinestatus'] == 'on') { 130 $hiddencount = 0; 131 $membercount = 0; 132 $guestcount = $db->result($db->query("SELECT COUNT(DISTINCT ip) AS guestcount FROM ".X_PREFIX."whosonline WHERE username = 'xguest123'"), 0); 133 $member = array(); 134 $query = $db->query("SELECT m.username, MAX(m.status) AS status, MAX(m.invisible) AS invisible FROM ".X_PREFIX."members AS m INNER JOIN ".X_PREFIX."whosonline USING (username) GROUP BY m.username ORDER BY m.username"); 135 while($online = $db->fetch_array($query)) { 136 if ($online['invisible'] != 0 && X_ADMIN) { 137 $member[] = $online; 138 $hiddencount++; 139 } else if ($online['invisible'] != 0) { 140 $hiddencount++; 141 } else { 142 $member[] = $online; 143 $membercount++; 144 } 145 } 146 $db->free_result($query); 147 148 $onlinetotal = $guestcount + $membercount; 149 150 if ($membercount != 1) { 151 $membern = '<strong>'.$membercount.'</strong> '.$lang['textmembers']; 152 } else { 153 $membern = '<strong>1</strong> '.$lang['textmem']; 154 } 155 156 if ($guestcount != 1) { 157 $guestn = '<strong>'.$guestcount.'</strong> '.$lang['textguests']; 158 } else { 159 $guestn = '<strong>1</strong> '.$lang['textguest1']; 160 } 161 162 if ($hiddencount != 1) { 163 $hiddenn = '<strong>'.$hiddencount.'</strong> '.$lang['texthmems']; 164 } else { 165 $hiddenn = '<strong>1</strong> '.$lang['texthmem']; 166 } 167 168 eval($lang['whosoneval']); 169 $memonmsg = '<span class="smalltxt">'.$lang['whosonmsg'].'</span>'; 170 171 $memtally = array(); 172 $num = 1; 173 $show_total = (X_ADMIN) ? ($membercount+$hiddencount) : ($membercount); 174 175 $show_inv_key = false; 176 for($mnum=0; $mnum<$show_total; $mnum++) { 177 $pre = $suff = ''; 178 179 $online = $member[$mnum]; 180 181 $pre = '<span class="status_'.str_replace(' ', '_', $online['status']).'">'; 182 $suff = '</span>'; 183 184 if ($online['invisible'] != 0) { 185 $pre .= '<strike>'; 186 $suff = '</strike>'.$suff; 187 if (!X_ADMIN && $online['username'] != $xmbuser) { 188 $num++; 189 continue; 190 } 191 } 192 193 if ($online['username'] == $xmbuser && $online['invisible'] != 0) { 194 $show_inv_key = true; 195 } 196 197 $memtally[] = '<a href="member.php?action=viewpro&member='.recodeOut($online['username']).'">'.$pre.''.$online['username'].''.$suff.'</a>'; 198 $num++; 199 } 200 201 if (X_ADMIN || $show_inv_key === true) { 202 $hidden = ' - <strike>'.$lang['texthmem'].'</strike>'; 203 } else { 204 $hidden = ''; 205 } 206 207 $memtally = implode(', ', $memtally); 208 if ($memtally == '') { 209 $memtally = ' '; 210 } 211 212 $whosonlinetoday = ''; 213 if ($SETTINGS['onlinetoday_status'] == 'on') { 214 $datecut = $onlinetime - (3600 * 24); 215 if (X_ADMIN) { 216 $query = $db->query("SELECT username, status FROM ".X_PREFIX."members WHERE lastvisit >= '$datecut' ORDER BY lastvisit DESC"); 217 } else { 218 $query = $db->query("SELECT username, status FROM ".X_PREFIX."members WHERE lastvisit >= '$datecut' AND invisible!=1 ORDER BY lastvisit DESC"); 219 } 220 221 $todaymembersnum = $db->num_rows($query); 222 $todaymembers = array(); 223 $pre = $suff = ''; 224 $x = 0; 225 while($memberstoday = $db->fetch_array($query)) { 226 if ($x <= $onlinetodaycount) { 227 $pre = '<span class="status_'.str_replace(' ', '_', $memberstoday['status']).'">'; 228 $suff = '</span>'; 229 $todaymembers[] = '<a href="member.php?action=viewpro&member='.recodeOut($memberstoday['username']).'">'.$pre.''.$memberstoday['username'].''.$suff.'</a>'; 230 $x++; 231 } else { 232 continue; 233 } 234 } 235 $todaymembers = implode(', ', $todaymembers); 236 $db->free_result($query); 237 238 if ($todaymembersnum == 1) { 239 $memontoday = $todaymembersnum.$lang['textmembertoday']; 240 } else { 241 $memontoday = $todaymembersnum.$lang['textmemberstoday']; 242 } 243 eval($lang['last50todayeval']); 244 eval('$whosonlinetoday = "'.template('index_whosonline_today').'";'); 245 } 246 247 eval('$whosonline = "'.template('index_whosonline').'";'); 248 } 249 250 $forums = getStructuredForums(TRUE); 251 $fquery = getIndexForums($forums); 252 } else { 253 $ticker = $welcome = $whosonline = $statsbar = $whosonlinetoday = ''; 254 255 $forums = getStructuredForums(TRUE); 256 $fquery = array(); 257 if (isset($forums['forum'][$cat['fid']])) { 258 foreach($forums['forum'][$cat['fid']] as $forum) { 259 $forum['cat_fid'] = $cat['fid']; 260 $forum['cat_name'] = $cat['name']; 261 $fquery[] = $forum; 262 } 263 } 264 } 265 266 $indexBarTop = $indexBar = $forumlist = $spacer = ''; 267 $forumarray = array(); 268 $catLessForums = $lastcat = 0; 269 270 if ($SETTINGS['space_cats'] == 'on') { 271 eval('$spacer = "'.template('index_category_spacer').'";'); 272 } 273 274 if ($SETTINGS['catsonly'] != 'on') { 275 if ($SETTINGS['indexshowbar'] == 1) { 276 eval('$indexBar = "'.template('index_category_hr').'";'); 277 $indexBarTop = $indexBar; 278 } 279 280 if ($SETTINGS['indexshowbar'] == 2) { 281 eval('$indexBarTop = "'.template('index_category_hr').'";'); 282 } 283 } else if ($gid > 0) { 284 eval('$indexBar = "'.template('index_category_hr').'";'); 285 } 286 287 // Collect Subforums ordered by fup, displayorder 288 $index_subforums = array(); 289 if ($SETTINGS['showsubforums'] == 'on') { 290 if ($SETTINGS['catsonly'] != 'on' || $gid > 0) { 291 foreach($forums['sub'] as $subForumsByFUP) { 292 foreach($subForumsByFUP as $forum) { 293 $index_subforums[] = $forum; 294 } 295 } 296 } 297 } 298 299 foreach($fquery as $thing) { 300 301 if ($SETTINGS['catsonly'] != 'on' || $gid > 0) { 302 $cforum = forum($thing, "index_forum", $index_subforums); 303 } else { 304 $cforum = ''; 305 } 306 307 if ((int)$thing['cat_fid'] === 0) { 308 $catLessForums++; 309 } 310 311 if ($lastcat != $thing['cat_fid'] && ($SETTINGS['catsonly'] == 'on' || (!empty($cforum) && $SETTINGS['catsonly'] != 'on'))) { 312 if ($forumlist != '') { 313 $forumarray[] = $forumlist; 314 $forumlist = ''; 315 } 316 $lastcat = $thing['cat_fid']; 317 $thing['cat_name'] = fnameOut($thing['cat_name']); 318 eval('$forumlist .= "'.template('index_category').'";'); 319 if ($SETTINGS['catsonly'] != 'on' || $gid > 0) { 320 $forumlist .= $indexBar; 321 } 322 } 323 324 if (!empty($cforum)) { 325 $forumlist .= $cforum; 326 } 327 328 } 329 330 $forumarray[] = $forumlist; 331 $forumlist = implode($spacer, $forumarray); 332 333 if ($forumlist == '') { 334 eval('$forumlist = "'.template('index_noforum').'";'); 335 } 336 unset($fquery); 337 338 if ($catLessForums == 0 && $SETTINGS['indexshowbar'] == 1) { 339 $indexBarTop = ''; 340 } 341 342 eval('$index = "'.template('index').'";'); 343 end_time(); 344 eval('$footer = "'.template('footer').'";'); 345 echo $header, $index, $footer; 346 347 /** 348 * @param array $forums Read-Only Variable. Must be a return value from the function getStructuredForums() 349 * @return array Two-dimensional array of forums sorted by the group's displayorder, then the forum's displayorder. 350 */ 351 function getIndexForums(&$forums) { 352 global $db, $SETTINGS; 353 354 // First sort the groups by displayorder. 355 $groups = array(); 356 foreach($forums['group']['0'] as $group) { 357 $group['cat_fid'] = $group['fid']; 358 $group['cat_name'] = $group['name']; 359 $groups[$group['displayorder']] = $group; 360 } 361 ksort($groups); 362 363 if ($SETTINGS['catsonly'] == 'on') { 364 $sorted =& $groups; 365 } else { 366 // Now simply sort the forums by each group. Remember to put ungrouped forums first. 367 $sorted = array(); 368 foreach($forums['forum']['0'] as $forum) { 369 $forum['cat_fid'] = ''; 370 $forum['cat_name'] = ''; 371 $sorted[] = $forum; 372 } 373 foreach($groups as $group) { 374 if (isset($forums['forum'][$group['fid']])) { 375 foreach($forums['forum'][$group['fid']] as $forum) { 376 $forum['cat_fid'] = $group['fid']; 377 $forum['cat_name'] = $group['name']; 378 $sorted[] = $forum; 379 } 380 } 381 } 382 } 383 384 return $sorted; 385 } 386 387 ?>
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 |