<?php
/* The Ghettronix Online Game Arcade
Author: Zoid
Website:
http://www.zoid.tk/
Released: December 28, 2004
Version: Hasn't reached 1.0
*** SEE README.TXT INCLUDED WITH THIS PACKAGE ***
************************************************** *****************************
** BUGS ************************************************** *********************
************************************************** *****************************
Send any bug reports to zoid ( see contact info below or visit
http://zoid.tk/ )
* Known Bugs/Problems:
- An extra character is read from the description and is placed in another
array, which affects the next game in the index. Only known to happen when only
one game is loaded.
- Inefficiency caused by reading the entire TXT file, when not all of it is
needed. (commented twice on this script)
- Background on all SWF files is set to black, it may need to be specifiable
in the data.txt in order to work properly on various games.
************************************************** ****************************
** CONTACT ************************************************** *****************
************************************************** ****************************
-ZOID-
Email:
zoid@jlmail.com
AIM: It Sux 4 U
Website:
http://www.zoid.tk/
************************************************** ****************************
© Copyright 2004 Ghettronix
All Rights Reserved
*/
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
include("header.php");
if ( strip_tags($_GET['game']) == "" ) { $index = 1; } else { $index = 0; }
OpenTable();
// --------------------------------------------------------------------------
// ***VAR CONFIG***
$perpage = 8; // How many to have per page
$perrow = 4; // How many columns to show in grid mode
$viewpref = "choose"; // The option to enable/disable different games list view stypes (a.k.a. indexstyle). Current options listed below:
/* Variable option: What it does:
"choose" gives users the option to pick their GArcade list page style, but by default shows the regular list with descriptions.
"list" forces users view the games list page-by-page with descriptions for each style. The option to view as grid style is removed.Iif you access the URL of the grid style page, it will still force this indexstyle on the user.
"grid" Just like "list," except it forces users onto the grid view. Decriptions are not displayed, and every game is visible on one single page. */
$showbutton = "yes"; // display the button link to Ghettronix at the end of each page.
echo "<center><image src=\"modules/GArcade/images/title.gif\" width=\"200\" height=\"72\" alt=\"Games Arcade\"><br>Games Arcade<br>"; // The Title Image
// --------------------------------------------------------------------------
$pg = strip_tags($_GET['pg']); //Get what page we're on
$game = strip_tags($_GET['game']);
if ( $viewpref == "choose" || $viewpref == "" ) { // toggle $viewpref and the user's chosen style to view the games index listing.
$indexstyle = $_GET['indexstyle']; // get what index style the user has chosen.
} elseif ( $viewpref == "list" ) {
$indexstyle = ""; // force the list index style onto the user (see variable config for description of this function).
} elseif ( $viewpref == "grid" ) {
$indexstyle = "grid"; // force the grid index style onto the user (see variable config for a description of this function).
} //end $viewpref toggle thing.
if ( $game == "" ) { // when $game == "" it's time to index all the games :)
// ------------------------
// get contents of txt file into an array. *THIS PART COULD USE SOME INCREASED EFFICIENCY* it'd be nice if it didnt have to load the entire text file.
$filename = $_SERVER['DOCUMENT_ROOT'].str_replace("modules.php","",$_SERVER['SCRIPT_NAME'])."modules/GArcade/gamedat/data.txt";
$handle = fopen($filename, "r");
if (!$handle) {
echo "Error opening data file. Check to see if the file exists.";
exit;
}
while (!feof($handle)) { $contents[] = fgets($handle, filesize($filename)); }
fclose($handle);
$howmany = count($contents); // find out how many games there are total
// each line of txt file was turned into a string in the array $contents
// The Title string, like the McDonalds "#### Served" sign:
echo "<br>Now Serving <b>$howmany</b> Games.<br>Select from the games listed below:";
echo "</center>";
if ($indexstyle == "") {
echo "<center><table border=\"0\" width=\"100%\">"; // You gotta start the table, right? How else can you contain the index?
} elseif ( $indexstyle == "grid" ) {
echo "<center><table border=\"0\">"; // if youre using the grid index style, you dont want width=100%, cuz that could look ugly.
}
if ( $indexstyle == "grid" ) { $perpage = $howmany; } // If you are using the GRID style, you want all the games to fit on a grid on one page, so you need to remove the limit on how many games are displayed on one page (so that all games are on one page).
for($i = ( 0 + ( $pg * $perpage ) ); $i < ( $perpage *( $pg + 1 ) ); $i++) { //this is the loop that will be run to generate the games index
// ---loop index---
$gameData = explode("||",$contents[$i]); // rip apart the $i string of the array into its own array
// Set up all vars with info needed for indexing:
$gameTitle = $gameData[0];
$gameThumb = $gameData[1];
if ($indexstyle == "") {
$gameDesc = $gameData[6];
}
// these vars aren't needed for indexing, but are left here for reference:
//$gameType = $gameData[2]; // ex: swf
//$gameFile = $gameData[3]; // ex: snake.swf
//$gameWidth = $gameData[4];
//$gameHeight = $gameData[5];
if ($i > ( $howmany - 1 )) { // All the links that show up on the index but don't correspond to a game are set to "Not Available"
$gameTitle = "Not Available";
$gameThumb = "unavailable.gif";
$gameDesc = "This game is not available.";
}
// Do the actual indexing, loop it and switch between formats depending on if $i is even or odd:
if ($indexstyle == "") {
if ( $i&1 ) {
$gameTitle = str_replace(array("_", "-"), " ", $gameTitle);
echo "<tr bgcolor=\"#F0F0F0\"><td colspan=\"2\" width=\"100%\" align=\"right\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b> #".($i + 1)."</p><p>".$gameDesc."</p></a></td><td width=\"70\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"></a></td></tr>";
} else {
$gameTitle = str_replace(array("_", "-"), " ", $gameTitle);
echo "<tr bgcolor=\"#E0E0E0\"><td width=\"70\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"></a></td><td colspan=\"2\" width=\"100%\" align=\"left\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b> #".($i + 1)."</p><p>".$gameDesc."</p></a></td></tr>";
}
} elseif ($indexstyle == "grid") {
if ( !isset($gridvar1) ) { $gridvar1 = 0; } // define $gridvar1 (the variable which counts how many cells per row have been created) as 0 if not already defined.
if ( $gridvar1 == 0 ) {
echo "<tr>";
}
$gameTitle = str_replace(array("_", "-"), " ", $gameTitle);
if ( $i&1 ) {
echo "<td width=\"70\" bgcolor=\"#F0F0F0\" align=\"center\"><a href=\"modules.php?name=GArcade&indexstyle=grid&ga me=".($i + 1)."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b></p></a></td>\n";
} else {
echo "<td width=\"70\" bgcolor=\"#E0E0E0\" align=\"center\"><a href=\"modules.php?name=GArcade&indexstyle=grid&ga me=".($i + 1)."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b></p></a></td>\n";
}
$gridvar1 = ($gridvar1 + 1);
if ( ($gridvar1 == $perrow) || ($i == $howmany) ) {
echo "</tr>";
$gridvar1 = 0;
}
} else {
echo "There was an error in choosing your view type. If the problem persists, please report this error to this website's administrator along with the URL you were trying to reach.<Br><br>More information about this error: check the indexstyle variable in this page's GET command (look in the URL somewhere after the question mark).";
}