3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2014 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2014 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: stats.php - Last Update: 07/21/2014 SVN 792 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="stats.php"||$File3Name=="/stats.php") {
20 if($_GET['act']=="stats") {
21 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=stats","&","=",$prexqstr['index'],$exqstr['index']);
22 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
23 $_SESSION['ViewingFile'] = $exfile['index'].$Settings['file_ext']; }
24 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
25 $_SESSION['ViewingFile'] = $exfile['index']; }
26 $_SESSION['PreViewingTitle'] = "Viewing";
27 $_SESSION['ViewingTitle'] = "Board Stats";
28 $_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:0; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;";
30 <div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>"><?php echo $Settings['board_name']; ?></a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=stats",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>#bstats">Board Statistics</a></div>
31 <div class="DivNavLinks"> </div>
33 $uolcuttime = $utccurtime->getTimestamp();
34 $uoltime = $uolcuttime - ini_get("session.gc_maxlifetime");
35 $uolquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."sessions\" WHERE \"expires\" >= %i ORDER BY \"expires\" DESC", array($uoltime));
36 $uolresult=sql_query($uolquery,$SQLStat);
37 $uolnum=sql_num_rows($uolresult);
38 $uoli=0; $olmn = 0; $olgn = 0; $olan = 0; $olmbn = 0;
39 $MembersOnline = null; $GuestsOnline = null;
40 while ($uoli < $uolnum) {
41 $session_data=sql_result($uolresult,$uoli,"session_data");
42 $serialized_data=sql_result($uolresult,$uoli,"serialized_data");
43 $session_user_agent=sql_result($uolresult,$uoli,"user_agent");
44 $session_ip_address=sql_result($uolresult,$uoli,"ip_address");
45 //$UserSessInfo = unserialize_session($session_data);
46 $UserSessInfo = unserialize($serialized_data);
47 if(!isset($UserSessInfo['UserGroup'])) { $UserSessInfo['UserGroup'] = $Settings['GuestGroup']; }
48 $AmIHiddenUser = "no";
49 $user_agent_check = false;
50 if(user_agent_check($session_user_agent)) {
51 $user_agent_check = user_agent_check($session_user_agent); }
52 if($UserSessInfo['UserGroup']!=$Settings['GuestGroup']||$user_agent_check!==false) {
53 $PreAmIHiddenUser = GetUserName($UserSessInfo['UserID'],$Settings['sqltable'],$SQLStat);
54 $AmIHiddenUser = $PreAmIHiddenUser['Hidden'];
55 if(($AmIHiddenUser=="no"&&$UserSessInfo['UserID']>0)||$user_agent_check!==false) {
56 if($olmbn>0) { $MembersOnline .= ", "; }
57 if($user_agent_check===false) {
59 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($session_user_agent, ENT_QUOTES, $Settings['charset'])."\""; }
60 $MembersOnline .= "<a".$uatitleadd." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UserSessInfo['UserID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$UserSessInfo['MemberName']."</a>";
61 if($GroupInfo['CanViewIPAddress']=="yes") {
62 $MembersOnline .= " (<a title=\"".$session_ip_address."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$session_ip_address)."\">".$session_ip_address."</a>)"; }
64 if($user_agent_check!==false) {
66 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($session_user_agent, ENT_QUOTES, $Settings['charset'])."\""; }
67 $MembersOnline .= "<span".$uatitleadd.">".$user_agent_check."</span>";
68 if($GroupInfo['CanViewIPAddress']=="yes") {
69 $MembersOnline .= " (<a title=\"".$session_ip_address."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$session_ip_address)."\">".$session_ip_address."</a>)"; }
71 if($UserSessInfo['UserID']<=0||$AmIHiddenUser=="yes") {
72 if($user_agent_check===false) {
74 if($UserSessInfo['UserGroup']==$Settings['GuestGroup']) {
76 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($session_user_agent, ENT_QUOTES, $Settings['charset'])."\""; }
77 $GuestsOnline .= "<a".$uatitleadd." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$MemList['ID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$MemList['Name']."</a>";
78 if($GroupInfo['CanViewIPAddress']=="yes") {
79 $GuestsOnline .= " (<a title=\"".$session_ip_address."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$session_ip_address)."\">".$session_ip_address."</a>)"; } */
82 if($_GET['act']=="view"||$_GET['act']=="stats") {
83 $ntquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\"".$ForumIgnoreList3, array(null));
84 $ntresult = sql_query($ntquery,$SQLStat);
85 $numtopics = sql_result($ntresult,0);
86 sql_free_result($ntresult);
87 $npquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."posts\"".$ForumIgnoreList3, array(null));
88 $npresult = sql_query($npquery,$SQLStat);
89 $numposts = sql_result($npresult,0);
90 sql_free_result($npresult);
91 if($Settings['AdminValidate']=="on") {
92 $nmquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\">=%i AND \"HiddenMember\"='no' AND \"Validated\"='yes' AND \"GroupID\"<>%i ORDER BY \"Joined\" DESC LIMIT 1", array(1,$Settings['ValidateGroup']));
93 $rnmquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."members\" WHERE \"id\">=%i AND \"HiddenMember\"='no' AND \"Validated\"='yes' AND \"GroupID\"<>%i", array(1,$Settings['ValidateGroup'])); }
94 if($Settings['AdminValidate']!="on") {
95 $nmquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\">=%i AND \"HiddenMember\"='no' ORDER BY \"Joined\" DESC LIMIT 1", array(1,$Settings['ValidateGroup']));
96 $rnmquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."members\" WHERE \"id\">=%i AND \"HiddenMember\"='no'", array(1,$Settings['ValidateGroup'])); }
97 $nmresult = sql_query($nmquery,$SQLStat);
98 $rnmresult = sql_query($rnmquery,$SQLStat);
99 //$nummembers = sql_num_rows($nmresult);
100 $nummembers = sql_result($rnmresult,0);
101 sql_free_result($rnmresult);
102 $NewestMem = array(null);
103 $NewestMem['ID'] = "0"; $NewestMem['Name'] = "Anonymous";
105 $NewestMem['ID']=sql_result($nmresult,0,"id");
106 $NewestMem['Name']=sql_result($nmresult,0,"Name");
107 $NewestMem['IP']=sql_result($nmresult,0,"IP"); }
108 if($nummembers<=0) { $NewestMem['ID'] = 0; }
109 if($NewestMem['ID']<=0) { $NewestMem['ID'] = "0"; $NewestMem['Name'] = "Anonymous"; $NewestMem['IP'] = "127.0.0.1"; }
110 $NewestMemTitle = null;
111 $NewestMemExtraIP = null;
112 if($GroupInfo['CanViewIPAddress']=="yes") {
113 $NewestMemTitle = " title=\"".$NewestMem['IP']."\"";
114 $NewestMemExtraIP = " (<a title=\"".$NewestMem['IP']."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$NewestMem['IP'])."\">".$NewestMem['IP']."</a>)"; }
115 $bdMonthChCk = $usercurtime->format("m");
116 $bdDayChCk = $usercurtime->format("d");
117 if($Settings['AdminValidate']=="on") {
118 $bdquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"BirthDay\"=%i AND \"BirthMonth\"=%i AND \"HiddenMember\"='no' AND \"Validated\"='yes' AND \"GroupID\"<>%i ORDER BY \"id\"", array($bdDayChCk,$bdMonthChCk,$Settings['ValidateGroup'])); }
119 if($Settings['AdminValidate']!="on") {
120 $bdquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"BirthDay\"=%i AND \"BirthMonth\"=%i AND \"HiddenMember\"='no' ORDER BY \"id\"", array($bdDayChCk,$bdMonthChCk)); }
121 $bdresult = sql_query($bdquery,$SQLStat);
122 $bdmembers = sql_num_rows($bdresult); $bdi = 0;
123 if($bdmembers>0) { $bdstring = $bdmembers." member(s) have a birthday today"; }
124 if($bdmembers<=0) { $bdstring = "<div> </div> No members have a birthday today<div> </div>"; }
125 while ($bdi < $bdmembers) {
126 $bdmemberz = $bdmembers - 1;
127 $birthday['ID']=sql_result($bdresult,$bdi,"id");
128 $birthday['Name']=sql_result($bdresult,$bdi,"Name");
129 $birthday['IP']=sql_result($bdresult,$bdi,"IP");
130 $birthday['BirthYear']=sql_result($bdresult,$bdi,"BirthYear");
131 $bdThisYear = $usercurtime->format("Y");
132 $birthday['Age'] = $bdThisYear - $birthday['BirthYear'];
134 if($GroupInfo['HasAdminCP']=="yes") {
135 $bdMemTitle = " title=\"".$birthday['IP']."\""; }
136 if($bdi===0) { $bdstring = $bdstring."\n<br /> "; }
137 $bdMemURL = "<a".$bdMemTitle." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$birthday['ID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$birthday['Name']."</a>";
138 if($bdi<$bdmemberz) { $bdstring = $bdstring.$bdMemURL." (<span style=\"font-weight: bold;\" title=\"".$birthday['Name']." is ".$birthday['Age']." years old\">".$birthday['Age']."</span>), "; }
139 if($bdi==$bdmemberz) { $bdstring = $bdstring.$bdMemURL." (<span style=\"font-weight: bold;\" title=\"".$birthday['Name']." is ".$birthday['Age']." years old\">".$birthday['Age']."</span>)"; }
141 sql_free_result($bdresult);
142 $active_month = $usercurtime->format("m");
143 $active_day = $usercurtime->format("d");
144 $active_year = $usercurtime->format("Y");
145 $active_start = mktime(0,0,0,$active_month,$active_day,$active_year);
146 $active_end = mktime(23,59,59,$active_month,$active_day,$active_year);
147 $tdMembersOnline = null;
148 $ggquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"Name\"='%s'", array($Settings['GuestGroup']));
149 $ggresult=sql_query($ggquery,$SQLStat);
150 $GGroup=sql_result($ggresult,0,"id");
151 sql_free_result($ggresult);
152 $tdquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"GroupID\"<>%i AND \"id\">=0 AND \"HiddenMember\"='no' AND (\"LastActive\">=%i AND \"LastActive\"<=%i) ORDER BY \"LastActive\" DESC", array($GGroup,$active_start,$active_end));
153 $tdrnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."members\" WHERE \"GroupID\"<>%i AND \"id\">=0 AND \"HiddenMember\"='no' AND (\"LastActive\">=%i AND \"LastActive\"<=%i)", array($GGroup,$active_start,$active_end));
154 $tdrnresult=sql_query($tdrnquery,$SQLStat);
155 $tdNumberMembers=sql_result($tdrnresult,0);
156 $tdresult=sql_query($tdquery,$SQLStat);
157 $tdnum=sql_num_rows($tdresult);
159 while($tdi < $tdnum) {
160 $tdMemList['ID']=sql_result($tdresult,$tdi,"id");
161 $tdMemList['Name']=sql_result($tdresult,$tdi,"Name");
162 $tdMemList['IP']=sql_result($tdresult,$tdi,"IP");
163 $tdMemList['LastActive']=sql_result($tdresult,$tdi,"LastActive");
164 $tmpusrcurtime = new DateTime();
165 $tmpusrcurtime->setTimestamp($tdMemList['LastActive']);
166 $tmpusrcurtime->setTimezone($usertz);
167 $tdMemList['LastActive']=$tmpusrcurtime->format("M j Y, ".$_SESSION['iDBTimeFormat']);
168 if($tdi>0) { $tdMembersOnline .= ", "; }
169 $tdMembersOnline .= "<a title=\"".$tdMemList['Name']." was last active at ".$tdMemList['LastActive']."\" href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$tdMemList['ID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$tdMemList['Name']."</a>";
170 if($GroupInfo['CanViewIPAddress']=="yes") {
171 $tdMembersOnline .= " (<a title=\"".$tdMemList['IP']."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$tdMemList['IP'])."\">".$tdMemList['IP']."</a>)"; }
174 <div class="StatsBorder">
175 <?php if($ThemeSet['TableStyle']=="div") { ?>
176 <div class="TableStatsRow1">
177 <span style="text-align: left;">
178 <?php echo $ThemeSet['TitleIcon']; ?><a id="bstats" href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=stats",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>#bstats">Board Statistics</a></span></div>
180 <table id="BoardStats" class="TableStats1">
181 <?php if($ThemeSet['TableStyle']=="table") { ?>
182 <tr class="TableStatsRow1">
183 <td class="TableStatsColumn1" colspan="2"><span style="text-align: left;">
184 <?php echo $ThemeSet['TitleIcon']; ?><a id="bstats" href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=stats",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>#bstats">Board Statistics</a></span>
187 <tr id="Stats1" class="TableStatsRow2">
188 <td class="TableStatsColumn2" colspan="2" style="width: 100%; font-weight: bold;"><?php echo $uolnum; ?> users online</td>
190 <tr class="TableStatsRow3" id="Stats2">
191 <td style="width: 4%;" class="TableStatsColumn3"><div class="statsicon">
192 <?php echo $ThemeSet['StatsIcon']; ?></div></td>
193 <td style="width: 96%;" class="TableStatsColumn3"><div class="statsinfo">
194 <span style="font-weight: bold;"><?php echo $olgn; ?></span> guests, <span style="font-weight: bold;"><?php echo $olmn; ?></span> members, <span style="font-weight: bold;"><?php echo $olan; ?></span> anonymous members <br />
195 <?php if($MembersOnline==null) { ?> <?php echo "\n<br />"; } ?>
196 <?php if($MembersOnline!=null) { ?> <?php echo $MembersOnline."\n<br />"; } ?>
197 Show detailed by: <a href="<?php echo url_maker($exfile['member'],$Settings['file_ext'],"act=online&list=all&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']); ?>">Last Click</a>, <a href="<?php echo url_maker($exfile['member'],$Settings['file_ext'],"act=online&list=members&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']); ?>">Member Name</a>
200 <tr id="Stats3" class="TableStatsRow2">
201 <td class="TableStatsColumn2" colspan="2" style="width: 100%; font-weight: bold;">Today's Birthdays</td>
203 <tr class="TableStatsRow3" id="Stats4">
204 <td style="width: 4%;" class="TableStatsColumn3"><div class="statsicon">
205 <?php echo $ThemeSet['StatsIcon']; ?></div></td>
206 <td style="width: 96%;" class="TableStatsColumn3"><div class="statsinfo">
207 <?php echo $bdstring; ?>
210 <tr id="Stats4" class="TableStatsRow2">
211 <td class="TableStatsColumn2" colspan="2" style="width: 100%; font-weight: bold;">Board Stats</td>
213 <tr class="TableStatsRow3" id="Stats6">
214 <td style="width: 4%;" class="TableStatsColumn3"><div class="statsicon">
215 <?php echo $ThemeSet['StatsIcon']; ?></div></td>
216 <td style="width: 96%;" class="TableStatsColumn3"><div class="statsinfo">
217 Our members have made a total of <?php echo $numposts; ?> posts<br />
218 Our members have made a total of <?php echo $numtopics; ?> topics<br />
219 We have <?php echo $nummembers; ?> registered members<br />
220 Our newest member is <a<?php echo $NewestMemTitle; ?> href="<?php echo url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$NewestMem['ID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']); ?>"><?php echo $NewestMem['Name']; ?></a><?php echo $NewestMemExtraIP; ?>
223 <tr id="Stats5" class="TableStatsRow2">
224 <td class="TableStatsColumn2" colspan="2" style="width: 100%; font-weight: bold;">Members Online Today: <?php echo $tdNumberMembers; ?></td>
226 <tr class="TableStatsRow3" id="Stats6">
227 <td style="width: 4%;" class="TableStatsColumn3"><div class="statsicon">
228 <?php echo $ThemeSet['StatsIcon']; ?></div></td>
229 <td style="width: 96%;" class="TableStatsColumn3"><div class="statsinfo">
230 Number of members online today: <?php echo $tdNumberMembers; ?><br />
231 The following members have visited today:<br />
232 <?php echo $tdMembersOnline; ?>
235 <tr id="Stats6" class="TableStatsRow4">
236 <td class="TableStatsColumn4" colspan="2"> </td>
239 <div class="DivStats"> </div>