<?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;
if(isset($resolution))
{
if ($resolution =='half'){
$game_rez = "width=\"200\" height=\"250\"";
}
if ($resolution =='threeq'){
$game_rez = "width=\"300\" height=\"375\"";
}
if ($resolution =='none'){
$game_rez = "width=\"400\" height=\"500\"";
}
if ($resolution =='plus25'){
$game_rez = "width=\"500\" height=\"625\"";
}
if ($resolution =='plus50'){
$game_rez = "width=\"600\" height=\"750\"";
}
if ($resolution =='times2'){
$game_rez = "width=\"800\" height=\"1000\"";
}
}else{
$game_rez = "width=\"680\" height=\"430\"";
}

$res = "SELECT * FROM ".$db_prefix."_casino_config;";
$res_arcade = $db->sql_query($res);
$arr = $db->sql_fetchrow($res);
$db->sql_freeresult($res);
while ($arr = $db->sql_fetchrow($res_arcade))
$arr_config[$arr['name']] = $arr['value'];
if (!$arr_config["enable"])bterror("<p><h3>Arcade is disabled.</h3></p>","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;
        }
}


OpenTable($_GET["gamename"]);
if (!is_user($btuser)) loginrequired("user");


?>
<div align=center>
<table  border=1 cellspacing=0 cellpadding=0><tr><td class=text>
<div align=center>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" <?php echo $game_rez; ?>>
<param name=movie value="flash/<?php echo $_GET["gameURI"]?>">
  <param name=quality value=high>
  <embed src="flash/<?php print $_GET["gameURI"];?>" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" <?php echo $game_rez; ?>>
  </embed>
</object>
<?php
if(isset($_GET["gameid"]))
{
$gameID=$_GET["gameid"];
if($gameID==1)
{
  print("<TABLE  border=1><TR><TD COLSPAN=3><center><B>Asteroids</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==2)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Breakout</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==3)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Hexxagon</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==4)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Invaders</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==5)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Moonlander</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==6)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Pacman</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==7)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Solitaire</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==8)
{
  print("<TABLE border=1><TR><TD COLSPAN=3><center><B>Simon</B></center></TD></TR>");
print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Score</TD></TR>");
}
if($gameID==9)
{
  print("<TABLE border=1><TR><TD COLSPAN=4><center><B>Snake</B></center></TD></TR>");
  print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Level</TD><TD>Score</TD></TR>");
}
if($gameID==10)
{
  print("<TABLE border=1><TR><TD COLSPAN=4><center><B>Tetris</B></center></TD></TR>");
  print("<TR><TD>Rank</TD><TD WIDTH=75%>Name</TD><TD>Level</TD><TD>Score</TD></TR>");
}
 $result = $db->sql_query("SELECT * FROM ".$db_prefix."_flashscores WHERE game = ".$gameID." ORDER BY score DESC LIMIT 10;");
 while($scores = $db->sql_fetchrow($result))
 {
  $userresult = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE id = ".$scores["user"].";");
$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"].";");
if($rankrow = $db->sql_fetchrow($ranking))
{
 $rank = $rankrow[0]+1;
}else{
 $rank = 1;
}
if($gameID < 9)
{
  if($scores["user"]== getuserid($btuser))
  {
 print("<TR style=\"background-color: #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"]== getuserid($btuser))
  {
 print("<TR style=\"background-color: #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 = '".$user->id."' ORDER BY score DESC LIMIT 1;");
 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.";");
if($ranking = $db->sql_fetchrow($yourranking))
{
 $yourrank = $ranking[0]+1;
}else{
 $yourrank = 1;
}
if($yourrank>10)
{
if($gameID < 9)
{
 print("<TR style=\"background-color: #BBBBBB\"><TD>".$yourrank."</TD><TD WIDTH=75%>".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%>".getusername($btuser)."</TD><TD>".$yourlevel."</TD><TD><div style=\"text-align:right;width:100%;\">".$yourhighscore."</div></TD></TR>");
}
}
 }
 print("</TABLE></P>");
}else{
  print("<TABLE border=1><TR><TD><center><B>".$_GET["gamename"]."</B></center></TD></TR>");
print("<TR><TD>Unable to Save HighScores for this Game!</TD></TR>");
print("</TABLE>");
}
?>

<!--</td></tr>
</table>
</form>
</div>-->
<?php
echo"</table>";
?>
								<table><tr><td><form style="margin-bottom:0;" action="./flash.php" method="get">
					<input name="gameURI" type="hidden" value="<?php print $_GET["gameURI"];?>" />
					<input name="gamename" type="hidden" value="<?php print $_GET["gamename"];?>" />
					<input name="gameid" type="hidden" value="<?php print $_GET["gameid"];?>" />
					<span class="gensmall"><b>Select resolution:</b><br /><select name='resolution' onchange='this.form.submit();'>
										<option selected="selected">SELECT</option>
										<option  value='half'>200 x 250</option>
										<option  value='threeq'>300 x 375</option>
										<option  value='none'>400 x 500</option>
										<option  value='plus25'>500 x 625</option>
										<option  value='plus50'>600 x 750</option>
										<option  value='times2'>800 x 1000</option></select></span>
				</form></td></tr></table>
<?php				
CloseTable();

include ("footer.php");
?>
