0) { $cat = $tempcat; } else { $cat = "random"; } } else { $cat = "random"; } echo " "; $sql="SELECT * FROM `arcade_categories` ORDER BY `displayorder`"; $result=mysql_query($sql); $catnum = mysql_num_rows($result); for($i = 0; $i < $catnum; $i++) { $row = mysql_fetch_array($result); $catname = $row["catname"]; echo " "; } ?>
   MENU:     
  
  
"; } if ($_REQUEST['sessdo'] == 'permrequest') { echo" Error"; echo "&validate=1µone=$microone&result=OK"; $score = $_REQUEST["score"]; $s2game = $_SESSION['sgameid']; $username = $VAR[4]; $sql = "INSERT INTO `arcade_highscores` (gamename, username, score) VALUES ('$s2game', '$username', '$score')"; $result=mysql_query($sql) or die(mysql_error()); exit; } if ($_REQUEST['sessdo'] == 'burn') { $gamename = $_SESSION['sgameid']; $sql="SELECT * FROM `arcade_games` WHERE `gameid` = '$gamename' LIMIT 1"; $result=mysql_query($sql); $row = mysql_fetch_array($result); $shortname = $row["shortname"]; $title = $row["title"]; $gameid = $row["gameid"]; $stdimage = $row["stdimage"]; $description = $row["description"]; $thiscat = $row["categoryid"]; $timesplayed = $row["timesplayed"]; $namecheck = $VAR[4]; $isreverse = $row["isreverse"]; echo "

   High Scores


$title
$description
Times played: $timesplayed


"; if($isrverse == 1){ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` LIMIT 100"; } else{ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` DESC LIMIT 100"; } $result=mysql_query($sql); for($i = 0; $i < 100; $i++) { $row = mysql_fetch_array($result); $username = $row["username"]; $score = $row["score"]; $rank = $i + 1; echo " "; } echo"
# Member Score
$rank. "; if ($username == $namecheck){ echo " "; } echo " $username "; if ($username == $namecheck){ echo " "; } echo " $score


"; if($isreverse == 1){ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' AND `username` = '$VAR[4]' ORDER BY `score` LIMIT 100"; } else{ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' AND `username` = '$VAR[4]' ORDER BY `score` DESC LIMIT 100"; } $result=mysql_query($sql); $rescheck = mysql_num_rows($result); for($i = 0; $i < 100; $i++) { $row = mysql_fetch_array($result); $score = $row["score"]; $rank = $i + 1; echo " "; } echo"
# Score
$rank. $score

"; } else if (isset($_GET['play'])){ $thisgameid = $_GET['play']; $_SESSION['sgameid'] = $thisgameid; $sql="SELECT * FROM `arcade_games` WHERE `gameid` = '$thisgameid' LIMIT 1"; $result=mysql_query($sql); $row = mysql_fetch_array($result); $shortname = $row["shortname"]; $title = $row["title"]; $gameid = $row["gameid"]; $stdimage = $row["stdimage"]; $description = $row["description"]; $thiscat = $row["categoryid"]; $timesplayed = $row["timesplayed"]; $file = $row["file"]; $width = $row["width"]; $height = $row["height"]; $gamename = $row["shortname"]; $isreverse = $row["isreverse"]; $timesnew = $timesplayed + 1; $sqlplay="UPDATE `arcade_games` SET `timesplayed` = '$timesnew' WHERE `gameid` = '$thisgameid' LIMIT 1"; $resultplay=mysql_query($sqlplay); $acta = mysql_query("SELECT * FROM `user_info` WHERE `user` = '$VAR[4]'"); $actb = mysql_fetch_array($acta); $actpa = $actb["total"]; $actpb = $actpa + 1; $actsql = mysql_query("UPDATE `user_info` SET `total` = '$actpb' WHERE `user` = '$VAR[4]' LIMIT 1"); if($isreverse == 1){ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` LIMIT 1"; } else{ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` DESC LIMIT 1"; } $result=mysql_query($sql); $champnum = mysql_num_rows($result); if($champnum == 1){ $row = mysql_fetch_array($result); $champname = $row["username"]; $champscore = $row["score"]; } else { $champname = "None"; $champscore = 0; } echo"
$title
$title Champion:
$champname
Score to Beat:
$champscore


"; } else if (isset($_GET['highscore'])){ $hsgameid = $_GET['highscore']; $sql="SELECT * FROM `arcade_games` WHERE `gameid` = '$hsgameid' LIMIT 1"; $result=mysql_query($sql); $row = mysql_fetch_array($result); $shortname = $row["shortname"]; $title = $row["title"]; $gameid = $row["gameid"]; $stdimage = $row["stdimage"]; $description = $row["description"]; $thiscat = $row["categoryid"]; $timesplayed = $row["timesplayed"]; $isreverse = $row["isreverse"]; echo"

   High Scores

