[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 define("IN_MYBB", 1); 12 define('THIS_SCRIPT', 'stats.php'); 13 14 $templatelist = "stats,stats_thread,stats_topforum"; 15 16 require_once "./global.php"; 17 require_once MYBB_ROOT."inc/functions_post.php"; 18 require_once MYBB_ROOT."inc/class_parser.php"; 19 $parser = new postParser; 20 21 // Load global language phrases 22 $lang->load("stats"); 23 24 add_breadcrumb($lang->nav_stats); 25 26 $stats = $cache->read("stats"); 27 28 if($stats['numthreads'] < 1 || $stats['numusers'] < 1) 29 { 30 error($lang->not_enough_info_stats); 31 } 32 33 if($mybb->settings['statsenabled'] != 1) 34 { 35 error($lang->stats_disabled); 36 } 37 38 $plugins->run_hooks("stats_start"); 39 40 $repliesperthread = my_number_format(round((($stats['numposts'] - $stats['numthreads']) / $stats['numthreads']), 2)); 41 $postspermember = my_number_format(round(($stats['numposts'] / $stats['numusers']), 2)); 42 $threadspermember = my_number_format(round(($stats['numthreads'] / $stats['numusers']), 2)); 43 44 // Get number of days since board start (might need improvement) 45 $query = $db->simple_select("users", "regdate", "", array('order_by' => 'regdate', 'limit' => 1)); 46 $result = $db->fetch_array($query); 47 $days = (TIME_NOW - $result['regdate']) / 86400; 48 if($days < 1) 49 { 50 $days = 1; 51 } 52 // Get "per day" things 53 $postsperday = my_number_format(round(($stats['numposts'] / $days), 2)); 54 $threadsperday = my_number_format(round(($stats['numthreads'] / $days), 2)); 55 $membersperday = my_number_format(round(($stats['numusers'] / $days), 2)); 56 57 // Get forum permissions 58 $unviewableforums = get_unviewable_forums(true); 59 $inactiveforums = get_inactive_forums(); 60 $unviewablefids = $inactivefids = array(); 61 $fidnot = ''; 62 63 if($unviewableforums) 64 { 65 $fidnot .= "AND fid NOT IN ($unviewableforums)"; 66 $unviewablefids = explode(',', $unviewableforums); 67 } 68 if($inactiveforums) 69 { 70 $fidnot .= "AND fid NOT IN ($inactiveforums)"; 71 $inactivefids = explode(',', $inactiveforums); 72 } 73 74 $unviewableforumsarray = array_merge($unviewablefids, $inactivefids); 75 76 // Check group permissions if we can't view threads not started by us 77 $group_permissions = forum_permissions(); 78 $onlyusfids = array(); 79 foreach($group_permissions as $gpfid => $forum_permissions) 80 { 81 if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1) 82 { 83 $onlyusfids[] = $gpfid; 84 } 85 } 86 87 // Most replied-to threads 88 $most_replied = $cache->read("most_replied_threads"); 89 90 if(!$most_replied) 91 { 92 $cache->update_most_replied_threads(); 93 $most_replied = $cache->read("most_replied_threads", true); 94 } 95 96 $mostreplies = ''; 97 if(!empty($most_replied)) 98 { 99 foreach($most_replied as $key => $thread) 100 { 101 if( 102 !in_array($thread['fid'], $unviewableforumsarray) && 103 (!in_array($thread['fid'], $onlyusfids) || ($mybb->user['uid'] && $thread['uid'] == $mybb->user['uid'])) 104 ) 105 { 106 $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); 107 $numberbit = my_number_format($thread['replies']); 108 $numbertype = $lang->replies; 109 $thread['threadlink'] = get_thread_link($thread['tid']); 110 eval("\$mostreplies .= \"".$templates->get("stats_thread")."\";"); 111 } 112 } 113 } 114 115 // Most viewed threads 116 $most_viewed = $cache->read("most_viewed_threads"); 117 118 if(!$most_viewed) 119 { 120 $cache->update_most_viewed_threads(); 121 $most_viewed = $cache->read("most_viewed_threads", true); 122 } 123 124 $mostviews = ''; 125 if(!empty($most_viewed)) 126 { 127 foreach($most_viewed as $key => $thread) 128 { 129 if( 130 !in_array($thread['fid'], $unviewableforumsarray) && 131 (!in_array($thread['fid'], $onlyusfids) || ($mybb->user['uid'] && $thread['uid'] == $mybb->user['uid'])) 132 ) 133 { 134 $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); 135 $numberbit = my_number_format($thread['views']); 136 $numbertype = $lang->views; 137 $thread['threadlink'] = get_thread_link($thread['tid']); 138 eval("\$mostviews .= \"".$templates->get("stats_thread")."\";"); 139 } 140 } 141 } 142 143 $statistics = $cache->read('statistics'); 144 $mybb->settings['statscachetime'] = (int)$mybb->settings['statscachetime']; 145 146 if($mybb->settings['statscachetime'] < 1) 147 { 148 $mybb->settings['statscachetime'] = 0; 149 } 150 151 $interval = $mybb->settings['statscachetime']*3600; 152 153 if(!$statistics || $interval == 0 || TIME_NOW - $interval > $statistics['time']) 154 { 155 $cache->update_statistics(); 156 $statistics = $cache->read('statistics'); 157 } 158 159 // Top forum 160 $query = $db->simple_select('forums', 'fid, name, threads, posts', "type='f'$fidnot", array('order_by' => 'posts', 'order_dir' => 'DESC', 'limit' => 1)); 161 $forum = $db->fetch_array($query); 162 163 if(!$forum) 164 { 165 $topforum = $lang->none; 166 $topforumposts = $lang->no; 167 $topforumthreads = $lang->no; 168 } 169 else 170 { 171 $forum['name'] = htmlspecialchars_uni(strip_tags($forum['name'])); 172 $forum['link'] = get_forum_link($forum['fid']); 173 eval("\$topforum = \"".$templates->get("stats_topforum")."\";"); 174 $topforumposts = $forum['posts']; 175 $topforumthreads = $forum['threads']; 176 } 177 178 // Top referrer defined for the templates even if we don't use it 179 $top_referrer = ''; 180 if($mybb->settings['statstopreferrer'] == 1 && isset($statistics['top_referrer']['uid'])) 181 { 182 // Only show this if we have anything more the 0 referrals 183 if($statistics['top_referrer']['referrals'] > 0) 184 { 185 $toprefuser = build_profile_link(htmlspecialchars_uni($statistics['top_referrer']['username']), $statistics['top_referrer']['uid']); 186 $top_referrer = $lang->sprintf($lang->top_referrer, $toprefuser, my_number_format($statistics['top_referrer']['referrals'])); 187 } 188 } 189 190 // Today's top poster 191 if(!isset($statistics['top_poster']['uid'])) 192 { 193 $topposter = $lang->nobody; 194 $topposterposts = $lang->no_posts; 195 } 196 else 197 { 198 if(!$statistics['top_poster']['uid']) 199 { 200 $topposter = $lang->guest; 201 } 202 else 203 { 204 $topposter = build_profile_link(htmlspecialchars_uni($statistics['top_poster']['username']), $statistics['top_poster']['uid']); 205 } 206 207 $topposterposts = $statistics['top_poster']['poststoday']; 208 } 209 210 // What percent of members have posted? 211 $posters = $statistics['posters']; 212 $havepostedpercent = my_number_format(round((($posters / $stats['numusers']) * 100), 2)) . "%"; 213 214 $lang->todays_top_poster = $lang->sprintf($lang->todays_top_poster, $topposter, my_number_format($topposterposts)); 215 $lang->popular_forum = $lang->sprintf($lang->popular_forum, $topforum, my_number_format($topforumposts), my_number_format($topforumthreads)); 216 217 $stats['numposts'] = my_number_format($stats['numposts']); 218 $stats['numthreads'] = my_number_format($stats['numthreads']); 219 $stats['numusers'] = my_number_format($stats['numusers']); 220 $stats['newest_user'] = build_profile_link($stats['lastusername'], $stats['lastuid']); 221 222 $plugins->run_hooks("stats_end"); 223 224 eval("\$stats = \"".$templates->get("stats")."\";"); 225 output_page($stats);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |