<a href="install.php?page=step&step=3">link to STEP 3 - Add tables and columns to DB</a>. If you see some errors it mean server has wrong configuration. Check FAQ or ask author of acc. maker.<br />';
$SQL->connect(); // show errors if can't connect
}
elseif($step == 3)
{
echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
echo 'Installer try to add new tables and columns to database.<br>';
$columns = array();
//$columns[] = array('table', 'name_of_column', 'type', 'length', 'default');
$columns[] = array('accounts', 'key', 'VARCHAR', '20', '0');
$columns[] = array('accounts', 'email_new', 'VARCHAR', '255', '');
$columns[] = array('accounts', 'email_new_time', 'INT', '11', '0');
$columns[] = array('accounts', 'rlname', 'VARCHAR', '255', '');
$columns[] = array('accounts', 'location', 'VARCHAR', '255', '');
$columns[] = array('accounts', 'page_access', 'INT', '11', '0');
$columns[] = array('accounts', 'email_code', 'VARCHAR', '255', '');
$columns[] = array('accounts', 'next_email', 'INT', '11', '0');
$columns[] = array('accounts', 'premium_points', 'INT', '11', '0');
$columns[] = array('accounts', 'create_date', 'INT', '11', '0');
$columns[] = array('accounts', 'create_ip', 'INT', '11', '0');
$columns[] = array('accounts', 'last_post', 'INT', '11', '0');
$columns[] = array('accounts', 'flag', 'VARCHAR', '80', '');
$columns[] = array('guilds', 'description', 'TEXT', '', '');
$columns[] = array('guilds', 'guild_logo', 'MEDIUMBLOB', '', NULL);
$columns[] = array('guilds', 'create_ip', 'INT', '11', '0');
$columns[] = array('guilds', 'balance', 'BIGINT UNSIGNED', '', '0');
$columns[] = array('killers', 'war', 'INT', '11', '0');
$columns[] = array('players', 'deleted', 'TINYINT', '1', '0');
$columns[] = array('players', 'description', 'VARCHAR', '255', '');
$columns[] = array('players', 'comment', 'TEXT', '', '');
$columns[] = array('players', 'create_ip', 'INT', '11', '0');
$columns[] = array('players', 'create_date', 'INT', '11', '0');
$columns[] = array('players', 'hide_char', 'INT', '11', '0');
$tables = array();
// mysql tables
$tables[Database::DB_MYSQL]['z_ots_comunication'] = "CREATE TABLE `z_ots_comunication` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`action` varchar(255) NOT NULL,
`param1` varchar(255) NOT NULL,
`param2` varchar(255) NOT NULL,
`param3` varchar(255) NOT NULL,
`param4` varchar(255) NOT NULL,
`param5` varchar(255) NOT NULL,
`param6` varchar(255) NOT NULL,
`param7` varchar(255) NOT NULL,
`delete_it` int(2) NOT NULL default '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$tables[Database::DB_MYSQL]['z_shop_offer'] = "CREATE TABLE `z_shop_offer` (
`id` int(11) NOT NULL auto_increment,
`points` int(11) NOT NULL default '0',
`itemid1` int(11) NOT NULL default '0',
`count1` int(11) NOT NULL default '0',
`itemid2` int(11) NOT NULL default '0',
`count2` int(11) NOT NULL default '0',
`offer_type` varchar(255) default NULL,
`offer_description` text NOT NULL,
`offer_name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$tables[Database::DB_MYSQL]['z_shop_history_item'] = "CREATE TABLE `z_shop_history_item` (
`id` int(11) NOT NULL auto_increment,
`to_name` varchar(255) NOT NULL default '0',
`to_account` int(11) NOT NULL default '0',
`from_nick` varchar(255) NOT NULL,
`from_account` int(11) NOT NULL default '0',
`price` int(11) NOT NULL default '0',
`offer_id` varchar(255) NOT NULL default '',
`trans_state` varchar(255) NOT NULL,
`trans_start` int(11) NOT NULL default '0',
`trans_real` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$tables[Database::DB_MYSQL]['z_forum'] = "CREATE TABLE `z_forum` (
`id` int(11) NOT NULL auto_increment,
`first_post` int(11) NOT NULL default '0',
`last_post` int(11) NOT NULL default '0',
`section` int(3) NOT NULL default '0',
`replies` int(20) NOT NULL default '0',
`views` int(20) NOT NULL default '0',
`author_aid` int(20) NOT NULL default '0',
`author_guid` int(20) NOT NULL default '0',
`post_text` text NOT NULL,
`post_topic` varchar(255) NOT NULL,
`post_smile` tinyint(1) NOT NULL default '0',
`post_date` int(20) NOT NULL default '0',
`last_edit_aid` int(20) NOT NULL default '0',
`edit_date` int(20) NOT NULL default '0',
`post_ip` varchar(15) NOT NULL default '0.0.0.0',
PRIMARY KEY (`id`),
KEY `section` (`section`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$tables[Database::DB_MYSQL]['guild_wars'] = "CREATE TABLE `guild_wars` (
`id` INT NOT NULL AUTO_INCREMENT,
`guild_id` INT NOT NULL,
`enemy_id` INT NOT NULL,
`begin` BIGINT NOT NULL DEFAULT '0',
`end` BIGINT NOT NULL DEFAULT '0',
`frags` INT UNSIGNED NOT NULL DEFAULT '0',
`payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',
`guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `guild_id` (`guild_id`),
KEY `enemy_id` (`enemy_id`)
) ENGINE=InnoDB;";
$tables[Database::DB_MYSQL]['guild_wars_table_references'] = "ALTER TABLE `guild_wars`
ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;";
$tables[Database::DB_MYSQL]['guild_kills'] = "CREATE TABLE `guild_kills` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`guild_id` INT NOT NULL,
`war_id` INT NOT NULL,
`death_id` INT NOT NULL
) ENGINE = InnoDB;";
$tables[Database::DB_MYSQL]['guild_kills_table_references'] = "ALTER TABLE `guild_kills`
ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;";
// sqlite tables
$tables[Database::DB_SQLITE]['z_ots_comunication'] = 'CREATE TABLE "z_ots_comunication" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL,
"type" varchar(255) NOT NULL,
"action" varchar(255) NOT NULL,
"param1" varchar(255) NOT NULL,
"param2" varchar(255) NOT NULL,
"param3" varchar(255) NOT NULL,
"param4" varchar(255) NOT NULL,
"param5" varchar(255) NOT NULL,
"param6" varchar(255) NOT NULL,
"param7" varchar(255) NOT NULL,
"delete_it" int(2) NOT NULL default 1);';
$tables[Database::DB_SQLITE]['z_shop_offer'] = 'CREATE TABLE "z_shop_offer" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"points" int(11) NOT NULL default 0,
"itemid1" int(11) NOT NULL default 0,
"count1" int(11) NOT NULL default 0,
"itemid2" int(11) NOT NULL default 0,
"count2" int(11) NOT NULL default 0,
"offer_type" varchar(255) default NULL,
"offer_description" text NOT NULL,
"offer_name" varchar(255) NOT NULL);';
$tables[Database::DB_SQLITE]['z_shop_history_item'] = 'CREATE TABLE "z_shop_history_item" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"to_name" varchar(255) NOT NULL default 0,
"to_account" int(11) NOT NULL default 0,
"from_nick" varchar(255) NOT NULL,
"from_account" int(11) NOT NULL default 0,
"price" int(11) NOT NULL default 0,
"offer_id" varchar(255) NOT NULL default "",
"trans_state" varchar(255) NOT NULL,
"trans_start" int(11) NOT NULL default 0,
"trans_real" int(11) NOT NULL default 0);';
$tables[Database::DB_SQLITE]['z_forum'] = 'CREATE TABLE "z_forum" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"first_post" int(11) NOT NULL default 0,
"last_post" int(11) NOT NULL default 0,
"section" int(3) NOT NULL default 0,
"replies" int(20) NOT NULL default 0,
"views" int(20) NOT NULL default 0,
"author_aid" int(20) NOT NULL default 0,
"author_guid" int(20) NOT NULL default 0,
"post_text" text NOT NULL,
"post_topic" varchar(255) NOT NULL,
"post_smile" tinyint(1) NOT NULL default 0,
"post_date" int(20) NOT NULL default 0,
"last_edit_aid" int(20) NOT NULL default 0,
"edit_date" int(20) NOT NULL default 0,
"post_ip" varchar(15) NOT NULL default "0.0.0.0");';
foreach($columns as $column)
{
if($column[4] === NULL && $SQL->query('ALTER TABLE ' . $SQL->tableName($column[0]) . ' ADD ' . $SQL->fieldName($column[1]) . ' ' . $column[2] . ' NULL DEFAULT NULL') !== false)
echo "<span style=\"color:green\">Column <b>" . $column[1] . "</b> added to table <b>" . $column[0] . "</b>.</span><br />";
elseif($SQL->query('ALTER TABLE ' . $SQL->tableName($column[0]) . ' ADD ' . $SQL->fieldName($column[1]) . ' ' . $column[2] . '' . (($column[3] == '') ? '' : '(' . $column[3] . ')') . ' NOT NULL DEFAULT \'' . $column[4] . '\'') !== false)
echo "<span style=\"color:green\">Column <b>" . $column[1] . "</b> added to table <b>" . $column[0] . "</b>.</span><br />";
else
echo "Could not add column <b>" . $column[1] . "</b> to table <b>" . $column[0] . "</b>. Already exist?<br />";
}
foreach($tables[$SQL->getDatabaseDriver()] as $tableName => $tableQuery)
{
if($SQL->query($tableQuery) !== false)
echo "<span style=\"color:green\">Table <b>" . $tableName . "</b> created.</span><br />";
else
echo "Could not create table <b>" . $tableName . "</b>. Already exist?<br />";
}
echo 'Tables and columns added to database.<br>Go to <a href="install.php?page=step&step=4">STEP 4 - Add samples</a>';
}
elseif($step == 4)
{
echo '<h1>STEP '.$step.'</h1>Add samples to DB:<br>';
$samplePlayers = array();
$samplePlayers[0] = 'Rook Sample';
$samplePlayers[1] = 'Sorcerer Sample';
$samplePlayers[2] = 'Druid Sample';
$samplePlayers[3] = 'Paladin Sample';
$samplePlayers[4] = 'Knight Sample';
$newPlayer = new Player('Account Manager', Player::LOADTYPE_NAME);
if($newPlayer->isLoaded())
{
foreach($samplePlayers as $vocationID => $name)
{
$samplePlayer = new Player($name, Player::LOADTYPE_NAME);
if(!$samplePlayer->isLoaded())
{
$samplePlayer = new Player('Account Manager', Player::LOADTYPE_NAME);
$samplePlayer->setID(null); // save as new player, not edited
$samplePlayer->setName($name);
$samplePlayer->setVocation($vocationID);
$samplePlayer->setGroupID(1);
$samplePlayer->setLookType(128);
$samplePlayer->save();
echo '<span style="color:green">Added sample character: </span><span style="color:green;font-weight:bold">' . $name . '</span><br/>';
}
else
echo 'Sample character: <span style="font-weight:bold">' . $name . '</span> already exist in database<br/>';
}
}
else
new Error_Critic('', 'Character <i>Account Manager</i> does not exist. Cannot install sample characters!');
}
elseif($step == 5)
{
echo '<h1>STEP '.$step.'</h1>Set Admin Account<br>';
if(empty($_REQUEST['saveaccpassword']))
{
echo 'Admin account login is: <b>1</b><br/>Set new password to this account.<br>';
echo 'New password: <form action="install.php" method=POST><input type="text" name="newpass" size="35">(Don\'t give it password to anyone!)';
echo '<input type="hidden" name="saveaccpassword" value="yes"><input type="hidden" name="page" value="step"><input type="hidden" name="step" value="5"><input type="submit" value="SET"></form><br>If account with login 1 doesn\'t exist installator will create it and set your password.';
}
else
{
include_once('./system/load.compat.php');
$newpass = trim($_POST['newpass']);
if(!check_password($newpass))
echo 'Password contains illegal characters. Please use only a-Z and 0-9. <a href="install.php?page=step&step=5">GO BACK</a> and write other password.';
else
{
//create / set pass to admin account
$account = new Account(1, Account::LOADTYPE_NAME);
if($account->isLoaded())
{
$account->setPassword($newpass); // setPassword encrypt it to ots encryption
$account->setPageAccess(3);
$account->setFlag('unknown');
$account->save();
}
else
{
$newAccount = new Account();
$newAccount->setName(1);
$newAccount->setPassword($newpass); // setPassword encrypt it to ots encryption
$newAccount->setMail(rand(0,999999) . '@gmail.com');
$newAccount->setPageAccess(3);
$newAccount->setGroupID(1);
$newAccount->setFlag('unknown');
$newAccount->setCreateIP(Visitor::getIP());
$newAccount->setCreateDate(time());
}
$_SESSION['account'] = 1;
$_SESSION['password'] = $newpass;
$logged = TRUE;
echo '<h1>Admin account login: 1<br>Admin account password: '.$newpass.'</h1><br/><h3>It\'s end of installation. Installation is blocked!</h3>';
if(!unlink('install.txt'))
new Error_Critic('', 'Cannot remove file <i>install.txt</i>. You must remove it to disable installer. I recommend you to go to step <i>0</i> and check if any other file got problems with WRITE permission.');
}
}
}