forked from joeroberts234/phpMyBitTorrent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflashscores2.php
234 lines (227 loc) · 7.4 KB
/
flashscores2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/*
*----------------------------phpMyBitTorrent V 2.0-beta4-----------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*-------------- Created By Antonio Anzivino (aka DJ Echelon) --------------*
*------------- http://www.p2pmania.it -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*------------- http://www.bittorrent.com -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*-- This program is free software; you can redistribute it and/or modify --*
*-- it under the terms of the GNU General Public License as published by --*
*-- the Free Software Foundation; either version 2 of the License, or --*
*-- (at your option) any later version. --*
*-- --*
*-- This program is distributed in the hope that it will be useful, --*
*-- but WITHOUT ANY WARRANTY; without even the implied warranty of --*
*-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --*
*-- GNU General Public License for more details. --*
*-- --*
*-- You should have received a copy of the GNU General Public License --*
*-- along with this program; if not, write to the Free Software --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --*
*-- --*
*------------------------------------------------------------------------------*
*------ ©2005 phpMyBitTorrent Development Team ------*
*----------- http://phpmybittorrent.com -----------*
*------------------------------------------------------------------------------*
*----------------- Sunday, September 14, 2008 9:05 PM ---------------------*
*/
include("header.php");
global $db, $db_prefix;
OpenTable("Score Stats");
if (!is_user($btuser)) loginrequired("user");
?>
<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td class=text>
<div align=center><CENTER><I>Stats from all Games Played</CENTER>
<?php
$ID=0;
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores GROUP BY user");
while($populate = $db->sql_fetchrow($result))
{
$ID++;
if(!isset($gamesplayed[$ID]))
{
$gamesplayed[$ID]=0;
}
if(!isset($totalscore[$ID]))
{
$totalscore[$ID]=0;
}
if(!isset($megascore[$ID]))
{
$megascore[$ID]=0;
}
if(!isset($losspoints[$ID]))
{
$losspoints[$ID]=0;
}
if(!isset($averagerank[$ID]))
{
$averagerank[$ID]=0;
}
if(!isset($player[$populate["user"]]))
{
$player[$populate["user"]]=$ID;
}
if(!isset($IDofuser[$ID]))
{
$IDofuser[$ID]=$populate["user"];
}
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores ORDER BY score DESC");
while($scores = $db->sql_fetchrow($result))
{
$ranking = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE game = ".$scores["game"]." AND score > ".$scores["score"]."") OR DIE(MySQL_ERROR());
if($rankrow = $db->sql_fetchrow($ranking))
{
$rank = $rankrow[0]+1;
}else{
$rank = 1;
}
$losspoints[$player[$scores["user"]]]+=$rank;
if($rank<6)
{
$totalscore[$player[$scores["user"]]]+=(10-(($rank-1)*2));
}
$megascore[$player[$scores["user"]]]+=$scores["score"];
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores GROUP BY user");
while($scores = $db->sql_fetchrow($result))
{
$result2 = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE user = ".$scores["user"]."");
if($gamesamount = $db->sql_fetchrow($result2))
{
$amountofgames = $gamesamount[0];
}
$gamesplayed[$player[$scores["user"]]]=$amountofgames;
}
arsort ($totalscore);
reset ($totalscore);
print("<TABLE><TR><TD COLSPAN=2><B><CENTER>Rank Based Scores</CENTER></B></TD></TR>");
while (list ($userID, $score) = each ($totalscore)) {
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = '".$IDofuser[$userID]."'")or bterr(result);
if($userX = $db->sql_fetchrow($result))
{
$username = $userX["username"];
}else{
$username = "Unknown?!";
}
if($score>0)
{
if($IDofuser[$userID]==$user->id)
{
echo "<TR style=\"background-color: #BBBBBB\"><TD>$username</TD><TD>$score</TD></TR>";
}else{
echo "<TR><TD>$username</TD><TD>$score</TD></TR>";
}
}
}
print("</TABLE><P>");
arsort ($gamesplayed);
reset ($gamesplayed);
print("<TABLE><TR><TD COLSPAN=2><B><CENTER>Number of games played</CENTER></B></TD></TR>");
while (list ($userID, $games) = each ($gamesplayed)) {
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = '".$IDofuser[$userID]."'");
if($userX = $db->sql_fetchrow($result))
{
$username = $userX["username"];
}else{
$username = "Unknown?!";
}
if($games>0)
{
if($IDofuser[$userID]==$user->id)
{
echo "<TR style=\"background-color: #BBBBBB\"><TD>$username</TD><TD>$games</TD></TR>";
}else{
echo "<TR><TD>$username</TD><TD>$games</TD></TR>";
}
}
}
print("</TABLE><P>");
arsort ($megascore);
reset ($megascore);
print("<TABLE><TR><TD COLSPAN=2><B><CENTER>Total Score</CENTER></B></TD></TR>");
while (list ($userID, $score) = each ($megascore)) {
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = '".$IDofuser[$userID]."'");
if($userX = $db->sql_fetchrow($result))
{
$username = $userX["username"];
}else{
$username = "Unknown?!";
}
if($score>0)
{
if($IDofuser[$userID]==$user->id)
{
echo "<TR style=\"background-color: #BBBBBB\"><TD>$username</TD><TD>$score</TD></TR>";
}else{
echo "<TR><TD>$username</TD><TD>$score</TD></TR>";
}
}
}
print("</TABLE><P>");
asort ($losspoints);
reset ($losspoints);
print("<TABLE><TR><TD COLSPAN=2><B><CENTER>Loose points</CENTER></B></TD></TR>");
while (list ($userID, $score) = each ($losspoints)) {
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = '".$IDofuser[$userID]."'");
if($userX = $db->sql_fetchrow($result))
{
$username = $userX["username"];
}else{
$username = "Unknown?!";
}
if($score>0)
{
if($IDofuser[$userID]==$user->id)
{
echo "<TR style=\"background-color: #BBBBBB\"><TD>$username</TD><TD>$score</TD></TR>";
}else{
echo "<TR><TD>$username</TD><TD>$score</TD></TR>";
}
}
}
print("</TABLE><P>");
$ID=0;
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores GROUP BY user");
while($populate = $db->sql_fetchrow($result))
{
$ID++;
$averagerank[$ID]=$losspoints[$ID]/$gamesplayed[$ID];
}
asort ($averagerank);
reset ($averagerank);
print("<TABLE><TR><TD COLSPAN=2><B><CENTER>Average Rate</CENTER></B></TD></TR>");
while (list ($userID, $score) = each ($averagerank)) {
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = '".$IDofuser[$userID]."'");
if($userX = $db->sql_fetchrow($result))
{
$username = $userX["username"];
}else{
$username = "Unknown?!";
}
if($score>0)
{
if($IDofuser[$userID]==$user->id)
{
echo "<TR style=\"background-color: #BBBBBB\"><TD>$username</TD><TD>$score</TD></TR>";
}else{
echo "<TR><TD>$username</TD><TD>$score</TD></TR>";
}
}
}
print("</TABLE><P>");
?>
</td></tr>
</table>
</form>
<br/>
<center><a href=arcade.php><h2>Return to Games Choice</h2></a></center>
</div>
<?php
CloseTable();
include ("footer.php");
?>