XMB PHP Cross Reference Discussion Forums

Source: /index.php - 383 lines - 12502 bytes - Summary - Text - Print

Description: eXtreme Message Board XMB 1.9.11 Developed And Maintained By The XMB Group Copyright (c) 2001-2012, The XMB Group http://www.xmbforum2.com/

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

title

Description

title

Description

title

Description

title

title

Body