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

// Some info about your mod.
$mod_title      = 'punBB Arcade Games';
$mod_version    = '';
$release_date   = '2006-06-05';
$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 ("MG Shootout", "mgshootout", "Mardi Gras Shootout. Do you have what it takes to defend and shoot against the best?", "mgshootout.jpg", 600, 450, 9)') or error('Unable to add game Mardi Gras Shootout', __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 ("Beckham Shootout", "beckhamsoccer", "Heres your chance to really bend it like Beckham.<br>Get the ball in the goal as quickly as possible.", "beckhamsoccer.jpg", 640, 480, 9)') or error('Unable to add game Beckham Shootout', __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 ("Card Toss", "cardtoss", "Toss the cards into the hat.", "cardtoss.jpg", 650, 450, 4)') or error('Unable to add game Beckham Shootout', __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 ("World Cup Pinball", "wcpinball", "A really good cross between a pinball game and footy!", "wcpinball.jpg", 535, 650, 4)') or error('Unable to add game World Cup 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 ("Knife Throw", "knifethrow", "Throw knives at your target but dont kill the girl!", "knifethrow.jpg", 535, 650, 4)') or error('Unable to add game World Cup 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 ("City Jumper", "cityjumper", "Time it perfect and see how many buildings you can jump.", "cityjumper.jpg", 535, 650, 4)') or error('Unable to add game World Cup 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 ("Bottle Shoot", "bottleshoot", "Shoot the bottles but be ware of the cat!", "bottleshoot.jpg", 535, 650, 4)') or error('Unable to add game World Cup 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 ("Nanaca Crash", "nanacacrash", "Nanaca Crash is a Flash game which uses anime characters from an adult game called Cross Channel.<br>Choose an angle and power at which you launch the poor dude.", "nanacacrash.jpg", 700, 400, 4)') or error('Unable to add game World Cup 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 ("Maple Story", "maplestory", "Travel around the world batteling monsters, doing quests, and make new friends.", "maplestory.jpg", 560, 490, 7)') or error('Unable to add game Maple Story', __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 ("Clash N Slash", "clash_n_slash", "Clash N Slash is completely addicting shooting game fun.<br>Blast tons of aliens with loads of upgrades, powerups, enemies, and huge bosses.", "clash_n_slash.jpg", 480, 360, 7)') or error('Unable to add game Clash N Slash', __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 ("Plops", "plops", "Produce Plops without them escaping from the field.", "plops.jpg", 398, 398, 7)') or error('Unable to add game Plops', __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 ("UFO", "ufo", "Shoot as many UFOs as possible.", "ufo.jpg", 550, 400, 7)') or error('Unable to add game UFO', __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 ("Hot Air", "hotair", "Hot Air is the cutest action puzzle game around!<br>Using your fan, guide the balloon past weird and whacky obstacles through each of 24 exciting levels.", "hotair.jpg", 550, 400, 4)') or error('Unable to add game Hot Air', __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 ("Flash Strike Rookie", "flashstriker", "A very detailed and featured shooter based around the popular Counter Strike game.", "flashstrike.jpg", 650, 450, 2)') or error('Unable to add game Hot Air', __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 ("Flash Strike Veteran", "flashstrikev", "A very detailed and featured shooter based around the popular Counter Strike game.", "flashstrike.jpg", 650, 450, 2)') or error('Unable to add game Hot Air', __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 ("IBM Soccer", "ibm", "Iran Baranda Mishe Soccer. Shoot as many goals as you can.", "ibm.jpg", 700, 500, 9)') or error('Unable to add game IBM Soccer', __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 on 1", "3on1", "Soccer fans rejoice! Its a great setup, three strikers versus the goalie and one defender. Do you have what it takes to score?", "3on1.jpg", 700, 525, 9)') or error('Unable to add game 3 on 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 ("Freekick", "freekick", "Simply use the mouse to aim, apply power, kick the soccer ball or football, and move your goalie so that he can make spectacular saves!", "freekick.jpg", 720, 480, 9)') or error('Unable to add game Hot Air', __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 ("Shoot Em In", "shootemin", "You have 10 tries to score at all 9 levels.", "shootemin.jpg", 352, 416, 9)') or error('Unable to add game Shoot Em In', __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 ("Add It Up", "additup", "Select a combination of tiles that add up to your target number. The target is located in the upper right corner of the screen. The more numbers you use to get to the target, the more points you get for that turn. Choose your combinations quickly to recieve time bonus points.", "additup.jpg", 550, 400, 3)') or error('Unable to add game Add It Up', __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 ("Driving Mad", "drivingmad", "Driving Mad is great golf driving range fun.", "drivingmad.jpg", 800, 600, 9)') or error('Unable to add game Driving Mad', __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 ("Word Spell", "wordspell", "The wizards library is a mess! All of the titles have disappeared from his spell books. Help him out by rearranging the letters to form common words. The more words you find, the more points you score.", "wordspell.jpg", 640, 460, 3)') or error('Unable to add game Freekick', __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 ("Newtons Nightmare", "newtonsnightmare", "Click on two apples to swap them. Each swap must make a matching set of three apples lined up vertically or horizontally. You get extra points for longer matches or for additional matches resulting from a move.", "newtonsnightmare.jpg", 525, 325, 3)') or error('Unable to add game Newtons Nightmare', __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 ("Zig Zag", "zigzag", "Click on tiles with the same pattern to remove them from the board. However, to remove them they must either be touching, or be connected by empty space which can be traversed in a line with no more than two angles.", "zigzag.jpg", 500, 370, 3)') or error('Unable to add game Zig Zag', __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>