Passed
Push — master ( a34f24...bc874f )
by SuperNova.WS
04:20
created
includes/update.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 }
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 //$config->db_loadItem('db_version');
43
-if($config->db_version == DB_VERSION) {
44
-} elseif($config->db_version > DB_VERSION) {
43
+if ($config->db_version == DB_VERSION) {
44
+} elseif ($config->db_version > DB_VERSION) {
45 45
   $config->db_saveItem('var_db_update_end', SN_TIME_NOW);
46 46
   die(
47 47
     'Internal error! Auotupdater detects DB version greater then can be handled!<br />
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 $upd_log = '';
54 54
 $new_version = floatval($config->db_version);
55
-if($new_version < 37) {
55
+if ($new_version < 37) {
56 56
   die('This version does not supports upgrades from SN below v37. Please, use SN v40 to upgrade old database.<br />
57 57
 Эта версия игры не поддерживает обновление движка версий ниже 37й. Пожалуйста, используйте SN v40 для апгрейда со старых версий игры.');
58 58
 }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 $update_tables  = array();
71 71
 $update_indexes = array();
72 72
 $query = upd_do_query('SHOW TABLES;', true);
73
-while($row = db_fetch_row($query)) {
73
+while ($row = db_fetch_row($query)) {
74 74
   upd_load_table_info($row[0]);
75 75
 }
76 76
 upd_log_message('Table info loaded. Now looking DB for upgrades...');
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 
81 81
 ini_set('memory_limit', '1024M');
82 82
 
83
-switch($new_version) {
83
+switch ($new_version) {
84 84
   case 37:
85 85
     upd_log_version_update();
86 86
 
87 87
     upd_check_key('player_vacation_timeout', PERIOD_WEEK, $config->player_vacation_timeout != PERIOD_WEEK);
88
-    upd_check_key('player_vacation_time', PERIOD_WEEK ,   $config->player_vacation_time != PERIOD_WEEK);
88
+    upd_check_key('player_vacation_time', PERIOD_WEEK, $config->player_vacation_time != PERIOD_WEEK);
89 89
 
90 90
     upd_alter_table('users', "ADD `vacation_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next datetime when player can go on vacation'", !$update_tables['users']['vacation_next']);
91 91
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
     upd_check_key('payment_currency_exchange_mm_', 2500, !$config->payment_currency_exchange_mm_);
97 97
 
98
-    if(!$update_tables['log_metamatter'])
98
+    if (!$update_tables['log_metamatter'])
99 99
     {
100 100
       upd_create_table('log_metamatter',
101 101
         "(
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
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
     {
126 126
       upd_alter_table('payment', array(
127 127
         "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     ), $update_tables['users']['metamatter']['Type'] == 'int(20)');
140 140
 
141 141
     $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE");
142
-    while($row = db_fetch($query))
142
+    while ($row = db_fetch($query))
143 143
     {
144 144
       $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']);
145 145
       upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE");
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
     LEFT JOIN {{planets}} AS p ON p.id = u.id_planet
159 159
     WHERE unit_snid in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ")
160 160
     FOR UPDATE");
161
-    while($row = db_fetch($query))
161
+    while ($row = db_fetch($query))
162 162
     {
163
-      if(!$row['id_planet'])
163
+      if (!$row['id_planet'])
164 164
       {
165 165
         continue;
166 166
       }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
       $unit_level = $row['unit_level'];
170 170
       $price = get_unit_param($unit_id, P_COST);
171 171
       $factor = $price['factor'];
172
-      foreach($price as $resource_id => &$resource_amount)
172
+      foreach ($price as $resource_id => &$resource_amount)
173 173
       {
174 174
         $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1);
175 175
       }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     // Вернуть ресы за уже исследованную Экспедиционную технологию
190 190
     upd_check_key('player_max_colonies', -1, $config->player_max_colonies >= 0);
191 191
 
192
-    if(!isset($update_tables['users']['player_rpg_explore_xp']))
192
+    if (!isset($update_tables['users']['player_rpg_explore_xp']))
193 193
     {
194 194
       upd_alter_table('users', array(
195 195
         "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
       ), !isset($update_tables['users']['player_rpg_explore_xp']));
198 198
     }
199 199
 
200
-    if(!$update_tables['log_users_online'])
200
+    if (!$update_tables['log_users_online'])
201 201
     {
202
-      upd_create_table('log_users_online',"(
202
+      upd_create_table('log_users_online', "(
203 203
         `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time',
204 204
         `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online',
205 205
 
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
       "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`",
214 214
     ), !$update_tables['users']['user_time_measured']);
215 215
 
216
-    if($update_tables['rw'])
216
+    if ($update_tables['rw'])
217 217
     {
218 218
       upd_do_query("DROP TABLE IF EXISTS {{rw}};");
219 219
     }
220 220
 
221
-    if(!$update_tables['player_award'])
221
+    if (!$update_tables['player_award'])
222 222
     {
223 223
       upd_create_table('player_award', "(
224 224
         `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
     upd_log_version_update();
262 262
 
263 263
 
264
-    if(!isset($update_tables['planets']['que_processed'])) {
264
+    if (!isset($update_tables['planets']['que_processed'])) {
265 265
       upd_alter_table('planets', array(
266 266
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`",
267 267
       ), true);
268 268
       upd_do_query("UPDATE {{planets}} SET que_processed = last_update;");
269 269
     }
270 270
 
271
-    if(!isset($update_tables['users']['que_processed'])) {
271
+    if (!isset($update_tables['users']['que_processed'])) {
272 272
       upd_alter_table('users', array(
273 273
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`",
274 274
       ), true);
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
 
281 281
 
282
-    if(isset($update_tables['planets']['que'])) {
282
+    if (isset($update_tables['planets']['que'])) {
283 283
       $sn_data_aux = array(
284 284
         SHIP_SMALL_FIGHTER_WRATH => array(
285 285
           'name' => 'ship_fighter_wrath',
@@ -364,20 +364,20 @@  discard block
 block discarded – undo
364 364
       $unit_data = array();
365 365
       $planets = array();
366 366
 
367
-      foreach($planet_unit_list as $unit_id) {
368
-        if(!($unit_name = get_unit_param($unit_id, P_NAME))) {
367
+      foreach ($planet_unit_list as $unit_id) {
368
+        if (!($unit_name = get_unit_param($unit_id, P_NAME))) {
369 369
           $unit_name = $sn_data_aux[$unit_id][P_NAME];
370 370
         }
371
-        if(isset($update_tables['planets'][$unit_name])) {
371
+        if (isset($update_tables['planets'][$unit_name])) {
372 372
           $drop[] = "DROP COLUMN `{$unit_name}`";
373 373
 
374
-          if(isset($aux_group[$unit_id])) {
374
+          if (isset($aux_group[$unit_id])) {
375 375
             $units_info[$unit_id] = $sn_data_aux[$unit_id];
376 376
             $units_info[$unit_id]['que'] = QUE_HANGAR;
377 377
           } else {
378 378
             $units_info[$unit_id] = get_unit_param($unit_id);
379
-            foreach($ques_info as $que_id => $que_data1) {
380
-              if(in_array($unit_id, $que_data1['unit_list'])) {
379
+            foreach ($ques_info as $que_id => $que_data1) {
380
+              if (in_array($unit_id, $que_data1['unit_list'])) {
381 381
                 $units_info[$unit_id]['que'] = $que_id;
382 382
                 break;
383 383
               }
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
       }
388 388
 
389 389
       $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE");
390
-      while($row = db_fetch($query)) {
390
+      while ($row = db_fetch($query)) {
391 391
         $user_id = $row['id_owner'];
392 392
         $planet_id = $row['id'];
393 393
 
@@ -395,12 +395,12 @@  discard block
 block discarded – undo
395 395
 
396 396
         // Конвертируем юниты
397 397
         $units_levels = array();
398
-        foreach($planet_unit_list as $unit_id) {
398
+        foreach ($planet_unit_list as $unit_id) {
399 399
           $unit_name = &$units_info[$unit_id][P_NAME];
400
-          if(!isset($row[$unit_name]) || !$row[$unit_name]) continue;
400
+          if (!isset($row[$unit_name]) || !$row[$unit_name]) continue;
401 401
           $units_levels[$unit_id] = $row[$unit_name];
402 402
           $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})";
403
-          if(count($unit_data) > 30) {
403
+          if (count($unit_data) > 30) {
404 404
             $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max;
405 405
             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) . ';');
406 406
             $unit_data = array();
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
         }
409 409
 
410 410
         // Конвертируем очередь построек
411
-        if($row['que']) {
411
+        if ($row['que']) {
412 412
           $que = explode(';', $row['que']);
413
-          foreach($que as $que_item) {
414
-            if(!$que_item) continue;
413
+          foreach ($que as $que_item) {
414
+            if (!$que_item) continue;
415 415
 
416 416
             $que_item = explode(',', $que_item);
417 417
 
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
             $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1;
425 425
             $price_increase = pow($unit_factor, $unit_level);
426 426
             // $unit_time = 0;
427
-            foreach($unit_cost as $resource_id => &$resource_amount) {
428
-              if(!in_array($resource_id, $group_resource_loot)) {
427
+            foreach ($unit_cost as $resource_id => &$resource_amount) {
428
+              if (!in_array($resource_id, $group_resource_loot)) {
429 429
                 unset($unit_cost[$resource_id]);
430 430
                 continue;
431 431
               }
@@ -439,33 +439,33 @@  discard block
 block discarded – undo
439 439
         }
440 440
  
441 441
         // Конвертируем очередь верфи
442
-        if($row['b_hangar_id']) {
443
-          $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0, );
442
+        if ($row['b_hangar_id']) {
443
+          $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,);
444 444
           $hangar_units = sys_unit_str2arr($row['b_hangar_id']);
445
-          foreach($hangar_units as $unit_id => $unit_count) {
446
-            if($unit_count <= 0) continue;
447
-            foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
448
-              if(!in_array($resource_id, $group_resource_loot)) continue;
445
+          foreach ($hangar_units as $unit_id => $unit_count) {
446
+            if ($unit_count <= 0) continue;
447
+            foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
448
+              if (!in_array($resource_id, $group_resource_loot)) continue;
449 449
               $return_resources[$resource_id] += $unit_count * $resource_amount;
450 450
             }
451 451
           }
452
-          if(array_sum($return_resources) > 0) {
452
+          if (array_sum($return_resources) > 0) {
453 453
             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");
454 454
           }
455 455
         }
456 456
 
457 457
 
458
-        if(count($que_data) > 10) {
458
+        if (count($que_data) > 10) {
459 459
           $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max;
460 460
           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) . ';');
461 461
           $que_data = array();
462 462
         }
463 463
       }
464 464
 
465
-      if(!empty($unit_data))
465
+      if (!empty($unit_data))
466 466
         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) . ';');
467 467
 
468
-      if(!empty($que_data))
468
+      if (!empty($que_data))
469 469
         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) . ';');
470 470
 
471 471
       upd_alter_table('planets', $drop, true);
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
       JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = ''
476 476
       SET u.`username` = CONCAT('[', a.`ally_tag`, ']');");
477 477
 
478
-    if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
478
+    if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
479 479
       upd_do_query("SET FOREIGN_KEY_CHECKS=0;");
480 480
       upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']);
481 481
       upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
       "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{$config->db_prefix}security_browser` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE",
572 572
     ), !isset($update_tables['users']['user_last_proxy']));
573 573
 
574
-    if(!isset($update_tables['notes']['planet_type'])) {
574
+    if (!isset($update_tables['notes']['planet_type'])) {
575 575
       upd_alter_table('notes', array(
576 576
 //      "ADD COLUMN `planet_name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `title`",
577 577
         "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`",
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot']));
591 591
     upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']);
592 592
 
593
-    if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
593
+    if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
594 594
       upd_alter_table('users', array(
595 595
         "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'",
596 596
       ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint');
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
       upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;");
599 599
     }
600 600
 
601
-    if(!isset($update_tables['log_users_online']['online_aggregated'])) {
601
+    if (!isset($update_tables['log_users_online']['online_aggregated'])) {
602 602
       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']));
603 603
       upd_alter_table('log_users_online', array(
604 604
         "DROP PRIMARY KEY",
@@ -606,13 +606,13 @@  discard block
 block discarded – undo
606 606
       ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,');
607 607
     }
608 608
 
609
-    if(!isset($update_tables['users']['gender'])) {
609
+    if (!isset($update_tables['users']['gender'])) {
610 610
       upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender']));
611
-      upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE. ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));");
611
+      upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));");
612 612
     }
613 613
     upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex']));
614 614
 
615
-    if(!$update_tables['users']['dark_matter_total']) {
615
+    if (!$update_tables['users']['dark_matter_total']) {
616 616
       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']);
617 617
       upd_do_query(
618 618
         "UPDATE `{{users}}` AS u
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
     }
626 626
 
627 627
     upd_check_key('player_metamatter_immortal', 100000, !isset($config->player_metamatter_immortal));
628
-    if(!$update_tables['users']['metamatter_total']) {
628
+    if (!$update_tables['users']['metamatter_total']) {
629 629
       upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']);
630 630
 
631 631
       upd_do_query(
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
             (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0)
638 638
           );");
639 639
     }
640
-    if(!isset($update_tables['users']['immortal'])) {
640
+    if (!isset($update_tables['users']['immortal'])) {
641 641
       upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal']));
642 642
       upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;");
643 643
     }
644
-    if(isset($update_tables['player_award'])) {
644
+    if (isset($update_tables['player_award'])) {
645 645
       upd_do_query(
646 646
         "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id
647 647
           SET metamatter_total = 1, immortal = NOW()
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
       CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
669 669
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
670 670
 
671
-    if(empty($update_tables['blitz_statpoints'])) {
671
+    if (empty($update_tables['blitz_statpoints'])) {
672 672
       upd_create_table('blitz_statpoints', " (
673 673
         `stat_date` int(11) NOT NULL DEFAULT '0',
674 674
         `id_owner` bigint(20) unsigned DEFAULT NULL,
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
       CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE
737 737
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
738 738
 
739
-    if(empty($update_tables['security_url'])) {
739
+    if (empty($update_tables['security_url'])) {
740 740
       upd_create_table('security_url', " (
741 741
         `url_id` int unsigned NOT NULL AUTO_INCREMENT,
742 742
         `url_string` VARCHAR(250) NOT NULL DEFAULT '',
@@ -749,9 +749,9 @@  discard block
 block discarded – undo
749 749
 
750 750
         $strings = array();
751 751
         $query = doquery($query);
752
-        while($row = db_fetch($query)) {
752
+        while ($row = db_fetch($query)) {
753 753
           $strings[] = '("' . db_escape($row['url']) . '")';
754
-          if(count($strings) > 100) {
754
+          if (count($strings) > 100) {
755 755
             doquery($query_string . implode(',', $strings));
756 756
             $strings = array();
757 757
           }
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
         !empty($strings) ? doquery($query_string . implode(',', $strings)) : false;
760 760
       }
761 761
 
762
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
762
+      if (isset($update_tables['counter']['page'])) // TODO REMOVE
763 763
       {
764 764
         update_security_url("SELECT DISTINCT `page` as url FROM {{counter}}");
765 765
         update_security_url("SELECT DISTINCT `url` as url FROM {{counter}}");
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
       "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
785 785
       "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
786 786
     ), !isset($update_tables['counter']['device_id']));
787
-    if(isset($update_tables['counter']['ip'])) {
787
+    if (isset($update_tables['counter']['ip'])) {
788 788
       // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)');
789 789
       upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)');
790 790
       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');
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 
836 836
     upd_check_key('stats_history_days', 14, !$config->stats_history_days);
837 837
 
838
-    if($config->payment_currency_default != 'USD') {
839
-      upd_check_key('payment_currency_default',      'USD', true);
838
+    if ($config->payment_currency_default != 'USD') {
839
+      upd_check_key('payment_currency_default', 'USD', true);
840 840
       upd_check_key('payment_currency_exchange_dm_', 20000, true);
841 841
       upd_check_key('payment_currency_exchange_mm_', 20000, true);
842 842
       upd_check_key('payment_currency_exchange_usd', 1, true);
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
     function propagade_player_options($old_option_name, $new_option_id) {
919 919
       global $update_tables;
920 920
 
921
-      if(!empty($update_tables['users'][$old_option_name])) {
921
+      if (!empty($update_tables['users'][$old_option_name])) {
922 922
         upd_do_query(
923 923
           "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`)
924 924
           SELECT `id`, {$new_option_id}, `{$old_option_name}`
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 
953 953
     // 2015-08-03 15:05:26 40a6.0
954 954
 
955
-    if(empty($update_tables['planets']['position_original'])) {
955
+    if (empty($update_tables['planets']['position_original'])) {
956 956
       upd_alter_table('planets', array(
957 957
         "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0",
958 958
         "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0",
@@ -980,12 +980,12 @@  discard block
 block discarded – undo
980 980
     // 2015-08-27 19:14:05 40a10.0
981 981
 
982 982
     // Старая версия таблицы
983
-    if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
983
+    if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
984 984
       upd_drop_table('account');
985 985
       upd_drop_table('account_translate');
986 986
     }
987 987
 
988
-    if(empty($update_tables['account'])) {
988
+    if (empty($update_tables['account'])) {
989 989
       upd_create_table('account', " (
990 990
           `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
991 991
           `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '',
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
     upd_alter_table('security_url', "MODIFY COLUMN `url_string` VARCHAR(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''", empty($update_tables['security_url']['ube_report_capture_result']));
1044 1044
 
1045 1045
     // 2015-09-24 11:39:37 40a10.25
1046
-    if(empty($update_tables['log_metamatter']['provider_id'])) {
1046
+    if (empty($update_tables['log_metamatter']['provider_id'])) {
1047 1047
       upd_alter_table('log_metamatter', array(
1048 1048
         "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'",
1049 1049
         "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0",
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
     upd_check_key('event_halloween_2015_code', '', !isset($config->event_halloween_2015_code));
1094 1094
     upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset($config->event_halloween_2015_timestamp));
1095 1095
     upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset($config->event_halloween_2015_units_used));
1096
-    if(empty($update_tables['log_halloween_2015'])) {
1096
+    if (empty($update_tables['log_halloween_2015'])) {
1097 1097
       upd_create_table('log_halloween_2015', " (
1098 1098
       `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1099 1099
       `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
     }
1108 1108
 
1109 1109
     // 2015-11-28 06:30:27 40a19.21
1110
-    if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1110
+    if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1111 1111
       upd_alter_table('ube_report', array(
1112 1112
         "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'",
1113 1113
 //        "ADD KEY `I_ube_report_debris_id` (`ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
     }
1123 1123
 
1124 1124
     // 2015-12-06 15:10:58 40b1.0
1125
-    if(!empty($update_indexes['planets']['I_metal_mine'])) {
1125
+    if (!empty($update_indexes['planets']['I_metal_mine'])) {
1126 1126
       upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']);
1127 1127
       upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']);
1128 1128
       upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']);
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
   case 40:
1188 1188
     upd_log_version_update();
1189 1189
 
1190
-    if(empty($update_tables['festival'])) {
1190
+    if (empty($update_tables['festival'])) {
1191 1191
       upd_create_table('festival', " (
1192 1192
           `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
1193 1193
           `start` datetime NOT NULL COMMENT 'Festival start datetime',
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
       );
1229 1229
     }
1230 1230
 
1231
-    if(empty($update_tables['festival_unit'])) {
1231
+    if (empty($update_tables['festival_unit'])) {
1232 1232
       upd_create_table('festival_unit', " (
1233 1233
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1234 1234
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
     }
1246 1246
 
1247 1247
     // 2015-12-21 06:06:09 41a0.12
1248
-    if(empty($update_tables['festival_unit_log'])) {
1248
+    if (empty($update_tables['festival_unit_log'])) {
1249 1249
       upd_create_table('festival_unit_log', " (
1250 1250
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1251 1251
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1273,13 +1273,13 @@  discard block
 block discarded – undo
1273 1273
       $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin'
1274 1274
     );
1275 1275
 
1276
-    if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1276
+    if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1277 1277
       upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true);
1278 1278
       upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true);
1279 1279
     }
1280 1280
 
1281 1281
     // 2016-12-03 20:36:46 41a61.0
1282
-    if(empty($update_tables['auth_vkontakte_account'])) {
1282
+    if (empty($update_tables['auth_vkontakte_account'])) {
1283 1283
       upd_create_table('auth_vkontakte_account', " (
1284 1284
           `user_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1285 1285
           `access_token` varchar(250) NOT NULL DEFAULT '',
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 
1322 1322
 classSupernova::$cache->unset_by_prefix('lng_');
1323 1323
 
1324
-if($new_version) {
1324
+if ($new_version) {
1325 1325
   $config->db_saveItem('db_version', $new_version);
1326 1326
   upd_log_message("<font color=green>DB version is now {$new_version}</font>");
1327 1327
 } else {
Please login to merge, or discard this patch.