forked from joeroberts234/phpMyBitTorrent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflashscores.php
277 lines (275 loc) · 11.8 KB
/
flashscores.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?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;
$viewing = $user->id;
$sql = ("SELECT * FROM ".$db_prefix."_casino_config") ;
$res = $db->sql_query($sql) or btsqlerror($sql);
while ($arr = $db->sql_fetchrow($res))
$arr_config[$arr['name']] = $arr['value'];
if (!$arr_config["enable"])bterror("ARCADE is Closed, try later...","Sorry");
//////////////////////////////////////////////////////////////////////////
$access_level = $arr_config["class_allowed"];
switch ($access_level) {
case "user": {
if (!$user->user) loginrequired("user");
break;
}
case "premium": {
if (!$user->premium) loginrequired("premium");
break;
}
case "moderator": {
if (!$user->moderator) loginrequired("moderator");
break;
}
case "admin": {
if (!$user->admin) loginrequired("admin");
break;
}
}
$query ="select * from ".$db_prefix."_casino where userid = '".$viewing."';";
$result = $db->sql_query($query) or die (mysql_error());
if($db->sql_affectedrows()!=1)
{
$db->sql_query("INSERT INTO ".$db_prefix."_casino (userid, win, lost, trys, date) VALUES(" .$viewing. ",0,0,0, NOW())") or mysql_error();
//bterror("This is the first time you try to play at the Casino please refresh the site","Hi ".$user->name);
$result = $db->sql_query($query); ///query another time to get the new user, if the bterror is uncomment
}
$row = $db->sql_fetchrow($result);
$user_enableplay = $row["enableplay"];
if($user_enableplay=="no")
bterror("Sorry ".getusername($btuser)."you're banned from casino.");
OpenTable("HighScores");
?>
<div align=center>
<table width=60% border=1 cellspacing=0 cellpadding=10><tr><td class=text>
<div align=center><B>HighScores Ranking</B>
<P>
<A HREF=flashscores2.php>Go to HighScores Stats</a><P>
<?php
for($gameID=1;$gameID<11;$gameID++)
{
if($gameID==1)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Asteroids</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==2)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Breakout</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==3)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Hexxagon</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==4)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Invaders</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==5)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Moonlander</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==6)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Pacman</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==7)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Solitaire</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==8)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=3 bgcolor=#0099FF><center><B>Simon</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Score</TD></TR>");
}
if($gameID==9)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=4 bgcolor=#0099FF><center><B>Snake</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Niveau</TD><TD>Score</TD></TR>");
}
if($gameID==10)
{
print("<TABLE WIDTH=100% border=1><TR><TD COLSPAN=4 bgcolor=#0099FF><center><B>Tetris</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75% align=center>Name</TD><TD>Niveau</TD><TD>Score</TD></TR>");
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores GROUP BY user;");
while($populate = $db->sql_fetchrow($result))
{
if(!isset($totalscore[$populate["user"]]))
{
$totalscore[$populate["user"]]=0;
}
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." ORDER BY score DESC;")or die(mysql_error());
while($scores = $db->sql_fetchrow($result))
{
$ranking = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." AND score > ".$scores["score"].";") or die(mysql_error());
if($rankrow = $db->sql_fetchrow($ranking))
{
$rank = $rankrow[0]+1;
}else{
$rank = 1;
}
if($rank<6)
{
$totalscore[$scores["user"]]+=(10-(($rank-1)*2));
}
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." ORDER BY score DESC LIMIT 5")or die(mysql_error());
while($scores = $db->sql_fetchrow($result))
{
$userresult = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = ".$scores["user"]."")or die(mysql_error());
$user = $db->sql_fetchrow($userresult);
$username = $user["username"];
$ranking = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." AND score > ".$scores["score"]."") or die(mysql_error());
if($rankrow = $db->sql_fetchrow($ranking))
{
$rank = $rankrow[0]+1;
}else{
$rank = 1;
}
if($gameID < 9)
{
if($scores["user"]==$viewing)
{
print("<TR bgcolor= #BBBBBB><TD>".$rank."</TD><TD WIDTH=75%>".$username."</TD><TD><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}else{
print("<TR><TD>".$rank."</TD><TD>".$username."</TD><TD><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}
}else{
if($scores["user"]==$viewing)
{
print("<TR bgcolor= #BBBBBB><TD>".$rank."</TD><TD WIDTH=75%>".$username."</TD><TD>".$scores["level"]."</TD><TD><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}else{
print("<TR><TD>".$rank."</TD><TD>".$username."</TD><TD>".$scores["level"]."</TD><TD><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}
}
}
$yourresult = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." AND user = '".$viewing."' ORDER BY score DESC LIMIT 1") or die(mysql_error());
if($yourscore = $db->sql_fetchrow($yourresult))
{
$yourhighscore = $yourscore["score"];
$yourlevel = $yourscore["level"];
$yourranking = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." AND score > ".$yourhighscore."") or die(mysql_error());
if($ranking = $db->sql_fetchrow($yourranking))
{
$yourrank = $ranking[0]+1;
}else{
$yourrank = 1;
}
if($yourrank>5)
{
if($gameID < 9)
{
print("<TR style=\"background-color: #BBBBBB\"><TD>".$yourrank."</TD><TD WIDTH=75% align=center>".getusername($btuser)."</TD><TD><div style=\"text-align:right;width:100%;\">".$yourhighscore."</div></TD></TR>");
}else{
print("<TR style=\"background-color: #BBBBBB\"><TD>".$yourrank."</TD><TD WIDTH=75% align=center>".getusername($btuser)."</TD><TD>".$yourlevel."</TD><TD><div style=\"text-align:right;width:100%;\">".$yourhighscore."</div></TD></TR>");
}
}
}
print("</TABLE><P>");
}
$maxplayed = 0;
$userplayed = 0;
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores GROUP BY user")or die(mysql_error());
while($flashuser = $db->sql_fetchrow($result))
{
$totalresult = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE user = '".$flashuser["user"]."'")or die(mysql_error());
if($totaluser = $db->sql_fetchrow($totalresult))
{
if($totaluser[0]>$maxplayed)
{
$userplayed = $flashuser["user"];
$maxplayed = $totaluser[0];
}
}
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = ".$userplayed."")or die(mysql_error());
if($user = $db->sql_fetchrow($result))
{
$username = $user["username"];
}else{
$username = "Unknown?!";
}
$yourtotalresult = $db->sql_query("SELECT COUNT(*) FROM ".$db_prefix."_flashscores WHERE user = '".$viewing."';")or die(mysql_error());
if($yourtotal = $db->sql_fetchrow($yourtotalresult))
{
$yourtotalgames = $yourtotal[0];
}else{
$yourtotalgames = 0;
}
$maxscore=0;
$maxscoreuser=0;
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores GROUP BY user")or die(mysql_error());
while($check = $db->sql_fetchrow($result))
{
if($totalscore[$check["user"]]>$maxscore)
{
$maxscore=$totalscore[$check["user"]];
$maxscoreuser=$check["user"];
}
}
$result = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = ".$maxscoreuser."")or die(mysql_error());
if($user3 = $db->sql_fetchrow($result))
{
$usernamescore = $user3["username"];
}else{
$usernamescore = "Unknown?!";
}
$yourscore=$totalscore[$viewing];
?>
You Have Played <?php echo $yourtotalgames?> Games!<P>
Your Total Score are <?php echo $yourscore?>!<P>
<TABLE>
<TR><TD><B><CENTER>Most Bored Award</CENTER></B></TD><TD><B><CENTER>Highest Score Award</CENTER></B></TD></TR>
<TR><TD><CENTER><IMG SRC=mostboredaward.php></CENTER></TD>
<TD><CENTER><IMG SRC=mostbetteraward.php></CENTER></TD>
<TR><TD><CENTER>Most Bored award goes to: <B><?php echo $username;?></B><BR/>With <?php echo $maxplayed;?> games played!<BR/><B>Congratulations!</B></CENTER></TD>
<TD><CENTER>The highest score award goes to:<B><?php echo $usernamescore;?></B><BR/>With a score of <?php echo $maxscore;?>!<BR/><B>Congratulations!</B/></CENTER></TD></TR>
</table>
</td></tr>
</table>
</form>
<br/>
<center><a href=arcade.php><h2>Return to Games Choice</h2></a></center>
</div>
<?php
CloseTable();
include ("footer.php");
?>