Completed
Push — work-fleets ( 7aaf68...e155c0 )
by SuperNova.WS
06:30
created
includes/alliance/ali_internal_admin_rights.inc 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
4 4
 {
5 5
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
6 6
 }
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 $new_rank_name = sys_get_param_str('newRankName');
15 15
 if ($new_rank_name)
16 16
 {
17
-  foreach($ally_rights as $fieldName)
17
+  foreach ($ally_rights as $fieldName)
18 18
   {
19 19
     $newRank[$fieldName] = 0;
20 20
   }
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 {
29 29
   unset($ranks);
30 30
 
31
-  foreach($rankListInput as $rankID => $rank)
31
+  foreach ($rankListInput as $rankID => $rank)
32 32
   {
33
-    foreach($ally_rights as $rightName)
33
+    foreach ($ally_rights as $rightName)
34 34
     {
35 35
       $ranks[$rankID][$rightName] = $rank[$rightName] ? 1 : 0;
36 36
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $d = sys_get_param_int('d');
42 42
 if ($d && isset($ranks[$d]))
43 43
 {
44
-  if(count($ranks) == 1)
44
+  if (count($ranks) == 1)
45 45
   {
46 46
     message(classLocale::$lang['ali_adm_lastRank'], classLocale::$lang['ali_adm_rights_title']);
47 47
   }
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 
54 54
 if (count($ranks))
55 55
 {
56
-  foreach($ranks as $rankID => $rank)
56
+  foreach ($ranks as $rankID => $rank)
57 57
   {
58 58
     $rank_data = array(
59 59
       'ID'   => $rankID,
60 60
       'NAME' => $rank['name'],
61 61
     );
62 62
 
63
-    for($i = 1; $i < count($rank); $i++)
63
+    for ($i = 1; $i < count($rank); $i++)
64 64
     {
65
-      $rank_data['R' . $i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : '') ;
66
-      $rank_data['N' . $i] = $ally_rights[$i];
65
+      $rank_data['R'.$i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : '');
66
+      $rank_data['N'.$i] = $ally_rights[$i];
67 67
     }
68 68
 
69 69
     $template->assign_block_vars('rank', $rank_data);
Please login to merge, or discard this patch.
includes/db/db_helpers.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35
-    $field = '`' . db_escape($field) . '`';
35
+    $field = '`'.db_escape($field).'`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41
-      $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
41
+      $new_value = '"'.db_escape($value).'"';
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
Please login to merge, or discard this patch.
includes/init_secondary.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
6
-  include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX);
5
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
6
+  include(SN_ROOT_PHYSICAL.'ajax_version_check'.DOT_PHP_EX);
7 7
 }
8 8
 
9
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
10
-  require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX);
9
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
10
+  require_once(SN_ROOT_PHYSICAL."includes/includes/user_birthday_celebrate".DOT_PHP_EX);
11 11
   sn_user_birthday_celebrate();
12 12
 }
13 13
 
14
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
14
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
15 15
   classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true));
16 16
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
17
-  if(classSupernova::$config->server_log_online) {
17
+  if (classSupernova::$config->server_log_online) {
18 18
     db_log_online_insert();
19 19
   }
20 20
 }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
42 42
 //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die();
43 43
 
44
-if(!empty($user['id'])) {
44
+if (!empty($user['id'])) {
45 45
   classSupernova::$user_options->user_change($user['id']);
46 46
 }
47 47
 
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
     : false
55 55
   );
56 56
 
57
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
58
-  $prohibited_characters = array_map(function ($value) {
59
-    return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
57
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
58
+  $prohibited_characters = array_map(function($value) {
59
+    return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'";
60 60
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
61 61
   $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters);
62 62
 }
63 63
 
64 64
 
65
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
65
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
66 66
   pdump("Отключи отладку перед продакшном!");
67 67
 }
68 68
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
   ? define('INSTALL_MODE', GAME_DISABLE_INSTALL)
77 77
   : false;
78 78
 
79
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
79
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
80 80
   $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse(
81 81
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
82 82
       ? classSupernova::$config->game_disable_reason
83 83
       : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
84 84
   );
85
-  if(defined('IN_API')) {
85
+  if (defined('IN_API')) {
86 86
     return;
87 87
   }
88 88
 
89
-  if(
89
+  if (
90 90
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
91 91
     &&
92 92
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
 // TODO ban
102 102
 // TODO $skip_ban_check
103
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
-  if(defined('IN_API')) {
103
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
+  if (defined('IN_API')) {
105 105
     return;
106 106
   }
107 107
 
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
 // pdump($allow_anonymous, '$allow_anonymous');
120 120
 // pdump($sys_user_logged_in, '$sys_user_logged_in');
121 121
 
122
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
123
-  sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
124
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
122
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
123
+  sys_redirect(SN_ROOT_VIRTUAL.'overview.php');
124
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
125 125
 //  pdump($sn_page_name);
126 126
 //  pdump(INITIAL_PAGE);
127 127
 //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
128
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
128
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
129 129
   // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
130
-  sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
130
+  sys_redirect(SN_ROOT_VIRTUAL.'login.php');
131 131
 }
132 132
 
133 133
 $user_time_diff = playerTimeDiff::user_time_diff_get();
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 
147 147
 global $skip_fleet_update;
148 148
 $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN');
149
-if(
149
+if (
150 150
   !$skip_fleet_update
151 151
   && !(defined('IN_AJAX') && IN_AJAX === true)
152 152
   && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval
153 153
 ) {
154
-  require_once(SN_ROOT_PHYSICAL . "includes/includes/flt_flying_fleet_handler2" . DOT_PHP_EX);
154
+  require_once(SN_ROOT_PHYSICAL."includes/includes/flt_flying_fleet_handler2".DOT_PHP_EX);
155 155
   flt_flying_fleet_handler($skip_fleet_update);
156 156
 }
157 157
 
158
-if(!defined('IN_AJAX')) {
158
+if (!defined('IN_AJAX')) {
159 159
   print("Scheduled processes is disabled<br />");
160 160
 }
161 161
 // scheduler_process();
Please login to merge, or discard this patch.
includes/update_old.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,12 +82,12 @@  discard block
 block discarded – undo
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
89
-            ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor . "
90
-        SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor . ");"
89
+            ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor."
90
+        SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor.");"
91 91
       );
92 92
     }
93 93
 
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,12 +269,12 @@  discard block
 block discarded – undo
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
-      upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup');
277
+      upd_alter_table('errors', ' RENAME TO '.classSupernova::$config->db_prefix.'errors_backup');
278 278
 
279 279
       upd_drop_table('errors');
280 280
     }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
668 668
       upd_do_query('COMMIT;', true);
669 669
     }
670 670
 
671
-    foreach($update_tables as $table_name => $cork) {
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') {
671
+    foreach ($update_tables as $table_name => $cork) {
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') {
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,23 +1340,23 @@  discard block
 block discarded – undo
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
-      doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};");
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();
1347 1347
       doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;");
1348 1348
     }
1349 1349
     // Renaming old ally players TODO: Remove on release
1350 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 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;");
1352
+    upd_do_query("UPDATE {{users}} SET `onlinetime` = ".SN_TIME_NOW." WHERE onlinetime = 0;");
1353 1353
 
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
-      doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};");
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();
1361 1361
       doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;");
1362 1362
     }
@@ -1385,10 +1385,10 @@  discard block
 block discarded – undo
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)) {
1391
-        $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
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 1392
         doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
1393 1393
       }
1394 1394
 
@@ -1400,10 +1400,10 @@  discard block
 block discarded – undo
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
-      doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY);
1406
+      doquery("UPDATE {{powerup}} SET powerup_category = ".BONUS_MERCENARY);
1407 1407
     }
1408 1408
 
1409 1409
     upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info));
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
1447
-            $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1446
+          if ($reward_resource == RES_DARK_MATTER) {
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
 block discarded – undo
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']);
@@ -1512,15 +1512,15 @@  discard block
 block discarded – undo
1512 1512
     upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price));
1513 1513
 
1514 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;");
1515
+    upd_do_query("UPDATE {{powerup}} SET powerup_category = ".UNIT_MERCENARIES." WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1516 1516
 
1517 1517
     // Convert Destructor to Death Star schematic
1518 1518
     upd_do_query("UPDATE {{powerup}}
1519
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . "
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 1521
     // Convert Assasin to SuperNova schematic
1522 1522
     upd_do_query("UPDATE {{powerup}}
1523
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . "
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 1526
     upd_alter_table('iraks', array(
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
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
 
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
       ), !$update_tables['payment']['payment_status']);
1545 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 1549
     upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date));
1550 1550
     upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures));
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 
1557 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 1562
     upd_do_query('COMMIT;', true);
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)) {
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])) {
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 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'",
@@ -2009,13 +2009,13 @@  discard block
 block discarded – undo
2009 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
-          `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
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 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
 block discarded – undo
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,20 +2079,20 @@  discard block
 block discarded – undo
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
-          $unit_cost[] = $resource_id . ',' . floor($resource_cost);
2086
+          $unit_cost[] = $resource_id.','.floor($resource_cost);
2087 2087
         }
2088 2088
         $unit_cost = implode(';', $unit_cost);
2089 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}')";
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 2092
       }
2093 2093
 
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));
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 2096
       }
2097 2097
 
2098 2098
       upd_alter_table('users', array(
@@ -2105,23 +2105,23 @@  discard block
 block discarded – undo
2105 2105
 
2106 2106
 
2107 2107
     // Ковертируем технологии в таблицы
2108
-    if($update_tables['users']['graviton_tech']) {
2109
-      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2108
+    if ($update_tables['users']['graviton_tech']) {
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)])) {
2118
-            $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
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));
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 2125
       }
2126 2126
 
2127 2127
       upd_alter_table('users', array(
@@ -2129,25 +2129,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -2204,10 +2204,10 @@  discard block
 block discarded – undo
2204 2204
 
2205 2205
     upd_alter_table('planets', array(
2206 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'",
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
 block discarded – undo
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
           }
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 function pname_factory_production_field_name($factory_unit_id)
6 6
 {
7
-  return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
7
+  return get_unit_param($factory_unit_id, P_NAME).'_porcent';
8 8
 }
9 9
 
10 10
 /**
Please login to merge, or discard this patch.
includes/includes/ube_zi_helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
   print($round);
28 28
   print('<table border=1>');
29 29
   print('<tr align="left">');
30
-  foreach($header as $key => $value)
30
+  foreach ($header as $key => $value)
31 31
   {
32
-    if(is_array($value))
32
+    if (is_array($value))
33 33
     {
34 34
       continue;
35 35
     }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
   );
62 62
 
63 63
   print('<tr align="right">');
64
-  foreach($unit_crossfire_result as $key => $value)
64
+  foreach ($unit_crossfire_result as $key => $value)
65 65
   {
66
-    if(is_array($value))
66
+    if (is_array($value))
67 67
     {
68 68
       continue;
69 69
     }
Please login to merge, or discard this patch.
includes/includes/flt_mission_colonize.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
   $TargetAddress = sprintf(classLocale::$lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']);
21 21
 
22 22
   $TheMessage = classLocale::$lang['sys_colo_no_colonizer'];
23
-  if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
23
+  if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
24 24
     $TheMessage = classLocale::$lang['sys_colo_notfree'];
25
-    if(empty($mission_data->dst_planet)) {
25
+    if (empty($mission_data->dst_planet)) {
26 26
       $iPlanetCount = get_player_current_colonies($src_user_row);
27 27
 
28 28
       // Can we colonize more planets?
29 29
       $TheMessage = classLocale::$lang['sys_colo_maxcolo'];
30
-      if($iPlanetCount < get_player_max_colonies($src_user_row)) {
30
+      if ($iPlanetCount < get_player_max_colonies($src_user_row)) {
31 31
         // Yes, we can colonize
32 32
         $TheMessage = classLocale::$lang['sys_colo_badpos'];
33 33
 
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
           $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'],
36 36
           $objFleet->playerOwnerId, "{$classLocale['sys_colo_defaultname']} {$iPlanetCount}", false,
37 37
           array('user_row' => $src_user_row));
38
-        if($NewOwnerPlanet) {
39
-          $TheMessage = classLocale::$lang['sys_colo_arrival'] . $TargetAddress . classLocale::$lang['sys_colo_allisok'];
38
+        if ($NewOwnerPlanet) {
39
+          $TheMessage = classLocale::$lang['sys_colo_arrival'].$TargetAddress.classLocale::$lang['sys_colo_allisok'];
40 40
           msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_colo_mess_from'], classLocale::$lang['sys_colo_mess_report'], $TheMessage);
41 41
 
42 42
           $objFleet->shipAdjustCount(SHIP_COLONIZER, -1);
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -2,28 +2,28 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(SN_IN_FLEET !== true) {
5
+if (SN_IN_FLEET !== true) {
6 6
   classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
7 7
 }
8 8
 
9 9
 $fleetid = sys_get_param_id('fleetid');
10 10
 
11
-if(!is_numeric($fleetid) || empty($fleetid)) {
11
+if (!is_numeric($fleetid) || empty($fleetid)) {
12 12
   header("Location: fleet.php");
13 13
   exit();
14 14
 }
15 15
 
16 16
 $objFleet = new Fleet();
17 17
 $objFleet->dbLoad($fleetid);
18
-if(!$objFleet->dbId) {
18
+if (!$objFleet->dbId) {
19 19
   message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']);
20 20
 }
21 21
 
22
-if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
22
+if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
23 23
   message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']);
24 24
 }
25 25
 
26
-if($objFleet->playerOwnerId != $user['id']) {
26
+if ($objFleet->playerOwnerId != $user['id']) {
27 27
   classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
28 28
   message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']);
29 29
 }
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 
35 35
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
36 36
 
37
-if($userToAdd_unsafe) {
37
+if ($userToAdd_unsafe) {
38 38
   $userToAdd = db_escape($userToAdd_unsafe);
39 39
   $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
40 40
   $userToAddID = $userToAddID['id'];
41 41
 
42
-  if($objFleet->target_owner_id == $userToAddID) {
42
+  if ($objFleet->target_owner_id == $userToAddID) {
43 43
     message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']);
44 44
   }
45 45
 
46
-  if($userToAddID) {
47
-    if(!$aks) {
46
+  if ($userToAddID) {
47
+    if (!$aks) {
48 48
       // No AСS exists - making one
49
-      if(!$objFleet->group_id) {
49
+      if (!$objFleet->group_id) {
50 50
         db_acs_insert($fleetid, $user, $objFleet);
51 51
 
52 52
         $aks = db_acs_get_by_fleet($fleetid);
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 
62 62
     $isUserExists = false;
63 63
     $invited_ar = explode(",", $aks['eingeladen']);
64
-    foreach($invited_ar as $inv) {
65
-      if($userToAddID == $inv) {
64
+    foreach ($invited_ar as $inv) {
65
+      if ($userToAddID == $inv) {
66 66
         $isUserExists = true;
67 67
       }
68 68
     }
69 69
 
70
-    if(count($invited_ar) >= 5) {
70
+    if (count($invited_ar) >= 5) {
71 71
       message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']);
72 72
     }
73 73
 
74
-    if($isUserExists) {
74
+    if ($isUserExists) {
75 75
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false;
76 76
     } else {
77 77
       $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd);
78 78
       !(db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], db_error())) : false;
79
-      $aks['eingeladen'] .= ',' . $userToAddID;
79
+      $aks['eingeladen'] .= ','.$userToAddID;
80 80
     }
81 81
     msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
82 82
       classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username']));
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
   'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS],
94 94
 ));
95 95
 
96
-if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
97
-  foreach($members as $row) {
96
+if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
97
+  foreach ($members as $row) {
98 98
     $template->assign_block_vars('invited', array(
99 99
       'NAME' => $row['username'],
100 100
     ));
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
120 120
 
121 121
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
122
-foreach($fleet_data['ships'] as $ship_data) {
122
+foreach ($fleet_data['ships'] as $ship_data) {
123 123
   $template->assign_block_vars('fleets.ships', $ship_data);
124 124
 }
125 125
 
Please login to merge, or discard this patch.
includes/includes/market_info.inc 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
5
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
6 6
 {
7 7
   classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
8 8
 }
@@ -17,54 +17,54 @@  discard block
 block discarded – undo
17 17
 ));
18 18
 
19 19
 $info_action = sys_get_param_int('action');
20
-if($info_action)
20
+if ($info_action)
21 21
 {
22 22
   try
23 23
   {
24 24
     sn_db_transaction_start();
25 25
 
26 26
     $user = db_user_by_id($user['id'], true);
27
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info)
27
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info)
28 28
     {
29 29
       throw new Exception(MARKET_NO_DM, ERR_ERROR);
30 30
     }
31 31
 
32
-    switch($info_action)
32
+    switch ($info_action)
33 33
     {
34 34
       case MARKET_INFO_PLAYER:
35 35
         $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name');
36
-        if(!$user_info_name_unsafe)
36
+        if (!$user_info_name_unsafe)
37 37
         {
38 38
           throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR);
39 39
         }
40 40
 
41
-        if(is_id($user_info_name_unsafe))
41
+        if (is_id($user_info_name_unsafe))
42 42
         {
43 43
           $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true);
44 44
         }
45
-        if(!is_array($user_info))
45
+        if (!is_array($user_info))
46 46
         {
47 47
           $user_info = db_user_by_username($user_info_name_unsafe, true, '`id`, `username`', true, true);
48 48
         }
49
-        if(!is_array($user_info))
49
+        if (!is_array($user_info))
50 50
         {
51 51
           throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR);
52 52
         }
53
-        if($user_info['id'] == $user['id'])
53
+        if ($user_info['id'] == $user['id'])
54 54
         {
55 55
           throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
56 56
         }
57 57
 
58 58
         $msg_text = array();
59
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
59
+        foreach (sn_get_groups('mercenaries') as $mercenary_id)
60 60
         {
61
-          $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']);
61
+          $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - ".(($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']);
62 62
         }
63
-        if($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM))
63
+        if ($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM))
64 64
         {
65 65
           $msg_text[] = "{$classLocale['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$classLocale['sys_level']}";
66 66
         }
67
-        $msg_text = sprintf(classLocale::$lang['eco_mrk_info_player_message'], $user_info['id'], $user_info['username']) . "\r\n" . implode("\r\n", $msg_text);
67
+        $msg_text = sprintf(classLocale::$lang['eco_mrk_info_player_message'], $user_info['id'], $user_info['username'])."\r\n".implode("\r\n", $msg_text);
68 68
 
69 69
         msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['eco_mrk_info_msg_from'], "{$classLocale['eco_mrk_info_player']} ID {$user_info['id']} [{$user_info['username']}]", $msg_text, false, true);
70 70
       break;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
       break;
75 75
     }
76 76
 
77
-    if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
77
+    if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
78 78
     {
79 79
       // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
80 80
     }
Please login to merge, or discard this patch.