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