diff --git a/TODO b/TODO
index 2ba0c32b..c2412624 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,6 @@
0.*
* support duplicated vocation names with different ids
* sandbox for plugins, don't install when requirements are not passed
- * load items & weapons on install, preferably with ajax
* add changelog management interface
* plugins require:
* php extension
diff --git a/images/loading_spinner.gif b/images/loading_spinner.gif
new file mode 100644
index 00000000..b3893127
Binary files /dev/null and b/images/loading_spinner.gif differ
diff --git a/install/includes/config.php b/install/includes/config.php
index 67a73e03..ccb38f72 100644
--- a/install/includes/config.php
+++ b/install/includes/config.php
@@ -6,36 +6,36 @@ if(!isset($_SESSION['var_server_path'])) {
$error = true;
}
- $config['server_path'] = $_SESSION['var_server_path'];
- // take care of trailing slash at the end
- if($config['server_path'][strlen($config['server_path']) - 1] != '/')
- $config['server_path'] .= '/';
+$config['server_path'] = $_SESSION['var_server_path'];
+// take care of trailing slash at the end
+if($config['server_path'][strlen($config['server_path']) - 1] != '/')
+ $config['server_path'] .= '/';
if((!isset($error) || !$error) && !file_exists($config['server_path'] . 'config.lua')) {
- error($locale['step_database_error_config']);
+ error($locale['step_database_error_config']);
+ $error = true;
+}
+
+if(!isset($error) || !$error) {
+ $config['lua'] = load_config_lua($config['server_path'] . 'config.lua');
+ if(isset($config['lua']['sqlType'])) // tfs 0.3
+ $config['database_type'] = $config['lua']['sqlType'];
+ else if(isset($config['lua']['mysqlHost'])) // tfs 0.2/1.0
+ $config['database_type'] = 'mysql';
+ else if(isset($config['lua']['database_type'])) // otserv
+ $config['database_type'] = $config['lua']['database_type'];
+ else if(isset($config['lua']['sql_type'])) // otserv
+ $config['database_type'] = $config['lua']['sql_type'];
+
+ $config['database_type'] = strtolower($config['database_type']);
+ if(empty($config['database_type'])) {
+ error($locale['step_database_error_database_empty']);
$error = true;
}
-
- if(!isset($error) || !$error) {
- $config['lua'] = load_config_lua($config['server_path'] . 'config.lua');
- if(isset($config['lua']['sqlType'])) // tfs 0.3
- $config['database_type'] = $config['lua']['sqlType'];
- else if(isset($config['lua']['mysqlHost'])) // tfs 0.2/1.0
- $config['database_type'] = 'mysql';
- else if(isset($config['lua']['database_type'])) // otserv
- $config['database_type'] = $config['lua']['database_type'];
- else if(isset($config['lua']['sql_type'])) // otserv
- $config['database_type'] = $config['lua']['sql_type'];
-
- $config['database_type'] = strtolower($config['database_type']);
- if(empty($config['database_type'])) {
- error($locale['step_database_error_database_empty']);
- $error = true;
- }
- else if($config['database_type'] != 'mysql') {
- $locale['step_database_error_only_mysql'] = str_replace('$DATABASE_TYPE$', '' . $config['database_type'] . '', $locale['step_database_error_only_mysql']);
- error($locale['step_database_error_only_mysql']);
- $error = true;
- }
+ else if($config['database_type'] != 'mysql') {
+ $locale['step_database_error_only_mysql'] = str_replace('$DATABASE_TYPE$', '' . $config['database_type'] . '', $locale['step_database_error_only_mysql']);
+ error($locale['step_database_error_only_mysql']);
+ $error = true;
}
+}
?>
\ No newline at end of file
diff --git a/install/steps/1-welcome.php b/install/steps/1-welcome.php
index 54391e9e..8a38e8ce 100644
--- a/install/steps/1-welcome.php
+++ b/install/steps/1-welcome.php
@@ -1,6 +1,6 @@
' . $locale['already_installed'] . '
';
}
else {
diff --git a/install/steps/5-database.php b/install/steps/5-database.php
index 23494e14..479503b8 100644
--- a/install/steps/5-database.php
+++ b/install/steps/5-database.php
@@ -47,197 +47,11 @@ if(!$error) {
success($locale['step_database_importing']);
require(BASE . 'install/includes/database.php');
- if(!$db->hasTable('accounts')) {
- $locale['step_database_error_table'] = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
- error($locale['step_database_error_table']);
- $error = true;
- }
- else if(!$db->hasTable('players')) {
- $locale['step_database_error_table'] = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
- error($locale['step_database_error_table']);
- $error = true;
- }
- else if(!$db->hasTable('guilds')) {
- $locale['step_database_error_table'] = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
- error($locale['step_database_error_table']);
- $error = true;
- }
+ echo $twig->render('install.installer.html.twig', array(
+ 'url' => 'tools/5-database.php',
+ 'message' => $locale['loading_spinner']
+ ));
- if($db->hasTable(TABLE_PREFIX . 'account_actions')) {
- $locale['step_database_error_table_exist'] = str_replace('$TABLE$', TABLE_PREFIX . 'account_actions', $locale['step_database_error_table_exist']);
- warning($locale['step_database_error_table_exist']);
- }
- else if(!$error) {
- // import schema
- try {
- $db->query(file_get_contents(BASE . 'install/includes/schema.sql'));
- }
- catch(PDOException $error_) {
- error($locale['step_database_error_schema'] . ' ' . $error_);
- $error = true;
- }
-
- if(!$error) {
- registerDatabaseConfig('database_version', DATABASE_VERSION);
- $locale['step_database_success_schema'] = str_replace('$PREFIX$', TABLE_PREFIX, $locale['step_database_success_schema']);
- success($locale['step_database_success_schema']);
- }
- }
-
- if(!$error) {
- if($db->hasColumn('accounts', 'key')) {
- if(query("ALTER TABLE `accounts` MODIFY `key` VARCHAR(64) NOT NULL DEFAULT '';"))
- success($locale['step_database_modifying_field'] . ' accounts.key...');
- }
- else {
- if(query("ALTER TABLE `accounts` ADD `key` VARCHAR(64) NOT NULL DEFAULT '' AFTER `email`;"))
- success($locale['step_database_adding_field'] . ' accounts.key...');
- }
-
- if(!$db->hasColumn('accounts', 'blocked')) {
- if(query("ALTER TABLE `accounts` ADD `blocked` TINYINT(1) NOT NULL DEFAULT FALSE COMMENT 'internal usage' AFTER `key`;"))
- success($locale['step_database_adding_field'] . ' accounts.blocked...');
- }
-
- if(!$db->hasColumn('accounts', 'created')) {
- if(query("ALTER TABLE `accounts` ADD `created` INT(11) NOT NULL DEFAULT 0 AFTER `" . ($db->hasColumn('accounts', 'group_id') ? 'group_id' : 'blocked') . "`;"))
- success($locale['step_database_adding_field'] . ' accounts.created...');
- }
-
- if(!$db->hasColumn('accounts', 'rlname')) {
- if(query("ALTER TABLE `accounts` ADD `rlname` VARCHAR(255) NOT NULL DEFAULT '' AFTER `created`;"))
- success($locale['step_database_adding_field'] . ' accounts.rlname...');
- }
-
- if(!$db->hasColumn('accounts', 'location')) {
- if(query("ALTER TABLE `accounts` ADD `location` VARCHAR(255) NOT NULL DEFAULT '' AFTER `rlname`;"))
- success($locale['step_database_adding_field'] . ' accounts.location...');
- }
-
- if(!$db->hasColumn('accounts', 'country')) {
- if(query("ALTER TABLE `accounts` ADD `country` VARCHAR(3) NOT NULL DEFAULT '' AFTER `location`;"))
- success($locale['step_database_adding_field'] . ' accounts.country...');
- }
-
- if($db->hasColumn('accounts', 'page_lastday')) {
- if(query("ALTER TABLE `accounts` CHANGE `page_lastday` `web_lastlogin` INT(11) NOT NULL DEFAULT 0;")) {
- $tmp = str_replace('$FIELD$', 'accounts.page_lastday', $locale['step_database_changing_field']);
- $tmp = str_replace('$FIELD_NEW$', 'accounts.web_lastlogin', $tmp);
- success($tmp);
- }
- }
- else if(!$db->hasColumn('accounts', 'web_lastlogin')) {
- if(query("ALTER TABLE `accounts` ADD `web_lastlogin` INT(11) NOT NULL DEFAULT 0 AFTER `country`;"))
- success($locale['step_database_adding_field'] . ' accounts.web_lastlogin...');
- }
-
- if(!$db->hasColumn('accounts', 'web_flags')) {
- if(query("ALTER TABLE `accounts` ADD `web_flags` INT(11) NOT NULL DEFAULT 0 AFTER `web_lastlogin`;"))
- success($locale['step_database_adding_field'] . ' accounts.web_flags...');
- }
-
- if(!$db->hasColumn('accounts', 'email_hash')) {
- if(query("ALTER TABLE `accounts` ADD `email_hash` VARCHAR(32) NOT NULL DEFAULT '' AFTER `web_flags`;"))
- success($locale['step_database_adding_field'] . ' accounts.email_hash...');
- }
-
- if(!$db->hasColumn('accounts', 'email_verified')) {
- if(query("ALTER TABLE `accounts` ADD `email_verified` TINYINT(1) NOT NULL DEFAULT 0 AFTER `email_hash`;"))
- success($locale['step_database_adding_field'] . ' accounts.email_verified...');
- }
-
- if(!$db->hasColumn('accounts', 'email_new')) {
- if(query("ALTER TABLE `accounts` ADD `email_new` VARCHAR(255) NOT NULL DEFAULT '' AFTER `email_hash`;"))
- success($locale['step_database_adding_field'] . ' accounts.email_new...');
- }
-
- if(!$db->hasColumn('accounts', 'email_new_time')) {
- if(query("ALTER TABLE `accounts` ADD `email_new_time` INT(11) NOT NULL DEFAULT 0 AFTER `email_new`;"))
- success($locale['step_database_adding_field'] . ' accounts.email_new_time...');
- }
-
- if(!$db->hasColumn('accounts', 'email_code')) {
- if(query("ALTER TABLE `accounts` ADD `email_code` VARCHAR(255) NOT NULL DEFAULT '' AFTER `email_new_time`;"))
- success($locale['step_database_adding_field'] . ' accounts.email_code...');
- }
-
- if($db->hasColumn('accounts', 'next_email')) {
- if(!$db->hasColumn('accounts', 'email_next')) {
- if(query("ALTER TABLE `accounts` CHANGE `next_email` `email_next` INT(11) NOT NULL DEFAULT 0;")) {
- $tmp = str_replace('$FIELD$', 'accounts.next_email', $locale['step_database_changing_field']);
- $tmp = str_replace('$FIELD_NEW$', 'accounts.email_next', $tmp);
- success($tmp);
- }
- }
- }
- else if(!$db->hasColumn('accounts', 'email_next')) {
- if(query("ALTER TABLE `accounts` ADD `email_next` INT(11) NOT NULL DEFAULT 0 AFTER `email_code`;"))
- success($locale['step_database_adding_field'] . ' accounts.email_next...');
- }
-
- if(!$db->hasColumn('accounts', 'premium_points')) {
- if(query("ALTER TABLE `accounts` ADD `premium_points` INT(11) NOT NULL DEFAULT 0 AFTER `email_next`;"))
- success($locale['step_database_adding_field'] . ' accounts.premium_points...');
- }
-
- if(!$db->hasColumn('guilds', 'description')) {
- if(query("ALTER TABLE `guilds` ADD `description` TEXT NOT NULL;"))
- success($locale['step_database_adding_field'] . ' guilds.description...');
- }
-
- if($db->hasColumn('guilds', 'logo_gfx_name')) {
- if(query("ALTER TABLE `guilds` CHANGE `logo_gfx_name` `logo_name` VARCHAR( 255 ) NOT NULL DEFAULT 'default.gif';")) {
- $tmp = str_replace('$FIELD$', 'guilds.logo_gfx_name', $locale['step_database_changing_field']);
- $tmp = str_replace('$FIELD_NEW$', 'guilds.logo_name', $tmp);
- success($tmp);
- }
- }
- else if(!$db->hasColumn('guilds', 'logo_name')) {
- if(query("ALTER TABLE `guilds` ADD `logo_name` VARCHAR( 255 ) NOT NULL DEFAULT 'default.gif';"))
- success($locale['step_database_adding_field'] . ' guilds.logo_name...');
- }
-
- if(!$db->hasColumn('players', 'created')) {
- if(query("ALTER TABLE `players` ADD `created` INT(11) NOT NULL DEFAULT 0;"))
- success($locale['step_database_adding_field'] . ' players.created...');
- }
-
- if(!$db->hasColumn('players', 'deleted') && !$db->hasColumn('players', 'deletion')) {
- if(query("ALTER TABLE `players` ADD `deleted` TINYINT(1) NOT NULL DEFAULT 0;"))
- success($locale['step_database_adding_field'] . ' players.comment...');
- }
-
- if($db->hasColumn('players', 'hide_char')) {
- if(!$db->hasColumn('players', 'hidden')) {
- if(query("ALTER TABLE `players` CHANGE `hide_char` `hidden` TINYINT(1) NOT NULL DEFAULT 0;")) {
- $tmp = str_replace('$FIELD$', 'players.hide_char', $locale['step_database_changing_field']);
- $tmp = str_replace('$FIELD_NEW$', 'players.hidden', $tmp);
- success($tmp);
- }
- }
- }
- else if(!$db->hasColumn('players', 'hidden')) {
- if(query("ALTER TABLE `players` ADD `hidden` TINYINT(1) NOT NULL DEFAULT 0;"))
- success($locale['step_database_adding_field'] . ' players.hidden...');
- }
-
- if(!$db->hasColumn('players', 'comment')) {
- if(query("ALTER TABLE `players` ADD `comment` TEXT NOT NULL;"))
- success($locale['step_database_adding_field'] . ' players.comment...');
- }
-
- if($db->hasColumn('players', 'rank_id')) {
- if(query("ALTER TABLE players MODIFY `rank_id` INT(11) NOT NULL DEFAULT 0;"))
- success($locale['step_database_modifying_field'] . ' players.rank_id...');
-
- if($db->hasColumn('players', 'guildnick')) {
- if(query("ALTER TABLE players MODIFY `guildnick` VARCHAR(255) NOT NULL DEFAULT '';")) {
- success($locale['step_database_modifying_field'] . ' players.guildnick...');
- }
- }
- }
- }
-
if(!$error) {
if(!Validator::email($_SESSION['var_mail_admin'])) {
error($locale['step_config_mail_admin_error']);
diff --git a/install/steps/7-finish.php b/install/steps/7-finish.php
index ac18cb19..30d30732 100644
--- a/install/steps/7-finish.php
+++ b/install/steps/7-finish.php
@@ -114,71 +114,11 @@ else {
success($locale['step_database_created_news']);
}
}
-
- $deleted = 'deleted';
- if($db->hasColumn('players', 'deletion'))
- $deleted = 'deletion';
-
- $time = time();
- function insert_sample_if_not_exist($p) {
- global $db, $success, $deleted, $time;
-
- $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote($p['name']));
- if($query->rowCount() == 0) {
- if(!query("INSERT INTO `players` (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `lastlogout`, `balance`, `$deleted`, `created`, `hidden`, `comment`) VALUES (null, " . $db->quote($p['name']) . ", 1, " . getSession('account') . ", " . $p['level'] . ", " . $p['vocation_id'] . ", " . $p['health'] . ", " . $p['healthmax'] . ", " . $p['experience'] . ", 118, 114, 38, 57, " . $p['looktype'] . ", 0, " . $p['mana'] . ", " . $p['manamax'] . ", 0, " . $p['soul'] . ", 1, 1000, 1000, 7, '', " . $p['cap'] . ", 1, " . $time . ", 2130706433, 1, " . $time . ", 0, 0, " . $time . ", 1, '');"))
- $success = false;
- }
- }
-
- $success = true;
- insert_sample_if_not_exist(array('name' => 'Rook Sample', 'level' => 1, 'vocation_id' => 0, 'health' => 150, 'healthmax' => 150, 'experience' => 0, 'looktype' => 130, 'mana' => 0, 'manamax' => 0, 'soul' => 100, 'cap' => 400));
- insert_sample_if_not_exist(array('name' => 'Sorcerer Sample', 'level' => 8, 'vocation_id' => 1, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 130, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
- insert_sample_if_not_exist(array('name' => 'Druid Sample', 'level' => 8, 'vocation_id' => 2, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 130, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
- insert_sample_if_not_exist(array('name' => 'Paladin Sample', 'level' => 8, 'vocation_id' => 3, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 129, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
- insert_sample_if_not_exist(array('name' => 'Knight Sample', 'level' => 8, 'vocation_id' => 4, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 131, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
-
- if($success) {
- success($locale['step_database_imported_players']);
- }
- require(LIBS . 'creatures.php');
- if(Creatures::loadFromXML()) {
- success($locale['step_database_loaded_monsters']);
-
- if(Creatures::getMonstersList()->hasErrors()) {
- $locale['step_database_error_monsters'] = str_replace('$LOG$', 'system/logs/error.log', $locale['step_database_error_monsters']);
- warning($locale['step_database_error_monsters']);
- }
- }
- else {
- error(Creatures::getLastError());
- }
-
- require(LIBS . 'spells.php');
- if(Spells::loadFromXML()) {
- success($locale['step_database_loaded_spells']);
- }
- else {
- error(Spells::getLastError());
- }
-
- $query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . " OR `name` = " . $db->quote("Account Manager") . ") ORDER BY `id`;");
-
- // update config.highscores_ids_hidden
- require_once(SYSTEM . 'migrations/20.php');
- $database_migration_20 = true;
- $content = '';
- if(!databaseMigration20($content)) {
- $locale['step_database_error_file'] = str_replace('$FILE$', '
diff --git a/install/tools/5-database.php b/install/tools/5-database.php
new file mode 100644
index 00000000..251f5331
--- /dev/null
+++ b/install/tools/5-database.php
@@ -0,0 +1,208 @@
+hasTable('accounts')) {
+ $locale['step_database_error_table'] = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
+ error($locale['step_database_error_table']);
+ $error = true;
+}
+else if(!$db->hasTable('players')) {
+ $locale['step_database_error_table'] = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
+ error($locale['step_database_error_table']);
+ $error = true;
+}
+else if(!$db->hasTable('guilds')) {
+ $locale['step_database_error_table'] = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
+ error($locale['step_database_error_table']);
+ $error = true;
+}
+
+if($db->hasTable(TABLE_PREFIX . 'account_actions')) {
+ $locale['step_database_error_table_exist'] = str_replace('$TABLE$', TABLE_PREFIX . 'account_actions', $locale['step_database_error_table_exist']);
+ warning($locale['step_database_error_table_exist']);
+}
+else if(!$error) {
+ // import schema
+ try {
+ $db->query(file_get_contents(BASE . 'install/includes/schema.sql'));
+
+ registerDatabaseConfig('database_version', DATABASE_VERSION);
+ $locale['step_database_success_schema'] = str_replace('$PREFIX$', TABLE_PREFIX, $locale['step_database_success_schema']);
+ success($locale['step_database_success_schema']);
+ }
+ catch(PDOException $error_) {
+ error($locale['step_database_error_schema'] . ' ' . $error_);
+ $error = true;
+ }
+}
+
+if($error) {
+ return;
+}
+
+if($db->hasColumn('accounts', 'key')) {
+ if(query("ALTER TABLE `accounts` MODIFY `key` VARCHAR(64) NOT NULL DEFAULT '';"))
+ success($locale['step_database_modifying_field'] . ' accounts.key...');
+}
+else {
+ if(query("ALTER TABLE `accounts` ADD `key` VARCHAR(64) NOT NULL DEFAULT '' AFTER `email`;"))
+ success($locale['step_database_adding_field'] . ' accounts.key...');
+}
+
+if(!$db->hasColumn('accounts', 'blocked')) {
+ if(query("ALTER TABLE `accounts` ADD `blocked` TINYINT(1) NOT NULL DEFAULT FALSE COMMENT 'internal usage' AFTER `key`;"))
+ success($locale['step_database_adding_field'] . ' accounts.blocked...');
+}
+
+if(!$db->hasColumn('accounts', 'created')) {
+ if(query("ALTER TABLE `accounts` ADD `created` INT(11) NOT NULL DEFAULT 0 AFTER `" . ($db->hasColumn('accounts', 'group_id') ? 'group_id' : 'blocked') . "`;"))
+ success($locale['step_database_adding_field'] . ' accounts.created...');
+}
+
+if(!$db->hasColumn('accounts', 'rlname')) {
+ if(query("ALTER TABLE `accounts` ADD `rlname` VARCHAR(255) NOT NULL DEFAULT '' AFTER `created`;"))
+ success($locale['step_database_adding_field'] . ' accounts.rlname...');
+}
+
+if(!$db->hasColumn('accounts', 'location')) {
+ if(query("ALTER TABLE `accounts` ADD `location` VARCHAR(255) NOT NULL DEFAULT '' AFTER `rlname`;"))
+ success($locale['step_database_adding_field'] . ' accounts.location...');
+}
+
+if(!$db->hasColumn('accounts', 'country')) {
+ if(query("ALTER TABLE `accounts` ADD `country` VARCHAR(3) NOT NULL DEFAULT '' AFTER `location`;"))
+ success($locale['step_database_adding_field'] . ' accounts.country...');
+}
+
+if($db->hasColumn('accounts', 'page_lastday')) {
+ if(query("ALTER TABLE `accounts` CHANGE `page_lastday` `web_lastlogin` INT(11) NOT NULL DEFAULT 0;")) {
+ $tmp = str_replace('$FIELD$', 'accounts.page_lastday', $locale['step_database_changing_field']);
+ $tmp = str_replace('$FIELD_NEW$', 'accounts.web_lastlogin', $tmp);
+ success($tmp);
+ }
+}
+else if(!$db->hasColumn('accounts', 'web_lastlogin')) {
+ if(query("ALTER TABLE `accounts` ADD `web_lastlogin` INT(11) NOT NULL DEFAULT 0 AFTER `country`;"))
+ success($locale['step_database_adding_field'] . ' accounts.web_lastlogin...');
+}
+
+if(!$db->hasColumn('accounts', 'web_flags')) {
+ if(query("ALTER TABLE `accounts` ADD `web_flags` INT(11) NOT NULL DEFAULT 0 AFTER `web_lastlogin`;"))
+ success($locale['step_database_adding_field'] . ' accounts.web_flags...');
+}
+
+if(!$db->hasColumn('accounts', 'email_hash')) {
+ if(query("ALTER TABLE `accounts` ADD `email_hash` VARCHAR(32) NOT NULL DEFAULT '' AFTER `web_flags`;"))
+ success($locale['step_database_adding_field'] . ' accounts.email_hash...');
+}
+
+if(!$db->hasColumn('accounts', 'email_verified')) {
+ if(query("ALTER TABLE `accounts` ADD `email_verified` TINYINT(1) NOT NULL DEFAULT 0 AFTER `email_hash`;"))
+ success($locale['step_database_adding_field'] . ' accounts.email_verified...');
+}
+
+if(!$db->hasColumn('accounts', 'email_new')) {
+ if(query("ALTER TABLE `accounts` ADD `email_new` VARCHAR(255) NOT NULL DEFAULT '' AFTER `email_hash`;"))
+ success($locale['step_database_adding_field'] . ' accounts.email_new...');
+}
+
+if(!$db->hasColumn('accounts', 'email_new_time')) {
+ if(query("ALTER TABLE `accounts` ADD `email_new_time` INT(11) NOT NULL DEFAULT 0 AFTER `email_new`;"))
+ success($locale['step_database_adding_field'] . ' accounts.email_new_time...');
+}
+
+if(!$db->hasColumn('accounts', 'email_code')) {
+ if(query("ALTER TABLE `accounts` ADD `email_code` VARCHAR(255) NOT NULL DEFAULT '' AFTER `email_new_time`;"))
+ success($locale['step_database_adding_field'] . ' accounts.email_code...');
+}
+
+if($db->hasColumn('accounts', 'next_email')) {
+ if(!$db->hasColumn('accounts', 'email_next')) {
+ if(query("ALTER TABLE `accounts` CHANGE `next_email` `email_next` INT(11) NOT NULL DEFAULT 0;")) {
+ $tmp = str_replace('$FIELD$', 'accounts.next_email', $locale['step_database_changing_field']);
+ $tmp = str_replace('$FIELD_NEW$', 'accounts.email_next', $tmp);
+ success($tmp);
+ }
+ }
+}
+else if(!$db->hasColumn('accounts', 'email_next')) {
+ if(query("ALTER TABLE `accounts` ADD `email_next` INT(11) NOT NULL DEFAULT 0 AFTER `email_code`;"))
+ success($locale['step_database_adding_field'] . ' accounts.email_next...');
+}
+
+if(!$db->hasColumn('accounts', 'premium_points')) {
+ if(query("ALTER TABLE `accounts` ADD `premium_points` INT(11) NOT NULL DEFAULT 0 AFTER `email_next`;"))
+ success($locale['step_database_adding_field'] . ' accounts.premium_points...');
+}
+
+if(!$db->hasColumn('guilds', 'description')) {
+ if(query("ALTER TABLE `guilds` ADD `description` TEXT NOT NULL;"))
+ success($locale['step_database_adding_field'] . ' guilds.description...');
+}
+
+if($db->hasColumn('guilds', 'logo_gfx_name')) {
+ if(query("ALTER TABLE `guilds` CHANGE `logo_gfx_name` `logo_name` VARCHAR( 255 ) NOT NULL DEFAULT 'default.gif';")) {
+ $tmp = str_replace('$FIELD$', 'guilds.logo_gfx_name', $locale['step_database_changing_field']);
+ $tmp = str_replace('$FIELD_NEW$', 'guilds.logo_name', $tmp);
+ success($tmp);
+ }
+}
+else if(!$db->hasColumn('guilds', 'logo_name')) {
+ if(query("ALTER TABLE `guilds` ADD `logo_name` VARCHAR( 255 ) NOT NULL DEFAULT 'default.gif';"))
+ success($locale['step_database_adding_field'] . ' guilds.logo_name...');
+}
+
+if(!$db->hasColumn('players', 'created')) {
+ if(query("ALTER TABLE `players` ADD `created` INT(11) NOT NULL DEFAULT 0;"))
+ success($locale['step_database_adding_field'] . ' players.created...');
+}
+
+if(!$db->hasColumn('players', 'deleted') && !$db->hasColumn('players', 'deletion')) {
+ if(query("ALTER TABLE `players` ADD `deleted` TINYINT(1) NOT NULL DEFAULT 0;"))
+ success($locale['step_database_adding_field'] . ' players.comment...');
+}
+
+if($db->hasColumn('players', 'hide_char')) {
+ if(!$db->hasColumn('players', 'hidden')) {
+ if(query("ALTER TABLE `players` CHANGE `hide_char` `hidden` TINYINT(1) NOT NULL DEFAULT 0;")) {
+ $tmp = str_replace('$FIELD$', 'players.hide_char', $locale['step_database_changing_field']);
+ $tmp = str_replace('$FIELD_NEW$', 'players.hidden', $tmp);
+ success($tmp);
+ }
+ }
+}
+else if(!$db->hasColumn('players', 'hidden')) {
+ if(query("ALTER TABLE `players` ADD `hidden` TINYINT(1) NOT NULL DEFAULT 0;"))
+ success($locale['step_database_adding_field'] . ' players.hidden...');
+}
+
+if(!$db->hasColumn('players', 'comment')) {
+ if(query("ALTER TABLE `players` ADD `comment` TEXT NOT NULL;"))
+ success($locale['step_database_adding_field'] . ' players.comment...');
+}
+
+if($db->hasColumn('players', 'rank_id')) {
+ if(query("ALTER TABLE players MODIFY `rank_id` INT(11) NOT NULL DEFAULT 0;"))
+ success($locale['step_database_modifying_field'] . ' players.rank_id...');
+
+ if($db->hasColumn('players', 'guildnick')) {
+ if(query("ALTER TABLE players MODIFY `guildnick` VARCHAR(255) NOT NULL DEFAULT '';")) {
+ success($locale['step_database_modifying_field'] . ' players.guildnick...');
+ }
+ }
+}
diff --git a/install/tools/7-finish.php b/install/tools/7-finish.php
new file mode 100644
index 00000000..a4145351
--- /dev/null
+++ b/install/tools/7-finish.php
@@ -0,0 +1,92 @@
+hasColumn('players', 'deletion'))
+ $deleted = 'deletion';
+
+$time = time();
+function insert_sample_if_not_exist($p) {
+ global $db, $success, $deleted, $time;
+
+ $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote($p['name']));
+ if($query->rowCount() == 0) {
+ if(!query("INSERT INTO `players` (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `lastlogout`, `balance`, `$deleted`, `created`, `hidden`, `comment`) VALUES (null, " . $db->quote($p['name']) . ", 1, " . getSession('account') . ", " . $p['level'] . ", " . $p['vocation_id'] . ", " . $p['health'] . ", " . $p['healthmax'] . ", " . $p['experience'] . ", 118, 114, 38, 57, " . $p['looktype'] . ", 0, " . $p['mana'] . ", " . $p['manamax'] . ", 0, " . $p['soul'] . ", 1, 1000, 1000, 7, '', " . $p['cap'] . ", 1, " . $time . ", 2130706433, 1, " . $time . ", 0, 0, " . $time . ", 1, '');"))
+ $success = false;
+ }
+}
+
+$success = true;
+insert_sample_if_not_exist(array('name' => 'Rook Sample', 'level' => 1, 'vocation_id' => 0, 'health' => 150, 'healthmax' => 150, 'experience' => 0, 'looktype' => 130, 'mana' => 0, 'manamax' => 0, 'soul' => 100, 'cap' => 400));
+insert_sample_if_not_exist(array('name' => 'Sorcerer Sample', 'level' => 8, 'vocation_id' => 1, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 130, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
+insert_sample_if_not_exist(array('name' => 'Druid Sample', 'level' => 8, 'vocation_id' => 2, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 130, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
+insert_sample_if_not_exist(array('name' => 'Paladin Sample', 'level' => 8, 'vocation_id' => 3, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 129, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
+insert_sample_if_not_exist(array('name' => 'Knight Sample', 'level' => 8, 'vocation_id' => 4, 'health' => 185, 'healthmax' => 185, 'experience' => 4200, 'looktype' => 131, 'mana' => 35, 'manamax' => 35, 'soul' => 100, 'cap' => 470));
+
+if($success) {
+ success($locale['step_database_imported_players']);
+}
+
+require(LIBS . 'items.php');
+if(Items::loadFromXML())
+ success($locale['step_database_loaded_items']);
+else
+ error(Items::getError());
+
+require(LIBS . 'weapons.php');
+if(Weapons::loadFromXML())
+ success($locale['step_database_loaded_weapons']);
+else
+ error(Weapons::getError());
+
+require(LIBS . 'creatures.php');
+if(Creatures::loadFromXML()) {
+ success($locale['step_database_loaded_monsters']);
+
+ if(Creatures::getMonstersList()->hasErrors()) {
+ $locale['step_database_error_monsters'] = str_replace('$LOG$', 'system/logs/error.log', $locale['step_database_error_monsters']);
+ warning($locale['step_database_error_monsters']);
+ }
+}
+else {
+ error(Creatures::getLastError());
+}
+
+require(LIBS . 'spells.php');
+if(Spells::loadFromXML()) {
+ success($locale['step_database_loaded_spells']);
+}
+else {
+ error(Spells::getLastError());
+}
+
+// update config.highscores_ids_hidden
+require_once(SYSTEM . 'migrations/20.php');
+$database_migration_20 = true;
+$content = '';
+if(!databaseMigration20($content)) {
+ $locale['step_database_error_file'] = str_replace('$FILE$', '
' . BASE . 'config.local.php', $locale['step_database_error_file']);
+ warning($locale['step_database_error_file'] . '
+
');
+}
+
+$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
+$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
+$locale['step_finish_desc'] = str_replace('$LINK$', generateLink('http://my-aac.org', 'http://my-aac.org', true), $locale['step_finish_desc']);
+
+success($locale['step_finish_desc']);
\ No newline at end of file
diff --git a/install/tools/installer.js b/install/tools/installer.js
new file mode 100644
index 00000000..9f7492ba
--- /dev/null
+++ b/install/tools/installer.js
@@ -0,0 +1,40 @@
+function performInstall(url) {
+ var lastResponseLength = false;
+ var lastId = 1;
+
+ var ajaxRequest = $.ajax({
+ type: 'get',
+ url: url,
+ data: {},
+ dataType: 'html',
+ processData: false,
+ xhrFields: {
+ // Getting on progress streaming response
+ onprogress: function (e) {
+ var progressResponse;
+ var response = e.currentTarget.response;
+ progressResponse = response;
+ if (lastResponseLength === false) {
+ progressResponse = response;
+ lastResponseLength = response.length;
+ }
+ else {
+ progressResponse = response.substring(lastResponseLength);
+ lastResponseLength = response.length;
+ }
+
+ $('
' + progressResponse + '
').insertAfter("#success-" + lastId);
+ lastId = lastId + 1;
+ }
+ }
+ });
+ // On completed
+ ajaxRequest.done(function(data) {
+ $('#spinner').hide();
+ });
+ // On failed
+ ajaxRequest.fail(function(error){
+ console.log('Error: ', error);
+ $('
Error while doing AJAX request. Please refresh the page.').insertAfter("#success-" + lastId);
+ });
+}
\ No newline at end of file
diff --git a/system/locale/de/install.php b/system/locale/de/install.php
index 98e0fa8e..0f971681 100644
--- a/system/locale/de/install.php
+++ b/system/locale/de/install.php
@@ -17,6 +17,8 @@ $locale['off'] = 'Aus';
$locale['loaded'] = 'Geladen';
$locale['not_loaded'] = 'Nicht geladen';
+$locale['loading_spinner'] = 'Bitte warten, installieren...';
+$locale['importing_spinner'] = 'Bitte warte, Daten werden importiert...';
$locale['please_fill_all'] = 'Bitte füllen Sie alle Felder aus!';
$locale['already_installed'] = 'MyAAC wurde bereits installiert. Bitte löschen
install/ Verzeichnis.';
@@ -75,6 +77,8 @@ $locale['step_database_adding_field'] = 'Folgendes Feld wurde hinzugefügt: ';
$locale['step_database_modifying_field'] = 'Folgendes Feld wurde geändert: ';
$locale['step_database_changing_field'] = 'Änderung von $FIELD$ zu $FIELD_NEW$...';
$locale['step_database_imported_players'] = 'Spielerproben wurden importiert...';
+$locale['step_database_loaded_items'] = 'Items wurden geladen...';
+$locale['step_database_loaded_weapons'] = 'Weapons wurden geladen...';
$locale['step_database_loaded_monsters'] = 'Monster wurden geladen...';
$locale['step_database_error_monsters'] = 'Beim Laden der Datei monsters.xml sind einige Probleme aufgetreten. Bitte überprüfen Sie $LOG$ für weitere Informationen.';
$locale['step_database_loaded_spells'] = 'Zauber wurden geladen...';
diff --git a/system/locale/en/install.php b/system/locale/en/install.php
index c365c58e..60279315 100644
--- a/system/locale/en/install.php
+++ b/system/locale/en/install.php
@@ -17,6 +17,8 @@ $locale['off'] = 'Off';
$locale['loaded'] = 'Loaded';
$locale['not_loaded'] = 'Not loaded';
+$locale['loading_spinner'] = 'Please wait, installing...';
+$locale['importing_spinner'] = 'Please wait, importing data...';
$locale['please_fill_all'] = 'Please fill all inputs!';
$locale['already_installed'] = 'MyAAC has been already installed. Please delete install/ directory.';
@@ -75,6 +77,8 @@ $locale['step_database_adding_field'] = 'Adding field';
$locale['step_database_modifying_field'] = 'Modifying field';
$locale['step_database_changing_field'] = 'Changing $FIELD$ to $FIELD_NEW$...';
$locale['step_database_imported_players'] = 'Player samples has been imported...';
+$locale['step_database_loaded_items'] = 'Items has been loaded...';
+$locale['step_database_loaded_weapons'] = 'Weapons has been loaded...';
$locale['step_database_loaded_monsters'] = 'Monsters has been loaded...';
$locale['step_database_error_monsters'] = 'There were some problems loading your monsters.xml file. Please check $LOG$ for more info.';
$locale['step_database_loaded_spells'] = 'Spells has been loaded...';
diff --git a/system/locale/pl/install.php b/system/locale/pl/install.php
index c76fd526..1e179860 100644
--- a/system/locale/pl/install.php
+++ b/system/locale/pl/install.php
@@ -17,6 +17,8 @@ $locale['off'] = 'Wyłączone';
$locale['loaded'] = 'Załadowane';
$locale['not_loaded'] = 'Nie załadowane';
+$locale['loading_spinner'] = 'Proszę czekać, trwa instalacja...';
+$locale['importing_spinner'] = 'Proszę czekać, trwa importowanie danych...';
$locale['please_fill_all'] = 'Proszę wypełnić wszystkie pola!';
$locale['already_installed'] = 'MyAAC został już zainstalowany. Proszę usunąć katalog install/.';
@@ -70,6 +72,8 @@ $locale['step_database_adding_field'] = 'Dodawanie pola';
$locale['step_database_modifying_field'] = 'Modyfikacja pola';
$locale['step_database_changing_field'] = 'Zmiana $FIELD$ na $FIELD_NEW$...';
$locale['step_database_imported_players'] = 'Importowanie schematów graczy...';
+$locale['step_database_loaded_items'] = 'Załadowano przedmioty (items)...';
+$locale['step_database_loaded_weapons'] = 'Załadowano bronie (weapons)...';
$locale['step_database_loaded_monsters'] = 'Załadowano potworki (monsters)...';
$locale['step_database_error_monsters'] = 'Wystąpiły problemy podczas ładowania pliku monsters.xml. Zobacz $LOG$ po więcej informacji.';
$locale['step_database_loaded_spells'] = 'Załadowano czary (spells)...';
diff --git a/system/pages/admin/items.php b/system/pages/admin/items.php
index 24033a6f..1d0d8269 100644
--- a/system/pages/admin/items.php
+++ b/system/pages/admin/items.php
@@ -26,5 +26,4 @@ if($reload) {
success('Successfully loaded weapons.');
else
error(Weapons::getError());
-
}
\ No newline at end of file
diff --git a/system/templates/install.installer.html.twig b/system/templates/install.installer.html.twig
new file mode 100644
index 00000000..d0694034
--- /dev/null
+++ b/system/templates/install.installer.html.twig
@@ -0,0 +1,11 @@
+
+
+
 }}images/loading_spinner.gif)
+ {{ message }}
+
+
+
\ No newline at end of file