<?php
/*********************************************
  CPG Dragonfly - DF_Arcade Module
  ********************************************
  CPG Dragonfly is copyright © 2004 - 2005 by CPG Dev Team
  http://www.dragonflycms.com

  Dragonfly and DF_Arcade are released under the terms
  and conditions of the GNU GPL version 2 or any later version

  port of pnFlashGames - http://pnflashgames.com/
  Written by gerry@redgerry.com
  redgerry.com - Home of RG_Sports
  Revision Date: 16/10/2005 11:46
  Version Number 1.00

  UNDER NO CIRCUMSTANCES MAY THIS CODE BE USED FOR ANY COMMERCIAL
  PURPOSES UNDER THE GUISE OF V.I.P. OR ANY OTHER DESCRIPTION
********************************************************/
if (!defined('ADMIN_MOD_INSTALL')) { exit; }

class DF_Arcade {
	var $description;
	var $radmin;
	var $modname;
	var $version;
	var $author;
	var $website;
	var $dbtables;
// class constructor
	function DF_Arcade() {
		$this->radmin = true;
		$this->version = '1.00';
		$this->modname = 'DF_Arcade';
		$this->description = 'Flash games arcade for Dragonfly';
		$this->author = 'Gerry Shields';
		$this->website = 'www.redgerry.com';
		$this->dbtables = array('rgarcade_cat', 'rgarcade_games', 'rgarcade_gtype_cat', 'rgarcade_hiscores');
	}
// module installer
	function install() {
		global $db, $prefix, $installer;
		$queries = array();
		$queries[] = "CREATE TABLE IF NOT EXISTS ".$prefix."_rgarcade_cat (
		cat_id int(11) NOT NULL auto_increment,
		cname varchar(50) NOT NULL,
		cdescription text NOT NULL,
		cimage varchar(100) NOT NULL,
		hits int(15) NOT NULL default '0',
  		PRIMARY KEY  (cat_id)
)";
		$queries[] = "CREATE TABLE IF NOT EXISTS ".$prefix."_rgarcade_games (
		game_id int(15) NOT NULL auto_increment,
		gcid int(15) NOT NULL default '0',
		gtype int(1) NOT NULL default '0',
		gname varchar(50) NOT NULL,
		gdescription text NOT NULL,
		gimage varchar(100) NOT NULL,
		gfilename varchar(50) NOT NULL,
		gauthorname varchar(100) NOT NULL,
		gauthorurl varchar(100) NOT NULL,
		gwidth int(5) NOT NULL,
		gheight int(5) NOT NULL,
		gcolor int(7) NOT NULL,
		hits int(15) NOT NULL default '0',
		glicensekey varchar(100) NOT NULL,
  		PRIMARY KEY  (game_id)
)";
		$queries[] = "CREATE TABLE IF NOT EXISTS ".$prefix."_rgarcade_gtype_cat (
		gtype_id int(11) NOT NULL auto_increment,
		typename varchar(50) NOT NULL,
		typedesc text NOT NULL,
  		PRIMARY KEY  (gtype_id)
)";
		$queries[] = "CREATE TABLE IF NOT EXISTS ".$prefix."_rgarcade_hiscores (
		high_id int(15) NOT NULL auto_increment,
  		game_id int(15) NOT NULL default '0',
  		uid int(11) NOT NULL,
  		playerscore int(10) NOT NULL default '0',
  		date datetime NOT NULL default '0000-00-00 00:00:00',
  		PRIMARY KEY  (high_id)
)";
		$installer->add_query('INSERT', 'rgarcade_cat', "'1', 'Space', 'Grab your O2 and start floating around', 'spaceani.gif', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'2', 'Just for Fun', 'Games that do not record high scores', 'forfun.png', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'3', 'Action', 'Shoot-em-Ups and the likes', 'actionani.gif', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'4', 'Arcade', 'The classics that you kept your change for', 'arcade.png', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'5', 'Board', 'They use to come in a box with a dice', 'boardani.gif', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'6', 'Casino', 'Bandits, cards and roulette', 'casinoani.gif', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'7', 'Puzzle', 'You dont have to be quick, just smart', 'puzzleani.gif', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'8', 'Racing', 'I feel the need, the need for speed', 'racingani.gif', '0'");
		$installer->add_query('INSERT', 'rgarcade_cat', "'9', 'Sport', 'So much easier from an armchair', 'sportani.gif', '0'");

		$installer->add_query('INSERT', 'rgarcade_gtype_cat', "'1', 'Highest Score Wins', 'Scores will be sorted from Highest to Lowest..  eg. 1st: 500  2nd: 100'");
		$installer->add_query('INSERT', 'rgarcade_gtype_cat', "'2', 'Lowest Score Wins', 'Scores will be sorted from Lowest to Highest.. eg. 1st: 100  2nd: 300'");
		$installer->add_query('INSERT', 'rgarcade_gtype_cat', "'3', 'No Scores Available', 'No Hi-Scores are available for this game'");

		foreach($queries AS $query) {
			$result = $db->sql_query($query, true);
			if (!$result) {
				$this->description = '<b>MySQL Error</b> while executing:<br/>'.$query.'<br/><br/>' . mysql_error();
				return false;
			}
		}
		return true;
	}
// module uninstaller
	function uninstall() {
		global $installer;
		$installer->add_query('DROP', 'rgarcade_cat');
		$installer->add_query('DROP', 'rgarcade_games');
		$installer->add_query('DROP', 'rgarcade_gtype_cat');
		$installer->add_query('DROP', 'rgarcade_hiscores');
		return true;
	}
	function upgrade($prev_version) {
        global $installer, $db, $prefix;

        return true;
    }
}
?>