Exemple #1
0
 upd_check_key('security_write_full_url_disabled', 1, !isset($config->security_write_full_url_disabled));
 // http://1whois.ru?url=
 upd_check_key('geoip_whois_url', 'https://who.is/whois-ip/ip-address/', !isset($config->core_geoip_whois_url));
 upd_check_key('ube_capture_points_diff', 2, !isset($config->ube_capture_points_diff));
 // 2015-10-17 14:46:32 40a15.5
 upd_check_key('game_users_online_timeout', 15 * 60, !isset($config->game_users_online_timeout));
 // 2015-10-22 14:37:58 40a17.5
 upd_check_key('locale_cache_disable', 0, !isset($config->locale_cache_disable));
 // 2015-10-30 19:09:01 40a19.5
 upd_check_key('event_halloween_2015_lock', 0, !isset($config->event_halloween_2015_lock));
 upd_check_key('event_halloween_2015_unit', 0, !isset($config->event_halloween_2015_unit));
 upd_check_key('event_halloween_2015_code', '', !isset($config->event_halloween_2015_code));
 upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset($config->event_halloween_2015_timestamp));
 upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset($config->event_halloween_2015_units_used));
 if (empty($update_tables['log_halloween_2015'])) {
     upd_create_table('log_halloween_2015', " (\n      `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n      `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',\n      `player_name` varchar(32) NOT NULL DEFAULT '',\n      `unit_snid` bigint(20) unsigned NOT NULL DEFAULT 0,\n      `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\n      PRIMARY KEY (`log_hw2015_id`),\n      KEY (`player_id`, `log_hw2015_id` DESC) -- For list on Imperator page\n      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
 }
 // 2015-11-28 06:30:27 40a19.21
 if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
     upd_alter_table('ube_report', array("ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)"), !isset($update_tables['ube_report']['ube_report_debris_total_in_metal']));
     $config_rpg_exchange_metal = floatval($config->rpg_exchange_metal) ? floatval($config->rpg_exchange_metal) : 1;
     $config_rpg_exchange_crystal = floatval($config->rpg_exchange_crystal) ? floatval($config->rpg_exchange_crystal) : 1;
     upd_do_query("UPDATE `{{ube_report}}`\n        SET `ube_report_debris_total_in_metal` = (`ube_report_debris_metal` + `ube_report_debris_crystal` * {$config_rpg_exchange_crystal}) / {$config_rpg_exchange_metal}");
 }
 // 2015-12-06 15:10:58 40b1.0
 if (!empty($update_indexes['planets']['I_metal_mine'])) {
     upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']);
     upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']);
     upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']);
     upd_alter_table('planets', "DROP KEY `I_ship_recycler_gluttony`", $update_indexes['planets']['I_ship_recycler_gluttony']);
     upd_alter_table('planets', "DROP KEY `I_ship_fighter_wrath`", $update_indexes['planets']['I_ship_fighter_wrath']);
Exemple #2
0
         }
     }
     upd_check_key('rpg_bonus_minimum', 10000, !isset($config->rpg_bonus_minimum));
     upd_check_key('rpg_bonus_divisor', !isset($config->rpg_bonus_divisor) ? 10 : ($config->rpg_bonus_divisor >= 1000 ? floor($config->rpg_bonus_divisor / 1000) : $config->rpg_bonus_divisor), !isset($config->rpg_bonus_divisor) || $config->rpg_bonus_divisor >= 1000);
     upd_check_key('var_news_last', 0, !isset($config->var_news_last));
     upd_do_query('COMMIT;', true);
     $new_version = 33;
 case 33:
     upd_log_version_update();
     upd_alter_table('users', array("ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)"), !$update_tables['users']['user_birthday']);
     upd_check_key('user_birthday_gift', 0, !isset($config->user_birthday_gift));
     upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range));
     upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate));
     if (!isset($update_tables['payment'])) {
         upd_alter_table('users', array("ADD KEY `I_user_id_name` (`id`, `username`)"), !$update_indexes['users']['I_user_id_name']);
         upd_create_table('payment', "(\n          `payment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Internal payment ID',\n          `payment_user_id` BIGINT(20) UNSIGNED DEFAULT NULL,\n          `payment_user_name` VARCHAR(64) DEFAULT NULL,\n          `payment_amount` DECIMAL(60,5) DEFAULT 0 COMMENT 'Amount paid',\n          `payment_currency` VARCHAR(3) DEFAULT '' COMMENT 'Payment currency',\n          `payment_dm` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained',\n          `payment_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Payment server timestamp',\n          `payment_comment` TEXT COMMENT 'Payment comment',\n\n          `payment_module_name` VARCHAR(255) DEFAULT '' COMMENT 'Payment module name',\n          `payment_internal_id` VARCHAR(255) DEFAULT '' COMMENT 'Internal payment ID in payment system',\n          `payment_internal_date` DATETIME COMMENT 'Internal payment timestamp in payment system',\n\n          PRIMARY KEY (`payment_id`),\n          KEY `I_payment_user` (`payment_user_id`, `payment_user_name`),\n          KEY `I_payment_module_internal_id` (`payment_module_name`, `payment_internal_id`),\n\n          CONSTRAINT `FK_payment_user` FOREIGN KEY (`payment_user_id`, `payment_user_name`) REFERENCES `{$config->db_prefix}users` (`id`, `username`) ON UPDATE CASCADE ON DELETE NO ACTION\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
         upd_check_key('payment_currency_default', 'UAH', !isset($config->payment_currency_default));
     }
     upd_check_key('payment_lot_size', 1000, !isset($config->payment_lot_size));
     upd_check_key('payment_lot_price', 1, !isset($config->payment_lot_price));
     // Updating category for Mercenaries
     upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
     // Convert Destructor to Death Star schematic
     upd_do_query("UPDATE {{powerup}}\n      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . "\n      WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;");
     // Convert Assasin to SuperNova schematic
     upd_do_query("UPDATE {{powerup}}\n      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . "\n      WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;");
     upd_alter_table('iraks', array("ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1"), !$update_tables['iraks']['fleet_start_type']);
     if (!$update_tables['payment']['payment_status']) {
         upd_alter_table('payment', array("ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'"), !$update_tables['payment']['payment_status']);
     }
     upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";");
Exemple #3
0
      KEY `BUILDS` (`build_points`),
      KEY `DEFS` (`defs_points`),
      KEY `FLEET` (`fleet_points`),
      KEY `TOTAL` (`total_points`),
      KEY `i_stats_owner` (`id_owner`,`stat_type`,`stat_code`,`tech_rank`,`build_rank`,`defs_rank`,`fleet_rank`,`total_rank`),
      KEY `I_stats_id_ally` (`id_ally`,`stat_type`,`stat_code`) USING BTREE,
      KEY `I_stats_type_code` (`stat_type`,`stat_code`) USING BTREE,
      CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `bl0_alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
      CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `bl0_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
     */
 }
 upd_create_table('survey', " (\n      `survey_id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n      `survey_announce_id` bigint(11) unsigned DEFAULT NULL,\n      `survey_question` varchar(250) NOT NULL,\n      `survey_until` datetime DEFAULT NULL,\n      PRIMARY KEY (`survey_id`),\n      KEY `I_survey_announce_id` (`survey_announce_id`) USING BTREE,\n      CONSTRAINT `FK_survey_announce_id` FOREIGN KEY (`survey_announce_id`) REFERENCES `{{announce}}` (`idAnnounce`) ON DELETE CASCADE ON UPDATE CASCADE\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
 upd_create_table('survey_answers', " (\n      `survey_answer_id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n      `survey_parent_id` int(10) unsigned DEFAULT NULL,\n      `survey_answer_text` varchar(250) DEFAULT NULL,\n      PRIMARY KEY (`survey_answer_id`),\n      KEY `I_survey_answers_survey_parent_id` (`survey_parent_id`) USING BTREE,\n      CONSTRAINT `FK_survey_answers_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
 upd_create_table('survey_votes', " (\n      `survey_vote_id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n      `survey_parent_id` int(10) unsigned DEFAULT NULL,\n      `survey_parent_answer_id` int(10) unsigned DEFAULT NULL,\n      `survey_vote_user_id` bigint(20) unsigned DEFAULT NULL,\n      `survey_vote_user_name` varchar(32) DEFAULT NULL,\n      PRIMARY KEY (`survey_vote_id`),\n      KEY `I_survey_votes_survey_parent_id` (`survey_parent_id`) USING BTREE,\n      KEY `I_survey_votes_user` (`survey_vote_user_id`,`survey_vote_user_name`) USING BTREE,\n      KEY `I_survey_votes_survey_parent_answer_id` (`survey_parent_answer_id`) USING BTREE,\n      CONSTRAINT `FK_survey_votes_user` FOREIGN KEY (`survey_vote_user_id`, `survey_vote_user_name`) REFERENCES `{{users}}` (`id`, `username`) ON DELETE NO ACTION ON UPDATE NO ACTION,\n      CONSTRAINT `FK_survey_votes_survey_parent_answer_id` FOREIGN KEY (`survey_parent_answer_id`) REFERENCES `{{survey_answers}}` (`survey_answer_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n      CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
 if (empty($update_tables['security_url'])) {
     upd_create_table('security_url', " (\n        `url_id` int unsigned NOT NULL AUTO_INCREMENT,\n        `url_string` VARCHAR(250) NOT NULL DEFAULT '',\n        PRIMARY KEY (`url_id`),\n        UNIQUE KEY `I_url_string` (`url_string`)\n      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
     function update_security_url($query)
     {
         static $query_string = "INSERT IGNORE INTO {{security_url}} (`url_string`) VALUES ";
         $strings = array();
         $query = doquery($query);
         while ($row = db_fetch($query)) {
             $strings[] = '("' . db_escape($row['url']) . '")';
             if (count($strings) > 100) {
                 doquery($query_string . implode(',', $strings));
                 $strings = array();
             }
         }
         !empty($strings) ? doquery($query_string . implode(',', $strings)) : false;
     }
     if (isset($update_tables['counter']['page'])) {
Exemple #4
0
     }
     upd_alter_table('planets', array("MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0"), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
     $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);");
     while ($illegal_moon_row = mysql_fetch_assoc($illegal_moon_query)) {
         upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
     }
     upd_check_key('allow_buffing', isset($config->fleet_buffing_check) ? !$config->fleet_buffing_check : 0, !isset($config->allow_buffing));
     upd_check_key('ally_help_weak', 0, !isset($config->ally_help_weak));
     upd_do_query('COMMIT;', true);
     $new_version = 29;
 case 29:
     upd_log_version_update();
     upd_check_key('game_email_pm', 0, !isset($config->game_email_pm));
     upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset($config->player_vacation_time));
     upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset($config->player_delete_time));
     upd_create_table('log_dark_matter', "(\r\n        `log_dark_matter_id` SERIAL,\r\n        `log_dark_matter_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp',\r\n        `log_dark_matter_username` varchar(64) NOT NULL DEFAULT '' COMMENT 'Username',\r\n        `log_dark_matter_reason` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Reason ID for dark matter adjustment',\r\n        `log_dark_matter_amount` INT(10) NOT NULL DEFAULT 0 COMMENT 'Amount of dark matter change',\r\n        `log_dark_matter_comment` TEXT COMMENT 'Comments',\r\n        `log_dark_matter_page` varchar(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log',\r\n        `log_dark_matter_sender` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'User ID which make log record',\r\n\r\n        PRIMARY KEY (`log_dark_matter_id`),\r\n        KEY `i_log_dark_matter_sender_id` (`log_dark_matter_sender`, `log_dark_matter_id`),\r\n        KEY `i_log_dark_matter_reason_sender_id` (`log_dark_matter_reason`, `log_dark_matter_sender`, `log_dark_matter_id`),\r\n        KEY `i_log_dark_matter_amount` (`log_dark_matter_amount`)\r\n      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;");
     upd_do_query('COMMIT;', true);
     $records = 1;
     while ($records) {
         upd_do_query('START TRANSACTION;', true);
         $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;");
         $records = mysql_numrows($query);
         while ($row = mysql_fetch_assoc($query)) {
             $result = preg_match('/^Player ID (\\d+) Dark Matter was adjusted with (\\-?\\d+). Reason: (.+)$/', $row['log_text'], $matches);
             $reason = RPG_NONE;
             $comment = $matches[3];
             switch ($matches[3]) {
                 case 'Level Up For Structure Building':
                     $reason = RPG_STRUCTURE;
                     break;
                 case 'Level Up For Raiding':
Exemple #5
0
 }
 upd_alter_table('users', array("ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`"), !$update_tables['users']['user_time_utc_offset']);
 if (!$update_foreigns['alliance']['FK_alliance_owner']) {
     upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})");
     upd_alter_table('alliance', array("ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE"), !$update_foreigns['alliance']['FK_alliance_owner']);
     upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id not in (select id from {{alliance}}) OR alliance_negotiation_contr_ally_id not in (select id from {{alliance}})");
     upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id");
     upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id");
 }
 upd_alter_table('fleets', array('MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE"), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED');
 upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer);
 if (!$update_tables['player_name_history']) {
     upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost);
     upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
     upd_alter_table('users', array("CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'"));
     upd_create_table('player_name_history', "(\n          `player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Player ID',\n          `player_name` VARCHAR(32) NOT NULL COMMENT 'Historical player name',\n          `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When player changed name',\n\n          PRIMARY KEY (`player_name`),\n          KEY `I_player_name_history_id_name` (`player_id`, `player_name`),\n\n          CONSTRAINT `FK_player_name_history_id` FOREIGN KEY (`player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;");
 }
 upd_alter_table('planets', array("ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'"), !$update_tables['planets']['density_index']);
 if ($update_tables['users']['player_artifact_list']) {
     upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
     upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']);
     upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']);
     $sn_data_artifacts = sn_get_groups('artifacts');
     $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;
         }