Ejemplo n.º 1
0
 function propagade_player_options($old_option_name, $new_option_id)
 {
     global $update_tables;
     if (!empty($update_tables['users'][$old_option_name])) {
         upd_do_query("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`)\n          SELECT `id`, {$new_option_id}, `{$old_option_name}`\n          FROM {{users}}\n          WHERE `user_as_ally` is null and `user_bot` = " . USER_BOT_PLAYER);
         // TODO - UNCOMMENT !!!
         upd_alter_table('users', array("DROP COLUMN `{$old_option_name}`"));
     }
 }
Ejemplo n.º 2
0
        upd_alter_table('chat', array("MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'"), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT');
        upd_alter_table('planets', array("ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'"), !$update_tables['planets']['ship_sattelite_sloth']);
        upd_alter_table('planets', array("ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)"), !$update_tables['planets']['ship_sattelite_sloth_porcent']);
        upd_check_key('stats_hide_admins', 1, !isset($config->stats_hide_admins));
        upd_check_key('stats_hide_player_list', '', !isset($config->stats_hide_player_list));
        upd_check_key('adv_seo_meta_description', '', !isset($config->adv_seo_meta_description));
        upd_check_key('adv_seo_meta_keywords', '', !isset($config->adv_seo_meta_keywords));
        upd_check_key('stats_hide_pm_link', '0', !isset($config->stats_hide_pm_link));
        upd_alter_table('notes', array("ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)"), !$update_indexes['notes']['I_owner_priority_time']);
        if (!$update_tables['buddy']['BUDDY_ID']) {
            upd_alter_table('buddy', array("CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'", "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", "DROP INDEX `id`", "DROP FOREIGN KEY `FK_buddy_sender_id`", "DROP FOREIGN KEY `FK_buddy_owner_id`", "DROP INDEX `I_buddy_sender`", "DROP INDEX `I_buddy_owner`"), !$update_tables['buddy']['BUDDY_ID']);
            upd_alter_table('buddy', array("CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'", "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'"), !$update_tables['buddy']['BUDDY_SENDER']);
            $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
            $found = $lost = array();
            while ($row = db_fetch($query)) {
                $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
                if (!isset($found[$index])) {
                    $found[$index] = $row['BUDDY_ID'];
                } else {
                    $lost[] = $row['BUDDY_ID'];
                }
            }
            $lost = implode(',', $lost);
            if ($lost) {
                upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
            }
            upd_alter_table('buddy', array("ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE"), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']);
        }
        upd_do_query('COMMIT;', true);
        $new_version = 35;
}
Ejemplo n.º 3
0
 upd_alter_table('users', array("ADD COLUMN `salt` char(16) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '' AFTER `password`"), !isset($update_tables['users']['salt']));
 // TODO Смерджить после выливания на живой
 upd_alter_table('users', array("ADD COLUMN `parent_account_id` bigint(20) unsigned NOT NULL DEFAULT 0", "ADD COLUMN `parent_account_global` tinyint(1) unsigned NOT NULL DEFAULT 0", "ADD KEY `I_user_account_id` (`parent_account_id`, `parent_account_global`)"), !isset($update_tables['users']['parent_account_id']));
 // TODO Смерджить после выливания на живой
 upd_alter_table('users', array("ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT ''"), !isset($update_tables['users']['server_name']));
 //    upd_alter_table('users', array(
 //      "ADD COLUMN `parent_account_id` bigint(20) unsigned NOT NULL DEFAULT 0",
 //      "ADD KEY `I_user_account_id` (`parent_account_id`)",
 //    ), !isset($update_tables['users']['parent_account_id']));
 //    upd_alter_table('users', array(
 //      "ADD COLUMN `parent_account_global` tinyint(1) unsigned NOT NULL DEFAULT 0",
 //      "DROP KEY `I_user_account_id`",
 //      "ADD KEY `I_user_account_id` (`parent_account_id`, `parent_account_global`)",
 //    ), !isset($update_tables['users']['parent_account_id']));
 upd_alter_table('security_browser', array("ADD COLUMN `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"), !isset($update_tables['security_browser']['timestamp']));
 upd_alter_table('security_device', array("ADD COLUMN `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"), !isset($update_tables['security_device']['timestamp']));
 // sn_version_compare($ver1, $ver2)
 //    // TODO remove after mine
 //    upd_alter_table('counter', array(
 //      "MODIFY COLUMN `user_ip` int(10) unsigned NULL DEFAULT NULL AFTER `browser_id`",
 //    ), strtolower($update_tables['counter']['user_ip']['Null']) == 'no');
 //
 //    upd_alter_table('security_player_entry', array(
 //      "MODIFY COLUMN `user_ip` int(10) unsigned NULL DEFAULT NULL",
 //    ), strtolower($update_tables['security_player_entry']['user_ip']['Null']) == 'no');
 //    pdump(strtolower($update_tables['security_player_entry']['user_ip']['Null']) == 'no');
 upd_check_key('game_multiaccount_enabled', 0, !isset($config->game_multiaccount_enabled));
 upd_check_key('stats_schedule', '04:00:00', $config->stats_schedule !== '04:00:00');
 upd_check_key('stats_php_memory', '1024M', !isset($config->stats_php_memory));
 upd_check_key('stats_minimal_interval', '600', !isset($config->stats_minimal_interval));
 upd_check_key('fleet_update_interval', 4, !intval($config->fleet_update_interval));
Ejemplo n.º 4
0
                    $row['log_username'] = mysql_real_escape_string($row['log_username']);
                    $row['log_page'] = mysql_real_escape_string($row['log_page']);
                    $comment = mysql_real_escape_string($comment);
                    upd_do_query("INSERT INTO {{log_dark_matter}} (`log_dark_matter_timestamp`, `log_dark_matter_username`, `log_dark_matter_reason`,\r\n              `log_dark_matter_amount`, `log_dark_matter_comment`, `log_dark_matter_page`, `log_dark_matter_sender`)\r\n            VALUES (\r\n              '{$row['log_timestamp']}', '{$row['log_username']}', {$reason},\r\n              {$matches[2]}, '{$comment}', '{$row['log_page']}', {$row['log_sender']});", true);
                }
            }
            upd_do_query("DELETE FROM {{logs}} WHERE log_code = 102 LIMIT 1000;", true);
            upd_do_query('COMMIT;', true);
        }
        foreach ($update_tables as $table_name => $cork) {
            $row = mysql_fetch_assoc(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '{$db_name}' AND TABLE_NAME = '{$config->db_prefix}{$table_name}';", true));
            if ($row['ENGINE'] != 'InnoDB') {
                upd_alter_table($table_name, 'ENGINE=InnoDB', true);
            }
            if ($row['TABLE_COLLATION'] != 'utf8_general_ci') {
                upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true);
            }
        }
        upd_do_query('COMMIT;', true);
        $new_version = 30;
    case 30:
        //    upd_log_version_update();
        //
        //  upd_do_query('COMMIT;', true);
        //  $new_version = 29.1;
}
upd_log_message('Upgrade complete.');
if ($new_version) {
    $config->db_saveItem('db_version', $new_version);
    upd_log_message("<font color=green>DB version is now {$new_version}</font>");
} else {
Ejemplo n.º 5
0
            $db_changeset = array();
            $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
            while ($row = db_fetch($query)) {
                $artifact_list = explode(';', $row['player_artifact_list']);
                if (!$row['player_artifact_list'] || empty($artifact_list)) {
                    continue;
                }
                foreach ($artifact_list as $key => &$value) {
                    $value = explode(',', $value);
                    if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
                        unset($artifact_list[$key]);
                        continue;
                    }
                    $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row);
                }
            }
            upd_db_changeset_apply($db_changeset);
            upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']);
        }
        upd_alter_table('users', array("DROP COLUMN `spy_tech`", "DROP COLUMN `computer_tech`", "DROP COLUMN `military_tech`", "DROP COLUMN `defence_tech`", "DROP COLUMN `shield_tech`", "DROP COLUMN `energy_tech`", "DROP COLUMN `hyperspace_tech`", "DROP COLUMN `combustion_tech`", "DROP COLUMN `impulse_motor_tech`", "DROP COLUMN `hyperspace_motor_tech`", "DROP COLUMN `laser_tech`", "DROP COLUMN `ionic_tech`", "DROP COLUMN `buster_tech`", "DROP COLUMN `intergalactic_tech`", "DROP COLUMN `expedition_tech`", "DROP COLUMN `colonisation_tech`"), $update_tables['users']['spy_tech']);
        upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
        upd_check_key('payment_currency_exchange_eur', 0.09259259259259001, !$config->payment_currency_exchange_eur);
        upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub);
        upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd);
        upd_check_key('payment_currency_exchange_wme', 0.09523809523810001, !$config->payment_currency_exchange_usd);
        upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr);
        upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu);
        upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz);
        upd_do_query('COMMIT;', true);
        $new_version = 37;
}