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

// Some info about your mod.
$mod_title      = 'punBB Arcade Games';
$mod_version    = '';
$release_date   = '2006-10-12';
$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 ("BMX Park", "bmxpark", "A very cool game once you get the hang of it. Ride your BMX bike around pulling stunts.", "bmxpark.jpg", 640, 517, 4)') or error('Unable to add game BMX Park', __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 ("Birdy", "birdy", "Eat all the smaller birds and avoid all the larger ones.", "birdy.jpg", 600, 400, 9)') or error('Unable to add game Birdy', __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 ("Count", "count", "Click the numbers from 1 - 10 as fast as you can.", "count.jpg", 550, 400, 4)') or error('Unable to add game Count', __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 ("Donkey Kong", "donkeykong", "A very addictive game that looks and plays almost exactly like the original.", "donkeykong.jpg", 450, 600, 7)') or error('Unable to add game Donkey Kong', __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 ("The Guradian", "guardian", "Protect the guy that has been captured from the balls by using your paddle to defend him.", "guardian.jpg", 650, 290, 4)') or error('Unable to add game The Guardian', __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 ("Acceleracers", "acceleracers", "Acceleracers Track Mod - You must connect the pieces from the left to right to move a car across the realm as soon as you can to get to next stage.", "acceleracers.jpg", 460, 320, 3)') or error('Unable to add game Acceleracers', __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 ("Alien Attack", "alienattack", "Shoot down the aliens that invade with your cannon blasters.", "alienattack.jpg", 640, 460, 2)') or error('Unable to add game The Alien Attack', __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 ("Watchmaker", "watchmaker", "You have to make the gears rotate in the same direction as shown by the arrows which are on the gears. Use additional gears to connect them to the driving gear.", "watchmaker.jpg", 560, 450, 4)') or error('Unable to add game Watchmaker', __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 ("WRAX", "wrax", "A tetris like game, but way more addictive. Take a spin and see how far you can get.", "wrax.jpg", 600, 550, 4)') or error('Unable to add game WRAX', __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 ("Hostile Skies", "skies", "Youre a fighter ace, complete a series of dangerous missions then challenge the evil Red Baron for supremacy of the hostile skies!", "skies.jpg", 550, 400, 2)') or error('Unable to add game Hostile Skies', __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 ("Railroad", "railroad", "Drag track sections onto grid to guide the train across the screen. Use Boms to remove any unwanted rail sedctions.", "railroad.jpg", 680, 430, 3)') or error('Unable to add game WRAX', __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 ("Gun Run", "gunrun", "In this quirky little shooting game you play as a scarf wearing hero who must shoot his way through.", "gunrun.jpg", 600, 400, 2)') or error('Unable to add game Gun Run', __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 ("TMAAS", "tmaas", "Traps, Mines and a Sheep is a flash game in the style of the famous Yeti-Games. The principle is easy: try to get as far as you can.", "tmaas.jpg", 600, 400, 4)') or error('Unable to add game TMAAS', __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 ("Escargone", "escargone", "Collect as many footballs you can and find the finsih ring. Click to make the snail jump, keep the button down to stick to the walls and climb.", "escargone.jpg", 640, 480, 7)') or error('Unable to add game Escargone', __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 ("Chain Reaction", "chainreaction", "The objective of flash game is to invoke a chain reaction for as long as possible in order to achieve the highest score in the game.", "chainreaction.jpg", 550, 400, 3)') or error('Unable to add game Chain Reaction', __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 ("Spider Solitaire", "spidersolitaire", "Build 8 sequences down in suit within the tableau from King to Ace. Build tableau piles down regardless of suit from King to Ace. Groups of cards in sequence of the same suit may be moved as a unit. You get extra time for each sequence and extra points if you finish before the time ends.", "spidersolitaire.jpg", 680, 480, 5)') or error('Unable to add game Spider Solitaire', __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 ("Jezzball", "jezzball", "Trap the jatoms into smaller spaces in order to make at least 75 percent of chamber disappear. Move the mouse until the wallbuilder is where you want it. Scroll the wheel of the mouse or press spacebar or enter key to change between vertical and horizontal wallbuilding positions. Click the left button to start building a wall. To pause game press the p button.", "jezzball.jpg", 550, 400, 4)') or error('Unable to add game Jezzball', __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 ("Fox Tower", "foxtower", "Try to attempt high as possible.", "foxtower.jpg", 500, 600, 4)') or error('Unable to add game Fox Tower', __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 ("Hammer Throw", "hammerthrow", "Throw hammer as far as you can. Spin hammer thrower with correct technique and build speed and then release hammer. But dont throw it into the cage.", "hammerthrow.jpg", 550, 400, 9)') or error('Unable to add game Hammer 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 ("Mahjongg 3D", "mahjongg3d", "The object with Mahjong Solitaire is to remove all 144 tiles from the play field. This version is definitely one of the best ever released.", "mahjongg3d.jpg", 640, 480, 3)') or error('Unable to add game Mahjongg 3D', __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>