XMB PHP Cross Reference Discussion Forums

Source: /stats.php - 207 lines - 7405 bytes - Summary - Text - Print

Description: eXtreme Message Board XMB 1.9.11

   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', 'stats.php');
  26  
  27  require  'header.php';
  28  
  29  nav($lang['altstats']);
  30  
  31  loadtemplates('feature_statistics');
  32  
  33  smcwcache();
  34  
  35  if ($SETTINGS['stats'] == 'off') {
  36      header('HTTP/1.0 403 Forbidden');
  37      error($lang['fnasorry3'], TRUE);
  38  }
  39  
  40  setCanonicalLink('stats.php');
  41  eval('$css = "'.template('css').'";');
  42  eval('$header = "'.template('header').'";');
  43  
  44  $fids = permittedForums(forumCache(), 'thread', 'csv');
  45  if (strlen($fids) == 0) {
  46      $restrict = ' FALSE';
  47  } else {
  48      $restrict = ' fid IN ('.$fids.')';
  49  }
  50  
  51  $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");
  52  $members = $db->result($query, 0);
  53  if ($members == false) {
  54      $members = 0;
  55  }
  56  
  57  $threads = $db->result($query, 1);
  58  if ($threads == false) {
  59      $threads = 0;
  60  }
  61  
  62  $posts = $db->result($query, 2);
  63  if ($posts == false) {
  64      $posts = 0;
  65  }
  66  $db->free_result($query);
  67  
  68  $query = $db->query("SELECT regdate FROM ".X_PREFIX."members ORDER BY regdate LIMIT 0, 1");
  69  $days = ($onlinetime - @$db->result($query, 0)) / 86400;
  70  if ($days > 0) {
  71      $membersday = number_format(($members / $days), 2);
  72  } else {
  73      $membersday = number_format(0, 2);
  74  }
  75  $db->free_result($query);
  76  
  77  // Get total amount of forums
  78  $query = $db->query("SELECT COUNT(fid) FROM ".X_PREFIX."forums WHERE type='forum'");
  79  $forums = $db->result($query, 0);
  80  $db->free_result($query);
  81  
  82  // Get total amount of forums that are ON
  83  $query = $db->query("SELECT COUNT(fid) FROM ".X_PREFIX."forums WHERE type='forum' AND status='on'");
  84  $forumsa = $db->result($query, 0);
  85  $db->free_result($query);
  86  
  87  // Get total amount of members that actually posted...
  88  $query = $db->query("SELECT COUNT(postnum) FROM ".X_PREFIX."members WHERE postnum > '0'");
  89  $membersact = $db->result($query, 0);
  90  $db->free_result($query);
  91  
  92  // In case any of these is 0, the stats will show wrong info, take care of that
  93  if ($posts == 0 || $members == 0 || $threads == 0 || $forums == 0 || $days < 1) {
  94      message($lang['stats_incomplete']);
  95  }
  96  
  97  // Get amount of posts per user
  98  $mempost = 0;
  99  $query = $db->query("SELECT SUM(postnum) FROM ".X_PREFIX."members");
 100  $mempost = number_format(($db->result($query, 0) / $members), 2);
 101  $db->free_result($query);
 102  
 103  // Get amount of posts per forum
 104  $forumpost = 0;
 105  $query = $db->query("SELECT SUM(posts) FROM ".X_PREFIX."forums");
 106  $forumpost = number_format(($db->result($query, 0) / $forums), 2);
 107  $db->free_result($query);
 108  
 109  // Get amount of posts per thread
 110  $threadreply = 0;
 111  $query = $db->query("SELECT SUM(replies) FROM ".X_PREFIX."threads");
 112  $threadreply = number_format(($db->result($query, 0) / $threads), 2);
 113  $db->free_result($query);
 114  
 115  // Check the percentage of members that posted against the amount of members that didn't post
 116  $mapercent  = number_format(($membersact*100/$members), 2).'%';
 117  
 118  // Get top 5 most viewed threads
 119  $viewmost = array();
 120  $query = $db->query("SELECT views, tid, subject FROM ".X_PREFIX."threads WHERE $restrict ORDER BY views DESC LIMIT 5");
 121  while($views = $db->fetch_array($query)) {
 122      $views['subject'] = shortenString(rawHTMLsubject(stripslashes($views['subject'])), 125, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...');
 123      $viewmost[] = '<a href="viewthread.php?tid='.intval($views['tid']).'">'.$views['subject'].'</a> ('.$views['views'].')';
 124  }
 125  $viewmost = implode('<br />', $viewmost);
 126  $db->free_result($query);
 127  
 128  // Get top 5 most replied to threads
 129  $replymost = array();
 130  $query = $db->query("SELECT replies, tid, subject FROM ".X_PREFIX."threads WHERE $restrict ORDER BY replies DESC LIMIT 5");
 131  while($reply = $db->fetch_array($query)) {
 132      $reply['subject'] = shortenString(rawHTMLsubject(stripslashes($reply['subject'])), 125, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...');
 133      $replymost[] = '<a href="viewthread.php?tid='.intval($reply['tid']).'">'.$reply['subject'].'</a> ('.$reply['replies'].')';
 134  }
 135  $replymost = implode('<br />', $replymost);
 136  $db->free_result($query);
 137  
 138  // Get last 5 posts
 139  $latest = array();
 140  $query = $db->query("SELECT lastpost, tid, subject FROM ".X_PREFIX."threads WHERE $restrict ORDER BY lastpost DESC LIMIT 5");
 141  $adjTime = ($timeoffset * 3600) + ($addtime * 3600);
 142  while($last = $db->fetch_array($query)) {
 143      $lpdate = gmdate($dateformat, $last['lastpost'] + $adjTime);
 144      $lptime = gmdate($timecode, $last['lastpost'] + $adjTime);
 145      $thislast = $lang['lpoststats'].' '.$lang['lastreply1'].' '.$lpdate.' '.$lang['textat'].' '.$lptime;
 146      $last['subject'] = shortenString(rawHTMLsubject(stripslashes($last['subject'])), 125, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...');
 147      $latest[] = '<a href="viewthread.php?tid='.intval($last['tid']).'">'.$last['subject'].'</a> ('.$thislast.')';
 148  }
 149  $latest = implode('<br />', $latest);
 150  $db->free_result($query);
 151  
 152  // Get most popular forum
 153  if (strlen($fids) == 0) {
 154      $popforum = $lang['textnoforumsexist'];
 155  } else {
 156      $query = $db->query("SELECT posts, threads, fid, name FROM ".X_PREFIX."forums WHERE $restrict AND (type='sub' OR type='forum') AND status='on' ORDER BY posts DESC LIMIT 0, 1");
 157      $pop = $db->fetch_array($query);
 158      $popforum = '<a href="forumdisplay.php?fid='.intval($pop['fid']).'"><strong>'.fnameOut($pop['name']).'</strong></a>';
 159      $db->free_result($query);
 160  }
 161  
 162  // Get amount of posts per day
 163  $postsday = number_format($posts / $days, 2);
 164  
 165  // Get best member
 166  $timesearch = $onlinetime - 86400;
 167  $eval = $lang['evalnobestmember'];
 168  
 169  $query = $db->query("SELECT author, COUNT(author) AS Total FROM ".X_PREFIX."posts WHERE dateline >= '$timesearch' GROUP BY author ORDER BY Total DESC LIMIT 1");
 170  $info = $db->fetch_array($query);
 171  
 172  $bestmember = $info['author'];
 173  if ($bestmember == '') {
 174      $bestmember = 'Nobody';
 175      $bestmemberpost = 'No';
 176  } else {
 177      if ($info['Total'] != 0) {
 178          $membesthtml = '<a href="member.php?action=viewpro&amp;member='.recodeOut($bestmember).'"><strong>'.$bestmember.'</strong></a>';
 179          $bestmemberpost = $info['Total'];
 180          $eval = $lang['evalbestmember'];
 181      }
 182  }
 183  $db->free_result($query);
 184  
 185  eval($eval);
 186  eval($lang['evalstats1']);
 187  eval($lang['evalstats2']);
 188  eval($lang['evalstats3']);
 189  eval($lang['evalstats4']);
 190  eval($lang['evalstats5']);
 191  eval($lang['evalstats6']);
 192  eval($lang['evalstats7']);
 193  eval($lang['evalstats8']);
 194  eval($lang['evalstats9']);
 195  eval($lang['evalstats10']);
 196  eval($lang['evalstats11']);
 197  eval($lang['evalstats12']);
 198  eval($lang['evalstats13']);
 199  eval($lang['evalstats14']);
 200  eval($lang['evalstats15']);
 201  
 202  eval('$statspage = "'.template('feature_statistics').'";');
 203  
 204  end_time();
 205  eval('$footer = "'.template('footer').'";');
 206  echo $header, $statspage, $footer;
 207  ?>

title

Description

title

Description

title

Description

title

title

Body