<?php
/***********************************************************************/

// Some info about your mod.
$mod_title      = 'punBB Arcade Games';
$mod_version    = '';
$release_date   = '2006-07-24';
$author         = 'ANGO';
$author_email   = '';

// Versions of PunBB this mod was created for. Minor variations (i.e. 1.2.4 vs 1.2.5) will be allowed, but a warning will be displayed.
$punbb_versions	= array('1.2.10', '1.2.11', '1.2.12');

// Set this to false if you haven't implemented the restore function (see below)
$mod_restore	= false;


// This following function will be called when the user presses the "Install" button
function install()
{
	global $db, $db_type, $pun_config;

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Tubin", "tubin", "Its time to lookout for Stars in Texas, the Lone Star State. Go tubing on the lake Tyler and collect stars.", "tubin.jpg", 550, 440, 4)') or error('Unable to add game Tubin', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Alpha Force", "alphaforce", "A good old fashion side scrolling shoot-em-up. Bosses! Smart bombs! Power up! and many more!", "alphaforce.jpg", 522, 340, 2)') or error('Unable to add game Alpha Force', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Blox Forever", "bloxforever", "Place similar colored gem blox together to remove them all from the board to solve the puzzle.", "bloxforever.jpg", 640, 480, 3)') or error('Unable to add game Blox Forever', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Plumber", "plumber1", "Create a continous pipeline by joining various parts of it to let the water flow.", "plumber1.jpg", 620, 400, 3)') or error('Unable to add game Plumber', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Starsky Hutch Pinball", "starskynhutch", "This pinball game is impressive.Complete the shots and hit the LOCK to nab the bad guys.", "starskynhutch.jpg", 550, 560, 4)') or error('Unable to add game Starsky Hutch Pinball', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Zed", "zed", "Guide Zed through ten vicious levels, collect enough gold to build his spacesuit!", "zed.jpg", 700, 500, 7)') or error('Unable to add game Zed', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Flower Power", "flowerpower", "Shoot the flower at the mass flowers above. If 3 flowers match, theyll disappear and youll get points. The more flowers disappear, the more points you get. Use LEFt and Right arrow key to rotate and UP to shoot.", "flowerpower.jpg", 550, 400, 3)') or error('Unable to add game Flower Power', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Crazy Cube", "crazycube", "Plot a pathway connecting each color together on this 3D cube.", "crazycube.jpg", 700, 525, 3)') or error('Unable to add game Crazy Cube', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Iconien", "iconien", "Avoid the bugs touching the central eye.", "iconien.jpg", 460, 400, 4)') or error('Unable to add game Iconien', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Invader 360", "invader360", "Invader360 is a great little Flash based tube shooter, similar to arcade classics Tempest or Gyruss.", "invader360.jpg", 400, 300, 2)') or error('Unable to add game Invader 360', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Bowman Bird Hunting", "bowmandash", "Kill as many birds as possible.", "bowmandash.jpg", 400, 300, 2)') or error('Unable to add game Bowman Bird Hunting', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("30 Seconds", "30seconds", "You have 30 seconds to hit the ball as far as possible.", "30seconds.jpg", 500, 400, 9)') or error('Unable to add game 30 Seconds', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Indepentend Throw", "indthrow", "Throw the newspaper to the right audience.", "indthrow.jpg", 500, 400, 4)') or error('Unable to add game Indepentend Throw', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Malibu 9", "malibu9", " Use the numbers to make the deepfried penguins jump, avoid cactus and ninja with swords and shooting stars.", "malibu9.jpg", 620, 340, 7)') or error('Unable to add game Malibu 9', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Shooting Target", "shootingtarget", "Test your ability at this target shooting game.", "shootingtarget.jpg", 550, 400, 2)') or error('Unable to add game Shooting Target', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Arcade Lanes", "arcadelanes", "To aim the ball, move the mouse back and forth. Once you find a good spot to throw the ball from, move thse mouse back and forth gently to aim the arrow in the direction where you want the ball to go. Press down on the mouse button to start a second arrow rotating around the ball. If you release the mouse button when the two arrows meet, the ball will have no spin. If you release the button earlier or later, the ball will spin in that direction.", "arcadelanes.jpg", 492, 450, 9)') or error('Unable to add game Iconien', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Force Within", "forcewithin", "Overall object is to remove the tiles from the playing area by creating rows or columns of 4 or more. The computer will try to stop you by placing tiles on the screen.", "forcewithin.jpg", 466, 350, 3)') or error('Unable to add game Force Within', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Freecell", "freecell", " Move cards of the same suit into the top four piles, starting with the Ace. Use the four freecells in the upper left as temporary storage areas. Cards can be moved from one stack to another in the tableau if they are in descending order and of a different color.", "freecell.jpg", 680, 460, 5)') or error('Unable to add game Freecell', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Quadramania", "quadramania", "Score points by forming single-color rectangles that are at least two by three tiles in size. Rectangles with extra tiles of the same color attached do not qualify. Also, you cannot drop a piece if it overlaps with a tile of the same color. The point value for each rectangle is ten times the square of the total number of tiles in the rectangle. The next piece coming is shown next to the board.", "quadramania.jpg", 550, 400, 3)') or error('Unable to add game Quadramania', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Rumbleball 1", "rumbleball1", "Hit the ball with your mouse and pick up the golden balls for points.", "rumbleball1.jpg", 400, 550, 4)') or error('Unable to add game Rumbleball 1', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Turmspringen", "turmspringen", "Press space to start, press space again to jump and use the cursor keys to make figures in air.", "turmspringen.jpg", 720, 540, 9)') or error('Unable to add game Turmspringen', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Mario Starcatcher 2", "mario_starcatcher2", "Try to catch the star in every Level in this Classic Game !", "mario_starcatcher2.jpg", 550, 400, 4)') or error('Unable to add game Mario Starcatcher 2', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Great Tournament", "greattournament", "Aim for the bulls eye and fire your bow and arrow. Score the highest number of points to win.", "greattournament.jpg", 520, 390, 9)') or error('Unable to add game Great Tournament', __FILE__, __LINE__, $db->error());


