@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | [!] DB code updates |
22 | 22 | */ |
23 | 23 | |
24 | -if(!defined('INIT')) { |
|
24 | +if (!defined('INIT')) { |
|
25 | 25 | // include_once('init.php'); |
26 | 26 | die('Unauthorized access'); |
27 | 27 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | classSupernova::$config->debug = 0; |
40 | 40 | |
41 | 41 | |
42 | -if(classSupernova::$config->db_version == DB_VERSION) { |
|
43 | -} elseif(classSupernova::$config->db_version > DB_VERSION) { |
|
42 | +if (classSupernova::$config->db_version == DB_VERSION) { |
|
43 | +} elseif (classSupernova::$config->db_version > DB_VERSION) { |
|
44 | 44 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
45 | 45 | die( |
46 | 46 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | -if(classSupernova::$config->db_version < 26) { |
|
52 | +if (classSupernova::$config->db_version < 26) { |
|
53 | 53 | $sys_log_disabled = true; |
54 | 54 | } |
55 | 55 | |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | $update_tables = array(); |
69 | 69 | $update_indexes = array(); |
70 | 70 | $query = upd_do_query('SHOW TABLES;', true); |
71 | -while($row = db_fetch_row($query)) { |
|
71 | +while ($row = db_fetch_row($query)) { |
|
72 | 72 | upd_load_table_info($row[0]); |
73 | 73 | } |
74 | 74 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
75 | 75 | |
76 | 76 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
77 | 77 | |
78 | -if($new_version < 37) { |
|
78 | +if ($new_version < 37) { |
|
79 | 79 | require_once('update_old.php'); |
80 | 80 | } |
81 | 81 | |
82 | 82 | ini_set('memory_limit', '1024M'); |
83 | 83 | |
84 | -switch($new_version) { |
|
84 | +switch ($new_version) { |
|
85 | 85 | case 37: |
86 | 86 | upd_log_version_update(); |
87 | 87 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_); |
98 | 98 | |
99 | - if(!$update_tables['log_metamatter']) { |
|
99 | + if (!$update_tables['log_metamatter']) { |
|
100 | 100 | upd_create_table('log_metamatter', |
101 | 101 | "( |
102 | 102 | `id` SERIAL, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
122 | 122 | ), !$update_tables['payment']['payment_test']); |
123 | 123 | |
124 | - if($update_tables['payment']['payment_test']['Default'] == 1) { |
|
124 | + if ($update_tables['payment']['payment_test']['Default'] == 1) { |
|
125 | 125 | upd_alter_table('payment', array( |
126 | 126 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
127 | 127 | )); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
139 | 139 | |
140 | 140 | $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
141 | - while($row = db_fetch($query)) { |
|
141 | + while ($row = db_fetch($query)) { |
|
142 | 142 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
143 | 143 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
144 | 144 | $price = sys_unit_str2arr($row['que_unit_price']); |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
157 | 157 | WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
158 | 158 | FOR UPDATE"); |
159 | - while($row = db_fetch($query)) { |
|
160 | - if(!$row['id_planet']) { |
|
159 | + while ($row = db_fetch($query)) { |
|
160 | + if (!$row['id_planet']) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $unit_level = $row['unit_level']; |
166 | 166 | $price = get_unit_param($unit_id, P_COST); |
167 | 167 | $factor = $price['factor']; |
168 | - foreach($price as $resource_id => &$resource_amount) { |
|
168 | + foreach ($price as $resource_id => &$resource_amount) { |
|
169 | 169 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
170 | 170 | } |
171 | 171 | // upd_do_query |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
185 | 185 | upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0); |
186 | 186 | |
187 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
187 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
188 | 188 | upd_alter_table('users', array( |
189 | 189 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
190 | 190 | "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
191 | 191 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
192 | 192 | } |
193 | 193 | |
194 | - if(!$update_tables['log_users_online']) { |
|
194 | + if (!$update_tables['log_users_online']) { |
|
195 | 195 | upd_create_table('log_users_online', "( |
196 | 196 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
197 | 197 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
207 | 207 | ), !$update_tables['users']['user_time_measured']); |
208 | 208 | |
209 | - if($update_tables['rw']) { |
|
209 | + if ($update_tables['rw']) { |
|
210 | 210 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
211 | 211 | } |
212 | 212 | |
213 | - if(!$update_tables['player_award']) { |
|
213 | + if (!$update_tables['player_award']) { |
|
214 | 214 | upd_create_table('player_award', "( |
215 | 215 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
216 | 216 | `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc', |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | upd_log_version_update(); |
253 | 253 | |
254 | 254 | |
255 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
255 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
256 | 256 | upd_alter_table('planets', array( |
257 | 257 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
258 | 258 | ), true); |
259 | 259 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
260 | 260 | } |
261 | 261 | |
262 | - if(!isset($update_tables['users']['que_processed'])) { |
|
262 | + if (!isset($update_tables['users']['que_processed'])) { |
|
263 | 263 | upd_alter_table('users', array( |
264 | 264 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
265 | 265 | ), true); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | |
270 | - if(isset($update_tables['planets']['que'])) { |
|
270 | + if (isset($update_tables['planets']['que'])) { |
|
271 | 271 | $sn_data_aux = array( |
272 | 272 | SHIP_SMALL_FIGHTER_WRATH => array( |
273 | 273 | 'name' => 'ship_fighter_wrath', |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | $unit_data = array(); |
353 | 353 | $planets = array(); |
354 | 354 | |
355 | - foreach($planet_unit_list as $unit_id) { |
|
356 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
355 | + foreach ($planet_unit_list as $unit_id) { |
|
356 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
357 | 357 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
358 | 358 | } |
359 | - if(isset($update_tables['planets'][$unit_name])) { |
|
359 | + if (isset($update_tables['planets'][$unit_name])) { |
|
360 | 360 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
361 | 361 | |
362 | - if(isset($aux_group[$unit_id])) { |
|
362 | + if (isset($aux_group[$unit_id])) { |
|
363 | 363 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
364 | 364 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
365 | 365 | } else { |
366 | 366 | $units_info[$unit_id] = get_unit_param($unit_id); |
367 | - foreach($ques_info as $que_id => $que_data1) { |
|
368 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
367 | + foreach ($ques_info as $que_id => $que_data1) { |
|
368 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
369 | 369 | $units_info[$unit_id]['que'] = $que_id; |
370 | 370 | break; |
371 | 371 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
378 | - while($row = db_fetch($query)) { |
|
378 | + while ($row = db_fetch($query)) { |
|
379 | 379 | $user_id = $row['id_owner']; |
380 | 380 | $planet_id = $row['id']; |
381 | 381 | |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | |
384 | 384 | // Конвертируем юниты |
385 | 385 | $units_levels = array(); |
386 | - foreach($planet_unit_list as $unit_id) { |
|
386 | + foreach ($planet_unit_list as $unit_id) { |
|
387 | 387 | $unit_name = &$units_info[$unit_id][P_NAME]; |
388 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
388 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | $units_levels[$unit_id] = $row[$unit_name]; |
392 | 392 | $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
393 | - if(count($unit_data) > 30) { |
|
393 | + if (count($unit_data) > 30) { |
|
394 | 394 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
395 | 395 | upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
396 | 396 | $unit_data = array(); |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | } |
399 | 399 | |
400 | 400 | // Конвертируем очередь построек |
401 | - if($row['que']) { |
|
401 | + if ($row['que']) { |
|
402 | 402 | $que = explode(';', $row['que']); |
403 | - foreach($que as $que_item) { |
|
404 | - if(!$que_item) { |
|
403 | + foreach ($que as $que_item) { |
|
404 | + if (!$que_item) { |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
417 | 417 | $price_increase = pow($unit_factor, $unit_level); |
418 | 418 | // $unit_time = 0; |
419 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
420 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
419 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
420 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
421 | 421 | unset($unit_cost[$resource_id]); |
422 | 422 | continue; |
423 | 423 | } |
@@ -431,38 +431,38 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | // Конвертируем очередь верфи |
434 | - if($row['b_hangar_id']) { |
|
434 | + if ($row['b_hangar_id']) { |
|
435 | 435 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
436 | 436 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
437 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
438 | - if($unit_count <= 0) { |
|
437 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
438 | + if ($unit_count <= 0) { |
|
439 | 439 | continue; |
440 | 440 | } |
441 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
442 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
441 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
442 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
446 | 446 | } |
447 | 447 | } |
448 | - if(array_sum($return_resources) > 0) { |
|
448 | + if (array_sum($return_resources) > 0) { |
|
449 | 449 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | 453 | |
454 | - if(count($que_data) > 10) { |
|
454 | + if (count($que_data) > 10) { |
|
455 | 455 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
456 | 456 | upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
457 | 457 | $que_data = array(); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - if(!empty($unit_data)) { |
|
461 | + if (!empty($unit_data)) { |
|
462 | 462 | upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
463 | 463 | } |
464 | 464 | |
465 | - if(!empty($que_data)) { |
|
465 | + if (!empty($que_data)) { |
|
466 | 466 | upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
467 | 467 | } |
468 | 468 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
474 | 474 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
475 | 475 | |
476 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
476 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
477 | 477 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
478 | 478 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
479 | 479 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
570 | 570 | ), !isset($update_tables['users']['user_last_proxy'])); |
571 | 571 | |
572 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
572 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
573 | 573 | upd_alter_table('notes', array( |
574 | 574 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
575 | 575 | "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`", |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
588 | 588 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
589 | 589 | |
590 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
590 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
591 | 591 | upd_alter_table('users', array( |
592 | 592 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
593 | 593 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
596 | 596 | } |
597 | 597 | |
598 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
598 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
599 | 599 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
600 | 600 | upd_alter_table('log_users_online', array( |
601 | 601 | "DROP PRIMARY KEY", |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
604 | 604 | } |
605 | 605 | |
606 | - if(!isset($update_tables['users']['gender'])) { |
|
606 | + if (!isset($update_tables['users']['gender'])) { |
|
607 | 607 | upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
608 | 608 | upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
609 | 609 | } |
610 | 610 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
611 | 611 | |
612 | - if(!$update_tables['users']['dark_matter_total']) { |
|
612 | + if (!$update_tables['users']['dark_matter_total']) { |
|
613 | 613 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
614 | 614 | upd_do_query( |
615 | 615 | "UPDATE `{{users}}` AS u |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | } |
623 | 623 | |
624 | 624 | upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal)); |
625 | - if(!$update_tables['users']['metamatter_total']) { |
|
625 | + if (!$update_tables['users']['metamatter_total']) { |
|
626 | 626 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
627 | 627 | |
628 | 628 | upd_do_query( |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
635 | 635 | );"); |
636 | 636 | } |
637 | - if(!isset($update_tables['users']['immortal'])) { |
|
637 | + if (!isset($update_tables['users']['immortal'])) { |
|
638 | 638 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
639 | 639 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
640 | 640 | } |
641 | - if(isset($update_tables['player_award'])) { |
|
641 | + if (isset($update_tables['player_award'])) { |
|
642 | 642 | upd_do_query( |
643 | 643 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
644 | 644 | SET metamatter_total = 1, immortal = NOW() |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
666 | 666 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
667 | 667 | |
668 | - if(empty($update_tables['blitz_statpoints'])) { |
|
668 | + if (empty($update_tables['blitz_statpoints'])) { |
|
669 | 669 | upd_create_table('blitz_statpoints', " ( |
670 | 670 | `stat_date` int(11) NOT NULL DEFAULT '0', |
671 | 671 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
734 | 734 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
735 | 735 | |
736 | - if(empty($update_tables['security_url'])) { |
|
736 | + if (empty($update_tables['security_url'])) { |
|
737 | 737 | upd_create_table('security_url', " ( |
738 | 738 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
739 | 739 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | |
747 | 747 | $strings = array(); |
748 | 748 | $query = doquery($query); |
749 | - while($row = db_fetch($query)) { |
|
749 | + while ($row = db_fetch($query)) { |
|
750 | 750 | $strings[] = '("' . db_escape($row['url']) . '")'; |
751 | - if(count($strings) > 100) { |
|
751 | + if (count($strings) > 100) { |
|
752 | 752 | doquery($query_string . implode(',', $strings)); |
753 | 753 | $strings = array(); |
754 | 754 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
757 | 757 | } |
758 | 758 | |
759 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
759 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
760 | 760 | { |
761 | 761 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
762 | 762 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
782 | 782 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
783 | 783 | ), !isset($update_tables['counter']['device_id'])); |
784 | - if(isset($update_tables['counter']['ip'])) { |
|
784 | + if (isset($update_tables['counter']['ip'])) { |
|
785 | 785 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
786 | 786 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
787 | 787 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | |
833 | 833 | upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days); |
834 | 834 | |
835 | - if(classSupernova::$config->payment_currency_default != 'USD') { |
|
835 | + if (classSupernova::$config->payment_currency_default != 'USD') { |
|
836 | 836 | upd_check_key('payment_currency_default', 'USD', true); |
837 | 837 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
838 | 838 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | function propagade_player_options($old_option_name, $new_option_id) { |
916 | 916 | global $update_tables; |
917 | 917 | |
918 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
918 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
919 | 919 | upd_do_query( |
920 | 920 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
921 | 921 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | |
950 | 950 | |
951 | 951 | // 2015-08-03 15:05:26 40a6.0 |
952 | - if(empty($update_tables['planets']['position_original'])) { |
|
952 | + if (empty($update_tables['planets']['position_original'])) { |
|
953 | 953 | upd_alter_table('planets', array( |
954 | 954 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
955 | 955 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -977,12 +977,12 @@ discard block |
||
977 | 977 | |
978 | 978 | // 2015-08-27 19:14:05 40a10.0 |
979 | 979 | // Старая версия таблицы |
980 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
980 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
981 | 981 | upd_drop_table('account'); |
982 | 982 | upd_drop_table('account_translate'); |
983 | 983 | } |
984 | 984 | |
985 | - if(empty($update_tables['account'])) { |
|
985 | + if (empty($update_tables['account'])) { |
|
986 | 986 | upd_create_table('account', " ( |
987 | 987 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
988 | 988 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | |
1045 | 1045 | |
1046 | 1046 | // 2015-09-24 11:39:37 40a10.25 |
1047 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1047 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1048 | 1048 | upd_alter_table('log_metamatter', array( |
1049 | 1049 | "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
1050 | 1050 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code)); |
1097 | 1097 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp)); |
1098 | 1098 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used)); |
1099 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1099 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1100 | 1100 | upd_create_table('log_halloween_2015', " ( |
1101 | 1101 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1102 | 1102 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | |
1113 | 1113 | // 2015-11-28 06:30:27 40a19.21 |
1114 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1114 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1115 | 1115 | upd_alter_table('ube_report', array( |
1116 | 1116 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1117 | 1117 | "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | |
1128 | 1128 | // 2015-12-06 15:10:58 40b1.0 |
1129 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1129 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1130 | 1130 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1131 | 1131 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1132 | 1132 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | case 40: |
1190 | 1190 | upd_log_version_update(); |
1191 | 1191 | |
1192 | - if(empty($update_tables['festival'])) { |
|
1192 | + if (empty($update_tables['festival'])) { |
|
1193 | 1193 | upd_create_table('festival', " ( |
1194 | 1194 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
1195 | 1195 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | ); |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - if(empty($update_tables['festival_unit'])) { |
|
1233 | + if (empty($update_tables['festival_unit'])) { |
|
1234 | 1234 | upd_create_table('festival_unit', " ( |
1235 | 1235 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1236 | 1236 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | // 2015-12-21 06:06:09 41a0.12 |
1250 | - if(empty($update_tables['festival_unit_log'])) { |
|
1250 | + if (empty($update_tables['festival_unit_log'])) { |
|
1251 | 1251 | upd_create_table('festival_unit_log', " ( |
1252 | 1252 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1253 | 1253 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1277,16 +1277,16 @@ discard block |
||
1277 | 1277 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1278 | 1278 | ); |
1279 | 1279 | |
1280 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1280 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1281 | 1281 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1282 | 1282 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if(!empty($update_tables['fleets']['fleet_array'])) { |
|
1285 | + if (!empty($update_tables['fleets']['fleet_array'])) { |
|
1286 | 1286 | $query = upd_do_query("SELECT * FROM {{fleets}}"); |
1287 | - while($row = db_fetch($query)) { |
|
1287 | + while ($row = db_fetch($query)) { |
|
1288 | 1288 | $unit_list = sys_unit_str2arr($row['fleet_array']); |
1289 | - foreach($unit_list as $unit_id => $unit_count) { |
|
1289 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
1290 | 1290 | upd_do_query( |
1291 | 1291 | "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES |
1292 | 1292 | ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | |
1323 | 1323 | classSupernova::$cache->unset_by_prefix('lng_'); |
1324 | 1324 | |
1325 | -if($new_version) { |
|
1325 | +if ($new_version) { |
|
1326 | 1326 | classSupernova::$config->db_saveItem('db_version', $new_version); |
1327 | 1327 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1328 | 1328 | } else { |
@@ -756,9 +756,11 @@ |
||
756 | 756 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
757 | 757 | } |
758 | 758 | |
759 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
759 | + if(isset($update_tables['counter']['page'])) { |
|
760 | + // TODO REMOVE |
|
760 | 761 | { |
761 | 762 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
763 | + } |
|
762 | 764 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
763 | 765 | } |
764 | 766 | } |
@@ -5,47 +5,47 @@ discard block |
||
5 | 5 | } |
6 | 6 | |
7 | 7 | switch($new_version) { |
8 | - case 0: |
|
9 | - case 1: |
|
10 | - case 2: |
|
11 | - case 3: |
|
12 | - case 4: |
|
13 | - case 5: |
|
14 | - case 6: |
|
15 | - case 7: |
|
16 | - case 8: |
|
17 | - case 9: |
|
18 | - upd_log_version_update(); |
|
19 | - |
|
20 | - upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']); |
|
21 | - upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']); |
|
22 | - |
|
23 | - upd_alter_table('planets', array( |
|
24 | - "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'", |
|
25 | - "ADD KEY `i_parent_planet` (`parent_planet`)" |
|
26 | - ), !$update_tables['planets']['parent_planet']); |
|
27 | - upd_do_query( |
|
28 | - "UPDATE `{{planets}}` AS lu |
|
8 | + case 0: |
|
9 | + case 1: |
|
10 | + case 2: |
|
11 | + case 3: |
|
12 | + case 4: |
|
13 | + case 5: |
|
14 | + case 6: |
|
15 | + case 7: |
|
16 | + case 8: |
|
17 | + case 9: |
|
18 | + upd_log_version_update(); |
|
19 | + |
|
20 | + upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']); |
|
21 | + upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']); |
|
22 | + |
|
23 | + upd_alter_table('planets', array( |
|
24 | + "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'", |
|
25 | + "ADD KEY `i_parent_planet` (`parent_planet`)" |
|
26 | + ), !$update_tables['planets']['parent_planet']); |
|
27 | + upd_do_query( |
|
28 | + "UPDATE `{{planets}}` AS lu |
|
29 | 29 | LEFT JOIN `{{planets}}` AS pl |
30 | 30 | ON pl.galaxy=lu.galaxy AND pl.system=lu.system AND pl.planet=lu.planet AND pl.planet_type=1 |
31 | 31 | SET lu.parent_planet=pl.id WHERE lu.planet_type=3;" |
32 | - ); |
|
33 | - upd_drop_table('lunas'); |
|
32 | + ); |
|
33 | + upd_drop_table('lunas'); |
|
34 | 34 | |
35 | - if($update_tables['galaxy']) { |
|
36 | - upd_do_query( |
|
37 | - 'UPDATE `{{planets}}` |
|
35 | + if($update_tables['galaxy']) { |
|
36 | + upd_do_query( |
|
37 | + 'UPDATE `{{planets}}` |
|
38 | 38 | LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id |
39 | 39 | SET |
40 | 40 | {{planets}}.debris_metal = {{galaxy}}.metal, |
41 | 41 | {{planets}}.debris_crystal = {{galaxy}}.crystal |
42 | 42 | WHERE {{galaxy}}.metal>0 OR {{galaxy}}.crystal>0;' |
43 | - ); |
|
44 | - } |
|
45 | - upd_drop_table('galaxy'); |
|
43 | + ); |
|
44 | + } |
|
45 | + upd_drop_table('galaxy'); |
|
46 | 46 | |
47 | - upd_create_table('counter', |
|
48 | - "( |
|
47 | + upd_create_table('counter', |
|
48 | + "( |
|
49 | 49 | `id` bigint(11) NOT NULL AUTO_INCREMENT, |
50 | 50 | `time` int(11) NOT NULL DEFAULT '0', |
51 | 51 | `page` varchar(255) CHARACTER SET utf8 DEFAULT '0', |
@@ -55,62 +55,62 @@ discard block |
||
55 | 55 | KEY `i_user_id` (`user_id`), |
56 | 56 | KEY `i_ip` (`ip`) |
57 | 57 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
58 | - ); |
|
59 | - upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']); |
|
58 | + ); |
|
59 | + upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']); |
|
60 | 60 | |
61 | - upd_alter_table('fleets', array( |
|
62 | - "ADD KEY `fleet_mess` (`fleet_mess`)", |
|
63 | - "ADD KEY `fleet_group` (`fleet_group`)" |
|
64 | - ), !$update_indexes['fleets']['fleet_mess']); |
|
61 | + upd_alter_table('fleets', array( |
|
62 | + "ADD KEY `fleet_mess` (`fleet_mess`)", |
|
63 | + "ADD KEY `fleet_group` (`fleet_group`)" |
|
64 | + ), !$update_indexes['fleets']['fleet_mess']); |
|
65 | 65 | |
66 | - upd_alter_table('referrals', "ADD `dark_matter` bigint(11) NOT NULL DEFAULT '0' COMMENT 'How much player have aquired Dark Matter'", !$update_tables['referrals']['dark_matter']); |
|
67 | - upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']); |
|
66 | + upd_alter_table('referrals', "ADD `dark_matter` bigint(11) NOT NULL DEFAULT '0' COMMENT 'How much player have aquired Dark Matter'", !$update_tables['referrals']['dark_matter']); |
|
67 | + upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']); |
|
68 | 68 | |
69 | - upd_check_key('rpg_bonus_divisor', 10); |
|
69 | + upd_check_key('rpg_bonus_divisor', 10); |
|
70 | 70 | |
71 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame', |
|
71 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame', |
|
72 | 72 | 'close_reason', 'dbVersion', 'ForumUserBarFrame', 'OverviewBanner', 'OverviewClickBanner', 'OverviewExternChat', |
73 | 73 | 'OverviewExternChatCmd', 'OverviewNewsText', 'UserbarURL', 'userbar_source');"); |
74 | 74 | |
75 | - $dm_change_legit = true; |
|
75 | + $dm_change_legit = true; |
|
76 | 76 | |
77 | - upd_do_query( |
|
78 | - "UPDATE {{referrals}} AS r |
|
77 | + upd_do_query( |
|
78 | + "UPDATE {{referrals}} AS r |
|
79 | 79 | LEFT JOIN {{users}} AS u |
80 | 80 | ON u.id = r.id |
81 | 81 | SET r.dark_matter = u.lvl_minier + u.lvl_raid;" |
82 | - ); |
|
83 | - upd_add_more_time(); |
|
82 | + ); |
|
83 | + upd_add_more_time(); |
|
84 | 84 | |
85 | - if($update_tables['users']['rpg_points']) { |
|
86 | - upd_do_query( |
|
87 | - "UPDATE {{users}} AS u |
|
85 | + if($update_tables['users']['rpg_points']) { |
|
86 | + upd_do_query( |
|
87 | + "UPDATE {{users}} AS u |
|
88 | 88 | RIGHT JOIN {{referrals}} AS r |
89 | 89 | ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor . " |
90 | 90 | SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor . ");" |
91 | - ); |
|
92 | - } |
|
91 | + ); |
|
92 | + } |
|
93 | 93 | |
94 | - $dm_change_legit = false; |
|
95 | - upd_do_query('COMMIT;', true); |
|
96 | - $new_version = 10; |
|
97 | - |
|
98 | - case 10: |
|
99 | - case 11: |
|
100 | - case 12: |
|
101 | - case 13: |
|
102 | - case 14: |
|
103 | - case 15: |
|
104 | - case 16: |
|
105 | - case 17: |
|
106 | - case 18: |
|
107 | - case 19: |
|
108 | - case 20: |
|
109 | - case 21: |
|
110 | - upd_log_version_update(); |
|
111 | - |
|
112 | - upd_create_table('alliance_requests', |
|
113 | - "( |
|
94 | + $dm_change_legit = false; |
|
95 | + upd_do_query('COMMIT;', true); |
|
96 | + $new_version = 10; |
|
97 | + |
|
98 | + case 10: |
|
99 | + case 11: |
|
100 | + case 12: |
|
101 | + case 13: |
|
102 | + case 14: |
|
103 | + case 15: |
|
104 | + case 16: |
|
105 | + case 17: |
|
106 | + case 18: |
|
107 | + case 19: |
|
108 | + case 20: |
|
109 | + case 21: |
|
110 | + upd_log_version_update(); |
|
111 | + |
|
112 | + upd_create_table('alliance_requests', |
|
113 | + "( |
|
114 | 114 | `id_user` int(11) NOT NULL, |
115 | 115 | `id_ally` int(11) NOT NULL DEFAULT '0', |
116 | 116 | `request_text` text, |
@@ -118,96 +118,96 @@ discard block |
||
118 | 118 | `request_denied` tinyint(1) unsigned NOT NULL DEFAULT '0', |
119 | 119 | PRIMARY KEY (`id_user`,`id_ally`) |
120 | 120 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;" |
121 | - ); |
|
122 | - |
|
123 | - upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']); |
|
124 | - |
|
125 | - upd_alter_table('counter', array("MODIFY `ip` VARCHAR(250) COMMENT 'User last IP'", "ADD `proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['counter']['proxy']); |
|
126 | - |
|
127 | - upd_alter_table('statpoints', array( |
|
128 | - "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'", |
|
129 | - "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'", |
|
130 | - "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'", |
|
131 | - "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'" |
|
132 | - ), !$update_tables['statpoints']['res_rank']); |
|
133 | - |
|
134 | - upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']); |
|
135 | - |
|
136 | - upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']); |
|
137 | - upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`", |
|
138 | - "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']); |
|
139 | - upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']); |
|
140 | - upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']); |
|
141 | - upd_alter_table('users', array("MODIFY `user_lastip` VARCHAR(250) COMMENT 'User last IP'", "ADD `user_proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['users']['user_proxy']); |
|
142 | - |
|
143 | - upd_drop_table('update'); |
|
144 | - |
|
145 | - upd_check_key('fleet_speed', classSupernova::$config->fleet_speed / 2500, classSupernova::$config->fleet_speed >= 2500); |
|
146 | - upd_check_key('game_counter', 0); |
|
147 | - upd_check_key('game_default_language', 'ru'); |
|
148 | - upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
|
149 | - upd_check_key('game_default_template', 'OpenGame'); |
|
150 | - upd_check_key('game_news_overview', 3); |
|
151 | - upd_check_key('game_news_actual', 259200); |
|
152 | - upd_check_key('game_noob_factor', 5, !isset(classSupernova::$config->game_noob_factor)); |
|
153 | - upd_check_key('game_noob_points', 5000, !isset(classSupernova::$config->game_noob_points)); |
|
154 | - upd_check_key('game_speed', classSupernova::$config->game_speed / 2500, classSupernova::$config->game_speed >= 2500); |
|
155 | - upd_check_key('int_format_date', 'd.m.Y'); |
|
156 | - upd_check_key('int_format_time', 'H:i:s', true); |
|
157 | - upd_check_key('int_banner_background', 'design/images/banner.png', true); |
|
158 | - upd_check_key('int_userbar_background', 'design/images/userbar.png', true); |
|
159 | - upd_check_key('player_max_colonies', classSupernova::$config->player_max_planets ? (classSupernova::$config->player_max_planets - 1) : 9); |
|
160 | - upd_check_key('url_forum', classSupernova::$config->forum_url, !isset(classSupernova::$config->url_forum)); |
|
161 | - upd_check_key('url_rules', classSupernova::$config->rules_url, !isset(classSupernova::$config->url_rules)); |
|
162 | - upd_check_key('url_dark_matter', '', !isset(classSupernova::$config->url_dark_matter)); |
|
163 | - |
|
164 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ( |
|
121 | + ); |
|
122 | + |
|
123 | + upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']); |
|
124 | + |
|
125 | + upd_alter_table('counter', array("MODIFY `ip` VARCHAR(250) COMMENT 'User last IP'", "ADD `proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['counter']['proxy']); |
|
126 | + |
|
127 | + upd_alter_table('statpoints', array( |
|
128 | + "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'", |
|
129 | + "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'", |
|
130 | + "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'", |
|
131 | + "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'" |
|
132 | + ), !$update_tables['statpoints']['res_rank']); |
|
133 | + |
|
134 | + upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']); |
|
135 | + |
|
136 | + upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']); |
|
137 | + upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`", |
|
138 | + "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']); |
|
139 | + upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']); |
|
140 | + upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']); |
|
141 | + upd_alter_table('users', array("MODIFY `user_lastip` VARCHAR(250) COMMENT 'User last IP'", "ADD `user_proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['users']['user_proxy']); |
|
142 | + |
|
143 | + upd_drop_table('update'); |
|
144 | + |
|
145 | + upd_check_key('fleet_speed', classSupernova::$config->fleet_speed / 2500, classSupernova::$config->fleet_speed >= 2500); |
|
146 | + upd_check_key('game_counter', 0); |
|
147 | + upd_check_key('game_default_language', 'ru'); |
|
148 | + upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
|
149 | + upd_check_key('game_default_template', 'OpenGame'); |
|
150 | + upd_check_key('game_news_overview', 3); |
|
151 | + upd_check_key('game_news_actual', 259200); |
|
152 | + upd_check_key('game_noob_factor', 5, !isset(classSupernova::$config->game_noob_factor)); |
|
153 | + upd_check_key('game_noob_points', 5000, !isset(classSupernova::$config->game_noob_points)); |
|
154 | + upd_check_key('game_speed', classSupernova::$config->game_speed / 2500, classSupernova::$config->game_speed >= 2500); |
|
155 | + upd_check_key('int_format_date', 'd.m.Y'); |
|
156 | + upd_check_key('int_format_time', 'H:i:s', true); |
|
157 | + upd_check_key('int_banner_background', 'design/images/banner.png', true); |
|
158 | + upd_check_key('int_userbar_background', 'design/images/userbar.png', true); |
|
159 | + upd_check_key('player_max_colonies', classSupernova::$config->player_max_planets ? (classSupernova::$config->player_max_planets - 1) : 9); |
|
160 | + upd_check_key('url_forum', classSupernova::$config->forum_url, !isset(classSupernova::$config->url_forum)); |
|
161 | + upd_check_key('url_rules', classSupernova::$config->rules_url, !isset(classSupernova::$config->url_rules)); |
|
162 | + upd_check_key('url_dark_matter', '', !isset(classSupernova::$config->url_dark_matter)); |
|
163 | + |
|
164 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ( |
|
165 | 165 | 'game_date_withTime', 'player_max_planets', 'OverviewNewsFrame', 'forum_url', 'rules_url' |
166 | 166 | );"); |
167 | 167 | |
168 | - upd_do_query('COMMIT;', true); |
|
169 | - $new_version = 22; |
|
170 | - |
|
171 | - case 22: |
|
172 | - upd_log_version_update(); |
|
173 | - |
|
174 | - upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']); |
|
175 | - upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
|
176 | - upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
|
177 | - |
|
178 | - if($update_tables['planets']['b_building']) { |
|
179 | - $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
|
180 | - $const_que_structures = QUE_STRUCTURES; |
|
181 | - while($planet_data = db_fetch($planet_query)) { |
|
182 | - $old_que = explode(';', $planet_data['b_building_id']); |
|
183 | - foreach($old_que as $old_que_item_string) { |
|
184 | - if(!$old_que_item_string) { |
|
185 | - continue; |
|
186 | - } |
|
168 | + upd_do_query('COMMIT;', true); |
|
169 | + $new_version = 22; |
|
170 | + |
|
171 | + case 22: |
|
172 | + upd_log_version_update(); |
|
173 | + |
|
174 | + upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']); |
|
175 | + upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
|
176 | + upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
|
177 | + |
|
178 | + if($update_tables['planets']['b_building']) { |
|
179 | + $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
|
180 | + $const_que_structures = QUE_STRUCTURES; |
|
181 | + while($planet_data = db_fetch($planet_query)) { |
|
182 | + $old_que = explode(';', $planet_data['b_building_id']); |
|
183 | + foreach($old_que as $old_que_item_string) { |
|
184 | + if(!$old_que_item_string) { |
|
185 | + continue; |
|
186 | + } |
|
187 | 187 | |
188 | - $old_que_item = explode(',', $old_que_item_string); |
|
189 | - if($old_que_item[4] == 'build') { |
|
190 | - $old_que_item[4] = BUILD_CREATE; |
|
191 | - } else { |
|
192 | - $old_que_item[4] = BUILD_DESTROY; |
|
193 | - } |
|
188 | + $old_que_item = explode(',', $old_que_item_string); |
|
189 | + if($old_que_item[4] == 'build') { |
|
190 | + $old_que_item[4] = BUILD_CREATE; |
|
191 | + } else { |
|
192 | + $old_que_item[4] = BUILD_DESTROY; |
|
193 | + } |
|
194 | 194 | |
195 | - $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1; |
|
196 | - $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}"; |
|
195 | + $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1; |
|
196 | + $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}"; |
|
197 | + } |
|
198 | + upd_do_query("UPDATE {{planets}} SET `que` = '{$planet_data['que']}', `b_building` = '0', `b_building_id` = '0' WHERE `id` = '{$planet_data['id']}' LIMIT 1;", true); |
|
197 | 199 | } |
198 | - upd_do_query("UPDATE {{planets}} SET `que` = '{$planet_data['que']}', `b_building` = '0', `b_building_id` = '0' WHERE `id` = '{$planet_data['id']}' LIMIT 1;", true); |
|
199 | 200 | } |
200 | - } |
|
201 | 201 | |
202 | - upd_do_query('COMMIT;', true); |
|
203 | - $new_version = 23; |
|
202 | + upd_do_query('COMMIT;', true); |
|
203 | + $new_version = 23; |
|
204 | 204 | |
205 | - case 23: |
|
206 | - case 24: |
|
207 | - upd_log_version_update(); |
|
205 | + case 23: |
|
206 | + case 24: |
|
207 | + upd_log_version_update(); |
|
208 | 208 | |
209 | - upd_create_table('confirmations', |
|
210 | - "( |
|
209 | + upd_create_table('confirmations', |
|
210 | + "( |
|
211 | 211 | `id` bigint(11) NOT NULL AUTO_INCREMENT, |
212 | 212 | `id_user` bigint(11) NOT NULL DEFAULT 0, |
213 | 213 | `type` SMALLINT NOT NULL DEFAULT 0, |
@@ -217,124 +217,124 @@ discard block |
||
217 | 217 | PRIMARY KEY (`id`), |
218 | 218 | KEY `i_code_email` (`code`, `email`) |
219 | 219 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
220 | - ); |
|
220 | + ); |
|
221 | 221 | |
222 | - if($update_tables['users']['urlaubs_until']) { |
|
223 | - upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
|
224 | - upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
|
225 | - upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
|
226 | - } |
|
222 | + if($update_tables['users']['urlaubs_until']) { |
|
223 | + upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
|
224 | + upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
|
225 | + upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
|
226 | + } |
|
227 | 227 | |
228 | - upd_check_key('user_vacation_disable', classSupernova::$config->urlaubs_modus_erz, !isset(classSupernova::$config->user_vacation_disable)); |
|
229 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');"); |
|
228 | + upd_check_key('user_vacation_disable', classSupernova::$config->urlaubs_modus_erz, !isset(classSupernova::$config->user_vacation_disable)); |
|
229 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');"); |
|
230 | 230 | |
231 | - upd_do_query('COMMIT;', true); |
|
232 | - $new_version = 25; |
|
233 | - |
|
234 | - case 25: |
|
235 | - upd_log_version_update(); |
|
236 | - |
|
237 | - upd_alter_table('rw', array( |
|
238 | - "DROP COLUMN `a_zestrzelona`", |
|
239 | - "DROP INDEX `rid`", |
|
240 | - "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST", |
|
241 | - "ADD PRIMARY KEY (`report_id`)", |
|
242 | - "ADD INDEX `i_rid` (`rid`)" |
|
243 | - ), !$update_tables['rw']['report_id']); |
|
244 | - |
|
245 | - upd_add_more_time(); |
|
246 | - upd_create_table('logs_backup', "AS (SELECT * FROM {{logs}});"); |
|
247 | - |
|
248 | - upd_alter_table('logs', array( |
|
249 | - "MODIFY COLUMN `log_id` INT(1)", |
|
250 | - "DROP PRIMARY KEY" |
|
251 | - ), !$update_tables['logs']['log_timestamp']); |
|
252 | - |
|
253 | - upd_alter_table('logs', array( |
|
254 | - "DROP COLUMN `log_id`", |
|
255 | - "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST", |
|
256 | - "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`", |
|
257 | - "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`", |
|
258 | - "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`", |
|
259 | - "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`", |
|
260 | - "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`", |
|
261 | - "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`", |
|
262 | - "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`", |
|
263 | - "ADD INDEX `i_log_username` (`log_username`)", |
|
264 | - "ADD INDEX `i_log_time` (`log_time`)", |
|
265 | - "ADD INDEX `i_log_sender` (`log_sender`)", |
|
266 | - "ADD INDEX `i_log_code` (`log_code`)", |
|
267 | - "ADD INDEX `i_log_page` (`log_page`)", |
|
268 | - "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" |
|
269 | - ), !$update_tables['logs']['log_timestamp']); |
|
270 | - upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
|
271 | - |
|
272 | - if($update_tables['errors']) { |
|
273 | - upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;'); |
|
274 | - if($update_tables['errors_backup']) { |
|
275 | - upd_drop_table('errors_backup'); |
|
276 | - } |
|
277 | - upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup'); |
|
231 | + upd_do_query('COMMIT;', true); |
|
232 | + $new_version = 25; |
|
233 | + |
|
234 | + case 25: |
|
235 | + upd_log_version_update(); |
|
236 | + |
|
237 | + upd_alter_table('rw', array( |
|
238 | + "DROP COLUMN `a_zestrzelona`", |
|
239 | + "DROP INDEX `rid`", |
|
240 | + "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST", |
|
241 | + "ADD PRIMARY KEY (`report_id`)", |
|
242 | + "ADD INDEX `i_rid` (`rid`)" |
|
243 | + ), !$update_tables['rw']['report_id']); |
|
244 | + |
|
245 | + upd_add_more_time(); |
|
246 | + upd_create_table('logs_backup', "AS (SELECT * FROM {{logs}});"); |
|
247 | + |
|
248 | + upd_alter_table('logs', array( |
|
249 | + "MODIFY COLUMN `log_id` INT(1)", |
|
250 | + "DROP PRIMARY KEY" |
|
251 | + ), !$update_tables['logs']['log_timestamp']); |
|
252 | + |
|
253 | + upd_alter_table('logs', array( |
|
254 | + "DROP COLUMN `log_id`", |
|
255 | + "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST", |
|
256 | + "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`", |
|
257 | + "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`", |
|
258 | + "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`", |
|
259 | + "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`", |
|
260 | + "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`", |
|
261 | + "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`", |
|
262 | + "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`", |
|
263 | + "ADD INDEX `i_log_username` (`log_username`)", |
|
264 | + "ADD INDEX `i_log_time` (`log_time`)", |
|
265 | + "ADD INDEX `i_log_sender` (`log_sender`)", |
|
266 | + "ADD INDEX `i_log_code` (`log_code`)", |
|
267 | + "ADD INDEX `i_log_page` (`log_page`)", |
|
268 | + "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" |
|
269 | + ), !$update_tables['logs']['log_timestamp']); |
|
270 | + upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
|
271 | + |
|
272 | + if($update_tables['errors']) { |
|
273 | + upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;'); |
|
274 | + if($update_tables['errors_backup']) { |
|
275 | + upd_drop_table('errors_backup'); |
|
276 | + } |
|
277 | + upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup'); |
|
278 | 278 | |
279 | - upd_drop_table('errors'); |
|
280 | - } |
|
279 | + upd_drop_table('errors'); |
|
280 | + } |
|
281 | 281 | |
282 | - upd_alter_table('logs', 'ORDER BY log_time'); |
|
282 | + upd_alter_table('logs', 'ORDER BY log_time'); |
|
283 | 283 | |
284 | - upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']); |
|
284 | + upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']); |
|
285 | 285 | |
286 | - upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);'); |
|
287 | - upd_do_query('UPDATE `{{logs}}` AS l LEFT JOIN `{{users}}` AS u ON u.id = l.log_sender SET l.log_username = u.username WHERE l.log_username IS NOT NULL;'); |
|
286 | + upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);'); |
|
287 | + upd_do_query('UPDATE `{{logs}}` AS l LEFT JOIN `{{users}}` AS u ON u.id = l.log_sender SET l.log_username = u.username WHERE l.log_username IS NOT NULL;'); |
|
288 | 288 | |
289 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';"); |
|
290 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';"); |
|
291 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';"); |
|
292 | - $sys_log_disabled = false; |
|
289 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';"); |
|
290 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';"); |
|
291 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';"); |
|
292 | + $sys_log_disabled = false; |
|
293 | 293 | |
294 | - upd_do_query('COMMIT;', true); |
|
295 | - $new_version = 26; |
|
294 | + upd_do_query('COMMIT;', true); |
|
295 | + $new_version = 26; |
|
296 | 296 | |
297 | - case 26: |
|
298 | - upd_log_version_update(); |
|
297 | + case 26: |
|
298 | + upd_log_version_update(); |
|
299 | 299 | |
300 | - $sys_log_disabled = false; |
|
300 | + $sys_log_disabled = false; |
|
301 | 301 | |
302 | - upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']); |
|
303 | - upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']); |
|
304 | - upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']); |
|
305 | - upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']); |
|
302 | + upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']); |
|
303 | + upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']); |
|
304 | + upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']); |
|
305 | + upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']); |
|
306 | 306 | |
307 | - upd_alter_table('messages', array( |
|
308 | - "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)", |
|
309 | - "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)", |
|
310 | - "ADD INDEX `i_time` (`message_time`)" |
|
311 | - ), !$update_indexes['messages']['i_owner_time']); |
|
307 | + upd_alter_table('messages', array( |
|
308 | + "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)", |
|
309 | + "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)", |
|
310 | + "ADD INDEX `i_time` (`message_time`)" |
|
311 | + ), !$update_indexes['messages']['i_owner_time']); |
|
312 | 312 | |
313 | - upd_drop_table('fleet_log'); |
|
313 | + upd_drop_table('fleet_log'); |
|
314 | 314 | |
315 | - upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;"); |
|
316 | - upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
|
317 | - upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
|
318 | - upd_alter_table('planets', array( |
|
319 | - "DROP COLUMN `b_building`", |
|
320 | - "DROP COLUMN `b_building_id`" |
|
321 | - ), $update_tables['planets']['b_building']); |
|
315 | + upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;"); |
|
316 | + upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
|
317 | + upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
|
318 | + upd_alter_table('planets', array( |
|
319 | + "DROP COLUMN `b_building`", |
|
320 | + "DROP COLUMN `b_building_id`" |
|
321 | + ), $update_tables['planets']['b_building']); |
|
322 | 322 | |
323 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
|
323 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
|
324 | 324 | |
325 | - upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;"); |
|
326 | - upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');"); |
|
325 | + upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;"); |
|
326 | + upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');"); |
|
327 | 327 | |
328 | - upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset(classSupernova::$config->chat_admin_highlight)); |
|
328 | + upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset(classSupernova::$config->chat_admin_highlight)); |
|
329 | 329 | |
330 | - upd_check_key('int_banner_URL', 'banner.php?type=banner', classSupernova::$config->int_banner_URL == '/banner.php?type=banner'); |
|
331 | - upd_check_key('int_userbar_URL', 'banner.php?type=userbar', classSupernova::$config->int_userbar_URL == '/banner.php?type=userbar'); |
|
330 | + upd_check_key('int_banner_URL', 'banner.php?type=banner', classSupernova::$config->int_banner_URL == '/banner.php?type=banner'); |
|
331 | + upd_check_key('int_userbar_URL', 'banner.php?type=userbar', classSupernova::$config->int_userbar_URL == '/banner.php?type=userbar'); |
|
332 | 332 | |
333 | - upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
|
333 | + upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
|
334 | 334 | |
335 | - if(!$update_tables['shortcut']) { |
|
336 | - upd_create_table('shortcut', |
|
337 | - "( |
|
335 | + if(!$update_tables['shortcut']) { |
|
336 | + upd_create_table('shortcut', |
|
337 | + "( |
|
338 | 338 | `shortcut_id` SERIAL, |
339 | 339 | `shortcut_user_id` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0, |
340 | 340 | `shortcut_planet_id` bigint(11) NOT NULL DEFAULT 0, |
@@ -351,70 +351,70 @@ discard block |
||
351 | 351 | CONSTRAINT `FK_shortcut_user_id` FOREIGN KEY (`shortcut_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
352 | 352 | |
353 | 353 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
354 | - ); |
|
354 | + ); |
|
355 | 355 | |
356 | - $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
|
356 | + $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
|
357 | 357 | |
358 | - $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
|
359 | - while($user_data = db_fetch($query)) { |
|
360 | - $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
|
361 | - foreach($shortcuts as $shortcut) { |
|
362 | - if(!$shortcut) { |
|
363 | - continue; |
|
364 | - } |
|
358 | + $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
|
359 | + while($user_data = db_fetch($query)) { |
|
360 | + $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
|
361 | + foreach($shortcuts as $shortcut) { |
|
362 | + if(!$shortcut) { |
|
363 | + continue; |
|
364 | + } |
|
365 | 365 | |
366 | - $shortcut = explode(',', $shortcut); |
|
367 | - $shortcut[0] = db_escape($shortcut[0]); |
|
368 | - $shortcut[1] = intval($shortcut[1]); |
|
369 | - $shortcut[2] = intval($shortcut[2]); |
|
370 | - $shortcut[3] = intval($shortcut[3]); |
|
371 | - $shortcut[4] = intval($shortcut[4]); |
|
366 | + $shortcut = explode(',', $shortcut); |
|
367 | + $shortcut[0] = db_escape($shortcut[0]); |
|
368 | + $shortcut[1] = intval($shortcut[1]); |
|
369 | + $shortcut[2] = intval($shortcut[2]); |
|
370 | + $shortcut[3] = intval($shortcut[3]); |
|
371 | + $shortcut[4] = intval($shortcut[4]); |
|
372 | 372 | |
373 | - if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
374 | - upd_do_query("INSERT INTO {classSupernova::$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true); |
|
373 | + if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
374 | + upd_do_query("INSERT INTO {classSupernova::$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true); |
|
375 | + } |
|
375 | 376 | } |
376 | 377 | } |
377 | - } |
|
378 | 378 | |
379 | - upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`'); |
|
380 | - }; |
|
379 | + upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`'); |
|
380 | + }; |
|
381 | 381 | |
382 | - upd_check_key('url_faq', '', !isset(classSupernova::$config->url_faq)); |
|
382 | + upd_check_key('url_faq', '', !isset(classSupernova::$config->url_faq)); |
|
383 | 383 | |
384 | - upd_do_query('COMMIT;', true); |
|
385 | - $new_version = 27; |
|
386 | - |
|
387 | - case 27: |
|
388 | - upd_log_version_update(); |
|
389 | - |
|
390 | - upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset(classSupernova::$config->chat_highlight_moderator)); |
|
391 | - upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset(classSupernova::$config->chat_highlight_operator)); |
|
392 | - upd_check_key('chat_highlight_admin', classSupernova::$config->chat_admin_highlight ? classSupernova::$config->chat_admin_highlight : '<font color=puple>$1</font>', !isset(classSupernova::$config->chat_highlight_admin)); |
|
393 | - |
|
394 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');"); |
|
395 | - |
|
396 | - upd_alter_table('banned', array( |
|
397 | - "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT", |
|
398 | - "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
399 | - "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''", |
|
400 | - "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0", |
|
401 | - "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0", |
|
402 | - "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
403 | - "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''", |
|
404 | - "DROP COLUMN who2", |
|
405 | - "ADD PRIMARY KEY (`ban_id`)" |
|
406 | - ), !$update_tables['banned']['ban_id']); |
|
407 | - |
|
408 | - upd_alter_table('alliance', array( |
|
409 | - "MODIFY COLUMN `id` SERIAL", |
|
410 | - "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)", |
|
411 | - "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", |
|
412 | - "ENGINE=InnoDB" |
|
413 | - ), !$update_indexes['alliance']['i_ally_name']); |
|
414 | - |
|
415 | - $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'"; |
|
416 | - upd_create_table('alliance_diplomacy', |
|
417 | - "( |
|
384 | + upd_do_query('COMMIT;', true); |
|
385 | + $new_version = 27; |
|
386 | + |
|
387 | + case 27: |
|
388 | + upd_log_version_update(); |
|
389 | + |
|
390 | + upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset(classSupernova::$config->chat_highlight_moderator)); |
|
391 | + upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset(classSupernova::$config->chat_highlight_operator)); |
|
392 | + upd_check_key('chat_highlight_admin', classSupernova::$config->chat_admin_highlight ? classSupernova::$config->chat_admin_highlight : '<font color=puple>$1</font>', !isset(classSupernova::$config->chat_highlight_admin)); |
|
393 | + |
|
394 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');"); |
|
395 | + |
|
396 | + upd_alter_table('banned', array( |
|
397 | + "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT", |
|
398 | + "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
399 | + "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''", |
|
400 | + "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0", |
|
401 | + "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0", |
|
402 | + "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
403 | + "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''", |
|
404 | + "DROP COLUMN who2", |
|
405 | + "ADD PRIMARY KEY (`ban_id`)" |
|
406 | + ), !$update_tables['banned']['ban_id']); |
|
407 | + |
|
408 | + upd_alter_table('alliance', array( |
|
409 | + "MODIFY COLUMN `id` SERIAL", |
|
410 | + "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)", |
|
411 | + "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", |
|
412 | + "ENGINE=InnoDB" |
|
413 | + ), !$update_indexes['alliance']['i_ally_name']); |
|
414 | + |
|
415 | + $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'"; |
|
416 | + upd_create_table('alliance_diplomacy', |
|
417 | + "( |
|
418 | 418 | `alliance_diplomacy_id` SERIAL, |
419 | 419 | `alliance_diplomacy_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
420 | 420 | `alliance_diplomacy_contr_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | ,CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
432 | 432 | ,CONSTRAINT `FK_diplomacy_contr_ally_name` FOREIGN KEY (`alliance_diplomacy_contr_ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE |
433 | 433 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
434 | - ); |
|
434 | + ); |
|
435 | 435 | |
436 | - upd_create_table('alliance_negotiation', |
|
437 | - "( |
|
436 | + upd_create_table('alliance_negotiation', |
|
437 | + "( |
|
438 | 438 | `alliance_negotiation_id` SERIAL, |
439 | 439 | `alliance_negotiation_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
440 | 440 | `alliance_negotiation_ally_name` varchar(32) DEFAULT '', |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | ,CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
456 | 456 | ,CONSTRAINT `FK_negotiation_contr_ally_name` FOREIGN KEY (`alliance_negotiation_contr_ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE |
457 | 457 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
458 | - ); |
|
458 | + ); |
|
459 | 459 | |
460 | - upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
461 | - upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
460 | + upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
461 | + upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
462 | 462 | |
463 | - upd_create_table('bashing', |
|
464 | - "( |
|
463 | + upd_create_table('bashing', |
|
464 | + "( |
|
465 | 465 | `bashing_id` SERIAL, |
466 | 466 | `bashing_user_id` bigint(11) UNSIGNED DEFAULT NULL, |
467 | 467 | `bashing_planet_id` bigint(11) UNSIGNED DEFAULT NULL, |
@@ -475,23 +475,23 @@ discard block |
||
475 | 475 | CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
476 | 476 | ,CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
477 | 477 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
478 | - ); |
|
478 | + ); |
|
479 | 479 | |
480 | - upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_war_delay)); |
|
481 | - upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_scope)); |
|
482 | - upd_check_key('fleet_bashing_interval', 30 * 60, !isset(classSupernova::$config->fleet_bashing_interval)); |
|
483 | - upd_check_key('fleet_bashing_waves', 3, !isset(classSupernova::$config->fleet_bashing_waves)); |
|
484 | - upd_check_key('fleet_bashing_attacks', 3, !isset(classSupernova::$config->fleet_bashing_attacks)); |
|
480 | + upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_war_delay)); |
|
481 | + upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_scope)); |
|
482 | + upd_check_key('fleet_bashing_interval', 30 * 60, !isset(classSupernova::$config->fleet_bashing_interval)); |
|
483 | + upd_check_key('fleet_bashing_waves', 3, !isset(classSupernova::$config->fleet_bashing_waves)); |
|
484 | + upd_check_key('fleet_bashing_attacks', 3, !isset(classSupernova::$config->fleet_bashing_attacks)); |
|
485 | 485 | |
486 | - upd_do_query('COMMIT;', true); |
|
487 | - $new_version = 28; |
|
486 | + upd_do_query('COMMIT;', true); |
|
487 | + $new_version = 28; |
|
488 | 488 | |
489 | - case 28: |
|
490 | - case 28.1: |
|
491 | - upd_log_version_update(); |
|
489 | + case 28: |
|
490 | + case 28.1: |
|
491 | + upd_log_version_update(); |
|
492 | 492 | |
493 | - upd_create_table('quest', |
|
494 | - "( |
|
493 | + upd_create_table('quest', |
|
494 | + "( |
|
495 | 495 | `quest_id` SERIAL, |
496 | 496 | `quest_name` VARCHAR(255) DEFAULT NULL, |
497 | 497 | `quest_description` TEXT, |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | PRIMARY KEY (`quest_id`) |
504 | 504 | ,KEY (`quest_type`, `quest_order`) |
505 | 505 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
506 | - ); |
|
506 | + ); |
|
507 | 507 | |
508 | - upd_create_table('quest_status', |
|
509 | - "( |
|
508 | + upd_create_table('quest_status', |
|
509 | + "( |
|
510 | 510 | `quest_status_id` SERIAL, |
511 | 511 | `quest_status_quest_id` bigint(20) UNSIGNED DEFAULT NULL, |
512 | 512 | `quest_status_user_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0', |
@@ -518,79 +518,79 @@ discard block |
||
518 | 518 | ,CONSTRAINT `FK_quest_status_quest_id` FOREIGN KEY (`quest_status_quest_id`) REFERENCES `{{quest}}` (`quest_id`) ON DELETE CASCADE ON UPDATE CASCADE |
519 | 519 | ,CONSTRAINT `FK_quest_status_user_id` FOREIGN KEY (`quest_status_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
520 | 520 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
521 | - ); |
|
522 | - |
|
523 | - upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total)); |
|
524 | - |
|
525 | - for($i = 0; $i < 25; $i++) { |
|
526 | - upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
|
527 | - upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
|
528 | - upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
|
529 | - } |
|
530 | - |
|
531 | - upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']); |
|
532 | - upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']); |
|
533 | - upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']); |
|
534 | - upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true); |
|
521 | + ); |
|
535 | 522 | |
536 | - upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']); |
|
537 | - upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']); |
|
523 | + upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total)); |
|
538 | 524 | |
539 | - upd_alter_table('users', array( |
|
540 | - 'DROP COLUMN `ally_request`', |
|
541 | - 'DROP COLUMN `ally_request_text`', |
|
542 | - ), $update_tables['users']['ally_request_text']); |
|
525 | + for($i = 0; $i < 25; $i++) { |
|
526 | + upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
|
527 | + upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
|
528 | + upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
|
529 | + } |
|
543 | 530 | |
544 | - upd_alter_table('users', array( |
|
545 | - 'ADD INDEX `i_ally_id` (`ally_id`)', |
|
546 | - 'ADD INDEX `i_ally_name` (`ally_name`)', |
|
547 | - ), !$update_indexes['users']['i_ally_id']); |
|
531 | + upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']); |
|
532 | + upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']); |
|
533 | + upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']); |
|
534 | + upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true); |
|
548 | 535 | |
549 | - upd_alter_table('users', array( |
|
550 | - "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
|
551 | - ), !$update_tables['users']['msg_admin']); |
|
536 | + upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']); |
|
537 | + upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']); |
|
552 | 538 | |
553 | - if(!$update_foreigns['users']['FK_users_ally_id']) { |
|
554 | 539 | upd_alter_table('users', array( |
555 | - 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
|
556 | - 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
557 | - ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
540 | + 'DROP COLUMN `ally_request`', |
|
541 | + 'DROP COLUMN `ally_request_text`', |
|
542 | + ), $update_tables['users']['ally_request_text']); |
|
558 | 543 | |
559 | - upd_do_query('DELETE FROM {{alliance}} WHERE id NOT IN (SELECT ally_id FROM {{users}} GROUP BY ally_id);'); |
|
560 | - upd_do_query("UPDATE {{users}} SET `ally_id` = NULL, ally_name = NULL, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` NOT IN (SELECT id FROM {{alliance}});"); |
|
561 | - upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
544 | + upd_alter_table('users', array( |
|
545 | + 'ADD INDEX `i_ally_id` (`ally_id`)', |
|
546 | + 'ADD INDEX `i_ally_name` (`ally_name`)', |
|
547 | + ), !$update_indexes['users']['i_ally_id']); |
|
562 | 548 | |
563 | 549 | upd_alter_table('users', array( |
564 | - "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
565 | - "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
566 | - ), !$update_foreigns['users']['FK_users_ally_id']); |
|
567 | - } |
|
550 | + "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
|
551 | + ), !$update_tables['users']['msg_admin']); |
|
552 | + |
|
553 | + if(!$update_foreigns['users']['FK_users_ally_id']) { |
|
554 | + upd_alter_table('users', array( |
|
555 | + 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
|
556 | + 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
557 | + ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
558 | + |
|
559 | + upd_do_query('DELETE FROM {{alliance}} WHERE id NOT IN (SELECT ally_id FROM {{users}} GROUP BY ally_id);'); |
|
560 | + upd_do_query("UPDATE {{users}} SET `ally_id` = NULL, ally_name = NULL, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` NOT IN (SELECT id FROM {{alliance}});"); |
|
561 | + upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
562 | + |
|
563 | + upd_alter_table('users', array( |
|
564 | + "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
565 | + "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
566 | + ), !$update_foreigns['users']['FK_users_ally_id']); |
|
567 | + } |
|
568 | 568 | |
569 | - upd_alter_table('planets', array( |
|
570 | - "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
571 | - "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
572 | - ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
569 | + upd_alter_table('planets', array( |
|
570 | + "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
571 | + "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
572 | + ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
573 | 573 | |
574 | - $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);"); |
|
575 | - while($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
576 | - upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
|
577 | - } |
|
574 | + $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);"); |
|
575 | + while($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
576 | + upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
|
577 | + } |
|
578 | 578 | |
579 | - upd_check_key('allow_buffing', isset(classSupernova::$config->fleet_buffing_check) ? !classSupernova::$config->fleet_buffing_check : 0, !isset(classSupernova::$config->allow_buffing)); |
|
580 | - upd_check_key('ally_help_weak', 0, !isset(classSupernova::$config->ally_help_weak)); |
|
579 | + upd_check_key('allow_buffing', isset(classSupernova::$config->fleet_buffing_check) ? !classSupernova::$config->fleet_buffing_check : 0, !isset(classSupernova::$config->allow_buffing)); |
|
580 | + upd_check_key('ally_help_weak', 0, !isset(classSupernova::$config->ally_help_weak)); |
|
581 | 581 | |
582 | - upd_do_query('COMMIT;', true); |
|
583 | - $new_version = 29; |
|
582 | + upd_do_query('COMMIT;', true); |
|
583 | + $new_version = 29; |
|
584 | 584 | |
585 | - case 29: |
|
586 | - upd_log_version_update(); |
|
585 | + case 29: |
|
586 | + upd_log_version_update(); |
|
587 | 587 | |
588 | - upd_check_key('game_email_pm', 0, !isset(classSupernova::$config->game_email_pm)); |
|
589 | - upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset(classSupernova::$config->player_vacation_time)); |
|
590 | - upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset(classSupernova::$config->player_delete_time)); |
|
588 | + upd_check_key('game_email_pm', 0, !isset(classSupernova::$config->game_email_pm)); |
|
589 | + upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset(classSupernova::$config->player_vacation_time)); |
|
590 | + upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset(classSupernova::$config->player_delete_time)); |
|
591 | 591 | |
592 | - upd_create_table('log_dark_matter', |
|
593 | - "( |
|
592 | + upd_create_table('log_dark_matter', |
|
593 | + "( |
|
594 | 594 | `log_dark_matter_id` SERIAL, |
595 | 595 | `log_dark_matter_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp', |
596 | 596 | `log_dark_matter_username` varchar(64) NOT NULL DEFAULT '' COMMENT 'Username', |
@@ -605,20 +605,20 @@ discard block |
||
605 | 605 | KEY `i_log_dark_matter_reason_sender_id` (`log_dark_matter_reason`, `log_dark_matter_sender`, `log_dark_matter_id`), |
606 | 606 | KEY `i_log_dark_matter_amount` (`log_dark_matter_amount`) |
607 | 607 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
608 | - ); |
|
609 | - upd_do_query('COMMIT;', true); |
|
608 | + ); |
|
609 | + upd_do_query('COMMIT;', true); |
|
610 | 610 | |
611 | - $records = 1; |
|
612 | - while($records) { |
|
613 | - upd_do_query('START TRANSACTION;', true); |
|
614 | - $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;"); |
|
615 | - $records = db_num_rows($query); |
|
616 | - while($row = db_fetch($query)) { |
|
617 | - $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
|
618 | - |
|
619 | - $reason = RPG_NONE; |
|
620 | - $comment = $matches[3]; |
|
621 | - switch($matches[3]) { |
|
611 | + $records = 1; |
|
612 | + while($records) { |
|
613 | + upd_do_query('START TRANSACTION;', true); |
|
614 | + $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;"); |
|
615 | + $records = db_num_rows($query); |
|
616 | + while($row = db_fetch($query)) { |
|
617 | + $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
|
618 | + |
|
619 | + $reason = RPG_NONE; |
|
620 | + $comment = $matches[3]; |
|
621 | + switch($matches[3]) { |
|
622 | 622 | case 'Level Up For Structure Building': |
623 | 623 | $reason = RPG_STRUCTURE; |
624 | 624 | break; |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | $comment = $matches2[1]; |
648 | 648 | } |
649 | 649 | break; |
650 | - } |
|
650 | + } |
|
651 | 651 | |
652 | 652 | if($matches[2]) { |
653 | 653 | $row['log_username'] = db_escape($row['log_username']); |
@@ -681,579 +681,579 @@ discard block |
||
681 | 681 | upd_do_query('COMMIT;', true); |
682 | 682 | $new_version = 30; |
683 | 683 | |
684 | - case 30: |
|
685 | - upd_log_version_update(); |
|
684 | + case 30: |
|
685 | + upd_log_version_update(); |
|
686 | 686 | |
687 | - upd_alter_table('users', array( |
|
688 | - "ADD `player_que` TEXT" |
|
689 | - ), !$update_tables['users']['player_que']); |
|
687 | + upd_alter_table('users', array( |
|
688 | + "ADD `player_que` TEXT" |
|
689 | + ), !$update_tables['users']['player_que']); |
|
690 | 690 | |
691 | - upd_alter_table('planets', array( |
|
692 | - "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0", |
|
693 | - "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
|
694 | - ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
|
691 | + upd_alter_table('planets', array( |
|
692 | + "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0", |
|
693 | + "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
|
694 | + ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
|
695 | + |
|
696 | + if($update_tables['users']['rpg_geologue']) { |
|
697 | + doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
|
698 | + |
|
699 | + upd_alter_table('users', array( |
|
700 | + "DROP COLUMN `rpg_geologue`", |
|
701 | + "DROP COLUMN `rpg_ingenieur`", |
|
702 | + "DROP COLUMN `rpg_constructeur`", |
|
703 | + "DROP COLUMN `rpg_technocrate`", |
|
704 | + "DROP COLUMN `rpg_scientifique`", |
|
705 | + "DROP COLUMN `rpg_defenseur`", |
|
706 | + ), $update_tables['users']['rpg_geologue']); |
|
707 | + } |
|
695 | 708 | |
696 | - if($update_tables['users']['rpg_geologue']) { |
|
697 | - doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
|
709 | + if($update_tables['users']['rpg_bunker']) { |
|
710 | + doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
|
698 | 711 | |
699 | - upd_alter_table('users', array( |
|
700 | - "DROP COLUMN `rpg_geologue`", |
|
701 | - "DROP COLUMN `rpg_ingenieur`", |
|
702 | - "DROP COLUMN `rpg_constructeur`", |
|
703 | - "DROP COLUMN `rpg_technocrate`", |
|
704 | - "DROP COLUMN `rpg_scientifique`", |
|
705 | - "DROP COLUMN `rpg_defenseur`", |
|
706 | - ), $update_tables['users']['rpg_geologue']); |
|
707 | - } |
|
708 | - |
|
709 | - if($update_tables['users']['rpg_bunker']) { |
|
710 | - doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
|
712 | + upd_alter_table('users', array( |
|
713 | + "DROP COLUMN `rpg_bunker`", |
|
714 | + ), $update_tables['users']['rpg_bunker']); |
|
715 | + } |
|
711 | 716 | |
712 | 717 | upd_alter_table('users', array( |
713 | - "DROP COLUMN `rpg_bunker`", |
|
714 | - ), $update_tables['users']['rpg_bunker']); |
|
715 | - } |
|
718 | + "DROP COLUMN `p_infligees`", |
|
719 | + "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`", |
|
720 | + ), $update_tables['users']['p_infligees']); |
|
716 | 721 | |
717 | - upd_alter_table('users', array( |
|
718 | - "DROP COLUMN `p_infligees`", |
|
719 | - "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`", |
|
720 | - ), $update_tables['users']['p_infligees']); |
|
721 | - |
|
722 | - upd_alter_table('users', array( |
|
723 | - "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0", |
|
724 | - ), !$update_tables['users']['mrc_academic']); |
|
725 | - |
|
726 | - upd_alter_table('users', array( |
|
727 | - "DROP COLUMN `db_deaktjava`", |
|
728 | - "DROP COLUMN `kolorminus`", |
|
729 | - "DROP COLUMN `kolorplus`", |
|
730 | - "DROP COLUMN `kolorpoziom`", |
|
731 | - "DROP COLUMN `deleteme`", |
|
732 | - |
|
733 | - "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
734 | - "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
735 | - "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
736 | - "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
737 | - "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
738 | - |
|
739 | - "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'", |
|
740 | - "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'", |
|
741 | - "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'", |
|
742 | - "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'", |
|
743 | - "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'", |
|
744 | - "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'", |
|
745 | - ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
746 | - |
|
747 | - upd_alter_table('users', array( |
|
748 | - "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
749 | - "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
750 | - ), !isset($update_tables['users']['total_rank'])); |
|
751 | - doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points;"); |
|
752 | - |
|
753 | - upd_alter_table('alliance', array( |
|
754 | - "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
755 | - "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
756 | - ), !isset($update_tables['alliance']['total_rank'])); |
|
757 | - doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
|
758 | - |
|
759 | - if(!isset($update_tables['users']['ally_tag'])) { |
|
760 | 722 | upd_alter_table('users', array( |
761 | - "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
762 | - ), !isset($update_tables['users']['ally_tag'])); |
|
763 | - doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_tag = a.ally_tag, u.ally_name = a.ally_name;"); |
|
764 | - doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_id = NULL, u.ally_tag = NULL, u.ally_name = NULL, u.ally_register_time = 0, ally_rank_id = 0 WHERE a.id IS NULL;"); |
|
765 | - upd_alter_table('users', array( |
|
766 | - "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{{alliance}}` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
767 | - ), !$update_foreigns['users']['FK_users_ally_tag']); |
|
768 | - } |
|
769 | - |
|
770 | - upd_alter_table('users', array( |
|
771 | - "ADD COLUMN `player_artifact_list` TEXT", |
|
772 | - ), !isset($update_tables['users']['player_artifact_list'])); |
|
773 | - |
|
774 | - if(!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
775 | - upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage)); |
|
723 | + "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0", |
|
724 | + ), !$update_tables['users']['mrc_academic']); |
|
776 | 725 | |
777 | 726 | upd_alter_table('users', array( |
778 | - "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
779 | - "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
780 | - ), !isset($update_tables['users']['player_rpg_tech_xp'])); |
|
781 | - |
|
782 | - doquery("UPDATE {{users}} AS u LEFT JOIN {{statpoints}} AS s ON s.id_owner = u.id AND s.stat_type = 1 AND s.stat_code = 1 SET u.player_rpg_tech_xp = s.tech_points;"); |
|
783 | - } |
|
727 | + "DROP COLUMN `db_deaktjava`", |
|
728 | + "DROP COLUMN `kolorminus`", |
|
729 | + "DROP COLUMN `kolorplus`", |
|
730 | + "DROP COLUMN `kolorpoziom`", |
|
731 | + "DROP COLUMN `deleteme`", |
|
732 | + |
|
733 | + "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
734 | + "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
735 | + "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
736 | + "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
737 | + "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
738 | + |
|
739 | + "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'", |
|
740 | + "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'", |
|
741 | + "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'", |
|
742 | + "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'", |
|
743 | + "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'", |
|
744 | + "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'", |
|
745 | + ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
784 | 746 | |
785 | - upd_alter_table('planets', array( |
|
786 | - "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`", |
|
787 | - ), !isset($update_tables['planets']['planet_cargo_hyper'])); |
|
747 | + upd_alter_table('users', array( |
|
748 | + "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
749 | + "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
750 | + ), !isset($update_tables['users']['total_rank'])); |
|
751 | + doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points;"); |
|
788 | 752 | |
789 | - upd_do_query('COMMIT;', true); |
|
790 | - $new_version = 31; |
|
753 | + upd_alter_table('alliance', array( |
|
754 | + "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
755 | + "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
756 | + ), !isset($update_tables['alliance']['total_rank'])); |
|
757 | + doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
|
758 | + |
|
759 | + if(!isset($update_tables['users']['ally_tag'])) { |
|
760 | + upd_alter_table('users', array( |
|
761 | + "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
762 | + ), !isset($update_tables['users']['ally_tag'])); |
|
763 | + doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_tag = a.ally_tag, u.ally_name = a.ally_name;"); |
|
764 | + doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_id = NULL, u.ally_tag = NULL, u.ally_name = NULL, u.ally_register_time = 0, ally_rank_id = 0 WHERE a.id IS NULL;"); |
|
765 | + upd_alter_table('users', array( |
|
766 | + "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{{alliance}}` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
767 | + ), !$update_foreigns['users']['FK_users_ally_tag']); |
|
768 | + } |
|
791 | 769 | |
792 | - case 31: |
|
793 | - upd_log_version_update(); |
|
770 | + upd_alter_table('users', array( |
|
771 | + "ADD COLUMN `player_artifact_list` TEXT", |
|
772 | + ), !isset($update_tables['users']['player_artifact_list'])); |
|
794 | 773 | |
795 | - upd_alter_table('aks', array( |
|
796 | - "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
797 | - ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
774 | + if(!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
775 | + upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage)); |
|
798 | 776 | |
799 | - upd_alter_table('alliance', array( |
|
800 | - "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
801 | - "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
802 | - ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
777 | + upd_alter_table('users', array( |
|
778 | + "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
779 | + "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
780 | + ), !isset($update_tables['users']['player_rpg_tech_xp'])); |
|
803 | 781 | |
804 | - if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
805 | - upd_alter_table('alliance_diplomacy', array( |
|
806 | - "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
|
807 | - "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
|
808 | - ), true); |
|
782 | + doquery("UPDATE {{users}} AS u LEFT JOIN {{statpoints}} AS s ON s.id_owner = u.id AND s.stat_type = 1 AND s.stat_code = 1 SET u.player_rpg_tech_xp = s.tech_points;"); |
|
783 | + } |
|
809 | 784 | |
810 | - upd_alter_table('alliance_diplomacy', array( |
|
811 | - "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
812 | - "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
785 | + upd_alter_table('planets', array( |
|
786 | + "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`", |
|
787 | + ), !isset($update_tables['planets']['planet_cargo_hyper'])); |
|
813 | 788 | |
814 | - "ADD CONSTRAINT `FK_diplomacy_ally_id` FOREIGN KEY (`alliance_diplomacy_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
815 | - "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
816 | - ), true); |
|
817 | - } |
|
789 | + upd_do_query('COMMIT;', true); |
|
790 | + $new_version = 31; |
|
818 | 791 | |
819 | - if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
820 | - upd_alter_table('alliance_negotiation', array( |
|
821 | - "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
|
822 | - "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
|
823 | - ), true); |
|
792 | + case 31: |
|
793 | + upd_log_version_update(); |
|
824 | 794 | |
825 | - upd_alter_table('alliance_negotiation', array( |
|
826 | - "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0", |
|
827 | - "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
828 | - "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
795 | + upd_alter_table('aks', array( |
|
796 | + "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
797 | + ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
829 | 798 | |
830 | - "ADD CONSTRAINT `FK_negotiation_ally_id` FOREIGN KEY (`alliance_negotiation_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
831 | - "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
832 | - ), true); |
|
833 | - } |
|
799 | + upd_alter_table('alliance', array( |
|
800 | + "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
801 | + "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
802 | + ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
803 | + |
|
804 | + if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
805 | + upd_alter_table('alliance_diplomacy', array( |
|
806 | + "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
|
807 | + "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
|
808 | + ), true); |
|
809 | + |
|
810 | + upd_alter_table('alliance_diplomacy', array( |
|
811 | + "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
812 | + "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
813 | + |
|
814 | + "ADD CONSTRAINT `FK_diplomacy_ally_id` FOREIGN KEY (`alliance_diplomacy_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
815 | + "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
816 | + ), true); |
|
817 | + } |
|
834 | 818 | |
835 | - if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
836 | - upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
819 | + if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
820 | + upd_alter_table('alliance_negotiation', array( |
|
821 | + "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
|
822 | + "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
|
823 | + ), true); |
|
837 | 824 | |
838 | - upd_alter_table('alliance_requests', array( |
|
839 | - "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
840 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
825 | + upd_alter_table('alliance_negotiation', array( |
|
826 | + "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0", |
|
827 | + "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
828 | + "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
841 | 829 | |
842 | - "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)", |
|
830 | + "ADD CONSTRAINT `FK_negotiation_ally_id` FOREIGN KEY (`alliance_negotiation_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
831 | + "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
832 | + ), true); |
|
833 | + } |
|
843 | 834 | |
844 | - "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
845 | - "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
846 | - ), true); |
|
847 | - } |
|
835 | + if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
836 | + upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
848 | 837 | |
849 | - if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
850 | - upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true); |
|
838 | + upd_alter_table('alliance_requests', array( |
|
839 | + "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
840 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
851 | 841 | |
852 | - upd_alter_table('annonce', array( |
|
853 | - "MODIFY COLUMN `id` SERIAL", |
|
854 | - "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL", |
|
842 | + "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)", |
|
855 | 843 | |
856 | - "ADD KEY `I_annonce_user` (`user`, `id`)", |
|
844 | + "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
845 | + "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
846 | + ), true); |
|
847 | + } |
|
857 | 848 | |
858 | - "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{{users}}` (`username`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
859 | - ), true); |
|
860 | - } |
|
849 | + if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
850 | + upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true); |
|
861 | 851 | |
862 | - if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
863 | - upd_alter_table('bashing', array( |
|
864 | - "DROP FOREIGN KEY `FK_bashing_user_id`", |
|
865 | - "DROP FOREIGN KEY `FK_bashing_planet_id`", |
|
866 | - ), true); |
|
852 | + upd_alter_table('annonce', array( |
|
853 | + "MODIFY COLUMN `id` SERIAL", |
|
854 | + "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL", |
|
867 | 855 | |
868 | - upd_alter_table('bashing', array( |
|
869 | - "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
870 | - "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
856 | + "ADD KEY `I_annonce_user` (`user`, `id`)", |
|
871 | 857 | |
872 | - "ADD CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
873 | - "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
874 | - ), true); |
|
875 | - } |
|
858 | + "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{{users}}` (`username`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
859 | + ), true); |
|
860 | + } |
|
876 | 861 | |
877 | - if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
878 | - upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
862 | + if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
863 | + upd_alter_table('bashing', array( |
|
864 | + "DROP FOREIGN KEY `FK_bashing_user_id`", |
|
865 | + "DROP FOREIGN KEY `FK_bashing_planet_id`", |
|
866 | + ), true); |
|
879 | 867 | |
880 | - upd_alter_table('buddy', array( |
|
881 | - "MODIFY COLUMN `id` SERIAL", |
|
882 | - "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
883 | - "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
884 | - "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
868 | + upd_alter_table('bashing', array( |
|
869 | + "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
870 | + "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
885 | 871 | |
886 | - "ADD KEY `I_buddy_sender` (`sender`)", |
|
887 | - "ADD KEY `I_buddy_owner` (`owner`)", |
|
872 | + "ADD CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
873 | + "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
874 | + ), true); |
|
875 | + } |
|
888 | 876 | |
889 | - "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
890 | - "ADD CONSTRAINT `FK_buddy_owner_id` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
891 | - ), true); |
|
892 | - } |
|
877 | + if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
878 | + upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
893 | 879 | |
894 | - upd_alter_table('chat', array( |
|
895 | - "MODIFY COLUMN `messageid` SERIAL", |
|
896 | - ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
880 | + upd_alter_table('buddy', array( |
|
881 | + "MODIFY COLUMN `id` SERIAL", |
|
882 | + "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
883 | + "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
884 | + "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
897 | 885 | |
898 | - upd_alter_table('counter', array( |
|
899 | - "CHANGE COLUMN `id` `counter_id` SERIAL", |
|
886 | + "ADD KEY `I_buddy_sender` (`sender`)", |
|
887 | + "ADD KEY `I_buddy_owner` (`owner`)", |
|
900 | 888 | |
901 | - "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0", |
|
889 | + "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
890 | + "ADD CONSTRAINT `FK_buddy_owner_id` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
891 | + ), true); |
|
892 | + } |
|
902 | 893 | |
903 | - "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`", |
|
894 | + upd_alter_table('chat', array( |
|
895 | + "MODIFY COLUMN `messageid` SERIAL", |
|
896 | + ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
904 | 897 | |
905 | - "ADD KEY `I_counter_user_name` (`user_name`)", |
|
906 | - ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
898 | + upd_alter_table('counter', array( |
|
899 | + "CHANGE COLUMN `id` `counter_id` SERIAL", |
|
907 | 900 | |
908 | - upd_alter_table('fleets', array( |
|
909 | - "MODIFY COLUMN `fleet_id` SERIAL", |
|
910 | - "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'", |
|
911 | - "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'", |
|
912 | - "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
|
913 | - ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
|
901 | + "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0", |
|
914 | 902 | |
915 | - if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
916 | - upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
|
903 | + "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`", |
|
917 | 904 | |
918 | - upd_alter_table('iraks', array( |
|
919 | - "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0", |
|
920 | - "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
921 | - "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
922 | - "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0", |
|
923 | - "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
924 | - "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0", |
|
925 | - "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0", |
|
926 | - |
|
927 | - "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
928 | - "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0", |
|
929 | - "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0", |
|
930 | - |
|
931 | - "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)", |
|
932 | - "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)", |
|
933 | - |
|
934 | - "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
935 | - "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
936 | - ), true); |
|
937 | - } |
|
905 | + "ADD KEY `I_counter_user_name` (`user_name`)", |
|
906 | + ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
938 | 907 | |
939 | - if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
940 | - upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
908 | + upd_alter_table('fleets', array( |
|
909 | + "MODIFY COLUMN `fleet_id` SERIAL", |
|
910 | + "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'", |
|
911 | + "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'", |
|
912 | + "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
|
913 | + ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
|
914 | + |
|
915 | + if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
916 | + upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
|
917 | + |
|
918 | + upd_alter_table('iraks', array( |
|
919 | + "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0", |
|
920 | + "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
921 | + "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
922 | + "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0", |
|
923 | + "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
924 | + "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0", |
|
925 | + "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0", |
|
926 | + |
|
927 | + "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
928 | + "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0", |
|
929 | + "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0", |
|
930 | + |
|
931 | + "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)", |
|
932 | + "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)", |
|
933 | + |
|
934 | + "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
935 | + "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
936 | + ), true); |
|
937 | + } |
|
941 | 938 | |
942 | - upd_alter_table('notes', array( |
|
943 | - "MODIFY COLUMN id SERIAL", |
|
944 | - "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
939 | + if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
940 | + upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
945 | 941 | |
946 | - "ADD KEY `I_notes_owner` (`owner`)", |
|
942 | + upd_alter_table('notes', array( |
|
943 | + "MODIFY COLUMN id SERIAL", |
|
944 | + "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
947 | 945 | |
948 | - "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
949 | - ), true); |
|
950 | - } |
|
946 | + "ADD KEY `I_notes_owner` (`owner`)", |
|
951 | 947 | |
952 | - upd_alter_table('planets', array( |
|
953 | - "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", |
|
954 | - "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL", |
|
955 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
956 | - "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'", |
|
957 | - "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'", |
|
958 | - "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'", |
|
959 | - "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'", |
|
960 | - |
|
961 | - "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'", |
|
962 | - "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`", |
|
963 | - "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`", |
|
964 | - "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`", |
|
965 | - "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`", |
|
966 | - |
|
967 | - "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
968 | - "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
969 | - "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'", |
|
970 | - "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
971 | - "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
972 | - "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
973 | - "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
974 | - "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'", |
|
975 | - "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
976 | - "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
977 | - "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'", |
|
978 | - "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'", |
|
979 | - "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`", |
|
980 | - "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'", |
|
981 | - "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'", |
|
982 | - "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'", |
|
983 | - "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`", |
|
984 | - "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`", |
|
985 | - "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`", |
|
986 | - "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`", |
|
987 | - |
|
988 | - "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
989 | - "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
990 | - "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`", |
|
991 | - "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`", |
|
992 | - "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`", |
|
993 | - "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`", |
|
994 | - "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`", |
|
995 | - "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`", |
|
996 | - |
|
997 | - "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
998 | - "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
999 | - "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1000 | - "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1001 | - "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1002 | - "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`", |
|
1003 | - "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1004 | - "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1005 | - "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1006 | - |
|
1007 | - "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1008 | - "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1009 | - "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1010 | - "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1011 | - "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1012 | - "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1013 | - |
|
1014 | - "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1015 | - "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1016 | - "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'", |
|
1017 | - |
|
1018 | - "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1019 | - "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1020 | - |
|
1021 | - "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`", |
|
1022 | - "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`", |
|
1023 | - "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`", |
|
1024 | - |
|
1025 | - "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1026 | - "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1027 | - "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1028 | - "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1029 | - "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1030 | - "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1031 | - |
|
1032 | - "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`", |
|
1033 | -// "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`", |
|
1034 | -// "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`", |
|
1035 | - "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`", |
|
1036 | - "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`", |
|
1037 | - "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`", |
|
1038 | - |
|
1039 | - "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`", |
|
1040 | - "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`", |
|
1041 | - "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`", |
|
1042 | - "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`", |
|
1043 | - "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`", |
|
1044 | - "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`", |
|
1045 | - "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`", |
|
1046 | - "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`", |
|
1047 | - "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`", |
|
1048 | - "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`", |
|
1049 | - |
|
1050 | - "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`", |
|
1051 | - "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`", |
|
1052 | - "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`", |
|
1053 | - |
|
1054 | - "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'", |
|
1055 | - "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'", |
|
1056 | - "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'", |
|
1057 | - "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'", |
|
1058 | - |
|
1059 | - "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'", |
|
1060 | - |
|
1061 | - "DROP COLUMN `b_hangar_plus`", |
|
1062 | - ), isset($update_tables['planets']['b_hangar_plus'])); |
|
1063 | - |
|
1064 | - if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1065 | - upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
|
1066 | - |
|
1067 | - upd_alter_table('referrals', array( |
|
1068 | - "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1069 | - "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1070 | - "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'", |
|
1071 | - |
|
1072 | - "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1073 | - "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1074 | - ), true); |
|
1075 | - } |
|
948 | + "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
949 | + ), true); |
|
950 | + } |
|
1076 | 951 | |
1077 | - upd_alter_table('rw', array( |
|
1078 | - "MODIFY COLUMN `report_id` SERIAL", |
|
1079 | - "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED", |
|
1080 | - "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
|
1081 | - ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1082 | - |
|
1083 | - if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1084 | - upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true); |
|
1085 | - |
|
1086 | - upd_alter_table('shortcut', array( |
|
1087 | - "MODIFY COLUMN `shortcut_id` SERIAL", |
|
1088 | - "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1089 | - "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1090 | - "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0", |
|
1091 | - "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0", |
|
1092 | - "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0", |
|
1093 | - |
|
1094 | - "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1095 | - ), true); |
|
1096 | - } |
|
952 | + upd_alter_table('planets', array( |
|
953 | + "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", |
|
954 | + "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL", |
|
955 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
956 | + "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'", |
|
957 | + "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'", |
|
958 | + "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'", |
|
959 | + "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'", |
|
960 | + |
|
961 | + "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'", |
|
962 | + "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`", |
|
963 | + "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`", |
|
964 | + "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`", |
|
965 | + "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`", |
|
966 | + |
|
967 | + "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
968 | + "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
969 | + "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'", |
|
970 | + "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
971 | + "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
972 | + "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
973 | + "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
974 | + "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'", |
|
975 | + "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
976 | + "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
977 | + "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'", |
|
978 | + "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'", |
|
979 | + "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`", |
|
980 | + "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'", |
|
981 | + "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'", |
|
982 | + "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'", |
|
983 | + "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`", |
|
984 | + "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`", |
|
985 | + "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`", |
|
986 | + "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`", |
|
987 | + |
|
988 | + "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
989 | + "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
990 | + "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`", |
|
991 | + "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`", |
|
992 | + "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`", |
|
993 | + "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`", |
|
994 | + "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`", |
|
995 | + "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`", |
|
996 | + |
|
997 | + "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
998 | + "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
999 | + "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1000 | + "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1001 | + "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1002 | + "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`", |
|
1003 | + "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1004 | + "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1005 | + "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1006 | + |
|
1007 | + "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1008 | + "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1009 | + "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1010 | + "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1011 | + "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1012 | + "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1013 | + |
|
1014 | + "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1015 | + "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1016 | + "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'", |
|
1017 | + |
|
1018 | + "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1019 | + "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1020 | + |
|
1021 | + "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`", |
|
1022 | + "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`", |
|
1023 | + "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`", |
|
1024 | + |
|
1025 | + "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1026 | + "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1027 | + "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1028 | + "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1029 | + "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1030 | + "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1031 | + |
|
1032 | + "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`", |
|
1033 | + // "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`", |
|
1034 | + // "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`", |
|
1035 | + "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`", |
|
1036 | + "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`", |
|
1037 | + "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`", |
|
1038 | + |
|
1039 | + "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`", |
|
1040 | + "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`", |
|
1041 | + "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`", |
|
1042 | + "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`", |
|
1043 | + "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`", |
|
1044 | + "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`", |
|
1045 | + "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`", |
|
1046 | + "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`", |
|
1047 | + "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`", |
|
1048 | + "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`", |
|
1049 | + |
|
1050 | + "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`", |
|
1051 | + "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`", |
|
1052 | + "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`", |
|
1053 | + |
|
1054 | + "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'", |
|
1055 | + "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'", |
|
1056 | + "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'", |
|
1057 | + "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'", |
|
1058 | + |
|
1059 | + "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'", |
|
1060 | + |
|
1061 | + "DROP COLUMN `b_hangar_plus`", |
|
1062 | + ), isset($update_tables['planets']['b_hangar_plus'])); |
|
1063 | + |
|
1064 | + if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1065 | + upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
|
1066 | + |
|
1067 | + upd_alter_table('referrals', array( |
|
1068 | + "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1069 | + "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1070 | + "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'", |
|
1071 | + |
|
1072 | + "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1073 | + "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1074 | + ), true); |
|
1075 | + } |
|
1097 | 1076 | |
1098 | - if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1099 | - upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
1077 | + upd_alter_table('rw', array( |
|
1078 | + "MODIFY COLUMN `report_id` SERIAL", |
|
1079 | + "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED", |
|
1080 | + "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
|
1081 | + ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1082 | + |
|
1083 | + if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1084 | + upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true); |
|
1085 | + |
|
1086 | + upd_alter_table('shortcut', array( |
|
1087 | + "MODIFY COLUMN `shortcut_id` SERIAL", |
|
1088 | + "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1089 | + "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1090 | + "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0", |
|
1091 | + "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0", |
|
1092 | + "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0", |
|
1093 | + |
|
1094 | + "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1095 | + ), true); |
|
1096 | + } |
|
1100 | 1097 | |
1101 | - upd_alter_table('statpoints', array( |
|
1102 | - "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
1103 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1104 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1105 | - "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
1106 | - "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1107 | - |
|
1108 | - "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1109 | - "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1110 | - "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1111 | - "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
1112 | - |
|
1113 | - "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1114 | - "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1115 | - "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1116 | - "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1117 | - |
|
1118 | - "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1119 | - "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1120 | - "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1121 | - "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1122 | - |
|
1123 | - "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1124 | - "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1125 | - "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1126 | - "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1127 | - |
|
1128 | - "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
1129 | - "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
1130 | - "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
1131 | - "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
1132 | - |
|
1133 | - "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1134 | - "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1135 | - "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1136 | - "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1137 | - |
|
1138 | - "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
1139 | - |
|
1140 | - "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1141 | - "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1142 | - ), true); |
|
1143 | - } |
|
1098 | + if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1099 | + upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
1100 | + |
|
1101 | + upd_alter_table('statpoints', array( |
|
1102 | + "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
1103 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1104 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1105 | + "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
1106 | + "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1107 | + |
|
1108 | + "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1109 | + "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1110 | + "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1111 | + "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
1112 | + |
|
1113 | + "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1114 | + "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1115 | + "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1116 | + "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1117 | + |
|
1118 | + "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1119 | + "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1120 | + "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1121 | + "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1122 | + |
|
1123 | + "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1124 | + "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1125 | + "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1126 | + "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1127 | + |
|
1128 | + "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
1129 | + "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
1130 | + "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
1131 | + "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
1132 | + |
|
1133 | + "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1134 | + "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1135 | + "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1136 | + "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1137 | + |
|
1138 | + "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
1139 | + |
|
1140 | + "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1141 | + "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1142 | + ), true); |
|
1143 | + } |
|
1144 | 1144 | |
1145 | - upd_alter_table('users', array( |
|
1146 | - "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`", |
|
1147 | - "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`", |
|
1148 | - "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`", |
|
1149 | - "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`", |
|
1150 | - "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1151 | - "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1152 | - "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1153 | - "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1154 | - "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1155 | - "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1156 | - "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1157 | - "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1158 | - "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1159 | - "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1160 | - "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1161 | - "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1162 | - "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1163 | - "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1164 | - "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1165 | - "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1166 | - "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1167 | - "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`", |
|
1168 | - "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`", |
|
1169 | - "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
1170 | - "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`", |
|
1171 | - "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`", |
|
1172 | - "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`", |
|
1173 | - "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`", |
|
1174 | - "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'", |
|
1175 | - "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`", |
|
1176 | - "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1177 | - "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1178 | - "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`", |
|
1179 | - "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'", |
|
1180 | - "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'", |
|
1181 | - "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'", |
|
1182 | - "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'", |
|
1183 | - "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`", |
|
1184 | - "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'", |
|
1185 | - "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'", |
|
1186 | - "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'", |
|
1187 | - "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'", |
|
1188 | - "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'", |
|
1189 | - "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'", |
|
1190 | - "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'", |
|
1191 | - "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'", |
|
1192 | - "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'", |
|
1193 | -// "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`", |
|
1194 | - "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'", |
|
1195 | - "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'", |
|
1196 | - "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'", |
|
1197 | - "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1198 | - "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`", |
|
1199 | - "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`", |
|
1200 | - "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`", |
|
1201 | - "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`", |
|
1202 | - "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`", |
|
1203 | - "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`", |
|
1204 | - "MODIFY COLUMN `sign` mediumtext AFTER `avatar`", |
|
1205 | - "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`", |
|
1206 | - "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`", |
|
1207 | - "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`", |
|
1208 | - "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`", |
|
1209 | - "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`", |
|
1210 | - "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`", |
|
1211 | - "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`", |
|
1212 | - "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`", |
|
1213 | - "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`", |
|
1214 | - "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`", |
|
1215 | - "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`", |
|
1216 | - "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`", |
|
1217 | - "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`", |
|
1218 | - "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`", |
|
1219 | - "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`", |
|
1220 | - "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`", |
|
1221 | - "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`", |
|
1222 | - "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`", |
|
1223 | - "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`", |
|
1224 | - "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`", |
|
1225 | - "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`", |
|
1226 | - "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`", |
|
1227 | - "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`", |
|
1228 | - "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`", |
|
1229 | - ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1145 | + upd_alter_table('users', array( |
|
1146 | + "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`", |
|
1147 | + "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`", |
|
1148 | + "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`", |
|
1149 | + "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`", |
|
1150 | + "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1151 | + "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1152 | + "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1153 | + "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1154 | + "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1155 | + "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1156 | + "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1157 | + "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1158 | + "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1159 | + "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1160 | + "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1161 | + "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1162 | + "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1163 | + "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1164 | + "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1165 | + "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1166 | + "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1167 | + "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`", |
|
1168 | + "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`", |
|
1169 | + "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
1170 | + "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`", |
|
1171 | + "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`", |
|
1172 | + "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`", |
|
1173 | + "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`", |
|
1174 | + "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'", |
|
1175 | + "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`", |
|
1176 | + "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1177 | + "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1178 | + "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`", |
|
1179 | + "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'", |
|
1180 | + "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'", |
|
1181 | + "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'", |
|
1182 | + "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'", |
|
1183 | + "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`", |
|
1184 | + "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'", |
|
1185 | + "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'", |
|
1186 | + "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'", |
|
1187 | + "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'", |
|
1188 | + "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'", |
|
1189 | + "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'", |
|
1190 | + "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'", |
|
1191 | + "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'", |
|
1192 | + "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'", |
|
1193 | + // "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`", |
|
1194 | + "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'", |
|
1195 | + "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'", |
|
1196 | + "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'", |
|
1197 | + "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1198 | + "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`", |
|
1199 | + "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`", |
|
1200 | + "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`", |
|
1201 | + "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`", |
|
1202 | + "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`", |
|
1203 | + "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`", |
|
1204 | + "MODIFY COLUMN `sign` mediumtext AFTER `avatar`", |
|
1205 | + "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`", |
|
1206 | + "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`", |
|
1207 | + "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`", |
|
1208 | + "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`", |
|
1209 | + "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`", |
|
1210 | + "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`", |
|
1211 | + "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`", |
|
1212 | + "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`", |
|
1213 | + "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`", |
|
1214 | + "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`", |
|
1215 | + "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`", |
|
1216 | + "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`", |
|
1217 | + "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`", |
|
1218 | + "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`", |
|
1219 | + "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`", |
|
1220 | + "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`", |
|
1221 | + "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`", |
|
1222 | + "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`", |
|
1223 | + "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`", |
|
1224 | + "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`", |
|
1225 | + "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`", |
|
1226 | + "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`", |
|
1227 | + "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`", |
|
1228 | + "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`", |
|
1229 | + ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1230 | 1230 | |
1231 | - upd_do_query('COMMIT;', true); |
|
1232 | - $new_version = 32; |
|
1231 | + upd_do_query('COMMIT;', true); |
|
1232 | + $new_version = 32; |
|
1233 | 1233 | |
1234 | - case 32: |
|
1235 | - upd_log_version_update(); |
|
1234 | + case 32: |
|
1235 | + upd_log_version_update(); |
|
1236 | 1236 | |
1237 | - upd_check_key('avatar_max_width', 128, !isset(classSupernova::$config->avatar_max_width)); |
|
1238 | - upd_check_key('avatar_max_height', 128, !isset(classSupernova::$config->avatar_max_height)); |
|
1237 | + upd_check_key('avatar_max_width', 128, !isset(classSupernova::$config->avatar_max_width)); |
|
1238 | + upd_check_key('avatar_max_height', 128, !isset(classSupernova::$config->avatar_max_height)); |
|
1239 | 1239 | |
1240 | - upd_alter_table('users', array( |
|
1241 | - "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1242 | - ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1240 | + upd_alter_table('users', array( |
|
1241 | + "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1242 | + ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1243 | 1243 | |
1244 | - upd_alter_table('alliance', array( |
|
1245 | - "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1246 | - ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1244 | + upd_alter_table('alliance', array( |
|
1245 | + "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1246 | + ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1247 | 1247 | |
1248 | - upd_alter_table('users', array( |
|
1249 | - "DROP COLUMN `settings_allylogo`", |
|
1250 | - ), isset($update_tables['users']['settings_allylogo'])); |
|
1248 | + upd_alter_table('users', array( |
|
1249 | + "DROP COLUMN `settings_allylogo`", |
|
1250 | + ), isset($update_tables['users']['settings_allylogo'])); |
|
1251 | 1251 | |
1252 | - if(!isset($update_tables['powerup'])) { |
|
1253 | - upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};"); |
|
1252 | + if(!isset($update_tables['powerup'])) { |
|
1253 | + upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};"); |
|
1254 | 1254 | |
1255 | - upd_create_table('powerup', |
|
1256 | - "( |
|
1255 | + upd_create_table('powerup', |
|
1256 | + "( |
|
1257 | 1257 | `powerup_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
1258 | 1258 | `powerup_user_id` bigint(20) UNSIGNED NULL DEFAULT NULL, |
1259 | 1259 | `powerup_planet_id` bigint(20) UNSIGNED NULL DEFAULT NULL, |
@@ -1272,33 +1272,33 @@ discard block |
||
1272 | 1272 | CONSTRAINT `FK_powerup_user_id` FOREIGN KEY (`powerup_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, |
1273 | 1273 | CONSTRAINT `FK_powerup_planet_id` FOREIGN KEY (`powerup_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
1274 | 1274 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1275 | - ); |
|
1276 | - |
|
1277 | - upd_check_key('empire_mercenary_temporary', 0, !isset(classSupernova::$config->empire_mercenary_temporary)); |
|
1278 | - upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset(classSupernova::$config->empire_mercenary_base_period)); |
|
1279 | - |
|
1280 | - $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
|
1281 | - $user_list = upd_do_query("SELECT * FROM {{users}};"); |
|
1282 | - while($user_row = db_fetch($user_list)) { |
|
1283 | - $update_query_str = ''; |
|
1284 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) { |
|
1285 | - $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
|
1286 | - if($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1287 | - $update_query_str = ", `{$mercenary_data_name}` = 0"; |
|
1288 | - upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
|
1289 | - upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
|
1275 | + ); |
|
1276 | + |
|
1277 | + upd_check_key('empire_mercenary_temporary', 0, !isset(classSupernova::$config->empire_mercenary_temporary)); |
|
1278 | + upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset(classSupernova::$config->empire_mercenary_base_period)); |
|
1279 | + |
|
1280 | + $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
|
1281 | + $user_list = upd_do_query("SELECT * FROM {{users}};"); |
|
1282 | + while($user_row = db_fetch($user_list)) { |
|
1283 | + $update_query_str = ''; |
|
1284 | + foreach(sn_get_groups('mercenaries') as $mercenary_id) { |
|
1285 | + $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
|
1286 | + if($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1287 | + $update_query_str = ", `{$mercenary_data_name}` = 0"; |
|
1288 | + upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
|
1289 | + upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
|
1290 | + } |
|
1290 | 1291 | } |
1291 | - } |
|
1292 | 1292 | |
1293 | - if($update_query_str) { |
|
1294 | - upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
|
1293 | + if($update_query_str) { |
|
1294 | + upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
|
1295 | + } |
|
1295 | 1296 | } |
1296 | 1297 | } |
1297 | - } |
|
1298 | 1298 | |
1299 | - if(!isset($update_tables['universe'])) { |
|
1300 | - upd_create_table('universe', |
|
1301 | - "( |
|
1299 | + if(!isset($update_tables['universe'])) { |
|
1300 | + upd_create_table('universe', |
|
1301 | + "( |
|
1302 | 1302 | `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
1303 | 1303 | `universe_system` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
1304 | 1304 | `universe_name` varchar(32) NOT NULL DEFAULT '', |
@@ -1306,185 +1306,185 @@ discard block |
||
1306 | 1306 | |
1307 | 1307 | PRIMARY KEY (`universe_galaxy`, `universe_system`) |
1308 | 1308 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1309 | - ); |
|
1309 | + ); |
|
1310 | 1310 | |
1311 | - upd_check_key('uni_price_galaxy', 10000, !isset(classSupernova::$config->uni_price_galaxy)); |
|
1312 | - upd_check_key('uni_price_system', 1000, !isset(classSupernova::$config->uni_price_system)); |
|
1313 | - } |
|
1311 | + upd_check_key('uni_price_galaxy', 10000, !isset(classSupernova::$config->uni_price_galaxy)); |
|
1312 | + upd_check_key('uni_price_system', 1000, !isset(classSupernova::$config->uni_price_system)); |
|
1313 | + } |
|
1314 | 1314 | |
1315 | - // ======================================================================== |
|
1316 | - // Ally player |
|
1317 | - // Adding config variable |
|
1318 | - upd_check_key('ali_bonus_members', 10, !isset(classSupernova::$config->ali_bonus_members)); |
|
1315 | + // ======================================================================== |
|
1316 | + // Ally player |
|
1317 | + // Adding config variable |
|
1318 | + upd_check_key('ali_bonus_members', 10, !isset(classSupernova::$config->ali_bonus_members)); |
|
1319 | 1319 | |
1320 | - // ------------------------------------------------------------------------ |
|
1321 | - // Modifying tables |
|
1322 | - if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1323 | - upd_alter_table('users', array( |
|
1324 | - "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1320 | + // ------------------------------------------------------------------------ |
|
1321 | + // Modifying tables |
|
1322 | + if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1323 | + upd_alter_table('users', array( |
|
1324 | + "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1325 | 1325 | |
1326 | - "ADD KEY `I_user_user_as_ally` (`user_as_ally`)", |
|
1326 | + "ADD KEY `I_user_user_as_ally` (`user_as_ally`)", |
|
1327 | 1327 | |
1328 | - "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1329 | - ), true); |
|
1328 | + "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1329 | + ), true); |
|
1330 | 1330 | |
1331 | - upd_alter_table('alliance', array( |
|
1332 | - "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1331 | + upd_alter_table('alliance', array( |
|
1332 | + "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1333 | 1333 | |
1334 | - "ADD KEY `I_ally_user_id` (`ally_user_id`)", |
|
1334 | + "ADD KEY `I_ally_user_id` (`ally_user_id`)", |
|
1335 | 1335 | |
1336 | - "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1337 | - ), true); |
|
1338 | - } |
|
1339 | - |
|
1340 | - // ------------------------------------------------------------------------ |
|
1341 | - // Creating players for allies |
|
1342 | - $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
|
1343 | - while($ally_row = db_fetch($ally_row_list)) { |
|
1344 | - $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
|
1345 | - doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
|
1346 | - $ally_user_id = db_insert_id(); |
|
1347 | - doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
|
1348 | - } |
|
1349 | - // Renaming old ally players TODO: Remove on release |
|
1350 | - upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';"); |
|
1351 | - // Setting last online time to old ally players TODO: Remove on release |
|
1352 | - upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
1353 | - |
|
1354 | - // ------------------------------------------------------------------------ |
|
1355 | - // Creating planets for allies |
|
1356 | - $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
|
1357 | - while($ally_user_row = db_fetch($ally_user_list)) { |
|
1358 | - $ally_planet_name = db_escape($ally_user_row['username']); |
|
1359 | - doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
|
1360 | - $ally_planet_id = db_insert_id(); |
|
1361 | - doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
|
1362 | - } |
|
1336 | + "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1337 | + ), true); |
|
1338 | + } |
|
1363 | 1339 | |
1364 | - upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
1365 | - |
|
1366 | - upd_alter_table('users', array( |
|
1367 | - "DROP COLUMN `rpg_amiral`", |
|
1368 | - "DROP COLUMN `mrc_academic`", |
|
1369 | - "DROP COLUMN `rpg_espion`", |
|
1370 | - "DROP COLUMN `rpg_commandant`", |
|
1371 | - "DROP COLUMN `rpg_stockeur`", |
|
1372 | - "DROP COLUMN `rpg_destructeur`", |
|
1373 | - "DROP COLUMN `rpg_general`", |
|
1374 | - "DROP COLUMN `rpg_raideur`", |
|
1375 | - "DROP COLUMN `rpg_empereur`", |
|
1376 | - |
|
1377 | - "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1378 | - "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1379 | - "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1380 | - ), $update_tables['users']['rpg_amiral']); |
|
1381 | - |
|
1382 | - |
|
1383 | - // ======================================================================== |
|
1384 | - // User que |
|
1385 | - // Adding db field |
|
1386 | - upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
|
1387 | - // Converting old data to new one and dropping old fields |
|
1388 | - if($update_tables['users']['b_tech_planet']) { |
|
1389 | - $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;"); |
|
1390 | - while($planet_row = db_fetch($query)) { |
|
1391 | - $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
1392 | - doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
|
1340 | + // ------------------------------------------------------------------------ |
|
1341 | + // Creating players for allies |
|
1342 | + $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
|
1343 | + while($ally_row = db_fetch($ally_row_list)) { |
|
1344 | + $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
|
1345 | + doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
|
1346 | + $ally_user_id = db_insert_id(); |
|
1347 | + doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
|
1348 | + } |
|
1349 | + // Renaming old ally players TODO: Remove on release |
|
1350 | + upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';"); |
|
1351 | + // Setting last online time to old ally players TODO: Remove on release |
|
1352 | + upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
1353 | + |
|
1354 | + // ------------------------------------------------------------------------ |
|
1355 | + // Creating planets for allies |
|
1356 | + $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
|
1357 | + while($ally_user_row = db_fetch($ally_user_list)) { |
|
1358 | + $ally_planet_name = db_escape($ally_user_row['username']); |
|
1359 | + doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
|
1360 | + $ally_planet_id = db_insert_id(); |
|
1361 | + doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
|
1393 | 1362 | } |
1394 | 1363 | |
1395 | - upd_alter_table('planets', array( |
|
1396 | - "DROP COLUMN `b_tech`", |
|
1397 | - "DROP COLUMN `b_tech_id`", |
|
1398 | - ), $update_tables['planets']['b_tech']); |
|
1364 | + upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
1399 | 1365 | |
1400 | - upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
|
1401 | - } |
|
1366 | + upd_alter_table('users', array( |
|
1367 | + "DROP COLUMN `rpg_amiral`", |
|
1368 | + "DROP COLUMN `mrc_academic`", |
|
1369 | + "DROP COLUMN `rpg_espion`", |
|
1370 | + "DROP COLUMN `rpg_commandant`", |
|
1371 | + "DROP COLUMN `rpg_stockeur`", |
|
1372 | + "DROP COLUMN `rpg_destructeur`", |
|
1373 | + "DROP COLUMN `rpg_general`", |
|
1374 | + "DROP COLUMN `rpg_raideur`", |
|
1375 | + "DROP COLUMN `rpg_empereur`", |
|
1376 | + |
|
1377 | + "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1378 | + "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1379 | + "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1380 | + ), $update_tables['users']['rpg_amiral']); |
|
1381 | + |
|
1382 | + |
|
1383 | + // ======================================================================== |
|
1384 | + // User que |
|
1385 | + // Adding db field |
|
1386 | + upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
|
1387 | + // Converting old data to new one and dropping old fields |
|
1388 | + if($update_tables['users']['b_tech_planet']) { |
|
1389 | + $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;"); |
|
1390 | + while($planet_row = db_fetch($query)) { |
|
1391 | + $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
1392 | + doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
|
1393 | + } |
|
1402 | 1394 | |
1403 | - if(!$update_tables['powerup']['powerup_category']) { |
|
1404 | - upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
|
1395 | + upd_alter_table('planets', array( |
|
1396 | + "DROP COLUMN `b_tech`", |
|
1397 | + "DROP COLUMN `b_tech_id`", |
|
1398 | + ), $update_tables['planets']['b_tech']); |
|
1405 | 1399 | |
1406 | - doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
1407 | - } |
|
1400 | + upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
|
1401 | + } |
|
1402 | + |
|
1403 | + if(!$update_tables['powerup']['powerup_category']) { |
|
1404 | + upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
|
1408 | 1405 | |
1409 | - upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info)); |
|
1410 | - upd_check_key('tpl_minifier', 0, !isset(classSupernova::$config->tpl_minifier)); |
|
1411 | - |
|
1412 | - upd_check_key('server_updater_check_auto', 0, !isset(classSupernova::$config->server_updater_check_auto)); |
|
1413 | - upd_check_key('server_updater_check_period', PERIOD_DAY, !isset(classSupernova::$config->server_updater_check_period)); |
|
1414 | - upd_check_key('server_updater_check_last', 0, !isset(classSupernova::$config->server_updater_check_last)); |
|
1415 | - upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset(classSupernova::$config->server_updater_check_result)); |
|
1416 | - upd_check_key('server_updater_key', '', !isset(classSupernova::$config->server_updater_key)); |
|
1417 | - upd_check_key('server_updater_id', 0, !isset(classSupernova::$config->server_updater_id)); |
|
1418 | - |
|
1419 | - upd_check_key('ali_bonus_algorithm', 0, !isset(classSupernova::$config->ali_bonus_algorithm)); |
|
1420 | - upd_check_key('ali_bonus_divisor', 10000000, !isset(classSupernova::$config->ali_bonus_divisor)); |
|
1421 | - upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
|
1422 | - upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
|
1423 | - |
|
1424 | - if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1425 | - $inflation_rate = 1000; |
|
1426 | - |
|
1427 | - classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
|
1428 | - classSupernova::$config->db_saveItem('rpg_cost_exchange', classSupernova::$config->rpg_cost_exchange * $inflation_rate); |
|
1429 | - classSupernova::$config->db_saveItem('rpg_cost_pawnshop', classSupernova::$config->rpg_cost_pawnshop * $inflation_rate); |
|
1430 | - classSupernova::$config->db_saveItem('rpg_cost_scraper', classSupernova::$config->rpg_cost_scraper * $inflation_rate); |
|
1431 | - classSupernova::$config->db_saveItem('rpg_cost_stockman', classSupernova::$config->rpg_cost_stockman * $inflation_rate); |
|
1432 | - classSupernova::$config->db_saveItem('rpg_cost_trader', classSupernova::$config->rpg_cost_trader * $inflation_rate); |
|
1433 | - |
|
1434 | - classSupernova::$config->db_saveItem('rpg_exchange_darkMatter', classSupernova::$config->rpg_exchange_darkMatter / $inflation_rate * 4); |
|
1435 | - |
|
1436 | - classSupernova::$config->db_saveItem('rpg_flt_explore', $inflation_rate); |
|
1437 | - |
|
1438 | - doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
|
1439 | - |
|
1440 | - $query = doquery("SELECT * FROM {{quest}}"); |
|
1441 | - while($row = db_fetch($query)) { |
|
1442 | - $query_add = ''; |
|
1443 | - $quest_reward_list = explode(';', $row['quest_rewards']); |
|
1444 | - foreach($quest_reward_list as &$quest_reward) { |
|
1445 | - list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
|
1446 | - if($reward_resource == RES_DARK_MATTER) { |
|
1447 | - $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
1406 | + doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
1407 | + } |
|
1408 | + |
|
1409 | + upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info)); |
|
1410 | + upd_check_key('tpl_minifier', 0, !isset(classSupernova::$config->tpl_minifier)); |
|
1411 | + |
|
1412 | + upd_check_key('server_updater_check_auto', 0, !isset(classSupernova::$config->server_updater_check_auto)); |
|
1413 | + upd_check_key('server_updater_check_period', PERIOD_DAY, !isset(classSupernova::$config->server_updater_check_period)); |
|
1414 | + upd_check_key('server_updater_check_last', 0, !isset(classSupernova::$config->server_updater_check_last)); |
|
1415 | + upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset(classSupernova::$config->server_updater_check_result)); |
|
1416 | + upd_check_key('server_updater_key', '', !isset(classSupernova::$config->server_updater_key)); |
|
1417 | + upd_check_key('server_updater_id', 0, !isset(classSupernova::$config->server_updater_id)); |
|
1418 | + |
|
1419 | + upd_check_key('ali_bonus_algorithm', 0, !isset(classSupernova::$config->ali_bonus_algorithm)); |
|
1420 | + upd_check_key('ali_bonus_divisor', 10000000, !isset(classSupernova::$config->ali_bonus_divisor)); |
|
1421 | + upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
|
1422 | + upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
|
1423 | + |
|
1424 | + if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1425 | + $inflation_rate = 1000; |
|
1426 | + |
|
1427 | + classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
|
1428 | + classSupernova::$config->db_saveItem('rpg_cost_exchange', classSupernova::$config->rpg_cost_exchange * $inflation_rate); |
|
1429 | + classSupernova::$config->db_saveItem('rpg_cost_pawnshop', classSupernova::$config->rpg_cost_pawnshop * $inflation_rate); |
|
1430 | + classSupernova::$config->db_saveItem('rpg_cost_scraper', classSupernova::$config->rpg_cost_scraper * $inflation_rate); |
|
1431 | + classSupernova::$config->db_saveItem('rpg_cost_stockman', classSupernova::$config->rpg_cost_stockman * $inflation_rate); |
|
1432 | + classSupernova::$config->db_saveItem('rpg_cost_trader', classSupernova::$config->rpg_cost_trader * $inflation_rate); |
|
1433 | + |
|
1434 | + classSupernova::$config->db_saveItem('rpg_exchange_darkMatter', classSupernova::$config->rpg_exchange_darkMatter / $inflation_rate * 4); |
|
1435 | + |
|
1436 | + classSupernova::$config->db_saveItem('rpg_flt_explore', $inflation_rate); |
|
1437 | + |
|
1438 | + doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
|
1439 | + |
|
1440 | + $query = doquery("SELECT * FROM {{quest}}"); |
|
1441 | + while($row = db_fetch($query)) { |
|
1442 | + $query_add = ''; |
|
1443 | + $quest_reward_list = explode(';', $row['quest_rewards']); |
|
1444 | + foreach($quest_reward_list as &$quest_reward) { |
|
1445 | + list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
|
1446 | + if($reward_resource == RES_DARK_MATTER) { |
|
1447 | + $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
1448 | + } |
|
1449 | + } |
|
1450 | + $new_rewards = implode(';', $quest_reward_list); |
|
1451 | + if($new_rewards != $row['quest_rewards']) { |
|
1452 | + doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
|
1448 | 1453 | } |
1449 | - } |
|
1450 | - $new_rewards = implode(';', $quest_reward_list); |
|
1451 | - if($new_rewards != $row['quest_rewards']) { |
|
1452 | - doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
|
1453 | 1454 | } |
1454 | 1455 | } |
1455 | - } |
|
1456 | 1456 | |
1457 | - upd_check_key('rpg_bonus_minimum', 10000, !isset(classSupernova::$config->rpg_bonus_minimum)); |
|
1458 | - upd_check_key('rpg_bonus_divisor', |
|
1459 | - !isset(classSupernova::$config->rpg_bonus_divisor) ? 10 : (classSupernova::$config->rpg_bonus_divisor >= 1000 ? floor(classSupernova::$config->rpg_bonus_divisor / 1000) : classSupernova::$config->rpg_bonus_divisor), |
|
1460 | - !isset(classSupernova::$config->rpg_bonus_divisor) || classSupernova::$config->rpg_bonus_divisor >= 1000); |
|
1457 | + upd_check_key('rpg_bonus_minimum', 10000, !isset(classSupernova::$config->rpg_bonus_minimum)); |
|
1458 | + upd_check_key('rpg_bonus_divisor', |
|
1459 | + !isset(classSupernova::$config->rpg_bonus_divisor) ? 10 : (classSupernova::$config->rpg_bonus_divisor >= 1000 ? floor(classSupernova::$config->rpg_bonus_divisor / 1000) : classSupernova::$config->rpg_bonus_divisor), |
|
1460 | + !isset(classSupernova::$config->rpg_bonus_divisor) || classSupernova::$config->rpg_bonus_divisor >= 1000); |
|
1461 | 1461 | |
1462 | - upd_check_key('var_news_last', 0, !isset(classSupernova::$config->var_news_last)); |
|
1462 | + upd_check_key('var_news_last', 0, !isset(classSupernova::$config->var_news_last)); |
|
1463 | 1463 | |
1464 | - upd_do_query('COMMIT;', true); |
|
1465 | - $new_version = 33; |
|
1464 | + upd_do_query('COMMIT;', true); |
|
1465 | + $new_version = 33; |
|
1466 | 1466 | |
1467 | - case 33: |
|
1468 | - upd_log_version_update(); |
|
1467 | + case 33: |
|
1468 | + upd_log_version_update(); |
|
1469 | 1469 | |
1470 | - upd_alter_table('users', array( |
|
1471 | - "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", |
|
1472 | - "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", |
|
1470 | + upd_alter_table('users', array( |
|
1471 | + "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", |
|
1472 | + "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", |
|
1473 | 1473 | |
1474 | - "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)", |
|
1475 | - ), !$update_tables['users']['user_birthday']); |
|
1474 | + "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)", |
|
1475 | + ), !$update_tables['users']['user_birthday']); |
|
1476 | 1476 | |
1477 | - upd_check_key('user_birthday_gift', 0, !isset(classSupernova::$config->user_birthday_gift)); |
|
1478 | - upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
|
1479 | - upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
|
1477 | + upd_check_key('user_birthday_gift', 0, !isset(classSupernova::$config->user_birthday_gift)); |
|
1478 | + upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
|
1479 | + upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
|
1480 | 1480 | |
1481 | - if(!isset($update_tables['payment'])) { |
|
1482 | - upd_alter_table('users', array( |
|
1483 | - "ADD KEY `I_user_id_name` (`id`, `username`)", |
|
1484 | - ), !$update_indexes['users']['I_user_id_name']); |
|
1481 | + if(!isset($update_tables['payment'])) { |
|
1482 | + upd_alter_table('users', array( |
|
1483 | + "ADD KEY `I_user_id_name` (`id`, `username`)", |
|
1484 | + ), !$update_indexes['users']['I_user_id_name']); |
|
1485 | 1485 | |
1486 | - upd_create_table('payment', |
|
1487 | - "( |
|
1486 | + upd_create_table('payment', |
|
1487 | + "( |
|
1488 | 1488 | `payment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Internal payment ID', |
1489 | 1489 | `payment_user_id` BIGINT(20) UNSIGNED DEFAULT NULL, |
1490 | 1490 | `payment_user_name` VARCHAR(64) DEFAULT NULL, |
@@ -1504,169 +1504,169 @@ discard block |
||
1504 | 1504 | |
1505 | 1505 | CONSTRAINT `FK_payment_user` FOREIGN KEY (`payment_user_id`, `payment_user_name`) REFERENCES `{{users}}` (`id`, `username`) ON UPDATE CASCADE ON DELETE NO ACTION |
1506 | 1506 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1507 | - ); |
|
1507 | + ); |
|
1508 | 1508 | |
1509 | - upd_check_key('payment_currency_default', 'UAH', !isset(classSupernova::$config->payment_currency_default)); |
|
1510 | - } |
|
1511 | - upd_check_key('payment_lot_size', 1000, !isset(classSupernova::$config->payment_lot_size)); |
|
1512 | - upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price)); |
|
1509 | + upd_check_key('payment_currency_default', 'UAH', !isset(classSupernova::$config->payment_currency_default)); |
|
1510 | + } |
|
1511 | + upd_check_key('payment_lot_size', 1000, !isset(classSupernova::$config->payment_lot_size)); |
|
1512 | + upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price)); |
|
1513 | 1513 | |
1514 | - // Updating category for Mercenaries |
|
1515 | - upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1514 | + // Updating category for Mercenaries |
|
1515 | + upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1516 | 1516 | |
1517 | - // Convert Destructor to Death Star schematic |
|
1518 | - upd_do_query("UPDATE {{powerup}} |
|
1517 | + // Convert Destructor to Death Star schematic |
|
1518 | + upd_do_query("UPDATE {{powerup}} |
|
1519 | 1519 | SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . " |
1520 | 1520 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;"); |
1521 | - // Convert Assasin to SuperNova schematic |
|
1522 | - upd_do_query("UPDATE {{powerup}} |
|
1521 | + // Convert Assasin to SuperNova schematic |
|
1522 | + upd_do_query("UPDATE {{powerup}} |
|
1523 | 1523 | SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . " |
1524 | 1524 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;"); |
1525 | 1525 | |
1526 | - upd_alter_table('iraks', array( |
|
1527 | - "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", |
|
1528 | - "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1", |
|
1529 | - ), !$update_tables['iraks']['fleet_start_type']); |
|
1526 | + upd_alter_table('iraks', array( |
|
1527 | + "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", |
|
1528 | + "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1", |
|
1529 | + ), !$update_tables['iraks']['fleet_start_type']); |
|
1530 | 1530 | |
1531 | 1531 | |
1532 | - if(!$update_tables['payment']['payment_status']) { |
|
1533 | - upd_alter_table('payment', array( |
|
1534 | - "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
|
1532 | + if(!$update_tables['payment']['payment_status']) { |
|
1533 | + upd_alter_table('payment', array( |
|
1534 | + "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
|
1535 | 1535 | |
1536 | - "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", |
|
1537 | - "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", |
|
1536 | + "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", |
|
1537 | + "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", |
|
1538 | 1538 | |
1539 | - "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", |
|
1540 | - "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", |
|
1541 | - "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", |
|
1542 | - "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", |
|
1543 | - "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'", |
|
1544 | - ), !$update_tables['payment']['payment_status']); |
|
1545 | - } |
|
1539 | + "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", |
|
1540 | + "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", |
|
1541 | + "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", |
|
1542 | + "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", |
|
1543 | + "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'", |
|
1544 | + ), !$update_tables['payment']['payment_status']); |
|
1545 | + } |
|
1546 | 1546 | |
1547 | - upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
1547 | + upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
1548 | 1548 | |
1549 | - upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date)); |
|
1550 | - upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures)); |
|
1551 | - upd_check_key('server_que_length_hangar', 5, !isset(classSupernova::$config->server_que_length_hangar)); |
|
1549 | + upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date)); |
|
1550 | + upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures)); |
|
1551 | + upd_check_key('server_que_length_hangar', 5, !isset(classSupernova::$config->server_que_length_hangar)); |
|
1552 | 1552 | |
1553 | - upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=green>$1</font>'); |
|
1554 | - upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=red>$1</font>'); |
|
1555 | - upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=purple>$1</font>'); |
|
1553 | + upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=green>$1</font>'); |
|
1554 | + upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=red>$1</font>'); |
|
1555 | + upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=purple>$1</font>'); |
|
1556 | 1556 | |
1557 | - upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium)); |
|
1557 | + upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium)); |
|
1558 | 1558 | |
1559 | - upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;"); |
|
1559 | + upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;"); |
|
1560 | 1560 | |
1561 | 1561 | |
1562 | - upd_do_query('COMMIT;', true); |
|
1563 | - $new_version = 34; |
|
1564 | - |
|
1565 | - case 34: |
|
1566 | - upd_log_version_update(); |
|
1567 | - |
|
1568 | - upd_alter_table('planets', array( |
|
1569 | - "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'", |
|
1570 | - ), !$update_tables['planets']['planet_teleport_next']); |
|
1571 | - |
|
1572 | - upd_check_key('planet_teleport_cost', 50000, !isset(classSupernova::$config->planet_teleport_cost)); |
|
1573 | - upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset(classSupernova::$config->planet_teleport_timeout)); |
|
1574 | - |
|
1575 | - upd_check_key('planet_capital_cost', 25000, !isset(classSupernova::$config->planet_capital_cost)); |
|
1576 | - |
|
1577 | - upd_alter_table('users', array( |
|
1578 | - "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'", |
|
1579 | - ), !$update_tables['users']['player_race']); |
|
1580 | - |
|
1581 | - upd_alter_table('chat', array( |
|
1582 | - "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'", |
|
1583 | - ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT'); |
|
1584 | - |
|
1585 | - upd_alter_table('planets', array( |
|
1586 | - "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", |
|
1587 | - "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", |
|
1588 | - "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", |
|
1589 | - "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", |
|
1590 | - "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", |
|
1591 | - "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'", |
|
1592 | - ), !$update_tables['planets']['ship_sattelite_sloth']); |
|
1593 | - |
|
1594 | - upd_alter_table('planets', array( |
|
1595 | - "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", |
|
1596 | - "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", |
|
1597 | - "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", |
|
1598 | - "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", |
|
1599 | - "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", |
|
1600 | - "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", |
|
1601 | - "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)", |
|
1602 | - ), !$update_tables['planets']['ship_sattelite_sloth_porcent']); |
|
1603 | - |
|
1604 | - upd_check_key('stats_hide_admins', 1, !isset(classSupernova::$config->stats_hide_admins)); |
|
1605 | - upd_check_key('stats_hide_player_list', '', !isset(classSupernova::$config->stats_hide_player_list)); |
|
1606 | - |
|
1607 | - upd_check_key('adv_seo_meta_description', '', !isset(classSupernova::$config->adv_seo_meta_description)); |
|
1608 | - upd_check_key('adv_seo_meta_keywords', '', !isset(classSupernova::$config->adv_seo_meta_keywords)); |
|
1609 | - |
|
1610 | - upd_check_key('stats_hide_pm_link', '0', !isset(classSupernova::$config->stats_hide_pm_link)); |
|
1611 | - |
|
1612 | - upd_alter_table('notes', array( |
|
1613 | - "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
|
1614 | - ), !$update_indexes['notes']['I_owner_priority_time']); |
|
1615 | - |
|
1616 | - if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1617 | - upd_alter_table('buddy', array( |
|
1618 | - "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", |
|
1619 | - "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'", |
|
1620 | - "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", // 255 chars |
|
1621 | - |
|
1622 | - "DROP INDEX `id`", |
|
1623 | - |
|
1624 | - "DROP FOREIGN KEY `FK_buddy_sender_id`", |
|
1625 | - "DROP FOREIGN KEY `FK_buddy_owner_id`", |
|
1626 | - "DROP INDEX `I_buddy_sender`", |
|
1627 | - "DROP INDEX `I_buddy_owner`", |
|
1628 | - ), !$update_tables['buddy']['BUDDY_ID']); |
|
1629 | - |
|
1630 | - upd_alter_table('buddy', array( |
|
1631 | - "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'", |
|
1632 | - "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'", |
|
1633 | - ), !$update_tables['buddy']['BUDDY_SENDER']); |
|
1634 | - |
|
1635 | - $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
|
1636 | - $found = $lost = array(); |
|
1637 | - while($row = db_fetch($query)) { |
|
1638 | - $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1639 | - if(!isset($found[$index])) { |
|
1640 | - $found[$index] = $row['BUDDY_ID']; |
|
1641 | - } else { |
|
1642 | - $lost[] = $row['BUDDY_ID']; |
|
1562 | + upd_do_query('COMMIT;', true); |
|
1563 | + $new_version = 34; |
|
1564 | + |
|
1565 | + case 34: |
|
1566 | + upd_log_version_update(); |
|
1567 | + |
|
1568 | + upd_alter_table('planets', array( |
|
1569 | + "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'", |
|
1570 | + ), !$update_tables['planets']['planet_teleport_next']); |
|
1571 | + |
|
1572 | + upd_check_key('planet_teleport_cost', 50000, !isset(classSupernova::$config->planet_teleport_cost)); |
|
1573 | + upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset(classSupernova::$config->planet_teleport_timeout)); |
|
1574 | + |
|
1575 | + upd_check_key('planet_capital_cost', 25000, !isset(classSupernova::$config->planet_capital_cost)); |
|
1576 | + |
|
1577 | + upd_alter_table('users', array( |
|
1578 | + "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'", |
|
1579 | + ), !$update_tables['users']['player_race']); |
|
1580 | + |
|
1581 | + upd_alter_table('chat', array( |
|
1582 | + "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'", |
|
1583 | + ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT'); |
|
1584 | + |
|
1585 | + upd_alter_table('planets', array( |
|
1586 | + "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", |
|
1587 | + "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", |
|
1588 | + "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", |
|
1589 | + "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", |
|
1590 | + "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", |
|
1591 | + "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'", |
|
1592 | + ), !$update_tables['planets']['ship_sattelite_sloth']); |
|
1593 | + |
|
1594 | + upd_alter_table('planets', array( |
|
1595 | + "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", |
|
1596 | + "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", |
|
1597 | + "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", |
|
1598 | + "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", |
|
1599 | + "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", |
|
1600 | + "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", |
|
1601 | + "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)", |
|
1602 | + ), !$update_tables['planets']['ship_sattelite_sloth_porcent']); |
|
1603 | + |
|
1604 | + upd_check_key('stats_hide_admins', 1, !isset(classSupernova::$config->stats_hide_admins)); |
|
1605 | + upd_check_key('stats_hide_player_list', '', !isset(classSupernova::$config->stats_hide_player_list)); |
|
1606 | + |
|
1607 | + upd_check_key('adv_seo_meta_description', '', !isset(classSupernova::$config->adv_seo_meta_description)); |
|
1608 | + upd_check_key('adv_seo_meta_keywords', '', !isset(classSupernova::$config->adv_seo_meta_keywords)); |
|
1609 | + |
|
1610 | + upd_check_key('stats_hide_pm_link', '0', !isset(classSupernova::$config->stats_hide_pm_link)); |
|
1611 | + |
|
1612 | + upd_alter_table('notes', array( |
|
1613 | + "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
|
1614 | + ), !$update_indexes['notes']['I_owner_priority_time']); |
|
1615 | + |
|
1616 | + if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1617 | + upd_alter_table('buddy', array( |
|
1618 | + "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", |
|
1619 | + "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'", |
|
1620 | + "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", // 255 chars |
|
1621 | + |
|
1622 | + "DROP INDEX `id`", |
|
1623 | + |
|
1624 | + "DROP FOREIGN KEY `FK_buddy_sender_id`", |
|
1625 | + "DROP FOREIGN KEY `FK_buddy_owner_id`", |
|
1626 | + "DROP INDEX `I_buddy_sender`", |
|
1627 | + "DROP INDEX `I_buddy_owner`", |
|
1628 | + ), !$update_tables['buddy']['BUDDY_ID']); |
|
1629 | + |
|
1630 | + upd_alter_table('buddy', array( |
|
1631 | + "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'", |
|
1632 | + "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'", |
|
1633 | + ), !$update_tables['buddy']['BUDDY_SENDER']); |
|
1634 | + |
|
1635 | + $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
|
1636 | + $found = $lost = array(); |
|
1637 | + while($row = db_fetch($query)) { |
|
1638 | + $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1639 | + if(!isset($found[$index])) { |
|
1640 | + $found[$index] = $row['BUDDY_ID']; |
|
1641 | + } else { |
|
1642 | + $lost[] = $row['BUDDY_ID']; |
|
1643 | + } |
|
1644 | + } |
|
1645 | + $lost = implode(',', $lost); |
|
1646 | + if($lost) { |
|
1647 | + upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
|
1643 | 1648 | } |
1644 | - } |
|
1645 | - $lost = implode(',', $lost); |
|
1646 | - if($lost) { |
|
1647 | - upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
|
1648 | - } |
|
1649 | 1649 | |
1650 | - upd_alter_table('buddy', array( |
|
1651 | - "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", |
|
1652 | - "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", |
|
1650 | + upd_alter_table('buddy', array( |
|
1651 | + "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", |
|
1652 | + "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", |
|
1653 | 1653 | |
1654 | - "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1655 | - "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1656 | - ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']); |
|
1657 | - } |
|
1654 | + "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1655 | + "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1656 | + ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']); |
|
1657 | + } |
|
1658 | 1658 | |
1659 | - upd_do_query('COMMIT;', true); |
|
1660 | - $new_version = 35; |
|
1659 | + upd_do_query('COMMIT;', true); |
|
1660 | + $new_version = 35; |
|
1661 | 1661 | |
1662 | - case 35: |
|
1663 | - upd_log_version_update(); |
|
1662 | + case 35: |
|
1663 | + upd_log_version_update(); |
|
1664 | 1664 | |
1665 | - upd_do_query("UPDATE {{users}} SET `ally_name` = NULL, `ally_tag` = NULL, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL"); |
|
1665 | + upd_do_query("UPDATE {{users}} SET `ally_name` = NULL, `ally_tag` = NULL, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL"); |
|
1666 | 1666 | |
1667 | - if(!$update_tables['ube_report']) { |
|
1668 | - upd_create_table('ube_report', |
|
1669 | - "( |
|
1667 | + if(!$update_tables['ube_report']) { |
|
1668 | + upd_create_table('ube_report', |
|
1669 | + "( |
|
1670 | 1670 | `ube_report_id` SERIAL COMMENT 'Report ID', |
1671 | 1671 | |
1672 | 1672 | `ube_report_cypher` CHAR(32) NOT NULL DEFAULT '' COMMENT '16 char secret report ID', |
@@ -1702,12 +1702,12 @@ discard block |
||
1702 | 1702 | PRIMARY KEY (`ube_report_id`), |
1703 | 1703 | KEY `I_ube_report_cypher` (`ube_report_cypher`) |
1704 | 1704 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1705 | - ); |
|
1706 | - } |
|
1705 | + ); |
|
1706 | + } |
|
1707 | 1707 | |
1708 | - if(!$update_tables['ube_report_player']) { |
|
1709 | - upd_create_table('ube_report_player', |
|
1710 | - "( |
|
1708 | + if(!$update_tables['ube_report_player']) { |
|
1709 | + upd_create_table('ube_report_player', |
|
1710 | + "( |
|
1711 | 1711 | `ube_report_player_id` SERIAL COMMENT 'Record ID', |
1712 | 1712 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
1713 | 1713 | `ube_report_player_player_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Player ID', |
@@ -1723,12 +1723,12 @@ discard block |
||
1723 | 1723 | KEY `I_ube_report_player_player_id` (`ube_report_player_player_id`), |
1724 | 1724 | CONSTRAINT `FK_ube_report_player_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1725 | 1725 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1726 | - ); |
|
1727 | - } |
|
1726 | + ); |
|
1727 | + } |
|
1728 | 1728 | |
1729 | - if(!$update_tables['ube_report_fleet']) { |
|
1730 | - upd_create_table('ube_report_fleet', |
|
1731 | - "( |
|
1729 | + if(!$update_tables['ube_report_fleet']) { |
|
1730 | + upd_create_table('ube_report_fleet', |
|
1731 | + "( |
|
1732 | 1732 | `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID', |
1733 | 1733 | |
1734 | 1734 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1753,16 +1753,16 @@ discard block |
||
1753 | 1753 | PRIMARY KEY (`ube_report_fleet_id`), |
1754 | 1754 | CONSTRAINT `FK_ube_report_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1755 | 1755 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1756 | - ); |
|
1757 | - } |
|
1756 | + ); |
|
1757 | + } |
|
1758 | 1758 | |
1759 | - if(!$update_tables['ube_report_unit']) { |
|
1760 | - // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
|
1761 | - // Может сохранять имена удаленных кораблей долго? |
|
1759 | + if(!$update_tables['ube_report_unit']) { |
|
1760 | + // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
|
1761 | + // Может сохранять имена удаленных кораблей долго? |
|
1762 | 1762 | |
1763 | - // round SIGNED!!! -1 например - для ауткома |
|
1764 | - upd_create_table('ube_report_unit', |
|
1765 | - "( |
|
1763 | + // round SIGNED!!! -1 например - для ауткома |
|
1764 | + upd_create_table('ube_report_unit', |
|
1765 | + "( |
|
1766 | 1766 | `ube_report_unit_id` SERIAL COMMENT 'Record DB ID', |
1767 | 1767 | |
1768 | 1768 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1790,12 +1790,12 @@ discard block |
||
1790 | 1790 | KEY `I_ube_report_unit_order` (`ube_report_unit_sort_order`), |
1791 | 1791 | CONSTRAINT `FK_ube_report_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1792 | 1792 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1793 | - ); |
|
1794 | - } |
|
1793 | + ); |
|
1794 | + } |
|
1795 | 1795 | |
1796 | - if(!$update_tables['ube_report_outcome_fleet']) { |
|
1797 | - upd_create_table('ube_report_outcome_fleet', |
|
1798 | - "( |
|
1796 | + if(!$update_tables['ube_report_outcome_fleet']) { |
|
1797 | + upd_create_table('ube_report_outcome_fleet', |
|
1798 | + "( |
|
1799 | 1799 | `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID', |
1800 | 1800 | |
1801 | 1801 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1819,12 +1819,12 @@ discard block |
||
1819 | 1819 | KEY `I_ube_report_outcome_fleet_report_fleet` (`ube_report_id`, `ube_report_outcome_fleet_fleet_id`), |
1820 | 1820 | CONSTRAINT `FK_ube_report_outcome_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1821 | 1821 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1822 | - ); |
|
1823 | - } |
|
1822 | + ); |
|
1823 | + } |
|
1824 | 1824 | |
1825 | - if(!$update_tables['ube_report_outcome_unit']) { |
|
1826 | - upd_create_table('ube_report_outcome_unit', |
|
1827 | - "( |
|
1825 | + if(!$update_tables['ube_report_outcome_unit']) { |
|
1826 | + upd_create_table('ube_report_outcome_unit', |
|
1827 | + "( |
|
1828 | 1828 | `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID', |
1829 | 1829 | |
1830 | 1830 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1840,12 +1840,12 @@ discard block |
||
1840 | 1840 | KEY `I_ube_report_outcome_unit_report_order` (`ube_report_id`, `ube_report_outcome_unit_sort_order`), |
1841 | 1841 | CONSTRAINT `FK_ube_report_outcome_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1842 | 1842 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1843 | - ); |
|
1844 | - } |
|
1843 | + ); |
|
1844 | + } |
|
1845 | 1845 | |
1846 | - if(!$update_tables['unit']) { |
|
1847 | - upd_create_table('unit', |
|
1848 | - "( |
|
1846 | + if(!$update_tables['unit']) { |
|
1847 | + upd_create_table('unit', |
|
1848 | + "( |
|
1849 | 1849 | `unit_id` SERIAL COMMENT 'Record ID', |
1850 | 1850 | |
1851 | 1851 | `unit_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Unit owner', |
@@ -1859,12 +1859,12 @@ discard block |
||
1859 | 1859 | KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`), |
1860 | 1860 | CONSTRAINT `FK_unit_player_id` FOREIGN KEY (`unit_player_id`) REFERENCES `{{users}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
1861 | 1861 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1862 | - ); |
|
1863 | - } |
|
1862 | + ); |
|
1863 | + } |
|
1864 | 1864 | |
1865 | - if(!$update_tables['captain']) { |
|
1866 | - upd_create_table('captain', |
|
1867 | - "( |
|
1865 | + if(!$update_tables['captain']) { |
|
1866 | + upd_create_table('captain', |
|
1867 | + "( |
|
1868 | 1868 | `captain_id` SERIAL COMMENT 'Record ID', |
1869 | 1869 | `captain_unit_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Link to `unit` record', |
1870 | 1870 | |
@@ -1879,34 +1879,34 @@ discard block |
||
1879 | 1879 | KEY `I_captain_unit_id` (`captain_unit_id`), |
1880 | 1880 | CONSTRAINT `FK_captain_unit_id` FOREIGN KEY (`captain_unit_id`) REFERENCES `{{unit}}` (`unit_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1881 | 1881 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1882 | - ); |
|
1883 | - } |
|
1882 | + ); |
|
1883 | + } |
|
1884 | 1884 | |
1885 | - if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1886 | - upd_alter_table('fleets', array( |
|
1887 | - "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
|
1888 | - "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
|
1885 | + if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1886 | + upd_alter_table('fleets', array( |
|
1887 | + "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
|
1888 | + "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
|
1889 | 1889 | |
1890 | - "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)", |
|
1891 | - "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)", |
|
1890 | + "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)", |
|
1891 | + "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)", |
|
1892 | 1892 | |
1893 | - "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1894 | - "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1895 | - ), !$update_tables['fleets']['fleet_start_planet_id']); |
|
1893 | + "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1894 | + "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1895 | + ), !$update_tables['fleets']['fleet_start_planet_id']); |
|
1896 | 1896 | |
1897 | - upd_do_query(" |
|
1897 | + upd_do_query(" |
|
1898 | 1898 | UPDATE {{fleets}} AS f |
1899 | 1899 | LEFT JOIN {{planets}} AS p_s ON p_s.galaxy = f.fleet_start_galaxy AND p_s.system = f.fleet_start_system AND p_s.planet = f.fleet_start_planet AND p_s.planet_type = f.fleet_start_type |
1900 | 1900 | LEFT JOIN {{planets}} AS p_e ON p_e.galaxy = f.fleet_end_galaxy AND p_e.system = f.fleet_end_system AND p_e.planet = f.fleet_end_planet AND p_e.planet_type = f.fleet_end_type |
1901 | 1901 | SET f.fleet_start_planet_id = p_s.id, f.fleet_end_planet_id = p_e.id |
1902 | 1902 | "); |
1903 | - } |
|
1903 | + } |
|
1904 | 1904 | |
1905 | - upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
|
1905 | + upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
|
1906 | 1906 | |
1907 | - if(!$update_tables['chat_player']) { |
|
1908 | - upd_create_table('chat_player', |
|
1909 | - "( |
|
1907 | + if(!$update_tables['chat_player']) { |
|
1908 | + upd_create_table('chat_player', |
|
1909 | + "( |
|
1910 | 1910 | `chat_player_id` SERIAL COMMENT 'Record ID', |
1911 | 1911 | |
1912 | 1912 | `chat_player_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Chat player record owner', |
@@ -1922,102 +1922,102 @@ discard block |
||
1922 | 1922 | CONSTRAINT `FK_chat_player_id` FOREIGN KEY (`chat_player_player_id`) REFERENCES `{{users}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
1923 | 1923 | |
1924 | 1924 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1925 | - ); |
|
1926 | - } |
|
1927 | - |
|
1928 | - upd_alter_table('chat', array( |
|
1929 | - "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`", |
|
1930 | - "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`", |
|
1931 | - |
|
1932 | - "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)", |
|
1933 | - "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)", |
|
1925 | + ); |
|
1926 | + } |
|
1934 | 1927 | |
1935 | - "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1936 | - "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1937 | - ), !$update_tables['chat']['chat_message_sender_id']); |
|
1928 | + upd_alter_table('chat', array( |
|
1929 | + "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`", |
|
1930 | + "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`", |
|
1938 | 1931 | |
1939 | - upd_alter_table('chat', array( |
|
1940 | - "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`", |
|
1941 | - "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`", |
|
1942 | - ), !$update_tables['chat']['chat_message_sender_name']); |
|
1932 | + "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)", |
|
1933 | + "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)", |
|
1943 | 1934 | |
1944 | - upd_alter_table('users', array( |
|
1945 | - "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'", |
|
1946 | - ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES'); |
|
1935 | + "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1936 | + "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1937 | + ), !$update_tables['chat']['chat_message_sender_id']); |
|
1947 | 1938 | |
1948 | - upd_alter_table('banned', array( |
|
1949 | - "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`", |
|
1950 | - "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`", |
|
1939 | + upd_alter_table('chat', array( |
|
1940 | + "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`", |
|
1941 | + "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`", |
|
1942 | + ), !$update_tables['chat']['chat_message_sender_name']); |
|
1951 | 1943 | |
1952 | - "ADD KEY `I_ban_user_id` (`ban_user_id`)", |
|
1953 | - "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)", |
|
1944 | + upd_alter_table('users', array( |
|
1945 | + "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'", |
|
1946 | + ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES'); |
|
1954 | 1947 | |
1955 | - "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1956 | - "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1957 | - ), !$update_tables['banned']['ban_user_id']); |
|
1948 | + upd_alter_table('banned', array( |
|
1949 | + "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`", |
|
1950 | + "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`", |
|
1958 | 1951 | |
1959 | - upd_do_query('COMMIT;', true); |
|
1960 | - $new_version = 36; |
|
1952 | + "ADD KEY `I_ban_user_id` (`ban_user_id`)", |
|
1953 | + "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)", |
|
1961 | 1954 | |
1962 | - case 36: |
|
1963 | - upd_log_version_update(); |
|
1955 | + "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1956 | + "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1957 | + ), !$update_tables['banned']['ban_user_id']); |
|
1964 | 1958 | |
1965 | - upd_alter_table('payment', array( |
|
1966 | - "DROP FOREIGN KEY `FK_payment_user`", |
|
1967 | - ), $update_foreigns['payment']['FK_payment_user']); |
|
1959 | + upd_do_query('COMMIT;', true); |
|
1960 | + $new_version = 36; |
|
1968 | 1961 | |
1969 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1970 | - upd_alter_table('chat', array( |
|
1971 | - "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
|
1972 | - "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
|
1973 | - ), true); |
|
1962 | + case 36: |
|
1963 | + upd_log_version_update(); |
|
1974 | 1964 | |
1975 | - upd_alter_table('chat', array( |
|
1976 | - "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1977 | - "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1978 | - ), true); |
|
1979 | - } |
|
1965 | + upd_alter_table('payment', array( |
|
1966 | + "DROP FOREIGN KEY `FK_payment_user`", |
|
1967 | + ), $update_foreigns['payment']['FK_payment_user']); |
|
1968 | + |
|
1969 | + if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1970 | + upd_alter_table('chat', array( |
|
1971 | + "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
|
1972 | + "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
|
1973 | + ), true); |
|
1974 | + |
|
1975 | + upd_alter_table('chat', array( |
|
1976 | + "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1977 | + "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1978 | + ), true); |
|
1979 | + } |
|
1980 | 1980 | |
1981 | - upd_alter_table('users', array( |
|
1982 | - "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`", |
|
1983 | - "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`", |
|
1984 | - ), !$update_tables['users']['user_time_diff']); |
|
1981 | + upd_alter_table('users', array( |
|
1982 | + "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`", |
|
1983 | + "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`", |
|
1984 | + ), !$update_tables['users']['user_time_diff']); |
|
1985 | 1985 | |
1986 | - upd_alter_table('planets', array( |
|
1987 | - "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'", |
|
1988 | - ), !$update_tables['planets']['ship_orbital_heavy']); |
|
1986 | + upd_alter_table('planets', array( |
|
1987 | + "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'", |
|
1988 | + ), !$update_tables['planets']['ship_orbital_heavy']); |
|
1989 | 1989 | |
1990 | - upd_check_key('chat_refresh_rate', 5, !isset(classSupernova::$config->chat_refresh_rate)); |
|
1990 | + upd_check_key('chat_refresh_rate', 5, !isset(classSupernova::$config->chat_refresh_rate)); |
|
1991 | 1991 | |
1992 | - upd_alter_table('chat_player', array( |
|
1993 | - "ADD `chat_player_refresh_last` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'", |
|
1992 | + upd_alter_table('chat_player', array( |
|
1993 | + "ADD `chat_player_refresh_last` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'", |
|
1994 | 1994 | |
1995 | - "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)", |
|
1996 | - ), !$update_tables['chat_player']['chat_player_refresh_last']); |
|
1995 | + "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)", |
|
1996 | + ), !$update_tables['chat_player']['chat_player_refresh_last']); |
|
1997 | 1997 | |
1998 | - upd_alter_table('ube_report', array( |
|
1999 | - "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
|
2000 | - ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
|
1998 | + upd_alter_table('ube_report', array( |
|
1999 | + "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
|
2000 | + ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
|
2001 | 2001 | |
2002 | - if(!$update_tables['unit']['unit_time_start']) { |
|
2003 | - upd_alter_table('unit', array( |
|
2004 | - "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
|
2005 | - "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
|
2006 | - ), !$update_tables['unit']['unit_time_start']); |
|
2002 | + if(!$update_tables['unit']['unit_time_start']) { |
|
2003 | + upd_alter_table('unit', array( |
|
2004 | + "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
|
2005 | + "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
|
2006 | + ), !$update_tables['unit']['unit_time_start']); |
|
2007 | 2007 | |
2008 | - upd_do_query( |
|
2009 | - "INSERT INTO {{unit}} |
|
2008 | + upd_do_query( |
|
2009 | + "INSERT INTO {{unit}} |
|
2010 | 2010 | (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish) |
2011 | 2011 | SELECT |
2012 | 2012 | `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
2013 | 2013 | , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL) |
2014 | 2014 | FROM {{powerup}}" |
2015 | - ); |
|
2016 | - } |
|
2015 | + ); |
|
2016 | + } |
|
2017 | 2017 | |
2018 | - if(!$update_tables['que']) { |
|
2019 | - upd_create_table('que', |
|
2020 | - "( |
|
2018 | + if(!$update_tables['que']) { |
|
2019 | + upd_create_table('que', |
|
2020 | + "( |
|
2021 | 2021 | `que_id` SERIAL COMMENT 'Internal que id', |
2022 | 2022 | |
2023 | 2023 | `que_player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Que owner ID', |
@@ -2043,151 +2043,151 @@ discard block |
||
2043 | 2043 | CONSTRAINT `FK_que_planet_id` FOREIGN KEY (`que_planet_id`) REFERENCES `{{planets}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE, |
2044 | 2044 | CONSTRAINT `FK_que_planet_id_origin` FOREIGN KEY (`que_planet_id_origin`) REFERENCES `{{planets}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
2045 | 2045 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
2046 | - ); |
|
2047 | - } |
|
2046 | + ); |
|
2047 | + } |
|
2048 | 2048 | |
2049 | - // Конвертирум очередь исследований |
|
2050 | - if($update_tables['users']['que']) { |
|
2051 | - $que_lines = array(); |
|
2052 | - $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
|
2053 | - while($que_row = db_fetch($que_query)) { |
|
2054 | - $que_data = explode(',', $que_row['que']); |
|
2049 | + // Конвертирум очередь исследований |
|
2050 | + if($update_tables['users']['que']) { |
|
2051 | + $que_lines = array(); |
|
2052 | + $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
|
2053 | + while($que_row = db_fetch($que_query)) { |
|
2054 | + $que_data = explode(',', $que_row['que']); |
|
2055 | 2055 | |
2056 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2057 | - continue; |
|
2058 | - } |
|
2056 | + if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2057 | + continue; |
|
2058 | + } |
|
2059 | 2059 | |
2060 | - $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
|
2061 | - // Если планета пустая - ставим главку |
|
2062 | - $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
|
2063 | - if($que_data[QI_PLANET_ID]) { |
|
2064 | - $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
|
2065 | - if(!$que_planet_check['id']) { |
|
2066 | - $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
|
2060 | + $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
|
2061 | + // Если планета пустая - ставим главку |
|
2062 | + $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
|
2063 | + if($que_data[QI_PLANET_ID]) { |
|
2067 | 2064 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2068 | 2065 | if(!$que_planet_check['id']) { |
2069 | - $que_data[QI_PLANET_ID] = 'NULL'; |
|
2066 | + $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
|
2067 | + $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
|
2068 | + if(!$que_planet_check['id']) { |
|
2069 | + $que_data[QI_PLANET_ID] = 'NULL'; |
|
2070 | + } |
|
2070 | 2071 | } |
2072 | + } else { |
|
2073 | + $que_data[QI_PLANET_ID] = 'NULL'; |
|
2071 | 2074 | } |
2072 | - } else { |
|
2073 | - $que_data[QI_PLANET_ID] = 'NULL'; |
|
2074 | - } |
|
2075 | 2075 | |
2076 | - $unit_info = get_unit_param($que_data[QI_UNIT_ID]); |
|
2077 | - $unit_level = $que_row[$unit_info[P_NAME]]; |
|
2078 | - $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1; |
|
2079 | - $price_increase = pow($unit_factor, $unit_level); |
|
2080 | - $unit_level++; |
|
2081 | - $unit_cost = array(); |
|
2082 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2083 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2084 | - continue; |
|
2076 | + $unit_info = get_unit_param($que_data[QI_UNIT_ID]); |
|
2077 | + $unit_level = $que_row[$unit_info[P_NAME]]; |
|
2078 | + $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1; |
|
2079 | + $price_increase = pow($unit_factor, $unit_level); |
|
2080 | + $unit_level++; |
|
2081 | + $unit_cost = array(); |
|
2082 | + foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2083 | + if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2084 | + continue; |
|
2085 | + } |
|
2086 | + $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
2085 | 2087 | } |
2086 | - $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
2088 | + $unit_cost = implode(';', $unit_cost); |
|
2089 | + |
|
2090 | + $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
2091 | + BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2087 | 2092 | } |
2088 | - $unit_cost = implode(';', $unit_cost); |
|
2089 | 2093 | |
2090 | - $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
2091 | - BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2092 | - } |
|
2094 | + if(!empty($que_lines)) { |
|
2095 | + upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines)); |
|
2096 | + } |
|
2093 | 2097 | |
2094 | - if(!empty($que_lines)) { |
|
2095 | - upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines)); |
|
2098 | + upd_alter_table('users', array( |
|
2099 | + "DROP COLUMN `que`", |
|
2100 | + ), $update_tables['users']['que']); |
|
2096 | 2101 | } |
2097 | 2102 | |
2098 | - upd_alter_table('users', array( |
|
2099 | - "DROP COLUMN `que`", |
|
2100 | - ), $update_tables['users']['que']); |
|
2101 | - } |
|
2102 | 2103 | |
2104 | + upd_check_key('server_que_length_research', 1, !isset(classSupernova::$config->server_que_length_research)); |
|
2103 | 2105 | |
2104 | - upd_check_key('server_que_length_research', 1, !isset(classSupernova::$config->server_que_length_research)); |
|
2105 | 2106 | |
2107 | + // Ковертируем технологии в таблицы |
|
2108 | + if($update_tables['users']['graviton_tech']) { |
|
2109 | + upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
2106 | 2110 | |
2107 | - // Ковертируем технологии в таблицы |
|
2108 | - if($update_tables['users']['graviton_tech']) { |
|
2109 | - upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
2110 | - |
|
2111 | - $que_lines = array(); |
|
2112 | - $user_query = upd_do_query("SELECT * FROM {{users}}"); |
|
2113 | - upd_add_more_time(300); |
|
2114 | - $sn_group_tech = sn_get_groups('tech'); |
|
2115 | - while($user_row = db_fetch($user_query)) { |
|
2116 | - foreach($sn_group_tech as $tech_id) { |
|
2117 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2118 | - $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
2111 | + $que_lines = array(); |
|
2112 | + $user_query = upd_do_query("SELECT * FROM {{users}}"); |
|
2113 | + upd_add_more_time(300); |
|
2114 | + $sn_group_tech = sn_get_groups('tech'); |
|
2115 | + while($user_row = db_fetch($user_query)) { |
|
2116 | + foreach($sn_group_tech as $tech_id) { |
|
2117 | + if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2118 | + $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
2119 | + } |
|
2119 | 2120 | } |
2120 | 2121 | } |
2121 | - } |
|
2122 | 2122 | |
2123 | - if(!empty($que_lines)) { |
|
2124 | - upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines)); |
|
2125 | - } |
|
2123 | + if(!empty($que_lines)) { |
|
2124 | + upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines)); |
|
2125 | + } |
|
2126 | 2126 | |
2127 | - upd_alter_table('users', array( |
|
2128 | - "DROP COLUMN `graviton_tech`", |
|
2129 | - ), $update_tables['users']['graviton_tech']); |
|
2130 | - } |
|
2127 | + upd_alter_table('users', array( |
|
2128 | + "DROP COLUMN `graviton_tech`", |
|
2129 | + ), $update_tables['users']['graviton_tech']); |
|
2130 | + } |
|
2131 | 2131 | |
2132 | - if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2133 | - upd_alter_table('unit', array( |
|
2134 | - "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
|
2135 | - ), !$update_indexes['unit']['I_unit_record_search']); |
|
2132 | + if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2133 | + upd_alter_table('unit', array( |
|
2134 | + "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
|
2135 | + ), !$update_indexes['unit']['I_unit_record_search']); |
|
2136 | 2136 | |
2137 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2138 | - $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
|
2139 | - } |
|
2140 | - $drop_index = array(); |
|
2141 | - $create_index = &$drop_index; // array(); |
|
2142 | - foreach($planet_units as $unit_name => $unit_create) { |
|
2143 | - if($update_indexes['planets']['I_' . $unit_name]) { |
|
2144 | - $drop_index[] = "DROP KEY I_{$unit_name}"; |
|
2145 | - } |
|
2146 | - if($update_indexes['planets']['i_' . $unit_name]) { |
|
2147 | - $drop_index[] = "DROP KEY i_{$unit_name}"; |
|
2137 | + foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2138 | + $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
|
2148 | 2139 | } |
2140 | + $drop_index = array(); |
|
2141 | + $create_index = &$drop_index; // array(); |
|
2142 | + foreach($planet_units as $unit_name => $unit_create) { |
|
2143 | + if($update_indexes['planets']['I_' . $unit_name]) { |
|
2144 | + $drop_index[] = "DROP KEY I_{$unit_name}"; |
|
2145 | + } |
|
2146 | + if($update_indexes['planets']['i_' . $unit_name]) { |
|
2147 | + $drop_index[] = "DROP KEY i_{$unit_name}"; |
|
2148 | + } |
|
2149 | 2149 | |
2150 | - if($unit_create) { |
|
2151 | - $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
|
2150 | + if($unit_create) { |
|
2151 | + $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
|
2152 | + } |
|
2152 | 2153 | } |
2154 | + upd_alter_table('planets', $drop_index, true); |
|
2153 | 2155 | } |
2154 | - upd_alter_table('planets', $drop_index, true); |
|
2155 | - } |
|
2156 | 2156 | |
2157 | - upd_alter_table('users', array( |
|
2158 | - "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
|
2159 | - ), !$update_tables['users']['user_time_utc_offset']); |
|
2157 | + upd_alter_table('users', array( |
|
2158 | + "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
|
2159 | + ), !$update_tables['users']['user_time_utc_offset']); |
|
2160 | 2160 | |
2161 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2162 | - upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
|
2161 | + if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2162 | + upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
|
2163 | 2163 | |
2164 | - upd_alter_table('alliance', array( |
|
2165 | - "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
2166 | - ), !$update_foreigns['alliance']['FK_alliance_owner']); |
|
2164 | + upd_alter_table('alliance', array( |
|
2165 | + "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
2166 | + ), !$update_foreigns['alliance']['FK_alliance_owner']); |
|
2167 | 2167 | |
2168 | - 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}})"); |
|
2168 | + 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}})"); |
|
2169 | 2169 | |
2170 | - upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id"); |
|
2171 | - upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id"); |
|
2172 | - } |
|
2170 | + upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id"); |
|
2171 | + upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id"); |
|
2172 | + } |
|
2173 | 2173 | |
2174 | - upd_alter_table('fleets', array( |
|
2175 | - 'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
2176 | - "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
2177 | - ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
2174 | + upd_alter_table('fleets', array( |
|
2175 | + 'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
2176 | + "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
2177 | + ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
2178 | 2178 | |
2179 | - upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
|
2179 | + upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
|
2180 | 2180 | |
2181 | - if(!$update_tables['player_name_history']) { |
|
2182 | - upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
|
2183 | - upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
|
2181 | + if(!$update_tables['player_name_history']) { |
|
2182 | + upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
|
2183 | + upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
|
2184 | 2184 | |
2185 | - upd_alter_table('users', array( |
|
2186 | - "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'", |
|
2187 | - )); |
|
2185 | + upd_alter_table('users', array( |
|
2186 | + "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'", |
|
2187 | + )); |
|
2188 | 2188 | |
2189 | - upd_create_table('player_name_history', |
|
2190 | - "( |
|
2189 | + upd_create_table('player_name_history', |
|
2190 | + "( |
|
2191 | 2191 | `player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Player ID', |
2192 | 2192 | `player_name` VARCHAR(32) NOT NULL COMMENT 'Historical player name', |
2193 | 2193 | `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When player changed name', |
@@ -2197,74 +2197,74 @@ discard block |
||
2197 | 2197 | |
2198 | 2198 | CONSTRAINT `FK_player_name_history_id` FOREIGN KEY (`player_id`) REFERENCES `{{users}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
2199 | 2199 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
2200 | - ); |
|
2200 | + ); |
|
2201 | 2201 | |
2202 | - upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;"); |
|
2203 | - } |
|
2202 | + upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;"); |
|
2203 | + } |
|
2204 | 2204 | |
2205 | - upd_alter_table('planets', array( |
|
2206 | - "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
|
2207 | - "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
2208 | - ), !$update_tables['planets']['density_index']); |
|
2205 | + upd_alter_table('planets', array( |
|
2206 | + "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
|
2207 | + "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
2208 | + ), !$update_tables['planets']['density_index']); |
|
2209 | 2209 | |
2210 | - if($update_tables['users']['player_artifact_list']) { |
|
2211 | - upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
|
2210 | + if($update_tables['users']['player_artifact_list']) { |
|
2211 | + upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
|
2212 | 2212 | |
2213 | - 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']); |
|
2214 | - upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']); |
|
2213 | + 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']); |
|
2214 | + upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']); |
|
2215 | 2215 | |
2216 | - $sn_data_artifacts = sn_get_groups('artifacts'); |
|
2217 | - $db_changeset = array(); |
|
2216 | + $sn_data_artifacts = sn_get_groups('artifacts'); |
|
2217 | + $db_changeset = array(); |
|
2218 | 2218 | |
2219 | - $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
|
2220 | - while($row = db_fetch($query)) { |
|
2221 | - $artifact_list = explode(';', $row['player_artifact_list']); |
|
2222 | - if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2223 | - continue; |
|
2224 | - } |
|
2225 | - foreach($artifact_list as $key => &$value) { |
|
2226 | - $value = explode(',', $value); |
|
2227 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2228 | - unset($artifact_list[$key]); |
|
2219 | + $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
|
2220 | + while($row = db_fetch($query)) { |
|
2221 | + $artifact_list = explode(';', $row['player_artifact_list']); |
|
2222 | + if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2229 | 2223 | continue; |
2230 | 2224 | } |
2231 | - $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row); |
|
2225 | + foreach($artifact_list as $key => &$value) { |
|
2226 | + $value = explode(',', $value); |
|
2227 | + if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2228 | + unset($artifact_list[$key]); |
|
2229 | + continue; |
|
2230 | + } |
|
2231 | + $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row); |
|
2232 | + } |
|
2232 | 2233 | } |
2233 | - } |
|
2234 | - upd_db_changeset_apply($db_changeset); |
|
2234 | + upd_db_changeset_apply($db_changeset); |
|
2235 | 2235 | |
2236 | - upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']); |
|
2237 | - } |
|
2236 | + upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']); |
|
2237 | + } |
|
2238 | 2238 | |
2239 | - upd_alter_table('users', array( |
|
2240 | - "DROP COLUMN `spy_tech`", |
|
2241 | - "DROP COLUMN `computer_tech`", |
|
2242 | - "DROP COLUMN `military_tech`", |
|
2243 | - "DROP COLUMN `defence_tech`", |
|
2244 | - "DROP COLUMN `shield_tech`", |
|
2245 | - "DROP COLUMN `energy_tech`", |
|
2246 | - "DROP COLUMN `hyperspace_tech`", |
|
2247 | - "DROP COLUMN `combustion_tech`", |
|
2248 | - "DROP COLUMN `impulse_motor_tech`", |
|
2249 | - "DROP COLUMN `hyperspace_motor_tech`", |
|
2250 | - "DROP COLUMN `laser_tech`", |
|
2251 | - "DROP COLUMN `ionic_tech`", |
|
2252 | - "DROP COLUMN `buster_tech`", |
|
2253 | - "DROP COLUMN `intergalactic_tech`", |
|
2254 | - "DROP COLUMN `expedition_tech`", |
|
2255 | - "DROP COLUMN `colonisation_tech`", |
|
2256 | - ), $update_tables['users']['spy_tech']); |
|
2257 | - |
|
2258 | - upd_check_key('payment_currency_exchange_dm_', 2500, !classSupernova::$config->payment_currency_exchange_dm_ || classSupernova::$config->payment_currency_exchange_dm_ == 1000); |
|
2259 | - upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !classSupernova::$config->payment_currency_exchange_eur); |
|
2260 | - upd_check_key('payment_currency_exchange_rub', 4.0, !classSupernova::$config->payment_currency_exchange_rub); |
|
2261 | - upd_check_key('payment_currency_exchange_usd', 0.125, !classSupernova::$config->payment_currency_exchange_usd); |
|
2262 | - upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !classSupernova::$config->payment_currency_exchange_usd); |
|
2263 | - upd_check_key('payment_currency_exchange_wmr', 4.1, !classSupernova::$config->payment_currency_exchange_wmr); |
|
2264 | - upd_check_key('payment_currency_exchange_wmu', 1.05, !classSupernova::$config->payment_currency_exchange_wmu); |
|
2265 | - upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !classSupernova::$config->payment_currency_exchange_wmz); |
|
2239 | + upd_alter_table('users', array( |
|
2240 | + "DROP COLUMN `spy_tech`", |
|
2241 | + "DROP COLUMN `computer_tech`", |
|
2242 | + "DROP COLUMN `military_tech`", |
|
2243 | + "DROP COLUMN `defence_tech`", |
|
2244 | + "DROP COLUMN `shield_tech`", |
|
2245 | + "DROP COLUMN `energy_tech`", |
|
2246 | + "DROP COLUMN `hyperspace_tech`", |
|
2247 | + "DROP COLUMN `combustion_tech`", |
|
2248 | + "DROP COLUMN `impulse_motor_tech`", |
|
2249 | + "DROP COLUMN `hyperspace_motor_tech`", |
|
2250 | + "DROP COLUMN `laser_tech`", |
|
2251 | + "DROP COLUMN `ionic_tech`", |
|
2252 | + "DROP COLUMN `buster_tech`", |
|
2253 | + "DROP COLUMN `intergalactic_tech`", |
|
2254 | + "DROP COLUMN `expedition_tech`", |
|
2255 | + "DROP COLUMN `colonisation_tech`", |
|
2256 | + ), $update_tables['users']['spy_tech']); |
|
2257 | + |
|
2258 | + upd_check_key('payment_currency_exchange_dm_', 2500, !classSupernova::$config->payment_currency_exchange_dm_ || classSupernova::$config->payment_currency_exchange_dm_ == 1000); |
|
2259 | + upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !classSupernova::$config->payment_currency_exchange_eur); |
|
2260 | + upd_check_key('payment_currency_exchange_rub', 4.0, !classSupernova::$config->payment_currency_exchange_rub); |
|
2261 | + upd_check_key('payment_currency_exchange_usd', 0.125, !classSupernova::$config->payment_currency_exchange_usd); |
|
2262 | + upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !classSupernova::$config->payment_currency_exchange_usd); |
|
2263 | + upd_check_key('payment_currency_exchange_wmr', 4.1, !classSupernova::$config->payment_currency_exchange_wmr); |
|
2264 | + upd_check_key('payment_currency_exchange_wmu', 1.05, !classSupernova::$config->payment_currency_exchange_wmu); |
|
2265 | + upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !classSupernova::$config->payment_currency_exchange_wmz); |
|
2266 | 2266 | |
2267 | - upd_do_query('COMMIT;', true); |
|
2268 | - $new_version = 37; |
|
2267 | + upd_do_query('COMMIT;', true); |
|
2268 | + $new_version = 37; |
|
2269 | 2269 | |
2270 | 2270 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('IN_UPDATE') || IN_UPDATE !== true) { |
|
3 | +if (!defined('IN_UPDATE') || IN_UPDATE !== true) { |
|
4 | 4 | die('Hack attempt'); |
5 | 5 | } |
6 | 6 | |
7 | -switch($new_version) { |
|
7 | +switch ($new_version) { |
|
8 | 8 | case 0: |
9 | 9 | case 1: |
10 | 10 | case 2: |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ); |
33 | 33 | upd_drop_table('lunas'); |
34 | 34 | |
35 | - if($update_tables['galaxy']) { |
|
35 | + if ($update_tables['galaxy']) { |
|
36 | 36 | upd_do_query( |
37 | 37 | 'UPDATE `{{planets}}` |
38 | 38 | LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ); |
83 | 83 | upd_add_more_time(); |
84 | 84 | |
85 | - if($update_tables['users']['rpg_points']) { |
|
85 | + if ($update_tables['users']['rpg_points']) { |
|
86 | 86 | upd_do_query( |
87 | 87 | "UPDATE {{users}} AS u |
88 | 88 | RIGHT JOIN {{referrals}} AS r |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
176 | 176 | upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
177 | 177 | |
178 | - if($update_tables['planets']['b_building']) { |
|
178 | + if ($update_tables['planets']['b_building']) { |
|
179 | 179 | $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
180 | 180 | $const_que_structures = QUE_STRUCTURES; |
181 | - while($planet_data = db_fetch($planet_query)) { |
|
181 | + while ($planet_data = db_fetch($planet_query)) { |
|
182 | 182 | $old_que = explode(';', $planet_data['b_building_id']); |
183 | - foreach($old_que as $old_que_item_string) { |
|
184 | - if(!$old_que_item_string) { |
|
183 | + foreach ($old_que as $old_que_item_string) { |
|
184 | + if (!$old_que_item_string) { |
|
185 | 185 | continue; |
186 | 186 | } |
187 | 187 | |
188 | 188 | $old_que_item = explode(',', $old_que_item_string); |
189 | - if($old_que_item[4] == 'build') { |
|
189 | + if ($old_que_item[4] == 'build') { |
|
190 | 190 | $old_que_item[4] = BUILD_CREATE; |
191 | 191 | } else { |
192 | 192 | $old_que_item[4] = BUILD_DESTROY; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
220 | 220 | ); |
221 | 221 | |
222 | - if($update_tables['users']['urlaubs_until']) { |
|
222 | + if ($update_tables['users']['urlaubs_until']) { |
|
223 | 223 | upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
224 | 224 | upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
225 | 225 | upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | ), !$update_tables['logs']['log_timestamp']); |
270 | 270 | upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
271 | 271 | |
272 | - if($update_tables['errors']) { |
|
272 | + if ($update_tables['errors']) { |
|
273 | 273 | upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;'); |
274 | - if($update_tables['errors_backup']) { |
|
274 | + if ($update_tables['errors_backup']) { |
|
275 | 275 | upd_drop_table('errors_backup'); |
276 | 276 | } |
277 | 277 | upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup'); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
334 | 334 | |
335 | - if(!$update_tables['shortcut']) { |
|
335 | + if (!$update_tables['shortcut']) { |
|
336 | 336 | upd_create_table('shortcut', |
337 | 337 | "( |
338 | 338 | `shortcut_id` SERIAL, |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
357 | 357 | |
358 | 358 | $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
359 | - while($user_data = db_fetch($query)) { |
|
359 | + while ($user_data = db_fetch($query)) { |
|
360 | 360 | $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
361 | - foreach($shortcuts as $shortcut) { |
|
362 | - if(!$shortcut) { |
|
361 | + foreach ($shortcuts as $shortcut) { |
|
362 | + if (!$shortcut) { |
|
363 | 363 | continue; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $shortcut[3] = intval($shortcut[3]); |
371 | 371 | $shortcut[4] = intval($shortcut[4]); |
372 | 372 | |
373 | - if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
373 | + if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
374 | 374 | upd_do_query("INSERT INTO {classSupernova::$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true); |
375 | 375 | } |
376 | 376 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total)); |
524 | 524 | |
525 | - for($i = 0; $i < 25; $i++) { |
|
525 | + for ($i = 0; $i < 25; $i++) { |
|
526 | 526 | upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
527 | 527 | upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
528 | 528 | upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
551 | 551 | ), !$update_tables['users']['msg_admin']); |
552 | 552 | |
553 | - if(!$update_foreigns['users']['FK_users_ally_id']) { |
|
553 | + if (!$update_foreigns['users']['FK_users_ally_id']) { |
|
554 | 554 | upd_alter_table('users', array( |
555 | 555 | 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
556 | 556 | 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
573 | 573 | |
574 | 574 | $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);"); |
575 | - while($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
575 | + while ($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
576 | 576 | upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
577 | 577 | } |
578 | 578 | |
@@ -609,16 +609,16 @@ discard block |
||
609 | 609 | upd_do_query('COMMIT;', true); |
610 | 610 | |
611 | 611 | $records = 1; |
612 | - while($records) { |
|
612 | + while ($records) { |
|
613 | 613 | upd_do_query('START TRANSACTION;', true); |
614 | 614 | $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;"); |
615 | 615 | $records = db_num_rows($query); |
616 | - while($row = db_fetch($query)) { |
|
616 | + while ($row = db_fetch($query)) { |
|
617 | 617 | $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
618 | 618 | |
619 | 619 | $reason = RPG_NONE; |
620 | 620 | $comment = $matches[3]; |
621 | - switch($matches[3]) { |
|
621 | + switch ($matches[3]) { |
|
622 | 622 | case 'Level Up For Structure Building': |
623 | 623 | $reason = RPG_STRUCTURE; |
624 | 624 | break; |
@@ -634,22 +634,22 @@ discard block |
||
634 | 634 | break; |
635 | 635 | |
636 | 636 | default: |
637 | - if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) { |
|
637 | + if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) { |
|
638 | 638 | $reason = RPG_MARKET; |
639 | - } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) { |
|
639 | + } elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) { |
|
640 | 640 | $reason = RPG_MERCENARY; |
641 | 641 | $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}"; |
642 | - } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) { |
|
642 | + } elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) { |
|
643 | 643 | $reason = RPG_REFERRAL; |
644 | 644 | $comment = "Incoming from referral ID {$matches[1]}"; |
645 | - } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) { |
|
645 | + } elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) { |
|
646 | 646 | $reason = RPG_ADMIN; |
647 | 647 | $comment = $matches2[1]; |
648 | 648 | } |
649 | 649 | break; |
650 | 650 | } |
651 | 651 | |
652 | - if($matches[2]) { |
|
652 | + if ($matches[2]) { |
|
653 | 653 | $row['log_username'] = db_escape($row['log_username']); |
654 | 654 | $row['log_page'] = db_escape($row['log_page']); |
655 | 655 | $comment = db_escape($comment); |
@@ -668,12 +668,12 @@ discard block |
||
668 | 668 | upd_do_query('COMMIT;', true); |
669 | 669 | } |
670 | 670 | |
671 | - foreach($update_tables as $table_name => $cork) { |
|
671 | + foreach ($update_tables as $table_name => $cork) { |
|
672 | 672 | $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '" . classSupernova::$config->db_prefix . "{$table_name}';", true)); |
673 | - if($row['ENGINE'] != 'InnoDB') { |
|
673 | + if ($row['ENGINE'] != 'InnoDB') { |
|
674 | 674 | upd_alter_table($table_name, 'ENGINE=InnoDB', true); |
675 | 675 | } |
676 | - if($row['TABLE_COLLATION'] != 'utf8_general_ci') { |
|
676 | + if ($row['TABLE_COLLATION'] != 'utf8_general_ci') { |
|
677 | 677 | upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true); |
678 | 678 | } |
679 | 679 | } |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
694 | 694 | ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
695 | 695 | |
696 | - if($update_tables['users']['rpg_geologue']) { |
|
696 | + if ($update_tables['users']['rpg_geologue']) { |
|
697 | 697 | doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
698 | 698 | |
699 | 699 | upd_alter_table('users', array( |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | ), $update_tables['users']['rpg_geologue']); |
707 | 707 | } |
708 | 708 | |
709 | - if($update_tables['users']['rpg_bunker']) { |
|
709 | + if ($update_tables['users']['rpg_bunker']) { |
|
710 | 710 | doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
711 | 711 | |
712 | 712 | upd_alter_table('users', array( |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | ), !isset($update_tables['alliance']['total_rank'])); |
757 | 757 | doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
758 | 758 | |
759 | - if(!isset($update_tables['users']['ally_tag'])) { |
|
759 | + if (!isset($update_tables['users']['ally_tag'])) { |
|
760 | 760 | upd_alter_table('users', array( |
761 | 761 | "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
762 | 762 | ), !isset($update_tables['users']['ally_tag'])); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | "ADD COLUMN `player_artifact_list` TEXT", |
772 | 772 | ), !isset($update_tables['users']['player_artifact_list'])); |
773 | 773 | |
774 | - if(!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
774 | + if (!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
775 | 775 | upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage)); |
776 | 776 | |
777 | 777 | upd_alter_table('users', array( |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
802 | 802 | ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
803 | 803 | |
804 | - if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
804 | + if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
805 | 805 | upd_alter_table('alliance_diplomacy', array( |
806 | 806 | "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
807 | 807 | "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | ), true); |
817 | 817 | } |
818 | 818 | |
819 | - if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
819 | + if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
820 | 820 | upd_alter_table('alliance_negotiation', array( |
821 | 821 | "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
822 | 822 | "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | ), true); |
833 | 833 | } |
834 | 834 | |
835 | - if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
835 | + if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
836 | 836 | upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
837 | 837 | |
838 | 838 | upd_alter_table('alliance_requests', array( |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | ), true); |
847 | 847 | } |
848 | 848 | |
849 | - if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
849 | + if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
850 | 850 | upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true); |
851 | 851 | |
852 | 852 | upd_alter_table('annonce', array( |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | ), true); |
860 | 860 | } |
861 | 861 | |
862 | - if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
862 | + if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
863 | 863 | upd_alter_table('bashing', array( |
864 | 864 | "DROP FOREIGN KEY `FK_bashing_user_id`", |
865 | 865 | "DROP FOREIGN KEY `FK_bashing_planet_id`", |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | ), true); |
875 | 875 | } |
876 | 876 | |
877 | - if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
877 | + if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
878 | 878 | upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true); |
879 | 879 | |
880 | 880 | upd_alter_table('buddy', array( |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
913 | 913 | ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
914 | 914 | |
915 | - if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
915 | + if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
916 | 916 | upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
917 | 917 | |
918 | 918 | upd_alter_table('iraks', array( |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | ), true); |
937 | 937 | } |
938 | 938 | |
939 | - if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
939 | + if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
940 | 940 | upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true); |
941 | 941 | |
942 | 942 | upd_alter_table('notes', array( |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | "DROP COLUMN `b_hangar_plus`", |
1062 | 1062 | ), isset($update_tables['planets']['b_hangar_plus'])); |
1063 | 1063 | |
1064 | - if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1064 | + if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1065 | 1065 | upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
1066 | 1066 | |
1067 | 1067 | upd_alter_table('referrals', array( |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
1081 | 1081 | ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
1082 | 1082 | |
1083 | - if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1083 | + if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1084 | 1084 | upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true); |
1085 | 1085 | |
1086 | 1086 | upd_alter_table('shortcut', array( |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | ), true); |
1096 | 1096 | } |
1097 | 1097 | |
1098 | - if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1098 | + if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1099 | 1099 | upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
1100 | 1100 | |
1101 | 1101 | upd_alter_table('statpoints', array( |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | "DROP COLUMN `settings_allylogo`", |
1250 | 1250 | ), isset($update_tables['users']['settings_allylogo'])); |
1251 | 1251 | |
1252 | - if(!isset($update_tables['powerup'])) { |
|
1252 | + if (!isset($update_tables['powerup'])) { |
|
1253 | 1253 | upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};"); |
1254 | 1254 | |
1255 | 1255 | upd_create_table('powerup', |
@@ -1279,24 +1279,24 @@ discard block |
||
1279 | 1279 | |
1280 | 1280 | $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
1281 | 1281 | $user_list = upd_do_query("SELECT * FROM {{users}};"); |
1282 | - while($user_row = db_fetch($user_list)) { |
|
1282 | + while ($user_row = db_fetch($user_list)) { |
|
1283 | 1283 | $update_query_str = ''; |
1284 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) { |
|
1284 | + foreach (sn_get_groups('mercenaries') as $mercenary_id) { |
|
1285 | 1285 | $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
1286 | - if($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1286 | + if ($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1287 | 1287 | $update_query_str = ", `{$mercenary_data_name}` = 0"; |
1288 | 1288 | upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
1289 | 1289 | upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - if($update_query_str) { |
|
1293 | + if ($update_query_str) { |
|
1294 | 1294 | upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
1295 | 1295 | } |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if(!isset($update_tables['universe'])) { |
|
1299 | + if (!isset($update_tables['universe'])) { |
|
1300 | 1300 | upd_create_table('universe', |
1301 | 1301 | "( |
1302 | 1302 | `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | |
1320 | 1320 | // ------------------------------------------------------------------------ |
1321 | 1321 | // Modifying tables |
1322 | - if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1322 | + if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1323 | 1323 | upd_alter_table('users', array( |
1324 | 1324 | "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
1325 | 1325 | |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | // ------------------------------------------------------------------------ |
1341 | 1341 | // Creating players for allies |
1342 | 1342 | $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
1343 | - while($ally_row = db_fetch($ally_row_list)) { |
|
1343 | + while ($ally_row = db_fetch($ally_row_list)) { |
|
1344 | 1344 | $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
1345 | 1345 | doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
1346 | 1346 | $ally_user_id = db_insert_id(); |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | // ------------------------------------------------------------------------ |
1355 | 1355 | // Creating planets for allies |
1356 | 1356 | $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
1357 | - while($ally_user_row = db_fetch($ally_user_list)) { |
|
1357 | + while ($ally_user_row = db_fetch($ally_user_list)) { |
|
1358 | 1358 | $ally_planet_name = db_escape($ally_user_row['username']); |
1359 | 1359 | doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
1360 | 1360 | $ally_planet_id = db_insert_id(); |
@@ -1385,9 +1385,9 @@ discard block |
||
1385 | 1385 | // Adding db field |
1386 | 1386 | upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
1387 | 1387 | // Converting old data to new one and dropping old fields |
1388 | - if($update_tables['users']['b_tech_planet']) { |
|
1388 | + if ($update_tables['users']['b_tech_planet']) { |
|
1389 | 1389 | $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;"); |
1390 | - while($planet_row = db_fetch($query)) { |
|
1390 | + while ($planet_row = db_fetch($query)) { |
|
1391 | 1391 | $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
1392 | 1392 | doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
1393 | 1393 | } |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if(!$update_tables['powerup']['powerup_category']) { |
|
1403 | + if (!$update_tables['powerup']['powerup_category']) { |
|
1404 | 1404 | upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
1405 | 1405 | |
1406 | 1406 | doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
1422 | 1422 | upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
1423 | 1423 | |
1424 | - if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1424 | + if (!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1425 | 1425 | $inflation_rate = 1000; |
1426 | 1426 | |
1427 | 1427 | classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
@@ -1438,17 +1438,17 @@ discard block |
||
1438 | 1438 | doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
1439 | 1439 | |
1440 | 1440 | $query = doquery("SELECT * FROM {{quest}}"); |
1441 | - while($row = db_fetch($query)) { |
|
1441 | + while ($row = db_fetch($query)) { |
|
1442 | 1442 | $query_add = ''; |
1443 | 1443 | $quest_reward_list = explode(';', $row['quest_rewards']); |
1444 | - foreach($quest_reward_list as &$quest_reward) { |
|
1444 | + foreach ($quest_reward_list as &$quest_reward) { |
|
1445 | 1445 | list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
1446 | - if($reward_resource == RES_DARK_MATTER) { |
|
1446 | + if ($reward_resource == RES_DARK_MATTER) { |
|
1447 | 1447 | $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
1448 | 1448 | } |
1449 | 1449 | } |
1450 | 1450 | $new_rewards = implode(';', $quest_reward_list); |
1451 | - if($new_rewards != $row['quest_rewards']) { |
|
1451 | + if ($new_rewards != $row['quest_rewards']) { |
|
1452 | 1452 | doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
1453 | 1453 | } |
1454 | 1454 | } |
@@ -1478,7 +1478,7 @@ discard block |
||
1478 | 1478 | upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
1479 | 1479 | upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
1480 | 1480 | |
1481 | - if(!isset($update_tables['payment'])) { |
|
1481 | + if (!isset($update_tables['payment'])) { |
|
1482 | 1482 | upd_alter_table('users', array( |
1483 | 1483 | "ADD KEY `I_user_id_name` (`id`, `username`)", |
1484 | 1484 | ), !$update_indexes['users']['I_user_id_name']); |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | ), !$update_tables['iraks']['fleet_start_type']); |
1530 | 1530 | |
1531 | 1531 | |
1532 | - if(!$update_tables['payment']['payment_status']) { |
|
1532 | + if (!$update_tables['payment']['payment_status']) { |
|
1533 | 1533 | upd_alter_table('payment', array( |
1534 | 1534 | "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
1535 | 1535 | |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
1614 | 1614 | ), !$update_indexes['notes']['I_owner_priority_time']); |
1615 | 1615 | |
1616 | - if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1616 | + if (!$update_tables['buddy']['BUDDY_ID']) { |
|
1617 | 1617 | upd_alter_table('buddy', array( |
1618 | 1618 | "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", |
1619 | 1619 | "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'", |
@@ -1634,16 +1634,16 @@ discard block |
||
1634 | 1634 | |
1635 | 1635 | $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
1636 | 1636 | $found = $lost = array(); |
1637 | - while($row = db_fetch($query)) { |
|
1637 | + while ($row = db_fetch($query)) { |
|
1638 | 1638 | $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
1639 | - if(!isset($found[$index])) { |
|
1639 | + if (!isset($found[$index])) { |
|
1640 | 1640 | $found[$index] = $row['BUDDY_ID']; |
1641 | 1641 | } else { |
1642 | 1642 | $lost[] = $row['BUDDY_ID']; |
1643 | 1643 | } |
1644 | 1644 | } |
1645 | 1645 | $lost = implode(',', $lost); |
1646 | - if($lost) { |
|
1646 | + if ($lost) { |
|
1647 | 1647 | upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
1648 | 1648 | } |
1649 | 1649 | |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | |
1665 | 1665 | upd_do_query("UPDATE {{users}} SET `ally_name` = NULL, `ally_tag` = NULL, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL"); |
1666 | 1666 | |
1667 | - if(!$update_tables['ube_report']) { |
|
1667 | + if (!$update_tables['ube_report']) { |
|
1668 | 1668 | upd_create_table('ube_report', |
1669 | 1669 | "( |
1670 | 1670 | `ube_report_id` SERIAL COMMENT 'Report ID', |
@@ -1705,7 +1705,7 @@ discard block |
||
1705 | 1705 | ); |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if(!$update_tables['ube_report_player']) { |
|
1708 | + if (!$update_tables['ube_report_player']) { |
|
1709 | 1709 | upd_create_table('ube_report_player', |
1710 | 1710 | "( |
1711 | 1711 | `ube_report_player_id` SERIAL COMMENT 'Record ID', |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | ); |
1727 | 1727 | } |
1728 | 1728 | |
1729 | - if(!$update_tables['ube_report_fleet']) { |
|
1729 | + if (!$update_tables['ube_report_fleet']) { |
|
1730 | 1730 | upd_create_table('ube_report_fleet', |
1731 | 1731 | "( |
1732 | 1732 | `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID', |
@@ -1756,7 +1756,7 @@ discard block |
||
1756 | 1756 | ); |
1757 | 1757 | } |
1758 | 1758 | |
1759 | - if(!$update_tables['ube_report_unit']) { |
|
1759 | + if (!$update_tables['ube_report_unit']) { |
|
1760 | 1760 | // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
1761 | 1761 | // Может сохранять имена удаленных кораблей долго? |
1762 | 1762 | |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | ); |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - if(!$update_tables['ube_report_outcome_fleet']) { |
|
1796 | + if (!$update_tables['ube_report_outcome_fleet']) { |
|
1797 | 1797 | upd_create_table('ube_report_outcome_fleet', |
1798 | 1798 | "( |
1799 | 1799 | `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID', |
@@ -1822,7 +1822,7 @@ discard block |
||
1822 | 1822 | ); |
1823 | 1823 | } |
1824 | 1824 | |
1825 | - if(!$update_tables['ube_report_outcome_unit']) { |
|
1825 | + if (!$update_tables['ube_report_outcome_unit']) { |
|
1826 | 1826 | upd_create_table('ube_report_outcome_unit', |
1827 | 1827 | "( |
1828 | 1828 | `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID', |
@@ -1843,7 +1843,7 @@ discard block |
||
1843 | 1843 | ); |
1844 | 1844 | } |
1845 | 1845 | |
1846 | - if(!$update_tables['unit']) { |
|
1846 | + if (!$update_tables['unit']) { |
|
1847 | 1847 | upd_create_table('unit', |
1848 | 1848 | "( |
1849 | 1849 | `unit_id` SERIAL COMMENT 'Record ID', |
@@ -1862,7 +1862,7 @@ discard block |
||
1862 | 1862 | ); |
1863 | 1863 | } |
1864 | 1864 | |
1865 | - if(!$update_tables['captain']) { |
|
1865 | + if (!$update_tables['captain']) { |
|
1866 | 1866 | upd_create_table('captain', |
1867 | 1867 | "( |
1868 | 1868 | `captain_id` SERIAL COMMENT 'Record ID', |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | ); |
1883 | 1883 | } |
1884 | 1884 | |
1885 | - if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1885 | + if (!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1886 | 1886 | upd_alter_table('fleets', array( |
1887 | 1887 | "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
1888 | 1888 | "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
@@ -1904,7 +1904,7 @@ discard block |
||
1904 | 1904 | |
1905 | 1905 | upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
1906 | 1906 | |
1907 | - if(!$update_tables['chat_player']) { |
|
1907 | + if (!$update_tables['chat_player']) { |
|
1908 | 1908 | upd_create_table('chat_player', |
1909 | 1909 | "( |
1910 | 1910 | `chat_player_id` SERIAL COMMENT 'Record ID', |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | "DROP FOREIGN KEY `FK_payment_user`", |
1967 | 1967 | ), $update_foreigns['payment']['FK_payment_user']); |
1968 | 1968 | |
1969 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1969 | + if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1970 | 1970 | upd_alter_table('chat', array( |
1971 | 1971 | "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
1972 | 1972 | "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
@@ -1999,7 +1999,7 @@ discard block |
||
1999 | 1999 | "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
2000 | 2000 | ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
2001 | 2001 | |
2002 | - if(!$update_tables['unit']['unit_time_start']) { |
|
2002 | + if (!$update_tables['unit']['unit_time_start']) { |
|
2003 | 2003 | upd_alter_table('unit', array( |
2004 | 2004 | "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
2005 | 2005 | "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
@@ -2015,7 +2015,7 @@ discard block |
||
2015 | 2015 | ); |
2016 | 2016 | } |
2017 | 2017 | |
2018 | - if(!$update_tables['que']) { |
|
2018 | + if (!$update_tables['que']) { |
|
2019 | 2019 | upd_create_table('que', |
2020 | 2020 | "( |
2021 | 2021 | `que_id` SERIAL COMMENT 'Internal que id', |
@@ -2047,25 +2047,25 @@ discard block |
||
2047 | 2047 | } |
2048 | 2048 | |
2049 | 2049 | // Конвертирум очередь исследований |
2050 | - if($update_tables['users']['que']) { |
|
2050 | + if ($update_tables['users']['que']) { |
|
2051 | 2051 | $que_lines = array(); |
2052 | 2052 | $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
2053 | - while($que_row = db_fetch($que_query)) { |
|
2053 | + while ($que_row = db_fetch($que_query)) { |
|
2054 | 2054 | $que_data = explode(',', $que_row['que']); |
2055 | 2055 | |
2056 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2056 | + if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2057 | 2057 | continue; |
2058 | 2058 | } |
2059 | 2059 | |
2060 | 2060 | $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
2061 | 2061 | // Если планета пустая - ставим главку |
2062 | 2062 | $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
2063 | - if($que_data[QI_PLANET_ID]) { |
|
2063 | + if ($que_data[QI_PLANET_ID]) { |
|
2064 | 2064 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2065 | - if(!$que_planet_check['id']) { |
|
2065 | + if (!$que_planet_check['id']) { |
|
2066 | 2066 | $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
2067 | 2067 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2068 | - if(!$que_planet_check['id']) { |
|
2068 | + if (!$que_planet_check['id']) { |
|
2069 | 2069 | $que_data[QI_PLANET_ID] = 'NULL'; |
2070 | 2070 | } |
2071 | 2071 | } |
@@ -2079,8 +2079,8 @@ discard block |
||
2079 | 2079 | $price_increase = pow($unit_factor, $unit_level); |
2080 | 2080 | $unit_level++; |
2081 | 2081 | $unit_cost = array(); |
2082 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2083 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2082 | + foreach ($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2083 | + if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2084 | 2084 | continue; |
2085 | 2085 | } |
2086 | 2086 | $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
@@ -2091,7 +2091,7 @@ discard block |
||
2091 | 2091 | BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
2092 | 2092 | } |
2093 | 2093 | |
2094 | - if(!empty($que_lines)) { |
|
2094 | + if (!empty($que_lines)) { |
|
2095 | 2095 | upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines)); |
2096 | 2096 | } |
2097 | 2097 | |
@@ -2105,22 +2105,22 @@ discard block |
||
2105 | 2105 | |
2106 | 2106 | |
2107 | 2107 | // Ковертируем технологии в таблицы |
2108 | - if($update_tables['users']['graviton_tech']) { |
|
2108 | + if ($update_tables['users']['graviton_tech']) { |
|
2109 | 2109 | upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
2110 | 2110 | |
2111 | 2111 | $que_lines = array(); |
2112 | 2112 | $user_query = upd_do_query("SELECT * FROM {{users}}"); |
2113 | 2113 | upd_add_more_time(300); |
2114 | 2114 | $sn_group_tech = sn_get_groups('tech'); |
2115 | - while($user_row = db_fetch($user_query)) { |
|
2116 | - foreach($sn_group_tech as $tech_id) { |
|
2117 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2115 | + while ($user_row = db_fetch($user_query)) { |
|
2116 | + foreach ($sn_group_tech as $tech_id) { |
|
2117 | + if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2118 | 2118 | $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
2119 | 2119 | } |
2120 | 2120 | } |
2121 | 2121 | } |
2122 | 2122 | |
2123 | - if(!empty($que_lines)) { |
|
2123 | + if (!empty($que_lines)) { |
|
2124 | 2124 | upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines)); |
2125 | 2125 | } |
2126 | 2126 | |
@@ -2129,25 +2129,25 @@ discard block |
||
2129 | 2129 | ), $update_tables['users']['graviton_tech']); |
2130 | 2130 | } |
2131 | 2131 | |
2132 | - if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2132 | + if (!$update_indexes['unit']['I_unit_record_search']) { |
|
2133 | 2133 | upd_alter_table('unit', array( |
2134 | 2134 | "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
2135 | 2135 | ), !$update_indexes['unit']['I_unit_record_search']); |
2136 | 2136 | |
2137 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2137 | + foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2138 | 2138 | $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
2139 | 2139 | } |
2140 | 2140 | $drop_index = array(); |
2141 | 2141 | $create_index = &$drop_index; // array(); |
2142 | - foreach($planet_units as $unit_name => $unit_create) { |
|
2143 | - if($update_indexes['planets']['I_' . $unit_name]) { |
|
2142 | + foreach ($planet_units as $unit_name => $unit_create) { |
|
2143 | + if ($update_indexes['planets']['I_' . $unit_name]) { |
|
2144 | 2144 | $drop_index[] = "DROP KEY I_{$unit_name}"; |
2145 | 2145 | } |
2146 | - if($update_indexes['planets']['i_' . $unit_name]) { |
|
2146 | + if ($update_indexes['planets']['i_' . $unit_name]) { |
|
2147 | 2147 | $drop_index[] = "DROP KEY i_{$unit_name}"; |
2148 | 2148 | } |
2149 | 2149 | |
2150 | - if($unit_create) { |
|
2150 | + if ($unit_create) { |
|
2151 | 2151 | $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
2152 | 2152 | } |
2153 | 2153 | } |
@@ -2158,7 +2158,7 @@ discard block |
||
2158 | 2158 | "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
2159 | 2159 | ), !$update_tables['users']['user_time_utc_offset']); |
2160 | 2160 | |
2161 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2161 | + if (!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2162 | 2162 | upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
2163 | 2163 | |
2164 | 2164 | upd_alter_table('alliance', array( |
@@ -2178,7 +2178,7 @@ discard block |
||
2178 | 2178 | |
2179 | 2179 | upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
2180 | 2180 | |
2181 | - if(!$update_tables['player_name_history']) { |
|
2181 | + if (!$update_tables['player_name_history']) { |
|
2182 | 2182 | upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
2183 | 2183 | upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
2184 | 2184 | |
@@ -2207,7 +2207,7 @@ discard block |
||
2207 | 2207 | "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
2208 | 2208 | ), !$update_tables['planets']['density_index']); |
2209 | 2209 | |
2210 | - if($update_tables['users']['player_artifact_list']) { |
|
2210 | + if ($update_tables['users']['player_artifact_list']) { |
|
2211 | 2211 | upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
2212 | 2212 | |
2213 | 2213 | 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']); |
@@ -2217,14 +2217,14 @@ discard block |
||
2217 | 2217 | $db_changeset = array(); |
2218 | 2218 | |
2219 | 2219 | $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
2220 | - while($row = db_fetch($query)) { |
|
2220 | + while ($row = db_fetch($query)) { |
|
2221 | 2221 | $artifact_list = explode(';', $row['player_artifact_list']); |
2222 | - if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2222 | + if (!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2223 | 2223 | continue; |
2224 | 2224 | } |
2225 | - foreach($artifact_list as $key => &$value) { |
|
2225 | + foreach ($artifact_list as $key => &$value) { |
|
2226 | 2226 | $value = explode(',', $value); |
2227 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2227 | + if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2228 | 2228 | unset($artifact_list[$key]); |
2229 | 2229 | continue; |
2230 | 2230 | } |
@@ -2,25 +2,25 @@ discard block |
||
2 | 2 | |
3 | 3 | // ------------------------------------------------------------------------------------------------------------------------------ |
4 | 4 | function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) { |
5 | - if(file_exists($dir_name)) { |
|
5 | + if (file_exists($dir_name)) { |
|
6 | 6 | $dir = opendir($dir_name); |
7 | - while(($file = readdir($dir)) !== false) { |
|
8 | - if($file == '..' || $file == '.') { |
|
7 | + while (($file = readdir($dir)) !== false) { |
|
8 | + if ($file == '..' || $file == '.') { |
|
9 | 9 | continue; |
10 | 10 | } |
11 | 11 | |
12 | 12 | $full_filename = $dir_name . $file; |
13 | - if($modules && is_dir($full_filename)) { |
|
14 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
13 | + if ($modules && is_dir($full_filename)) { |
|
14 | + if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
15 | 15 | require_once($full_filename); |
16 | 16 | // Registering module |
17 | - if(class_exists($file)) { |
|
17 | + if (class_exists($file)) { |
|
18 | 18 | new $file($full_filename); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $extension = substr($full_filename, -strlen($load_extension)); |
23 | - if($extension == $load_extension) { |
|
23 | + if ($extension == $load_extension) { |
|
24 | 24 | require_once($full_filename); |
25 | 25 | } |
26 | 26 | } |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function init_update() { |
41 | 41 | $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; |
42 | - if(file_exists($update_file)) { |
|
43 | - if(filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | - if(defined('IN_ADMIN')) { |
|
42 | + if (file_exists($update_file)) { |
|
43 | + if (filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | + if (defined('IN_ADMIN')) { |
|
45 | 45 | sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована |
46 | - if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) { |
|
46 | + if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) { |
|
47 | 47 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW + (classSupernova::$config->upd_lock_time ? classSupernova::$config->upd_lock_time : 300)); |
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $current_time = time(); |
54 | 54 | classSupernova::$config->db_saveItem('var_db_update', $current_time); |
55 | 55 | classSupernova::$config->db_saveItem('var_db_update_end', $current_time); |
56 | - } elseif(filemtime($update_file) > classSupernova::$config->var_db_update) { |
|
56 | + } elseif (filemtime($update_file) > classSupernova::$config->var_db_update) { |
|
57 | 57 | $timeout = classSupernova::$config->var_db_update_end - SN_TIME_NOW; |
58 | 58 | die( |
59 | 59 | "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br /> |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
5 | +if (classSupernova::$config->game_mode == GAME_BLITZ) { |
|
6 | 6 | message(classLocale::$lang['sys_blitz_page_disabled'], classLocale::$lang['sys_error'], 'overview.php', 10); |
7 | 7 | die(); |
8 | 8 | } |
@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | |
15 | 15 | $mode = sys_get_param_str('mode'); |
16 | 16 | |
17 | -if($mode == 'ainfo') { |
|
17 | +if ($mode == 'ainfo') { |
|
18 | 18 | include('includes/alliance/ali_info.inc'); |
19 | 19 | } |
20 | 20 | |
21 | -if(!$user['ally_id']) { |
|
21 | +if (!$user['ally_id']) { |
|
22 | 22 | $user_request = db_ally_request_get_by_user_id($user['id']); |
23 | - if($user_request['id_user']) { |
|
23 | + if ($user_request['id_user']) { |
|
24 | 24 | require('includes/alliance/ali_external_request.inc'); |
25 | 25 | } else { |
26 | - switch($mode) { |
|
26 | + switch ($mode) { |
|
27 | 27 | case 'search': |
28 | 28 | require('includes/alliance/ali_external_search.inc'); |
29 | 29 | break; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | sn_ali_fill_user_ally($user); |
47 | -if(!isset($user['ally'])) { |
|
47 | +if (!isset($user['ally'])) { |
|
48 | 48 | db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_register_time` = 0, `ally_rank_id` = 0"); |
49 | 49 | message(classLocale::$lang['ali_sys_notFound'], classLocale::$lang['your_alliance'], 'alliance.php'); |
50 | 50 | } |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | |
73 | 73 | // This piece converting old ally data to new one |
74 | 74 | // unset($ally['ranklist']); |
75 | -if(!$ally['ranklist'] && $ally['ally_ranks']) { |
|
75 | +if (!$ally['ranklist'] && $ally['ally_ranks']) { |
|
76 | 76 | $ally_ranks = unserialize($ally['ally_ranks']); |
77 | 77 | $i = 0; |
78 | - foreach($ally_ranks as $rank_id => $rank) { |
|
79 | - foreach($ally_rights as $key => $value) { |
|
78 | + foreach ($ally_ranks as $rank_id => $rank) { |
|
79 | + foreach ($ally_rights as $key => $value) { |
|
80 | 80 | $ranks[$i][$value] = $rank[$rights_old[$key]]; |
81 | 81 | } |
82 | 82 | db_user_list_set_ally_deprecated_convert_ranks($user['ally_id'], $i, $rank_id); |
83 | 83 | $i++; |
84 | 84 | } |
85 | 85 | |
86 | - if(!empty($ranks)) { |
|
86 | + if (!empty($ranks)) { |
|
87 | 87 | ali_rank_list_save($ranks); |
88 | 88 | } |
89 | 89 | } |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | |
102 | 102 | $edit = sys_get_param_str('edit'); |
103 | 103 | ally_pre_call(); |
104 | -switch($mode) { |
|
104 | +switch ($mode) { |
|
105 | 105 | case 'admin': |
106 | - if(!array_key_exists($edit, $sn_ali_admin_internal)) { |
|
106 | + if (!array_key_exists($edit, $sn_ali_admin_internal)) { |
|
107 | 107 | $edit = 'default'; |
108 | 108 | } |
109 | - if($sn_ali_admin_internal[$edit]['include']) { |
|
109 | + if ($sn_ali_admin_internal[$edit]['include']) { |
|
110 | 110 | require("includes/{$sn_ali_admin_internal[$edit]['include']}"); |
111 | 111 | } |
112 | - if(isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) { |
|
112 | + if (isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) { |
|
113 | 113 | call_user_func($sn_ali_admin_internal[$edit]['function']); |
114 | 114 | } |
115 | 115 | break; |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | * @copyright 2008 by ??????? for XNova |
9 | 9 | */ |
10 | 10 | |
11 | -define('INSIDE' , true); |
|
12 | -define('INSTALL' , false); |
|
11 | +define('INSIDE', true); |
|
12 | +define('INSTALL', false); |
|
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
15 | 15 | |
16 | -if($user['authlevel'] < 3) { |
|
16 | +if ($user['authlevel'] < 3) { |
|
17 | 17 | AdminMessage(classLocale::$lang['adm_err_denied']); |
18 | 18 | } |
19 | 19 | |
20 | 20 | $template = gettemplate('admin/settings', true); |
21 | 21 | |
22 | -if(sys_get_param('save')) { |
|
22 | +if (sys_get_param('save')) { |
|
23 | 23 | classSupernova::$config->game_name = sys_get_param_str_unsafe('game_name'); |
24 | 24 | classSupernova::$config->game_mode = sys_get_param_int('game_mode'); |
25 | 25 | classSupernova::$config->game_speed = sys_get_param_float('game_speed', 1); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | classSupernova::$config->url_faq = sys_get_param_str_unsafe('url_faq'); |
30 | 30 | classSupernova::$config->url_forum = sys_get_param_str_unsafe('url_forum'); |
31 | 31 | classSupernova::$config->url_rules = sys_get_param_str_unsafe('url_rules'); |
32 | - classSupernova::$config->url_purchase_metamatter = sys_get_param_str_unsafe('url_purchase_metamatter'); |
|
32 | + classSupernova::$config->url_purchase_metamatter = sys_get_param_str_unsafe('url_purchase_metamatter'); |
|
33 | 33 | classSupernova::$config->game_disable = sys_get_param_int('game_disable'); |
34 | 34 | classSupernova::$config->game_disable_reason = sys_get_param_str_unsafe('game_disable_reason'); |
35 | 35 | classSupernova::$config->server_updater_check_auto = sys_get_param_int('server_updater_check_auto'); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | classSupernova::$config->stats_schedule = sys_get_param_str('stats_schedule'); |
97 | 97 | |
98 | 98 | classSupernova::$config->empire_mercenary_base_period = sys_get_param_int('empire_mercenary_base_period'); |
99 | - if(classSupernova::$config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { |
|
100 | - if(classSupernova::$config->empire_mercenary_temporary) { |
|
99 | + if (classSupernova::$config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { |
|
100 | + if (classSupernova::$config->empire_mercenary_temporary) { |
|
101 | 101 | db_unit_list_admin_delete_mercenaries_finished(); |
102 | 102 | } else { |
103 | 103 | db_unit_list_admin_set_mercenaries_expire_time(classSupernova::$config->empire_mercenary_base_period); |
@@ -138,21 +138,21 @@ discard block |
||
138 | 138 | 'STATS_HIDE_PM_LINK' => classSupernova::$config->stats_hide_pm_link, |
139 | 139 | )); |
140 | 140 | |
141 | -foreach(classLocale::$lang['sys_game_disable_reason'] as $id => $name) { |
|
141 | +foreach (classLocale::$lang['sys_game_disable_reason'] as $id => $name) { |
|
142 | 142 | $template->assign_block_vars('sys_game_disable_reason', array( |
143 | 143 | 'ID' => $id, |
144 | 144 | 'NAME' => $name, |
145 | 145 | )); |
146 | 146 | } |
147 | 147 | |
148 | -foreach(classLocale::$lang['sys_game_mode'] as $mode_id => $mode_name) { |
|
148 | +foreach (classLocale::$lang['sys_game_mode'] as $mode_id => $mode_name) { |
|
149 | 149 | $template->assign_block_vars('game_modes', array( |
150 | 150 | 'ID' => $mode_id, |
151 | 151 | 'NAME' => $mode_name, |
152 | 152 | )); |
153 | 153 | } |
154 | 154 | |
155 | -foreach(classLocale::$lang['adm_opt_ver_response'] as $ver_id => $ver_response) { |
|
155 | +foreach (classLocale::$lang['adm_opt_ver_response'] as $ver_id => $ver_response) { |
|
156 | 156 | $template->assign_block_vars('ver_response', array( |
157 | 157 | 'ID' => $ver_id, |
158 | 158 | 'NAME' => js_safe_string($ver_response), |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | $lang_list = lng_get_list(); |
163 | -foreach($lang_list as $lang_id => $lang_data) { |
|
163 | +foreach ($lang_list as $lang_id => $lang_data) { |
|
164 | 164 | $template->assign_block_vars('game_languages', array( |
165 | 165 | 'ID' => $lang_id, |
166 | 166 | 'NAME' => "{$lang_data['LANG_NAME_NATIVE']} ({$lang_data['LANG_NAME_ENGLISH']})", |
@@ -13,15 +13,15 @@ |
||
13 | 13 | . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
14 | 14 | |
15 | 15 | switch($mode) { |
16 | - case SNC_MODE_REGISTER: |
|
17 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | - if($ajax) { |
|
19 | - print(SNC_VER_REGISTER_ERROR_REGISTERED); |
|
16 | + case SNC_MODE_REGISTER: |
|
17 | + if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | + if($ajax) { |
|
19 | + print(SNC_VER_REGISTER_ERROR_REGISTERED); |
|
20 | + } |
|
21 | + die(); |
|
20 | 22 | } |
21 | - die(); |
|
22 | - } |
|
23 | - $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
24 | - break; |
|
23 | + $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
24 | + break; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $check_result = sn_get_url_contents($url); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | . '&key=' . urlencode(classSupernova::$config->server_updater_key) |
13 | 13 | . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
14 | 14 | |
15 | -switch($mode) { |
|
15 | +switch ($mode) { |
|
16 | 16 | case SNC_MODE_REGISTER: |
17 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | - if($ajax) { |
|
17 | + if (classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | + if ($ajax) { |
|
19 | 19 | print(SNC_VER_REGISTER_ERROR_REGISTERED); |
20 | 20 | } |
21 | 21 | die(); |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | $check_result = sn_get_url_contents($url); |
28 | -if(!$check_result) { |
|
28 | +if (!$check_result) { |
|
29 | 29 | $version_check = SNC_VER_ERROR_CONNECT; |
30 | -} elseif(($version_check = intval($check_result)) && $version_check == $check_result) { |
|
30 | +} elseif (($version_check = intval($check_result)) && $version_check == $check_result) { |
|
31 | 31 | $version_check = $check_result; |
32 | 32 | } else { |
33 | 33 | // JSON decode if string |
34 | 34 | $check_result = json_decode($check_result, true); |
35 | 35 | $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check']; |
36 | 36 | |
37 | - switch($mode) { |
|
37 | + switch ($mode) { |
|
38 | 38 | case SNC_MODE_REGISTER: |
39 | - if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
39 | + if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
40 | 40 | classSupernova::$config->db_saveItem('server_updater_key', $check_result['site']['site_key']); |
41 | 41 | classSupernova::$config->db_saveItem('server_updater_id', $check_result['site']['site_id']); |
42 | 42 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | classSupernova::$config->db_saveItem('server_updater_check_last', SN_TIME_NOW); |
50 | 50 | classSupernova::$config->db_saveItem('server_updater_check_result', $version_check); |
51 | 51 | |
52 | -if($ajax) { |
|
52 | +if ($ajax) { |
|
53 | 53 | define('IN_AJAX', true); |
54 | 54 | print($version_check); |
55 | 55 | } |
@@ -22,6 +22,10 @@ discard block |
||
22 | 22 | doquery('DELETE FROM `{{aks}}` WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM `{{fleets}}`);'); |
23 | 23 | } |
24 | 24 | |
25 | +/** |
|
26 | + * @param double $arrival |
|
27 | + * @param integer $target_structure |
|
28 | + */ |
|
25 | 29 | function db_missile_insert($target_coord, $user, $planetrow, $arrival, $fleet_ship_count, $target_structure) { |
26 | 30 | doquery( |
27 | 31 | "INSERT INTO `{{iraks}}` SET |
@@ -52,7 +56,7 @@ discard block |
||
52 | 56 | /** |
53 | 57 | * @param $user |
54 | 58 | * @param $planet_dst |
55 | - * @param $time_limit |
|
59 | + * @param integer $time_limit |
|
56 | 60 | * |
57 | 61 | * @return array|bool|mysqli_result|null |
58 | 62 | */ |
@@ -113,14 +117,14 @@ discard block |
||
113 | 117 | |
114 | 118 | |
115 | 119 | /** |
116 | - * @param $fleet_group_id_list |
|
120 | + * @param string $fleet_group_id_list |
|
117 | 121 | */ |
118 | 122 | function db_acs_delete_by_list($fleet_group_id_list) { |
119 | 123 | doquery("DELETE FROM {{aks}} WHERE `id` IN ({$fleet_group_id_list})"); |
120 | 124 | } |
121 | 125 | |
122 | 126 | /** |
123 | - * @param $bashing_list |
|
127 | + * @param string $bashing_list |
|
124 | 128 | */ |
125 | 129 | function db_bashing_insert($bashing_list) { |
126 | 130 | doquery("INSERT INTO {{bashing}} (bashing_user_id, bashing_planet_id, bashing_time) VALUES {$bashing_list};"); |
@@ -11,6 +11,9 @@ discard block |
||
11 | 11 | require_once('general/math.php'); |
12 | 12 | require_once('general_pname.php'); |
13 | 13 | |
14 | +/** |
|
15 | + * @param string $func_name |
|
16 | + */ |
|
14 | 17 | function sn_function_call($func_name, $func_arg = array()) { |
15 | 18 | // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
16 | 19 | |
@@ -57,6 +60,9 @@ discard block |
||
57 | 60 | |
58 | 61 | // ---------------------------------------------------------------------------------------------------------------- |
59 | 62 | // Fonction de lecture / ecriture / exploitation de templates |
63 | +/** |
|
64 | + * @param string $filename |
|
65 | + */ |
|
60 | 66 | function sys_file_read($filename) { |
61 | 67 | return @file_get_contents($filename); |
62 | 68 | } |
@@ -99,7 +105,7 @@ discard block |
||
99 | 105 | /** |
100 | 106 | * Получение курса обмены валюты в серверную валюту |
101 | 107 | * |
102 | - * @param $currency_symbol |
|
108 | + * @param string $currency_symbol |
|
103 | 109 | * |
104 | 110 | * @return float |
105 | 111 | */ |
@@ -140,7 +146,7 @@ discard block |
||
140 | 146 | * @param float $n |
141 | 147 | * @param int|bool $floor |
142 | 148 | * @param int|bool $color |
143 | - * @param int|bool $limit |
|
149 | + * @param boolean $limit |
|
144 | 150 | * @param bool|null $style |
145 | 151 | * |
146 | 152 | * @return array|float|string |
@@ -241,6 +247,9 @@ discard block |
||
241 | 247 | return preg_replace($ListCensure, '*', $String); |
242 | 248 | } |
243 | 249 | |
250 | +/** |
|
251 | + * @param string $email |
|
252 | + */ |
|
244 | 253 | function is_email($email) { |
245 | 254 | return (preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); |
246 | 255 | } |
@@ -273,6 +282,9 @@ discard block |
||
273 | 282 | return floatval(sys_get_param($param_name, $default)); |
274 | 283 | } |
275 | 284 | |
285 | +/** |
|
286 | + * @param string $param_name |
|
287 | + */ |
|
276 | 288 | function sys_get_param_escaped($param_name, $default = '') { |
277 | 289 | return db_escape(sys_get_param($param_name, $default)); |
278 | 290 | } |
@@ -505,6 +517,9 @@ discard block |
||
505 | 517 | } |
506 | 518 | |
507 | 519 | // Generates random string of $length symbols from $allowed_chars charset |
520 | +/** |
|
521 | + * @param string $allowed_chars |
|
522 | + */ |
|
508 | 523 | function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) { |
509 | 524 | $allowed_length = strlen($allowed_chars); |
510 | 525 | |
@@ -609,6 +624,9 @@ discard block |
||
609 | 624 | return implode(';', $fleet_string); |
610 | 625 | } |
611 | 626 | |
627 | +/** |
|
628 | + * @param string $body |
|
629 | + */ |
|
612 | 630 | function mymail($email_unsafe, $title, $body, $from = '', $html = false) { |
613 | 631 | $from = trim($from ? $from : classSupernova::$config->game_adminEmail); |
614 | 632 | |
@@ -863,6 +881,9 @@ discard block |
||
863 | 881 | return serialize($nick_array); |
864 | 882 | } |
865 | 883 | |
884 | +/** |
|
885 | + * @param string $nick_string |
|
886 | + */ |
|
866 | 887 | function player_nick_uncompact($nick_string) { |
867 | 888 | try { |
868 | 889 | $result = unserialize($nick_string); |
@@ -1110,6 +1131,9 @@ discard block |
||
1110 | 1131 | return $ranks; |
1111 | 1132 | } |
1112 | 1133 | |
1134 | +/** |
|
1135 | + * @param boolean $planet_id |
|
1136 | + */ |
|
1113 | 1137 | function sys_player_new_adjust($user_id, $planet_id) { return sn_function_call(__FUNCTION__, array($user_id, $planet_id, &$result)); } |
1114 | 1138 | |
1115 | 1139 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
@@ -1420,6 +1444,9 @@ discard block |
||
1420 | 1444 | return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2)); |
1421 | 1445 | } |
1422 | 1446 | |
1447 | +/** |
|
1448 | + * @param string $name |
|
1449 | + */ |
|
1423 | 1450 | function sn_setcookie($name, $value = null, $expire = null, $path = SN_ROOT_RELATIVE, $domain = null, $secure = null, $httponly = null) { |
1424 | 1451 | $_COOKIE[$name] = $value; |
1425 | 1452 |
@@ -14,24 +14,24 @@ discard block |
||
14 | 14 | function sn_function_call($func_name, $func_arg = array()) { |
15 | 15 | // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
16 | 16 | |
17 | - if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
17 | + if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
18 | 18 | // Chain-callable functions should be made as following: |
19 | 19 | // 1. Never use incomplete calls with parameters "by default" |
20 | 20 | // 2. Reserve last parameter for cumulative result |
21 | 21 | // 3. Use same format for original value and cumulative result (if there is original value) |
22 | 22 | // 4. Honor cumulative result |
23 | 23 | // 5. Return cumulative result |
24 | - foreach(classSupernova::$functions[$func_name] as $func_chain_name) { |
|
24 | + foreach (classSupernova::$functions[$func_name] as $func_chain_name) { |
|
25 | 25 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
26 | 26 | // Но для старых модулей... |
27 | - if(is_callable($func_chain_name)) { |
|
27 | + if (is_callable($func_chain_name)) { |
|
28 | 28 | $result = call_user_func_array($func_chain_name, $func_arg); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | } else { |
32 | 32 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
33 | 33 | $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name); |
34 | - if(is_callable($func_name)) { |
|
34 | + if (is_callable($func_name)) { |
|
35 | 35 | $result = call_user_func_array($func_name, $func_arg); |
36 | 36 | } |
37 | 37 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук |
47 | 47 | */ |
48 | 48 | function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { |
49 | - if(!empty($hook_list)) { |
|
50 | - foreach($hook_list as $hook) { |
|
51 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
49 | + if (!empty($hook_list)) { |
|
50 | + foreach ($hook_list as $hook) { |
|
51 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
52 | 52 | $template = call_user_func($hook_call, $template, $hook_type, $page_name); |
53 | 53 | } |
54 | 54 | } |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { |
149 | 149 | $n = floatval($n); |
150 | - if(is_int($floor)) { |
|
150 | + if (is_int($floor)) { |
|
151 | 151 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
152 | - } elseif($floor === true) { |
|
152 | + } elseif ($floor === true) { |
|
153 | 153 | $n = floor($n); |
154 | 154 | $floor = 0; |
155 | 155 | } else { |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | $ret = $n; |
160 | 160 | |
161 | 161 | $suffix = ''; |
162 | - if($limit) { |
|
163 | - if($ret > 0) { |
|
164 | - while($ret > $limit) { |
|
162 | + if ($limit) { |
|
163 | + if ($ret > 0) { |
|
164 | + while ($ret > $limit) { |
|
165 | 165 | $suffix .= 'k'; |
166 | 166 | $ret = round($ret / 1000); |
167 | 167 | } |
168 | 168 | } else { |
169 | - while($ret < -$limit) { |
|
169 | + while ($ret < -$limit) { |
|
170 | 170 | $suffix .= 'k'; |
171 | 171 | $ret = round($ret / 1000); |
172 | 172 | } |
@@ -176,16 +176,16 @@ discard block |
||
176 | 176 | $ret = number_format($ret, $floor, ',', '.'); |
177 | 177 | $ret .= $suffix; |
178 | 178 | |
179 | - if($color !== false) { |
|
180 | - if($color === true) { |
|
179 | + if ($color !== false) { |
|
180 | + if ($color === true) { |
|
181 | 181 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
182 | - } elseif($color >= 0) { |
|
182 | + } elseif ($color >= 0) { |
|
183 | 183 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
184 | 184 | } else { |
185 | 185 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
186 | 186 | } |
187 | 187 | |
188 | - if(!isset($style)) { |
|
188 | + if (!isset($style)) { |
|
189 | 189 | $ret = "<span class='{$class}'>{$ret}</span>"; |
190 | 190 | } else { |
191 | 191 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | |
315 | 315 | function sys_get_param_phone($param_name, $default = '') { |
316 | 316 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
317 | - if($phone_raw) { |
|
317 | + if ($phone_raw) { |
|
318 | 318 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
319 | - for($i = 0; $i < strlen($phone_raw); $i++) { |
|
319 | + for ($i = 0; $i < strlen($phone_raw); $i++) { |
|
320 | 320 | $ord = ord($phone_raw[$i]); |
321 | - if($ord >= 48 && $ord <= 57) { |
|
321 | + if ($ord >= 48 && $ord <= 57) { |
|
322 | 322 | $phone .= $phone_raw[$i]; |
323 | 323 | } |
324 | 324 | } |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | function CheckAbandonPlanetState(&$planet) { |
338 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
338 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
339 | 339 | db_planet_delete_by_id($planet['id']); |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | 343 | function eco_get_total_cost($unit_id, $unit_level) { |
344 | 344 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
345 | - if(!$rate) { |
|
345 | + if (!$rate) { |
|
346 | 346 | $sn_group_resources_all = sn_get_groups('resources_all'); |
347 | 347 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
348 | 348 | |
@@ -352,19 +352,19 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
355 | - if(!is_array($unit_cost_data)) { |
|
355 | + if (!is_array($unit_cost_data)) { |
|
356 | 356 | return array('total' => 0); |
357 | 357 | } |
358 | 358 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
359 | 359 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
360 | 360 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
361 | - foreach($unit_cost_data as $resource_id => $resource_amount) { |
|
362 | - if(!in_array($resource_id, $sn_group_resources_all)) { |
|
361 | + foreach ($unit_cost_data as $resource_id => $resource_amount) { |
|
362 | + if (!in_array($resource_id, $sn_group_resources_all)) { |
|
363 | 363 | continue; |
364 | 364 | } |
365 | 365 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
366 | 366 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
367 | - if(in_array($resource_id, $sn_group_resources_loot)) { |
|
367 | + if (in_array($resource_id, $sn_group_resources_loot)) { |
|
368 | 368 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
369 | 369 | } |
370 | 370 | } |
@@ -448,19 +448,19 @@ discard block |
||
448 | 448 | $mercenary_level = 0; |
449 | 449 | $unit_db_name = pname_resource_name($unit_id); |
450 | 450 | |
451 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
451 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
452 | 452 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
453 | 453 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
454 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
454 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
455 | 455 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
456 | 456 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
457 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
457 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
458 | 458 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
459 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
459 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
460 | 460 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
461 | - } elseif($unit_id == RES_METAMATTER) { |
|
461 | + } elseif ($unit_id == RES_METAMATTER) { |
|
462 | 462 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
463 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
463 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
464 | 464 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
465 | 465 | } |
466 | 466 | |
@@ -470,19 +470,19 @@ discard block |
||
470 | 470 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); } |
471 | 471 | |
472 | 472 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
473 | - if(!is_array($mercenaries)) { |
|
473 | + if (!is_array($mercenaries)) { |
|
474 | 474 | $mercenaries = array($mercenaries); |
475 | 475 | } |
476 | 476 | |
477 | 477 | $base_value = isset($base_value) ? $base_value : $value; |
478 | 478 | |
479 | - foreach($mercenaries as $mercenary_id) { |
|
479 | + foreach ($mercenaries as $mercenary_id) { |
|
480 | 480 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
481 | 481 | |
482 | 482 | $mercenary = get_unit_param($mercenary_id); |
483 | 483 | $mercenary_bonus = $mercenary['bonus']; |
484 | 484 | |
485 | - switch($mercenary['bonus_type']) { |
|
485 | + switch ($mercenary['bonus_type']) { |
|
486 | 486 | case BONUS_PERCENT_CUMULATIVE: |
487 | 487 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
488 | 488 | break; |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | $allowed_length = strlen($allowed_chars); |
514 | 514 | |
515 | 515 | $random_string = ''; |
516 | - for($i = 0; $i < $length; $i++) { |
|
516 | + for ($i = 0; $i < $length; $i++) { |
|
517 | 517 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
518 | 518 | } |
519 | 519 | |
@@ -533,12 +533,12 @@ discard block |
||
533 | 533 | |
534 | 534 | $options = ''; |
535 | 535 | $option_list = array(); |
536 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
536 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
537 | 537 | $option_list[$option_group_id] = array(); |
538 | - foreach($option_group as $option_name => $option_value) { |
|
539 | - if(!isset($user[$option_name])) { |
|
538 | + foreach ($option_group as $option_name => $option_value) { |
|
539 | + if (!isset($user[$option_name])) { |
|
540 | 540 | $user[$option_name] = $option_value; |
541 | - } elseif($user[$option_name] == '') { |
|
541 | + } elseif ($user[$option_name] == '') { |
|
542 | 542 | $user[$option_name] = 0; |
543 | 543 | } |
544 | 544 | $options .= "{$option_name}^{$user[$option_name]}|"; |
@@ -558,16 +558,16 @@ discard block |
||
558 | 558 | $option_list = array(); |
559 | 559 | $option_string_list = explode('|', $user['options']); |
560 | 560 | |
561 | - foreach($option_string_list as $option_string) { |
|
561 | + foreach ($option_string_list as $option_string) { |
|
562 | 562 | list($option_name, $option_value) = explode('^', $option_string); |
563 | 563 | $option_list[$option_name] = $option_value; |
564 | 564 | } |
565 | 565 | |
566 | 566 | $final_list = array(); |
567 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
567 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
568 | 568 | $final_list[$option_group_id] = array(); |
569 | - foreach($option_group as $option_name => $option_value) { |
|
570 | - if(!isset($option_list[$option_name])) { |
|
569 | + foreach ($option_group as $option_name => $option_value) { |
|
570 | + if (!isset($option_list[$option_name])) { |
|
571 | 571 | $option_list[$option_name] = $option_value; |
572 | 572 | } |
573 | 573 | $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name]; |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | |
582 | 582 | function sys_unit_str2arr($fleet_string) { |
583 | 583 | $fleet_array = array(); |
584 | - if(!empty($fleet_string)) { |
|
584 | + if (!empty($fleet_string)) { |
|
585 | 585 | $arrTemp = explode(';', $fleet_string); |
586 | - foreach($arrTemp as $temp) { |
|
587 | - if($temp) { |
|
586 | + foreach ($arrTemp as $temp) { |
|
587 | + if ($temp) { |
|
588 | 588 | $temp = explode(',', $temp); |
589 | - if(!empty($temp[0]) && !empty($temp[1])) { |
|
589 | + if (!empty($temp[0]) && !empty($temp[1])) { |
|
590 | 590 | $fleet_array[$temp[0]] += $temp[1]; |
591 | 591 | } |
592 | 592 | } |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | |
599 | 599 | function sys_unit_arr2str($unit_list) { |
600 | 600 | $fleet_string = array(); |
601 | - if(isset($unit_list)) { |
|
602 | - if(!is_array($unit_list)) { |
|
601 | + if (isset($unit_list)) { |
|
602 | + if (!is_array($unit_list)) { |
|
603 | 603 | $unit_list = array($unit_list => 1); |
604 | 604 | } |
605 | 605 | |
606 | - foreach($unit_list as $unit_id => $unit_count) { |
|
607 | - if($unit_id && $unit_count) { |
|
606 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
607 | + if ($unit_id && $unit_count) { |
|
608 | 608 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
609 | 609 | } |
610 | 610 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | $body = str_replace("\r\n", "\n", $body); |
631 | 631 | $body = str_replace("\n", "\r\n", $body); |
632 | 632 | |
633 | - if($html) { |
|
633 | + if ($html) { |
|
634 | 634 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
635 | 635 | } |
636 | 636 | |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | function sn_ali_fill_user_ally(&$user) { |
677 | - if(!$user['ally_id']) { |
|
677 | + if (!$user['ally_id']) { |
|
678 | 678 | return; |
679 | 679 | } |
680 | 680 | |
681 | - if(!isset($user['ally'])) { |
|
681 | + if (!isset($user['ally'])) { |
|
682 | 682 | $user['ally'] = db_ally_get_by_id($user['ally_id']); |
683 | 683 | } |
684 | 684 | |
685 | - if(!isset($user['ally']['player'])) { |
|
685 | + if (!isset($user['ally']['player'])) { |
|
686 | 686 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | function sn_get_url_contents($url) { |
691 | - if(function_exists('curl_init')) { |
|
691 | + if (function_exists('curl_init')) { |
|
692 | 692 | $crl = curl_init(); |
693 | 693 | $timeout = 5; |
694 | 694 | curl_setopt($crl, CURLOPT_URL, $url); |
@@ -723,10 +723,10 @@ discard block |
||
723 | 723 | |
724 | 724 | function get_ship_data($ship_id, $user) { |
725 | 725 | $ship_data = array(); |
726 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
727 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) { |
|
726 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
727 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) { |
|
728 | 728 | $tech_level = intval(mrc_get_level($user, null, $engine_info['tech'])); |
729 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
729 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
730 | 730 | $ship_data = $engine_info; |
731 | 731 | $ship_data['tech_level'] = $tech_level; |
732 | 732 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | return $ship_data; |
739 | 739 | } |
740 | 740 | |
741 | -if(!function_exists('strptime')) { |
|
741 | +if (!function_exists('strptime')) { |
|
742 | 742 | function strptime($date, $format) { |
743 | 743 | $masks = array( |
744 | 744 | '%d' => '(?P<d>[0-9]{2})', |
@@ -751,12 +751,12 @@ discard block |
||
751 | 751 | ); |
752 | 752 | |
753 | 753 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
754 | - if(preg_match($rexep, $date, $out)) { |
|
754 | + if (preg_match($rexep, $date, $out)) { |
|
755 | 755 | $ret = array( |
756 | - "tm_sec" => (int)$out['S'], |
|
757 | - "tm_min" => (int)$out['M'], |
|
758 | - "tm_hour" => (int)$out['H'], |
|
759 | - "tm_mday" => (int)$out['d'], |
|
756 | + "tm_sec" => (int) $out['S'], |
|
757 | + "tm_min" => (int) $out['M'], |
|
758 | + "tm_hour" => (int) $out['H'], |
|
759 | + "tm_mday" => (int) $out['d'], |
|
760 | 760 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
761 | 761 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
762 | 762 | ); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | function sn_sys_sector_buy($redirect = 'overview.php') { |
772 | 772 | global $user, $planetrow; |
773 | 773 | |
774 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
774 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
775 | 775 | return; |
776 | 776 | } |
777 | 777 | |
@@ -784,9 +784,9 @@ discard block |
||
784 | 784 | // $planetrow = $planetrow['planet']; |
785 | 785 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
786 | 786 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
787 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
787 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
788 | 788 | $planet_name_text = uni_render_planet($planetrow); |
789 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
789 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
790 | 790 | $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
791 | 791 | )) { |
792 | 792 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -801,30 +801,30 @@ discard block |
||
801 | 801 | } |
802 | 802 | |
803 | 803 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
804 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
805 | - foreach($handler_list as $function_name => $function_data) { |
|
806 | - if(is_string($function_data)) { |
|
804 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
805 | + foreach ($handler_list as $function_name => $function_data) { |
|
806 | + if (is_string($function_data)) { |
|
807 | 807 | $override_with = &$function_data; |
808 | - } elseif(isset($function_data['callable'])) { |
|
808 | + } elseif (isset($function_data['callable'])) { |
|
809 | 809 | $override_with = &$function_data['callable']; |
810 | 810 | } |
811 | 811 | |
812 | 812 | $overwrite = $override_with[0] == '*'; |
813 | - if($overwrite) { |
|
813 | + if ($overwrite) { |
|
814 | 814 | $override_with = substr($override_with, 1); |
815 | 815 | } |
816 | 816 | |
817 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
817 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
818 | 818 | $override_with = array($class_module_name, $override_with); |
819 | - } elseif($point_position == 0) { |
|
819 | + } elseif ($point_position == 0) { |
|
820 | 820 | $override_with = substr($override_with, 1); |
821 | - } elseif($point_position > 0) { |
|
821 | + } elseif ($point_position > 0) { |
|
822 | 822 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
823 | 823 | } |
824 | 824 | |
825 | - if($overwrite) { |
|
825 | + if ($overwrite) { |
|
826 | 826 | $functions[$function_name] = array(); |
827 | - } elseif(!isset($functions[$function_name])) { |
|
827 | + } elseif (!isset($functions[$function_name])) { |
|
828 | 828 | $functions[$function_name] = array(); |
829 | 829 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
830 | 830 | $functions[$function_name][] = $sn_function_name; |
@@ -840,15 +840,15 @@ discard block |
||
840 | 840 | function player_nick_render_to_html($result, $options = false) { |
841 | 841 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
842 | 842 | |
843 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
843 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
844 | 844 | $result = player_nick_uncompact($result); |
845 | 845 | } |
846 | 846 | |
847 | - if(is_array($result)) { |
|
848 | - if(isset($result['id'])) { |
|
847 | + if (is_array($result)) { |
|
848 | + if (isset($result['id'])) { |
|
849 | 849 | $result = player_nick_render_current_to_array($result, $options); |
850 | 850 | } |
851 | - if(!isset($result[NICK_HTML])) { |
|
851 | + if (!isset($result[NICK_HTML])) { |
|
852 | 852 | $result = player_nick_render_array_to_html($result); |
853 | 853 | } |
854 | 854 | unset($result[NICK_HTML]); |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | try { |
872 | 872 | $result = unserialize($nick_string); |
873 | 873 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
874 | - } catch(exception $e) { |
|
874 | + } catch (exception $e) { |
|
875 | 875 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
876 | 876 | } |
877 | 877 | |
@@ -884,20 +884,20 @@ discard block |
||
884 | 884 | global $user; |
885 | 885 | |
886 | 886 | // ALL STRING ARE UNSAFE!!! |
887 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
887 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
888 | 888 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
889 | 889 | } |
890 | 890 | |
891 | - if(isset($nick_array[NICK_VACATION])) { |
|
891 | + if (isset($nick_array[NICK_VACATION])) { |
|
892 | 892 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
893 | 893 | } |
894 | 894 | |
895 | - if(isset($nick_array[NICK_GENDER])) { |
|
895 | + if (isset($nick_array[NICK_GENDER])) { |
|
896 | 896 | $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
897 | 897 | } |
898 | 898 | |
899 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
900 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
899 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
900 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
901 | 901 | case 4: |
902 | 902 | $highlight = classSupernova::$config->chat_highlight_developer; |
903 | 903 | break; |
@@ -918,20 +918,20 @@ discard block |
||
918 | 918 | $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : ''; |
919 | 919 | } |
920 | 920 | |
921 | - if($highlight) { |
|
921 | + if ($highlight) { |
|
922 | 922 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
923 | 923 | } |
924 | 924 | // $result = preg_replace("#(.+)#", $highlight, $result); |
925 | 925 | } |
926 | 926 | |
927 | - if(isset($nick_array[NICK_CLASS])) { |
|
927 | + if (isset($nick_array[NICK_CLASS])) { |
|
928 | 928 | $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
929 | 929 | $result[NICK_CLASS_END] = '</span>'; |
930 | 930 | } |
931 | 931 | |
932 | 932 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
933 | 933 | |
934 | - if(isset($nick_array[NICK_ALLY])) { |
|
934 | + if (isset($nick_array[NICK_ALLY])) { |
|
935 | 935 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
936 | 936 | } |
937 | 937 | |
@@ -955,32 +955,32 @@ discard block |
||
955 | 955 | */ |
956 | 956 | |
957 | 957 | |
958 | - if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
958 | + if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
959 | 959 | $result[NICK_BIRTHSDAY] = ''; |
960 | 960 | } |
961 | 961 | |
962 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
962 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
963 | 963 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
964 | 964 | } |
965 | 965 | |
966 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
966 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
967 | 967 | $result[NICK_VACATION] = $render_user['vacation']; |
968 | 968 | } |
969 | 969 | |
970 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
971 | - if($user_auth_level = $render_user['authlevel']) { |
|
970 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
971 | + if ($user_auth_level = $render_user['authlevel']) { |
|
972 | 972 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
973 | 973 | } |
974 | - if($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { |
|
974 | + if ($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { |
|
975 | 975 | $result[NICK_PREMIUM] = $user_premium; |
976 | 976 | } |
977 | 977 | } |
978 | 978 | |
979 | - if((isset($options['class']) && $options['class'])) { |
|
979 | + if ((isset($options['class']) && $options['class'])) { |
|
980 | 980 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
981 | 981 | } |
982 | 982 | |
983 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
983 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
984 | 984 | $result[NICK_ALLY] = $render_user['ally_tag']; |
985 | 985 | } |
986 | 986 | |
@@ -996,25 +996,25 @@ discard block |
||
996 | 996 | |
997 | 997 | $user_skip_list = array(); |
998 | 998 | |
999 | - if(classSupernova::$config->stats_hide_admins) { |
|
999 | + if (classSupernova::$config->stats_hide_admins) { |
|
1000 | 1000 | $user_skip_list[] = '`authlevel` > 0'; |
1001 | 1001 | } |
1002 | 1002 | |
1003 | - if(classSupernova::$config->stats_hide_player_list) { |
|
1003 | + if (classSupernova::$config->stats_hide_player_list) { |
|
1004 | 1004 | $temp = explode(',', classSupernova::$config->stats_hide_player_list); |
1005 | - foreach($temp as $user_id) { |
|
1005 | + foreach ($temp as $user_id) { |
|
1006 | 1006 | $user_id = floatval($user_id); |
1007 | - if($user_id) { |
|
1007 | + if ($user_id) { |
|
1008 | 1008 | $user_skip_list[] = '`id` = ' . $user_id; |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if(!empty($user_skip_list)) { |
|
1013 | + if (!empty($user_skip_list)) { |
|
1014 | 1014 | $user_skip_list = implode(' OR ', $user_skip_list); |
1015 | 1015 | $user_skip_query = db_user_list($user_skip_list); |
1016 | - if(!empty($user_skip_query)) { |
|
1017 | - foreach($user_skip_query as $user_skip_row) { |
|
1016 | + if (!empty($user_skip_query)) { |
|
1017 | + foreach ($user_skip_query as $user_skip_row) { |
|
1018 | 1018 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
1019 | 1019 | } |
1020 | 1020 | } |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | |
1046 | 1046 | function sn_sn_get_groups($groups, &$result) { |
1047 | 1047 | $result = is_array($result) ? $result : array(); |
1048 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
1048 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
1049 | 1049 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
1050 | 1050 | } |
1051 | 1051 | |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | $sn_data_unit = get_unit_param($unit_id); |
1072 | 1072 | |
1073 | 1073 | $result = is_array($result) ? $result : array(); |
1074 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) { |
|
1075 | - foreach($sn_data_unit[$field] as $require_id => $require_level) { |
|
1074 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) { |
|
1075 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) { |
|
1076 | 1076 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
1077 | 1077 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
1078 | 1078 | $result[] = array( |
@@ -1096,16 +1096,16 @@ discard block |
||
1096 | 1096 | |
1097 | 1097 | $ranks = array(); |
1098 | 1098 | |
1099 | - if($ally['ranklist']) { |
|
1099 | + if ($ally['ranklist']) { |
|
1100 | 1100 | $str_ranks = explode(';', $ally['ranklist']); |
1101 | - foreach($str_ranks as $str_rank) { |
|
1102 | - if(!$str_rank) { |
|
1101 | + foreach ($str_ranks as $str_rank) { |
|
1102 | + if (!$str_rank) { |
|
1103 | 1103 | continue; |
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | $tmp = explode(',', $str_rank); |
1107 | 1107 | $rank_id = count($ranks); |
1108 | - foreach($ally_rights as $key => $value) { |
|
1108 | + foreach ($ally_rights as $key => $value) { |
|
1109 | 1109 | $ranks[$rank_id][$value] = $tmp[$key]; |
1110 | 1110 | } |
1111 | 1111 | } |
@@ -1121,8 +1121,8 @@ discard block |
||
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | function array_merge_recursive_numeric($array1, $array2) { |
1124 | - if(!empty($array2) && is_array($array2)) { |
|
1125 | - foreach($array2 as $key => $value) { |
|
1124 | + if (!empty($array2) && is_array($array2)) { |
|
1125 | + foreach ($array2 as $key => $value) { |
|
1126 | 1126 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
1127 | 1127 | // $array1[$key] = $value; |
1128 | 1128 | // } else { |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | |
1138 | 1138 | function sn_sys_array_cumulative_sum(&$array) { |
1139 | 1139 | $accum = 0; |
1140 | - foreach($array as &$value) { |
|
1140 | + foreach ($array as &$value) { |
|
1141 | 1141 | $accum += $value; |
1142 | 1142 | $value = $accum; |
1143 | 1143 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | $sn_data_density = sn_get_groups('planet_density'); |
1148 | 1148 | $density_price_chart = array(); |
1149 | 1149 | |
1150 | - foreach($sn_data_density as $density_id => $density_data) { |
|
1150 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
1151 | 1151 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
1152 | 1152 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
1153 | 1153 | } |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | |
1156 | 1156 | $total_rarity = array_sum($density_price_chart); |
1157 | 1157 | |
1158 | - foreach($density_price_chart as &$density_data) { |
|
1158 | + foreach ($density_price_chart as &$density_data) { |
|
1159 | 1159 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
1160 | 1160 | } |
1161 | 1161 | |
@@ -1163,16 +1163,16 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
1166 | - if(!sys_get_param_str('transmute')) { |
|
1166 | + if (!sys_get_param_str('transmute')) { |
|
1167 | 1167 | return array(); |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | try { |
1171 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
1171 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
1172 | 1172 | throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR); |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
1175 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
1176 | 1176 | throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING); |
1177 | 1177 | } |
1178 | 1178 | |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $planet_density_index = $planetrow['density_index']; |
1187 | 1187 | |
1188 | 1188 | $density_price_chart = planet_density_price_chart($planetrow); |
1189 | - if(!isset($density_price_chart[$new_density_index])) { |
|
1189 | + if (!isset($density_price_chart[$new_density_index])) { |
|
1190 | 1190 | // Hack attempt |
1191 | 1191 | throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
1192 | 1192 | } |
@@ -1195,13 +1195,13 @@ discard block |
||
1195 | 1195 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
1196 | 1196 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
1197 | 1197 | $transmute_cost = $density_price_chart[$new_density_index]; |
1198 | - if($user_dark_matter < $transmute_cost) { |
|
1198 | + if ($user_dark_matter < $transmute_cost) { |
|
1199 | 1199 | throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | $sn_data_planet_density = sn_get_groups('planet_density'); |
1203 | - foreach($sn_data_planet_density as $key => $value) { |
|
1204 | - if($key == $new_density_index) { |
|
1203 | + foreach ($sn_data_planet_density as $key => $value) { |
|
1204 | + if ($key == $new_density_index) { |
|
1205 | 1205 | break; |
1206 | 1206 | } |
1207 | 1207 | $prev_density_index = $key; |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | 'STATUS' => ERR_NONE, |
1233 | 1233 | 'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density), |
1234 | 1234 | ); |
1235 | - } catch(exception $e) { |
|
1235 | + } catch (exception $e) { |
|
1236 | 1236 | sn_db_transaction_rollback(); |
1237 | 1237 | $result = array( |
1238 | 1238 | 'STATUS' => $e->getCode(), |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | |
1246 | 1246 | function sn_module_get_active_count($group = '*') { |
1247 | 1247 | $active_modules = 0; |
1248 | - if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
1249 | - foreach(sn_module::$sn_module_list[$group] as $payment_module) { |
|
1248 | + if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
1249 | + foreach (sn_module::$sn_module_list[$group] as $payment_module) { |
|
1250 | 1250 | $active_modules += $payment_module->manifest['active']; |
1251 | 1251 | } |
1252 | 1252 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | function get_resource_exchange() { |
1258 | 1258 | static $rates; |
1259 | 1259 | |
1260 | - if(!$rates) { |
|
1260 | + if (!$rates) { |
|
1261 | 1261 | $rates = array( |
1262 | 1262 | RES_METAL => 'rpg_exchange_metal', |
1263 | 1263 | RES_CRYSTAL => 'rpg_exchange_crystal', |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
1266 | 1266 | ); |
1267 | 1267 | |
1268 | - foreach($rates as &$rate) { |
|
1268 | + foreach ($rates as &$rate) { |
|
1269 | 1269 | $rate = classSupernova::$config->$rate; |
1270 | 1270 | } |
1271 | 1271 | } |
@@ -1276,12 +1276,12 @@ discard block |
||
1276 | 1276 | function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
1277 | 1277 | static $rates; |
1278 | 1278 | |
1279 | - if(!$rates) { |
|
1279 | + if (!$rates) { |
|
1280 | 1280 | $rates = get_resource_exchange(); |
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | $metal_cost = 0; |
1284 | - foreach($cost as $resource_id => $resource_value) { |
|
1284 | + foreach ($cost as $resource_id => $resource_value) { |
|
1285 | 1285 | $metal_cost += $rates[$resource_id] * $resource_value; |
1286 | 1286 | } |
1287 | 1287 | |
@@ -1291,8 +1291,8 @@ discard block |
||
1291 | 1291 | function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); } |
1292 | 1292 | |
1293 | 1293 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
1294 | - if($astrotech == -1) { |
|
1295 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
1294 | + if ($astrotech == -1) { |
|
1295 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
1296 | 1296 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH); |
1297 | 1297 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
1298 | 1298 | } |
@@ -1308,8 +1308,8 @@ discard block |
||
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | function get_player_max_colonies(&$user, $astrotech = -1) { |
1311 | - if($astrotech == -1) { |
|
1312 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
1311 | + if ($astrotech == -1) { |
|
1312 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
1313 | 1313 | |
1314 | 1314 | $expeditions = get_player_max_expeditons($user); |
1315 | 1315 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH); |
@@ -1354,10 +1354,10 @@ discard block |
||
1354 | 1354 | |
1355 | 1355 | // pdump($powerup_unit, '$powerup_unit'); |
1356 | 1356 | $level_current = $term_original = $time_left = 0; |
1357 | - if($is_upgrade) { |
|
1357 | + if ($is_upgrade) { |
|
1358 | 1358 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
1359 | 1359 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
1360 | - if($time_left > 0) { |
|
1360 | + if ($time_left > 0) { |
|
1361 | 1361 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
1362 | 1362 | $level_current = $powerup_unit['unit_level']; |
1363 | 1363 | } |
@@ -1365,22 +1365,22 @@ discard block |
||
1365 | 1365 | |
1366 | 1366 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
1367 | 1367 | $original_cost = 0; |
1368 | - for($i = 1; $i <= $level_max; $i++) { |
|
1368 | + for ($i = 1; $i <= $level_max; $i++) { |
|
1369 | 1369 | $base_cost = eco_get_total_cost($powerup_id, $i); |
1370 | 1370 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
1371 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
1371 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
1372 | 1372 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
1373 | 1373 | $result[$i][$period] = $upgrade_price; |
1374 | 1374 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | |
1378 | - if($is_upgrade && $time_left) { |
|
1378 | + if ($is_upgrade && $time_left) { |
|
1379 | 1379 | $term_original = round($term_original / PERIOD_DAY); |
1380 | 1380 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
1381 | 1381 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
1382 | 1382 | |
1383 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
1383 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
1384 | 1384 | $value -= $cost_left; |
1385 | 1385 | }); |
1386 | 1386 | } |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | |
1437 | 1437 | function print_rr($var, $capture = false) { |
1438 | 1438 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
1439 | - if($capture) { |
|
1439 | + if ($capture) { |
|
1440 | 1440 | return $print; |
1441 | 1441 | } else { |
1442 | 1442 | print($print); |
@@ -1515,8 +1515,8 @@ discard block |
||
1515 | 1515 | * @return mixed |
1516 | 1516 | */ |
1517 | 1517 | function sortUnitRenderedList(&$ListToSort, $sort_option, $sort_option_inverse) { |
1518 | - if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
1519 | - switch($sort_option) { |
|
1518 | + if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
1519 | + switch ($sort_option) { |
|
1520 | 1520 | case PLAYER_OPTION_SORT_NAME: |
1521 | 1521 | $sort_option_field = 'NAME'; |
1522 | 1522 | break; |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | break; |
1538 | 1538 | } |
1539 | 1539 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1; |
1540 | - usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
1540 | + usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
1541 | 1541 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : ( |
1542 | 1542 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0 |
1543 | 1543 | ); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * @param $query |
|
127 | + * @param string $query |
|
128 | 128 | * |
129 | 129 | * @return mixed |
130 | 130 | */ |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | - * @param $query |
|
144 | - * @param $fetch |
|
143 | + * @param string $query |
|
144 | + * @param boolean $fetch |
|
145 | 145 | */ |
146 | 146 | public function logQuery($query, $fetch) { |
147 | 147 | if(!classSupernova::$config->debug) { |
@@ -204,6 +204,10 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | // TODO Заменить это на новый логгер |
207 | + |
|
208 | + /** |
|
209 | + * @param string $query |
|
210 | + */ |
|
207 | 211 | function security_watch_user_queries($query) { |
208 | 212 | global $user; |
209 | 213 | |
@@ -227,6 +231,9 @@ discard block |
||
227 | 231 | } |
228 | 232 | |
229 | 233 | |
234 | + /** |
|
235 | + * @param string $query |
|
236 | + */ |
|
230 | 237 | function security_query_check_bad_words($query) { |
231 | 238 | global $user, $dm_change_legit, $mm_change_legit; |
232 | 239 |
@@ -73,23 +73,23 @@ discard block |
||
73 | 73 | public function sn_db_connect($external_db_settings = null) { |
74 | 74 | $this->db_disconnect(); |
75 | 75 | |
76 | - if(!empty($external_db_settings) && is_array($external_db_settings)) { |
|
76 | + if (!empty($external_db_settings) && is_array($external_db_settings)) { |
|
77 | 77 | $this->dbsettings = $external_db_settings; |
78 | 78 | } |
79 | 79 | |
80 | - if(empty($this->dbsettings)) { |
|
80 | + if (empty($this->dbsettings)) { |
|
81 | 81 | $this->load_db_settings(); |
82 | 82 | } |
83 | 83 | |
84 | 84 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
85 | - if(!empty($this->dbsettings)) { |
|
85 | + if (!empty($this->dbsettings)) { |
|
86 | 86 | $driver_name = empty($this->dbsettings['sn_driver']) ? 'db_mysql_v5' : $this->dbsettings['sn_driver']; |
87 | 87 | $this->driver = new $driver_name(); |
88 | 88 | $this->db_prefix = $this->dbsettings['prefix']; |
89 | 89 | |
90 | 90 | $this->connected = $this->connected || $this->driver_connect(); |
91 | 91 | |
92 | - if($this->connected) { |
|
92 | + if ($this->connected) { |
|
93 | 93 | $this->table_list = $this->db_get_table_list(); |
94 | 94 | // TODO Проверка на пустоту |
95 | 95 | } |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | protected function driver_connect() { |
104 | 104 | global $debug; |
105 | 105 | |
106 | - if(!is_object($this->driver)) { |
|
106 | + if (!is_object($this->driver)) { |
|
107 | 107 | $debug->error_fatal('DB Error - No driver for MySQL found!'); |
108 | 108 | } |
109 | 109 | |
110 | - if(!method_exists($this->driver, 'mysql_connect')) { |
|
110 | + if (!method_exists($this->driver, 'mysql_connect')) { |
|
111 | 111 | $debug->error_fatal('DB Error - WRONG MySQL driver!'); |
112 | 112 | } |
113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public function db_disconnect() { |
118 | - if($this->connected) { |
|
118 | + if ($this->connected) { |
|
119 | 119 | $this->connected = !$this->driver_disconnect(); |
120 | 120 | $this->connected = false; |
121 | 121 | } |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function replaceTablePlaceholders($query) { |
132 | 132 | $sql = $query; |
133 | - if(strpos($sql, '{{') !== false) { |
|
134 | - foreach($this->table_list as $tableName) { |
|
133 | + if (strpos($sql, '{{') !== false) { |
|
134 | + foreach ($this->table_list as $tableName) { |
|
135 | 135 | $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
136 | 136 | } |
137 | 137 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param $fetch |
145 | 145 | */ |
146 | 146 | protected function logQuery($query, $fetch) { |
147 | - if(!classSupernova::$config->debug) { |
|
147 | + if (!classSupernova::$config->debug) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | * @return void |
163 | 163 | */ |
164 | 164 | protected function commentQuery(&$sql) { |
165 | - if(!defined('DEBUG_SQL_COMMENT')) { |
|
165 | + if (!defined('DEBUG_SQL_COMMENT')) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | $backtrace = debug_backtrace(); |
169 | 169 | $sql_comment = classSupernova::$debug->compact_backtrace($backtrace, defined('DEBUG_SQL_COMMENT_LONG')); |
170 | 170 | |
171 | 171 | $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ ' . preg_replace("/\s+/", ' ', $sql); |
172 | - if(defined('DEBUG_SQL_ONLINE')) { |
|
172 | + if (defined('DEBUG_SQL_ONLINE')) { |
|
173 | 173 | classSupernova::$debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL); |
174 | 174 | } |
175 | 175 | |
176 | - if(defined('DEBUG_SQL_ERROR')) { |
|
176 | + if (defined('DEBUG_SQL_ERROR')) { |
|
177 | 177 | array_unshift($sql_comment, preg_replace("/\s+/", ' ', $sql)); |
178 | 178 | classSupernova::$debug->add_to_array($sql_comment); |
179 | 179 | } |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | public function doquery($query, $table = '', $fetch = false, $skip_query_check = false) { |
185 | - if(!is_string($table)) { |
|
185 | + if (!is_string($table)) { |
|
186 | 186 | $fetch = $table; |
187 | 187 | } |
188 | 188 | |
189 | - if(!$this->connected) { |
|
189 | + if (!$this->connected) { |
|
190 | 190 | $this->sn_db_connect(); |
191 | 191 | } |
192 | 192 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | protected function security_watch_user_queries($query) { |
208 | 208 | global $user; |
209 | 209 | |
210 | - if( |
|
210 | + if ( |
|
211 | 211 | !$this->isWatching // Not already watching |
212 | 212 | && !empty(classSupernova::$config->game_watchlist_array) // There is some players in watchlist |
213 | 213 | && in_array($user['id'], classSupernova::$config->game_watchlist_array) // Current player is in watchlist |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | ) { |
216 | 216 | $this->isWatching = true; |
217 | 217 | $msg = "\$query = \"{$query}\"\n\r"; |
218 | - if(!empty($_POST)) { |
|
218 | + if (!empty($_POST)) { |
|
219 | 219 | $msg .= "\n\r" . dump($_POST, '$_POST'); |
220 | 220 | } |
221 | - if(!empty($_GET)) { |
|
221 | + if (!empty($_GET)) { |
|
222 | 222 | $msg .= "\n\r" . dump($_GET, '$_GET'); |
223 | 223 | } |
224 | 224 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function security_query_check_bad_words($query) { |
231 | 231 | global $user, $dm_change_legit, $mm_change_legit; |
232 | 232 | |
233 | - switch(true) { |
|
233 | + switch (true) { |
|
234 | 234 | case stripos($query, 'RUNCATE TABL') != false: |
235 | 235 | case stripos($query, 'ROP TABL') != false: |
236 | 236 | case stripos($query, 'ENAME TABL') != false: |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | $prefix_length = strlen($this->db_prefix); |
293 | 293 | |
294 | 294 | $tl = array(); |
295 | - while($row = $this->db_fetch($query)) { |
|
296 | - foreach($row as $table_name) { |
|
297 | - if(strpos($table_name, $this->db_prefix) === 0) { |
|
295 | + while ($row = $this->db_fetch($query)) { |
|
296 | + foreach ($row as $table_name) { |
|
297 | + if (strpos($table_name, $this->db_prefix) === 0) { |
|
298 | 298 | $table_name = substr($table_name, $prefix_length); |
299 | - } elseif($prefixed_only) { |
|
299 | + } elseif ($prefixed_only) { |
|
300 | 300 | continue; |
301 | 301 | } |
302 | 302 | // $table_name = str_replace($db_prefix, '', $table_name); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $result = array(); |
392 | 392 | |
393 | 393 | $status = explode(' ', $this->driver->mysql_stat()); |
394 | - foreach($status as $value) { |
|
394 | + foreach ($status as $value) { |
|
395 | 395 | $row = explode(': ', $value); |
396 | 396 | $result[$row[0]] = $row[1]; |
397 | 397 | } |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | $result = array(); |
408 | 408 | |
409 | 409 | $query = $this->db_sql_query('SHOW STATUS;'); |
410 | - if(is_bool($query)) { |
|
410 | + if (is_bool($query)) { |
|
411 | 411 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
412 | 412 | } |
413 | - while($row = db_fetch($query)) { |
|
413 | + while ($row = db_fetch($query)) { |
|
414 | 414 | $result[$row['Variable_name']] = $row['Value']; |
415 | 415 | } |
416 | 416 |