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

// Some info about your mod.
$mod_title      = 'punBB Arcade Games';
$mod_version    = '';
$release_date   = '2006-04-30';
$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 ("Cleaner", "cleaner", "Youre the Cleaner in a dirty, dirty world. For starters there are the monsters. Youll need to clean them or get out of their way as you collect all the coins and try to find your mop on each level.", "cleaner.jpg", 500, 460, 7)') or error('Unable to add game Cleaner', __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 ("Bubbles", "bubbles", "Use the arrow keys to move. Get weird looking bubbles for bonus points.", "bubbles.jpg", 350, 400, 4)') or error('Unable to add game Bubbles', __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 ("Bungee Ball", "bungeeball", "Ever wonder what its like to jump on a trampoline while hooked up to a bungee cord and slam a ball into a net held out by another person who is precariously dangling from a bungee cord too? Well wonder no longer!", "bungeeball.jpg", 540, 400, 9)') or error('Unable to add game Bungee Ball', __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 NY", "cityjumpernyc", "Try the all new City Jumper sequel, packed with New York City landmarks.", "cityjumper.jpg", 800, 600, 4)') or error('Unable to add game City Jumper NY', __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 ("Counter-Strike Lite", "counterstrikelite", "Simply shoot the moving target! The game has different scenarios to choose from.", "counterstrikelite.jpg", 760, 400, 2)') or error('Unable to add game Counter-Strike Lite', __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 ("Tinos", "tinos", "Click on a square to move Rikki to that sqaure and pick up that piece of fruit. Rikki is the monkey in the middle of the board", "tinos.jpg", 550, 400, 3)') or error('Unable to add game Tinos', __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 ("Base Defender", "base_defender", "A meteor shower is coming. Defend your Lunar BAse Stations by destroying the meteors with your lasers.", "basedefender.jpg", 550, 440, 1)') or error('Unable to add game Base Defender', __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 Bonus", "cityjumperbonus", "City Jumper Bonus Levels gets 100 new levels for the advanced player.", "cityjumperbonus.jpg", 802, 600, 4)') or error('Unable to add game City Jumper Bonus', __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 ("Defend Castle", "defendcastle", "Kill some time and see how long you can defend your castle.", "defendcastle.jpg", 550, 400, 1)') or error('Unable to add game Defend Castle', __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 ("Fishy", "fishy", "Eat fish smaller than you. Get eaten by fish bigger than you.", "fishy.jpg", 550, 400, 4)') or error('Unable to add game Fishy', __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 ("SD Pong", "sdpong", "Hit the ball back and forth while trying to make your opponent miss or hit it off the table.", "sdpong.jpg", 550, 400, 4)') or error('Unable to add game SD Pong', __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 ("Yetisports Puzzle Kick", "yetisports_pk", "Another Chris Hilgert game much like Zuma.", "yetisports_pk.jpg", 640, 480, 4)') or error('Unable to add game Yetisports Puzzle Kick', __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 ("Fisher", "fisher", "A highly fun skill game, will keep you busy for hours.", "fisher.jpg", 550, 400, 4)') or error('Unable to add game Fisher', __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 ("Indiana", "indiana", "Collect all diamonds.", "indiana.jpg", 540, 400, 4)') or error('Unable to add game Indiana', __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", "blox", "Move the blocks around off walls and match them up to explode them.", "blox.jpg", 640, 480, 3)') or error('Unable to add game Blox', __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 ("3 Finder", "3finder", "In der Mitte werden drei Kugeln angezeigt, ihr müsst diese Kombination auf dem äusseren Ring innerhalb von 10 Sekunden finden und sie anklicken.", "3finder.jpg", 550, 400, 3)') or error('Unable to add game 3 Finder', __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 ("Black Dragon", "blackdragon", "The overall objects of the game is to remove tiles in sets 4 that are made up of the same symbol, color or both.", "blackdragon.jpg", 560, 400, 3)') or error('Unable to add game Black Dragon', __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 ("Bouncy Jump", "bouncyjump", "Jump as high as you can.", "bouncyjump.jpg", 550, 400, 4)') or error('Unable to add game Blox', __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 ("Camera Mind", "cameramind", "Pick the last born circle.", "cameramind.jpg", 550, 400, 3)') or error('Unable to add game Camera Mind', __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 ("Bubble Shooter N", "bubbleshooternovoice", "The goal is to clean the bubbles off the field. . This is the novoice mode.", "bubbleshooternovoice.jpg", 800, 600, 4)') or error('Unable to add game Bubble Shooter N', __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 ("Bubble Shooter E", "bubbleshooterexpert", "The goal is to clean the bubbles off the field. . This is the expert mode.", "bubbleshooterexpert.jpg", 800, 600, 4)') or error('Unable to add game Bubble Shooter E', __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 ("Balls on drugs", "ballsondrugs", "Dont hit the red balls. The balls get faster and faster! Control the ball with the arrow keys.", "ballsondrugs.jpg", 550, 400, 4)') or error('Unable to add game Balls on drugs', __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 ("Black Knight", "blackknight", "The queen wants a new pair of shoes! Your job is to bash the peasants and collect taxes for the king.", "blackknight.jpg", 550, 400, 1)') or error('Unable to add game Black Knight', __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 Keepups", "crazykeepups", "Keep the ball up and make sure it does not lose too much air. Click on the powerups to help you maximize your score.", "crazykeepups.jpg", 520, 390, 9)') or error('Unable to add game Crazy Keepups', __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 ("Pendulumeca", "pendulumeca", "You have to use all your skills on order not to fall down on the needles. Try to do your best!", "pendulumeca.jpg", 550, 420, 4)') or error('Unable to add game Pendulumeca', __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>