$title
$description

Times played: $timesplayed


"; $namecheck = $VAR[4]; if($isrverse == 1){ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` LIMIT 100"; } else{ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` DESC LIMIT 100"; } $result=mysql_query($sql); for($i = 0; $i < 100; $i++) { $row = mysql_fetch_array($result); $username = $row["username"]; $score = $row["score"]; $rank = $i + 1; echo " "; } echo"
# Member Score
$rank. "; if ($username == $namecheck){ echo " "; } echo " $username "; if ($username == $namecheck){ echo " "; } echo " $score


"; if($isreverse == 1){ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' AND `username` = '$VAR[4]' ORDER BY `score` LIMIT 100"; } else{ $sql="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' AND `username` = '$VAR[4]' ORDER BY `score` DESC LIMIT 100"; } $result=mysql_query($sql); $rescheck = mysql_num_rows($result); for($i = 0; $i < 100; $i++) { $row = mysql_fetch_array($result); $score = $row["score"]; $rank = $i + 1; echo " "; } echo"
# Score
$rank. $score

"; } // show games list else { function dbg_mysql_query($query) { echo '
sql query', htmlentities($query), "
\n"; $r = mysql_query($query); if (!$r) { echo mysql_error(); } else { echo 'num_rows: ', mysql_num_rows($r); } echo "
\n"; return $r; } echo "
Welcome to the Arcade!
You are browsing games in the $cat category.
"; if ($cat == 'random') { $sql1 = "SELECT * FROM `arcade_games` ORDER BY `title`"; } else { $sql = "SELECT * FROM `arcade_categories` WHERE `catname` = '$cat' LIMIT 1"; $result=mysql_query($sql) or die('Could not run the query for catnames: ' . mysql_error()); $row = mysql_fetch_array($result); $maincat = $row["catid"]; $sql1="SELECT * FROM `arcade_games` WHERE `categoryid` = '$maincat' ORDER BY `shortname`"; } $result1 = mysql_query($sql1) or die ('Could not process sql1 query: ' . mysql_error()); $gamenum = mysql_num_rows($result1); // This is for the looping construct $game_array = array(); if ($gamenum > 0) { while ($row = mysql_fetch_array($result1)) { $game_array[] = $row; } } $game_count = count($game_array); // End loop construct stuff $begin = 0; $end = 20; if ($gamenum < 20) { $end = $gamenum; } elseif ( isset($_GET['begin']) ) { $begin = intval($_GET['begin']); // What is someone passed begin=fred in the URI? $end = ( ($begin + 20) < $game_count ) ? $begin + 20 : $game_count; } for($i = $begin; $i < $end; $i++) { $shortname = $game_array[$i]["shortname"]; $title = $game_array[$i]["title"]; $gameid = $game_array[$i]["gameid"]; $stdimage = $game_array[$i]["stdimage"]; $description = $game_array[$i]["description"]; $thiscat = $game_array[$i]["categoryid"]; $isreverse = $game_array[$i]["isreverse"]; $sql2="SELECT * FROM `arcade_categories` WHERE `catid` = $thiscat LIMIT 1"; $result2=mysql_query($sql2) or die('Could not run the inner loop query: ' . mysql_error()); $row = mysql_fetch_array($result2); $tempcat = $row["catname"]; if($isreverse == 1){ $sql3="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` LIMIT 1"; } else{ $sql3="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' ORDER BY `score` DESC LIMIT 1"; } $result3=mysql_query($sql3); $champnum = mysql_num_rows($result3); if($champnum == 1){ $row = mysql_fetch_array($result3); $champname = $row["username"]; $champscore = $row["score"]; } else { $champname = "None"; $champscore = 0; } $user = $VAR[4]; $sql4="SELECT * FROM `arcade_highscores` WHERE `gamename` = '$gameid' AND `username` = '$user' ORDER BY `score` DESC LIMIT 1"; $result4=mysql_query($sql4); $row4 = mysql_fetch_array($result4); $scorenum = mysql_num_rows($result4); if($scorenum == 1){ $yourscore = $row4["score"]; } else { $yourscore = "None"; } echo "
$title
$description
$tempcat
(More)
$champname
With a high score of:
$champscore
Your high score:
$yourscore
[High Scores]
"; } } ?>
$gnumcheck){ $gnumcheck += 1; $x += 1; echo" | $x"; $gnumcheck += 19; } } else { $gnumcheck = 0; $x = 0; while($gamenum > $gnumcheck){ $gnumcheck += 1; $x += 1; echo" | $x"; $gnumcheck += 19; } } ?>