$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Little Erde", "littleerde", "Toss the sausage around the globle.", "littleerde.jpg", 676, 548, 4)') or error('Unable to add game Little Erde', __FILE__, __LINE__, $db->error());

$db->query('INSERT INTO '.$db->prefix.'arcade_games (game_name, game_filename, game_desc, game_image, game_width, game_height, game_cat) VALUES ("Little Erde 2", "littleerde2", "In the episode 1,erde Toss the sausage around globle,but now its his turn.", "littleerde2.jpg", 676, 548, 4)') or error('Unable to add game Little Erde 2', __FILE__, __LINE__, $db->error());
}


// This following function will be called when the user presses the "Restore" button (only if $mod_uninstall is true (see above))
function restore()
{
	global $db, $db_type, $pun_config;
	switch ($db_type)
	{
		default:

			break;
	}

}

/***********************************************************************/

// DO NOT EDIT ANYTHING BELOW THIS LINE!


// Circumvent maintenance mode
define('PUN_TURN_OFF_MAINT', 1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';

// We want the complete error message if the script fails
if (!defined('PUN_DEBUG'))
	define('PUN_DEBUG', 1);

// Make sure we are running a PunBB version that this mod works with
$version_warning = false;
if(!in_array($pun_config['o_cur_version'], $punbb_versions))
{
	foreach ($punbb_versions as $temp)
	{
		if (substr($temp, 0, 3) == substr($pun_config['o_cur_version'], 0, 3))
		{
			$version_warning = true;
			break;
		}
	}

	if (!$version_warning)
		exit('You are running a version of PunBB ('.$pun_config['o_cur_version'].') that this mod does not support. This mod supports PunBB versions: '.implode(', ', $punbb_versions));
}


$style = (isset($cur_user)) ? $cur_user['style'] : $pun_config['o_default_style'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $mod_title ?> installation</title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_config['o_default_style'].'.css' ?>" />
</head>
<body>

<div id="punwrap">
<div id="puninstall" class="pun" style="margin: 10% 20% auto 20%">

<?php

if (isset($_POST['form_sent']))
{
	if (isset($_POST['install']))
	{
		// Run the install function (defined above)
		install();

?>
<div class="block">
	<h2><span>Installation successful</span></h2>
	<div class="box">
		<div class="inbox">
			<p>Your database has been successfully prepared for <?php echo pun_htmlspecialchars($mod_title) ?>. See readme.txt for further instructions.</p>
		</div>
	</div>
</div>
<?php

	}
	else
	{
		// Run the restore function (defined above)
		restore();

?>
<div class="block">
	<h2><span>Restore successful</span></h2>
	<div class="box">
		<div class="inbox">
			<p>Your database has been successfully restored.</p>
		</div>
	</div>
</div>
<?php

	}
}
else
{

?>
<div class="blockform">
	<h2><span>Mod installation</span></h2>
	<div class="box">
		<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar">
			<div><input type="hidden" name="form_sent" value="1" /></div>
			<div class="inform">
				<p>This script will update your database to work with the following modification:</p>
				<p><strong>Mod title:</strong> <?php echo pun_htmlspecialchars($mod_title).' '.$mod_version ?></p>
				<p><strong>Author:</strong> <?php echo pun_htmlspecialchars($author) ?> (<a href="mailto:<?php echo pun_htmlspecialchars($author_email) ?>"><?php echo pun_htmlspecialchars($author_email) ?></a>)</p>
				<p><strong>Disclaimer:</strong> Mods are not officially supported by PunBB. Mods generally can't be uninstalled without running SQL queries manually against the database. Make backups of all data you deem necessary before installing.</p>
<?php if ($mod_restore): ?>				<p>If you've previously installed this mod and would like to uninstall it, you can click the restore button below to restore the database.</p>
<?php endif; ?><?php if ($version_warning): ?>				<p style="color: #a00"><strong>Warning:</strong> The mod you are about to install was not made specifically to support your current version of PunBB (<?php echo $pun_config['o_cur_version']; ?>). However, in most cases this is not a problem and the mod will most likely work with your version as well. If you are uncertain about installning the mod due to this potential version conflict, contact the mod author.</p>
<?php endif; ?>			</div>
			<p><input type="submit" name="install" value="Install" /><?php if ($mod_restore): ?><input type="submit" name="restore" value="Restore" /><?php endif; ?></p>
		</form>
	</div>
</div>
<?php

}

?>

</div>
</div>

</body>
</html>