<?

require_once("include/bittorrent.php");
hit_start();

dbconn(false);

hit_count();

loggedinorreturn();


stdhead("Flash Scores");

if (get_user_class() < UC_USER)
{
stdmsg("Sorry...", "you do not have access.");
stdfoot();
exit;
}

?>
<table class=tableoutborder width=60% border=0 cellspacing=1 cellpadding=5><tr><td class=tabletitle>
<div align=center><B>Score Charts</B></td></tr>
<P>
<tr><td class=tablea><center><A HREF=arcade.php><b>Zurück zur Arcade</b></a></center></td></tr>
<tr><td class=tablea><center><A HREF=flashscores2.php><b>Zur zweiten Seite</b></a></center><P></td></tr>
<P></table><br><br>
<?
for($gameID=1;$gameID<34;$gameID++)
{
if($gameID==1)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Asteroids</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==2)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Breakout</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==3)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Hexxagon</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==4)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Invaders</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==5)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Moonlander</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==6)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Pacman</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==7)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Solitaire</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==8)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Simon</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==32)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=4><center><B>Snake</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><td class=tableb><b>Level</b></td><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==33)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=4><center><B>Tetris</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><td class=tableb><b>Level</b></td><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==11)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Raiden</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==12)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Donkey Kong</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==13)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Algar</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==14)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Curveball</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==15)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Doom</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==16)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Tischkicker</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==17)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Frogger</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==18)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>GTA</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==19)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Homers Beer Run</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==20)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Jungleescape</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==21)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Marblemayhem</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==22)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Pathfinder</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==23)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Super Flash Mario Bros</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==24)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>3D Net Blazer</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==25)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Star Wars</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==26)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Bomberman</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==27)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Turtles</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==28)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>FingerFooty</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==29)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Bubble Shooter</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==30)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>MicroMachines</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==31)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Action Driving</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==9)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Breakfast Brawl</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
if($gameID==10)
{
print("<table class=tableoutborder border=0 cellspacing=1 cellpadding=5 align=center width=60%><TR><TD class=tabletitle COLSPAN=3><center><B>Xevious</B></center></TD></TR>");
print("<TR><TD align=center class=tableb><b>Rang</b></TD><TD align=center class=tableb WIDTH=75%><center><b>Name</b></center></TD><TD align=center class=tableb><b>Score</b></TD></TR>");
}
$result = MySQL_QUERY("SELECT * FROM flashscores GROUP BY user;");
while($populate = MySQL_FETCH_ARRAY($result))
{
if(!isset($totalscore[$populate["user"]]))
{
$totalscore[$populate["user"]]=0;
}
}
$result = MySQL_QUERY("SELECT * FROM flashscores WHERE game = ".$gameID." ORDER BY score DESC;");
while($scores = MySQL_FETCH_ARRAY($result))
{
$ranking = MySQL_QUERY("SELECT COUNT(*) FROM flashscores WHERE game = ".$gameID." AND score > ".$scores["score"].";") OR DIE(MySQL_ERROR());
if($rankrow = mysql_fetch_row($ranking))
{
$rank = $rankrow[0]+1;
}else{
$rank = 1;
}
if($rank<6)
{
$totalscore[$scores["user"]]+=(10-(($rank-1)*2));
}
}
$result = MySQL_QUERY("SELECT * FROM flashscores WHERE game = ".$gameID." ORDER BY score DESC LIMIT 5;");
while($scores = MySQL_FETCH_ARRAY($result))
{
$userresult = MySQL_QUERY("SELECT * FROM users WHERE id = ".$scores["user"].";");
$user = MySQL_FETCH_ARRAY($userresult);
$username = $user["username"];
$ranking = MySQL_QUERY("SELECT COUNT(*) FROM flashscores WHERE game = ".$gameID." AND score > ".$scores["score"].";") OR DIE(MySQL_ERROR());
if($rankrow = mysql_fetch_row($ranking))
{
$rank = $rankrow[0]+1;
}else{
$rank = 1;
}
if($gameID < 32)
{
if($scores["user"]==$CURUSER["id"])
{
print("<TR style=\"background-color: #BBBBBB\"><TD class=tableb>".$rank."</TD><TD class=tableb align=center>".$username."</TD><TD class=tableb><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}else{
print("<TR><TD class=tableb>".$rank."</TD><TD class=tableb align=center>".$username."</TD><TD class=tableb><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}
}else{
if($scores["user"]==$CURUSER["id"])
{
print("<TR style=\"background-color: #BBBBBB\"><TD class=tableb>".$rank."</TD><TD class=tableb align=center>".$username."</TD><TD class=tableb>".$scores["level"]."</TD><TD class=tableb><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");
}else{
print("<TR><TD class=tableb>".$rank."</TD><TD class=tableb align=center>".$username."</TD><TD class=tableb>".$scores["level"]."</TD><TD class=tableb><div style=\"text-align:right;width:100%;\">".$scores["score"]."</div></TD></TR>");

}
}
}
$yourresult = MySQL_QUERY("SELECT * FROM flashscores WHERE game = ".$gameID." AND user = ".$CURUSER["id"]." ORDER BY score DESC LIMIT 1;") OR DIE(MySQL_ERROR());
if($yourscore = MySQL_FETCH_ARRAY($yourresult))
{
$yourhighscore = $yourscore["score"];
$yourlevel = $yourscore["level"];
$yourranking = MySQL_QUERY("SELECT COUNT(*) FROM flashscores WHERE game = ".$gameID." AND score > ".$yourhighscore.";") OR DIE(MySQL_ERROR());
if($ranking = mysql_fetch_row($yourranking))
{
$yourrank = $ranking[0]+1;
}else{
$yourrank = 1;
}
if($yourrank>5)
{
if($gameID < 32)
{
print("<TR style=\"background-color: #BBBBBB\"><TD>".$yourrank."</TD><TD WIDTH=75%>".$CURUSER["username"]."</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%>".$CURUSER["username"]."</TD><TD>".$yourlevel."</TD><TD><div style=\"text-align:right;width:100%;\">".$yourhighscore."</div></TD></TR>");
}
}
}
print("</TABLE><P>");
}
$maxplayed = 0;
$userplayed = 0;
$result = MySQL_QUERY("SELECT * FROM flashscores GROUP BY user;");
while($flashuser = MySQL_FETCH_ARRAY($result))
{
$totalresult = MySQL_QUERY("SELECT COUNT(*) FROM flashscores WHERE user = '".$flashuser["user"]."';");
if($totaluser = MySQL_FETCH_ROW($totalresult))
{
if($totaluser[0]>$maxplayed)
{
$userplayed = $flashuser["user"];
$maxplayed = $totaluser[0];
}
}
}
$result = MySQL_QUERY("SELECT * FROM users WHERE id = ".$userplayed.";");
if($user = MySQL_FETCH_ARRAY($result))
{
$username = $user["username"];
}else{
$username = "Unknown?!";
}
$yourtotalresult = MySQL_QUERY("SELECT COUNT(*) FROM flashscores WHERE user = '".$CURUSER["id"]."';");
if($yourtotal = MySQL_FETCH_ROW($yourtotalresult))
{
$yourtotalgames = $yourtotal[0];
}else{
$yourtotalgames = 0;
}
$maxscore=0;
$maxscoreuser=0;
$result = MySQL_QUERY("SELECT * FROM flashscores GROUP BY user;");
while($check = MySQL_FETCH_ARRAY($result))
{
if($totalscore[$check["user"]]>$maxscore)
{
$maxscore=$totalscore[$check["user"]];
$maxscoreuser=$check["user"];
}
}
$result = MySQL_QUERY("SELECT * FROM users WHERE id = ".$maxscoreuser.";");
if($user = MySQL_FETCH_ARRAY($result))
{
$usernamescore = $user["username"];
}else{
$usernamescore = "Unknown?!";
}
$yourscore=$totalscore[$CURUSER["id"]];
?>
<p>
<table class=tableoutborder  cellspacing=1 cellpadding=5>
<tr><td align=center colspan=3 class=tabletitle><font size=2><b>User Stats</b></font></td></tr>
<TR><TD class=tablea>Du hast <b> <?=$yourtotalgames?> </b> Spiele gespielt!</td></tr>
<TR><TD class=tablea>Deine Gesamt-Score ist <b> <?=$yourscore?></b>!</td></tr>
</table>
<p>

<table class=tableoutborder  cellspacing=1 cellpadding=5>
<tr><td align=center colspan=3 class=tabletitle><font size=2><b>Most Bored Award</b></font></td></tr><TR><TD class=tablea><CENTER><IMG SRC=pic/pokal.gif></CENTER></TD></tr>
<TR><TD class=tablea><CENTER>Der most Bored Award geht an:<BR><B><?=$username?></B><BR>mit <?=$maxplayed?> gespielten Spiele!<BR><B>Glückwunsch!</B></CENTER></TD></TR>
</table>
<p>

<table class=tableoutborder  cellspacing=1 cellpadding=5>
<tr><td align=center colspan=3 class=tabletitle><font size=2><b>Highest Score Award</b></font></td></tr><TR><TD class=tablea><CENTER><IMG SRC=pic/pokal.gif></CENTER></TD></tr>
<TR><TD class=tablea><CENTER>Der Highest Score Award geht an:<BR><B><?=$usernamescore?></B><BR>mit einer Score von <?=$maxscore?>!<BR><B>Glückwunsch!</B></CENTER></TD></TR>
</table>

</td></tr>
</table>
</form>
<?

stdfoot();
hit_end();

?>