<?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 ("Drive & Dodge", "drivedoge", "Drive counter-clockwise picking flags and dodging opponent car or cars by changing lanes in this fun free dodge racing games online.", "drivedoge.jpg", 550, 400, 4)') or error('Unable to add game Drive & Doge', __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 ("Equilibrium", "equilibrium", " Move your mouse back and forth to balance the tight rope walker on his unicycle, bounce up and catch balls for points.', __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 ("Homerun Derby", "homerunderby", "Hit enough homers and go to the next inning and face a new pitcher.", "homerunderby.jpg", 640, 480, 9)') or error('Unable to add game Homerun Derby', __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 ("Laby", "laby", "Moving the ball with the keyboard arrows, pass on every tile. You cant pass two times on the same tile!", "laby.jpg", 550, 400, 3)') or error('Unable to add game Laby', __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 ("Mon Buster", "monbuster", "Nice Puzzle game.", "monbuster.jpg", 550, 450, 3)') or error('Unable to add game Mon Buster', __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 ("Among The Clouds", "amongtheclouds", "Among the Clouds takes us into the minds of these dreamers as they drift off to sleep and wake up in a world where they own the skies.", "amongtheclouds.jpg", 700, 450, 4)') or error('Unable to add game Among The Cluds', __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 ("Connexions", "connexions", "Click on the pipe segments to rotate them clockwise and try to create a continuous pipeline. The longer the pipeline is, the more points youll be rewarded.", "connexions.jpg", 600, 440, 3)') or error('Unable to add game Connexions', __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 ("Get A Grip", "getagrip", "Accelerate all through the path, and break by pressing down between the yellow arrow and the line, then you have to balance with left and right arrows to stay up on the bike as long as possible.", "getagrip.jpg", 760, 350, 9)') or error('Unable to add game Drive & Doge', __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 ("City Jumper Extreme", "cityjumperextreme", "The most intense City Jumper yet, in beautiful London, England.", "cityjumper.jpg", 800, 562, 4)') or error('Unable to add game City Jumper Extreme', __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 ("Flashcraft", "flashcraft", "Defend your castle by building towers in the warcraft atmosphere. This game is easy but has several difficulty levels. There are many different ennemies, and you must boost all your towers and make all upgrades you can to achieve the game. Good luck !", "flashcraft.jpg", 550, 474, 1)') or error('Unable to add game Flashcraft', __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 2", "rumbleball2", "Using a pointer like a pool cut, hit as many items as you can. The ball will bounce off the large cubes, break through the smaller ones. Collect the small yellow balls with a pleasant tinkling bell sound for more points. Level ends when you have all the yellow balls.", "rumbleball2.jpg", 400, 550, 4)') or error('Unable to add game Rumbleball 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 ("Speedball", "speedball", "Try to keep the ball from hitting the bottom you have 5 lives good luck.", "speedball.jpg", 150, 280, 4)') or error('Unable to add Speedball', __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 ("Tribal Jump", "tribaljump", "Use your MOUSE select an angle and power. Once satisfied, LEFT CLICK to jump.", "tribaljump.jpg", 550, 450, 4)') or error('Unable to add game Tribal Jump', __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 ("Eva Project", "evaproject", "Avoid and destroy incoming ships using the arrow keys to move, space bar to shoot and Ctrl for a Telsa cannon. Use the Shift key to choose your upgrade.", "evaproject.jpg", 640, 320, 2)') or error('Unable to add game Eva Project', __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 ("I m with stupid", "imwithstupid", "Help the moron walk across high beams on construction sites using balloons to prevent him from falling.", "imwithstupid.jpg", 700, 480, 4)') or error('Unable to add game I m with stupid', __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 ("Sneek", "sneek", "The object is to keep your pointer inside of a box that steadily moves around faster and also shrinks.", "sneek.jpg", 550, 400, 4)') or error('Unable to add game Homerun Sneek', __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 ("Arctic Quest", "arcticquest", "In Arctic Quest, you set out to solve the puzzles, each of which takes the shape of an animal or other tropical wonder.", "arcticquest.jpg", 640, 480, 3)') or error('Unable to add game Arctic Quest', __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 ("Fish eat fish", "fisheatfish", "Eat and dont be eaten.", "fisheatfish.jpg", 700, 500, 4)') or error('Unable to add game Fish eat fish', __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 ("Magic Arrow", "magicarrow", "Protect your territory from harmful enemy balloons by shooting all of them.", "magicarrow.jpg", 640, 480, 9)') or error('Unable to add game Magic Arrow', __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 ("Prison Escape", "prisonescape", "Kill the prisoners before they escape by shooting them with your pistol, shotgun or assault rifle.", "prisonescape.jpg", 550, 400, 2)') or error('Unable to add game Prison Escape', __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 ("Space Flight", "spaceflight", "Abduce all the creatures and land on the platforms. Remember that the gravity will change according to the planet where you are.", "spaceflight.jpg", 550, 400, 4)') or error('Unable to add game Space Flight', __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 ("Lightning Pool", "lightningpool", "Fast paced solitaire pool game with several twists.", "lightningpool.jpg", 640, 460, 4)') or error('Unable to add game Lightning Pool', __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 ("Collapse", "collapse", "Click on the bricks that match up atleast two or more before the time runs out remove all to win.", "collapse.jpg", 650, 420, 3)') or error('Unable to add game Collapse', __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 ("Mahjong Connect", "mahjongconnect", "Different style of mahjongg, where you need to match two tiles by connecting them with a pathway.", "mahjongconnect.jpg", 750, 550, 3)') or error('Unable to add game Mahjong Connect', __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 ("Taz Football", "tazfb", "Make the biggest score you can by making as many touchdown as possible and neutralizing the opponents on your way.", "tazfb.jpg", 500, 375, 9)') or error('Unable to add game Taz Football', __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>