<?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 ("Black Jack", "blackjack", "In blackjack, the players bet against the house dealer rather than against each other.<br>The goal of each player is to have a higher point total than the dealer without going over 21.", "blackjack.jpg", 550, 400, 5)') or error('Unable to add game Black Jack', __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 ("Kwikshot", "kwikshot", "Try to hit the clays as they fly past the screen.<br>You only have 2 shots per pair of clays!", "kwikshot.jpg", 550, 400, 2)') or error('Unable to add game Kwikshot', __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 ("Golden Arrow 2", "goldenarrow2", "If you like wearing silly hats and tights then this is the game for you.<br>Try your hand in Practice mode before entering Tournament mode. ", "goldenarrow2.jpg", 550, 400, 9)') or error('Unable to add game Golden Arrow 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 ("Bumper Cards", "bumpercards", "Add cards to stack until they add up to 21 in this popular solitaire variant.", "bumpercards.jpg", 720, 465, 5)') or error('Unable to add game Bumber Cards', __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 ("Match", "match", "Flip cards by clicking on them.<br>Flip two matching cards to clear them.", "match.jpg", 600, 450, 3)') or error('Unable to add game Match', __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 2", "plumber2", "Rotate the pipes and align them properly so that the water flows from one end to the other.", "plumber2.jpg", 720, 485, 3)') or error('Unable to add game Plumber 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 ("Skeet Shoot", "skeetshoot", "See how good of a skeet shooter you are.", "skeetshoot.jpg", 740, 480, 2)') or error('Unable to add game Skeet Shoot', __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 ("Bloody Day", "bloodyday", "Plane, simple and violent pretty much sums this game up.<br>You are camping behing a trash can and shooting the poor stick figure enemies who can only hope you miss.<br>Great game if you have to take your anger out on something, enjoy!", "bloodyday.jpg", 550, 400, 2)') or error('Unable to add game Bloody Day', __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 ("H O R S E", "horse", "Classic backyard basketball game.", "horse.jpg", 720, 400, 9)') or error('Unable to add game H O R S 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 ("Garage Door Tennis", "garagedoortennis", "Another backyard classic to help you reminisce about lazy summer days while avoiding thoughts about your corporate existence.", "garageDoortennis.jpg", 535, 400, 9)') or error('Unable to add game Garage Door Tennis', __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 ("Rat Wheel", "ratwheel", "Do crazy tricks on your treadmill as the worlds most acrobatic rat!", "ratwheel.jpg", 550, 400, 4)') or error('Unable to add game Rat Wheel', __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 ("Mooncave", "mooncave", "Collect all the energy spheres while controlling your space pod in dangerous caves.<br>Watch out for walls and other obstacles!", "mooncave.jpg", 550, 400, 4)') or error('Unable to add game Mooncave', __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 Garden", "mahjonggarden", "Mahjong is a traditional Chinese game for centuries, Mahjong combines elements of skill, strategy, memory, and intuition into a challenging game of patience.", "mahjonggarden.jpg", 680, 500, 3)') or error('Unable to add game Mahjong Garden', __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 Tales", "fishtales", "Eat others and grow or you will be eaten by others.<br>In Fish Tales, its your job to aid Sunny in his quest to survive the treacherous waters.Stop the big fish from eating him and help him grow big and strong on tadpole treats.", "fishtales.jpg", 550, 400, 4)') or error('Unable to add game Fish Tales', __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 Drop", "magicdrop", "Help wizard to arrange identical magic potions in groups of 3 or more to keep them from overflowing the screen.", "magicdrop.jpg", 550, 400, 3)') or error('Unable to add game Magic Drop', __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 ("Yeti Bubbles Arcade", "yetibubblesarcade", "Fire colored balls to make groups of three or more, but dont let them reach the water.", "yetibubblesarcade.jpg", 550, 400, 3)') or error('Unable to add game Yeti Bubbles Arcade', __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 ("Yeti Bubbles Classic", "yetibubblesclassic", "Fire colored balls to make groups of three or more, but dont let them reach the water.", "yetibubblesclassic.jpg", 550, 400, 3)') or error('Unable to add game Yeti Bubbles Arcade', __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 ("Minesweeper", "minesweeper", "Try to locate all the mines hidden below a square grid.", "minesweeper.jpg", 700, 500, 3)') or error('Unable to add game Minesweeper', __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 ("Rumble Ball 4", "rumbleball4", "This is the advanced version with more challenging levels.<br>Hit the metal ball around and destroy the blocks.", "rumbleball4.jpg", 440, 590, 4)') or error('Unable to add game Rumble Ball 4', __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 ("Galaxy Invaders", "galaxyinvaders", "This game is sort of like the space invaders arcade game but with a twist.", "galaxyinvaders.jpg", 550, 400, 1)') or error('Unable to add game Yeti Bubbles Arcade', __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 Clones", "alienclones", "Shoot all the Alien Clones and save the planet from destruction.", "alienclones.jpg", 600, 540, 1)') or error('Unable to add game Alien Clones', __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 ("Burger Time", "burgertime", "Help the chef make burgers by putting together all the pieces scattered around, avoiding the hotdogs!", "burgertime.jpg", 480, 512, 4)') or error('Unable to add game Burger Time', __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 ("Gold Strike", "goldstrike", "Click on a block of rock or gold to throw a pick at it.<br>If two or more blocks of the same type are connected, you can remove all of the connected blocks.", "goldstrike.jpg", 640, 460, 3)') or error('Unable to add game Gold Strike', __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 ("Klondike Solitaire", "klondike", "Classic Solitaire game, stack the cards from king to ace, and move them to the top right pales, ace to king.", "klondike.jpg", 720, 500, 5)') or error('Unable to add game Klondike 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 ("Turbo Spirit", "turbospirit", "This race motorcycle game features one track with five segments.<br>You have 30 seconds for each segment, dont run out of time!", "turbospirit.jpg", 550, 400, 8)') or error('Unable to add game Turbo Spirit', __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>