Completed
Push — work-fleets ( 04acf9...8f8df9 )
by SuperNova.WS
07:02
created
includes/includes/mrc_mercenary.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 function mrc_officer_accessible(&$user, $mercenary_id) {
6 6
   $mercenary_info = get_unit_param($mercenary_id);
7
-  if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
7
+  if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
8 8
     return true;
9 9
   }
10 10
 
11
-  if(isset($mercenary_info[P_REQUIRE])) {
12
-    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
-      if(mrc_get_level($user, null, $unit_id) < $unit_level) {
11
+  if (isset($mercenary_info[P_REQUIRE])) {
12
+    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
+      if (mrc_get_level($user, null, $unit_id) < $unit_level) {
14 14
         return false;
15 15
       }
16 16
     }
@@ -26,35 +26,35 @@  discard block
 block discarded – undo
26 26
     $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
27 27
     $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
28 28
     $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
29
-    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
29
+    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
30 30
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR);
31 31
     }
32 32
 
33
-    if(!mrc_officer_accessible($user, $mercenary_id)) {
33
+    if (!mrc_officer_accessible($user, $mercenary_id)) {
34 34
       throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR);
35 35
     }
36 36
 
37 37
     $mercenary_level = sys_get_param_int('mercenary_level');
38
-    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
38
+    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
39 39
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR);
40 40
     }
41 41
 
42
-    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
42
+    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
43 43
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR);
44 44
     }
45 45
 
46 46
     sn_db_transaction_start();
47 47
 
48 48
     $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true);
49
-    if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
49
+    if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
50 50
       throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first
51
-    } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
51
+    } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
52 52
       throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error
53 53
     }
54 54
 
55
-    if($mercenary_level) {
55
+    if ($mercenary_level) {
56 56
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
57
-      if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
57
+      if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
58 58
         $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
59 59
         $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
60 60
       }
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     }
65 65
     $darkmater_cost *= $cost_alliance_multiplyer;
66 66
 
67
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
67
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
68 68
       throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR);
69 69
     }
70 70
 
71
-    if(($darkmater_cost && $mercenary_level) || !$is_permanent) {
71
+    if (($darkmater_cost && $mercenary_level) || !$is_permanent) {
72 72
       $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id);
73
-      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
73
+      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
74 74
         $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']);
75 75
         $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER];
76 76
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
       db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id);
84 84
     }
85 85
 
86
-    if($darkmater_cost && $mercenary_level) {
86
+    if ($darkmater_cost && $mercenary_level) {
87 87
       db_unit_set_insert(
88 88
         "unit_player_id = {$user['id']},
89 89
         unit_location_type = " . LOC_USER . ",
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     }
101 101
     sn_db_transaction_commit();
102 102
     sys_redirect($_SERVER['REQUEST_URI']);
103
-  } catch(Exception $e) {
103
+  } catch (Exception $e) {
104 104
     sn_db_transaction_rollback();
105 105
     $operation_result = array(
106 106
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES;
119 119
   $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
120 120
 
121
-  if($mercenary_id = sys_get_param_int('mercenary_id')) {
121
+  if ($mercenary_id = sys_get_param_int('mercenary_id')) {
122 122
     $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id);
123 123
   }
124 124
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
   $template = gettemplate('mrc_mercenary_hire', true);
128 128
 
129
-  if(!empty($operation_result)) {
129
+  if (!empty($operation_result)) {
130 130
     $template->assign_block_vars('result', $operation_result);
131 131
   }
132 132
 
133
-  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
133
+  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
134 134
     $template->assign_block_vars('period', array(
135 135
       'LENGTH'   => $hire_period,
136 136
       'TEXT'     => classLocale::$lang['mrc_period_list'][$hire_period],
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
   $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
143 143
   $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
144 144
   $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
145
-  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
145
+  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
146 146
     {
147 147
       $mercenary = get_unit_param($mercenary_id);
148 148
       $mercenary_bonus = $mercenary['bonus'];
149 149
       $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}";
150
-      switch($mercenary['bonus_type']) {
150
+      switch ($mercenary['bonus_type']) {
151 151
         case BONUS_PERCENT:
152 152
           $mercenary_bonus = "{$mercenary_bonus}% ";
153 153
         break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
       $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true);
165 165
       $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level);
166 166
       $total_cost_old = 0;
167
-      if($is_permanent) {
167
+      if ($is_permanent) {
168 168
         $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level);
169 169
         $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer;
170 170
       }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
       ));
194 194
 
195 195
       $upgrade_cost = 1;
196
-      for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
196
+      for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
197 197
         $total_cost = eco_get_total_cost($mercenary_id, $i);
198 198
         $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer;
199 199
         $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old;
Please login to merge, or discard this patch.
includes/alliance/ali_external_create_ally.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 // Pretty Safe
3 3
 // TODO: Add ally_tag to usertable
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
@@ -11,22 +11,22 @@  discard block
 block discarded – undo
11 11
 $ally_name_unsafe = sys_get_param_str_unsafe('name');
12 12
 $ally_name = db_escape($ally_name_unsafe);
13 13
 
14
-if($ally_tag) {
15
-  if(!$ally_name_unsafe || !$ally_tag_unsafe) {
14
+if ($ally_tag) {
15
+  if (!$ally_name_unsafe || !$ally_tag_unsafe) {
16 16
     message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']);
17 17
   }
18 18
 
19 19
   $query = DBStaticAlly::db_ally_get_by_name_or_tag($ally_tag, $ally_name);
20
-  if($query) {
20
+  if ($query) {
21 21
     message(str_replace('%s', $query['ally_tag'] == $ally_tag_unsafe ? $ally_tag_unsafe : $ally_name_unsafe, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']);
22 22
   }
23 23
 
24 24
   DBStaticAlly::db_ally_insert($ally_name_unsafe, $ally_tag_unsafe, $user['id']);
25 25
   $ally_id = classSupernova::$db->db_insert_id();
26
-  DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= " . SN_TIME_NOW . "");
26
+  DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= ".SN_TIME_NOW."");
27 27
 
28 28
   $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, array(
29
-    'username'      => "[" . $ally_tag_unsafe . "]",
29
+    'username'      => "[".$ally_tag_unsafe."]",
30 30
     'register_time' => SN_TIME_NOW,
31 31
     'user_as_ally'  => $ally_id,
32 32
   ));
Please login to merge, or discard this patch.
includes/update_old.php 1 patch
Spacing   +132 added lines, -132 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
             $db_prefix = classSupernova::$config->db_prefix;
375 375
             upd_do_query("INSERT INTO {$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);
376 376
           }
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
     upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total));
525 525
 
526
-    for($i = 0; $i < 25; $i++) {
526
+    for ($i = 0; $i < 25; $i++) {
527 527
       upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
528 528
       upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
529 529
       upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]);
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
       "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
552 552
     ), !$update_tables['users']['msg_admin']);
553 553
 
554
-    if(!$update_foreigns['users']['FK_users_ally_id']) {
554
+    if (!$update_foreigns['users']['FK_users_ally_id']) {
555 555
       upd_alter_table('users', array(
556 556
         'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
557 557
         'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL',
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
     ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
574 574
 
575 575
     $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);");
576
-    while($illegal_moon_row = db_fetch($illegal_moon_query)) {
576
+    while ($illegal_moon_row = db_fetch($illegal_moon_query)) {
577 577
       upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
578 578
     }
579 579
 
@@ -610,16 +610,16 @@  discard block
 block discarded – undo
610 610
     upd_do_query('COMMIT;', true);
611 611
 
612 612
     $records = 1;
613
-    while($records) {
613
+    while ($records) {
614 614
       upd_do_query('START TRANSACTION;', true);
615 615
       $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;");
616 616
       $records = classSupernova::$db->db_num_rows($query);
617
-      while($row = db_fetch($query)) {
617
+      while ($row = db_fetch($query)) {
618 618
         $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
619 619
 
620 620
         $reason = RPG_NONE;
621 621
         $comment = $matches[3];
622
-        switch($matches[3]) {
622
+        switch ($matches[3]) {
623 623
           case 'Level Up For Structure Building':
624 624
             $reason = RPG_STRUCTURE;
625 625
           break;
@@ -635,22 +635,22 @@  discard block
 block discarded – undo
635 635
           break;
636 636
 
637 637
           default:
638
-            if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) {
638
+            if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) {
639 639
               $reason = RPG_MARKET;
640
-            } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) {
640
+            } elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) {
641 641
               $reason = RPG_MERCENARY;
642 642
               $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}";
643
-            } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) {
643
+            } elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) {
644 644
               $reason = RPG_REFERRAL;
645 645
               $comment = "Incoming from referral ID {$matches[1]}";
646
-            } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) {
646
+            } elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) {
647 647
               $reason = RPG_ADMIN;
648 648
               $comment = $matches2[1];
649 649
             }
650 650
           break;
651 651
         }
652 652
 
653
-        if($matches[2]) {
653
+        if ($matches[2]) {
654 654
           $row['log_username'] = db_escape($row['log_username']);
655 655
           $row['log_page'] = db_escape($row['log_page']);
656 656
           $comment = db_escape($comment);
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
       upd_do_query('COMMIT;', true);
670 670
     }
671 671
 
672
-    foreach($update_tables as $table_name => $cork) {
673
-      $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));
674
-      if($row['ENGINE'] != 'InnoDB') {
672
+    foreach ($update_tables as $table_name => $cork) {
673
+      $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));
674
+      if ($row['ENGINE'] != 'InnoDB') {
675 675
         upd_alter_table($table_name, 'ENGINE=InnoDB', true);
676 676
       }
677
-      if($row['TABLE_COLLATION'] != 'utf8_general_ci') {
677
+      if ($row['TABLE_COLLATION'] != 'utf8_general_ci') {
678 678
         upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true);
679 679
       }
680 680
     }
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
       "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
695 695
     ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
696 696
 
697
-    if($update_tables['users']['rpg_geologue']) {
697
+    if ($update_tables['users']['rpg_geologue']) {
698 698
       classSupernova::$db->doUpdate("UPDATE `{{users}}` SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
699 699
 
700 700
       upd_alter_table('users', array(
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
       ), $update_tables['users']['rpg_geologue']);
708 708
     }
709 709
 
710
-    if($update_tables['users']['rpg_bunker']) {
710
+    if ($update_tables['users']['rpg_bunker']) {
711 711
       classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
712 712
 
713 713
       upd_alter_table('users', array(
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
     ), !isset($update_tables['alliance']['total_rank']));
758 758
     classSupernova::$db->doUpdate("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;");
759 759
 
760
-    if(!isset($update_tables['users']['ally_tag'])) {
760
+    if (!isset($update_tables['users']['ally_tag'])) {
761 761
       upd_alter_table('users', array(
762 762
         "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
763 763
       ), !isset($update_tables['users']['ally_tag']));
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
       "ADD COLUMN `player_artifact_list` TEXT",
773 773
     ), !isset($update_tables['users']['player_artifact_list']));
774 774
 
775
-    if(!isset($update_tables['users']['player_rpg_tech_xp'])) {
775
+    if (!isset($update_tables['users']['player_rpg_tech_xp'])) {
776 776
       upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage));
777 777
 
778 778
       upd_alter_table('users', array(
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
       "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
803 803
     ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
804 804
 
805
-    if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
805
+    if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
806 806
       upd_alter_table('alliance_diplomacy', array(
807 807
         "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
808 808
         "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`"
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
       ), true);
818 818
     }
819 819
 
820
-    if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
820
+    if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
821 821
       upd_alter_table('alliance_negotiation', array(
822 822
         "DROP FOREIGN KEY `FK_negotiation_ally_id`",
823 823
         "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`"
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
       ), true);
834 834
     }
835 835
 
836
-    if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') {
836
+    if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') {
837 837
       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);
838 838
 
839 839
       upd_alter_table('alliance_requests', array(
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
       ), true);
848 848
     }
849 849
 
850
-    if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
850
+    if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
851 851
       upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true);
852 852
 
853 853
       upd_alter_table('annonce', array(
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
       ), true);
861 861
     }
862 862
 
863
-    if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
863
+    if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
864 864
       upd_alter_table('bashing', array(
865 865
         "DROP FOREIGN KEY `FK_bashing_user_id`",
866 866
         "DROP FOREIGN KEY `FK_bashing_planet_id`",
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
       ), true);
876 876
     }
877 877
 
878
-    if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
878
+    if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
879 879
       upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true);
880 880
 
881 881
       upd_alter_table('buddy', array(
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
       "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
914 914
     ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
915 915
 
916
-    if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
916
+    if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
917 917
       upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
918 918
 
919 919
       upd_alter_table('iraks', array(
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
       ), true);
938 938
     }
939 939
 
940
-    if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') {
940
+    if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') {
941 941
       upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true);
942 942
 
943 943
       upd_alter_table('notes', array(
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
       "DROP COLUMN `b_hangar_plus`",
1063 1063
     ), isset($update_tables['planets']['b_hangar_plus']));
1064 1064
 
1065
-    if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') {
1065
+    if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') {
1066 1066
       upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
1067 1067
 
1068 1068
       upd_alter_table('referrals', array(
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
       "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1082 1082
     ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1083 1083
 
1084
-    if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
1084
+    if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
1085 1085
       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);
1086 1086
 
1087 1087
       upd_alter_table('shortcut', array(
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
       ), true);
1097 1097
     }
1098 1098
 
1099
-    if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
1099
+    if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
1100 1100
       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);
1101 1101
 
1102 1102
       upd_alter_table('statpoints', array(
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
       "DROP COLUMN `settings_allylogo`",
1251 1251
     ), isset($update_tables['users']['settings_allylogo']));
1252 1252
 
1253
-    if(!isset($update_tables['powerup'])) {
1253
+    if (!isset($update_tables['powerup'])) {
1254 1254
       upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};");
1255 1255
 
1256 1256
       upd_create_table('powerup',
@@ -1280,24 +1280,24 @@  discard block
 block discarded – undo
1280 1280
 
1281 1281
       $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1282 1282
       $user_list = upd_do_query("SELECT * FROM {{users}};");
1283
-      while($user_row = db_fetch($user_list)) {
1283
+      while ($user_row = db_fetch($user_list)) {
1284 1284
         $update_query_str = '';
1285
-        foreach(sn_get_groups('mercenaries') as $mercenary_id) {
1285
+        foreach (sn_get_groups('mercenaries') as $mercenary_id) {
1286 1286
           $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1287
-          if($mercenary_level = $user_row[$mercenary_data_name]) {
1287
+          if ($mercenary_level = $user_row[$mercenary_data_name]) {
1288 1288
             $update_query_str = ", `{$mercenary_data_name}` = 0";
1289 1289
             upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
1290 1290
             upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};");
1291 1291
           }
1292 1292
         }
1293 1293
 
1294
-        if($update_query_str) {
1294
+        if ($update_query_str) {
1295 1295
           upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1296 1296
         }
1297 1297
       }
1298 1298
     }
1299 1299
 
1300
-    if(!isset($update_tables['universe'])) {
1300
+    if (!isset($update_tables['universe'])) {
1301 1301
       upd_create_table('universe',
1302 1302
         "(
1303 1303
           `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 
1321 1321
     // ------------------------------------------------------------------------
1322 1322
     // Modifying tables
1323
-    if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') {
1323
+    if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') {
1324 1324
       upd_alter_table('users', array(
1325 1325
         "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
1326 1326
 
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
     // ------------------------------------------------------------------------
1342 1342
     // Creating players for allies
1343 1343
     $ally_row_list = classSupernova::$db->doSelect("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1344
-    while($ally_row = db_fetch($ally_row_list)) {
1344
+    while ($ally_row = db_fetch($ally_row_list)) {
1345 1345
       classSupernova::$db->doInsertSet(TABLE_USERS, array(
1346 1346
         'username'      => "[{$ally_row['ally_tag']}]",
1347 1347
         'register_time' => SN_TIME_NOW,
@@ -1354,12 +1354,12 @@  discard block
 block discarded – undo
1354 1354
     // Renaming old ally players TODO: Remove on release
1355 1355
     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 = '';");
1356 1356
     // Setting last online time to old ally players TODO: Remove on release
1357
-    upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;");
1357
+    upd_do_query("UPDATE {{users}} SET `onlinetime` = ".SN_TIME_NOW." WHERE onlinetime = 0;");
1358 1358
 
1359 1359
     // ------------------------------------------------------------------------
1360 1360
     // Creating planets for allies
1361 1361
     $ally_user_list = classSupernova::$db->doSelect("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1362
-    while($ally_user_row = db_fetch($ally_user_list)) {
1362
+    while ($ally_user_row = db_fetch($ally_user_list)) {
1363 1363
       classSupernova::$db->doInsertSet(TABLE_PLANETS, array(
1364 1364
         'name'        => $ally_user_row['username'],
1365 1365
         'last_update' => SN_TIME_NOW,
@@ -1394,10 +1394,10 @@  discard block
 block discarded – undo
1394 1394
     // Adding db field
1395 1395
     upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1396 1396
     // Converting old data to new one and dropping old fields
1397
-    if($update_tables['users']['b_tech_planet']) {
1397
+    if ($update_tables['users']['b_tech_planet']) {
1398 1398
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{planets}}` WHERE `b_tech_id` <> 0;");
1399
-      while($planet_row = db_fetch($query)) {
1400
-        $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1399
+      while ($planet_row = db_fetch($query)) {
1400
+        $que_item_string = "{$planet_row['b_tech_id']},1,".max(0, $planet_row['b_tech'] - SN_TIME_NOW).",".BUILD_CREATE.",".QUE_RESEARCH;
1401 1401
         classSupernova::$db->doUpdate("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
1402 1402
       }
1403 1403
 
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
       upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1410 1410
     }
1411 1411
 
1412
-    if(!$update_tables['powerup']['powerup_category']) {
1412
+    if (!$update_tables['powerup']['powerup_category']) {
1413 1413
       upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1414 1414
 
1415
-      classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY);
1415
+      classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = ".BONUS_MERCENARY);
1416 1416
     }
1417 1417
 
1418 1418
     upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info));
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
     upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets));
1431 1431
     upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor));
1432 1432
 
1433
-    if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) {
1433
+    if (!classSupernova::$config->db_loadItem('rpg_flt_explore')) {
1434 1434
       $inflation_rate = 1000;
1435 1435
 
1436 1436
       classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate);
@@ -1447,17 +1447,17 @@  discard block
 block discarded – undo
1447 1447
       classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1448 1448
 
1449 1449
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{quest}}`");
1450
-      while($row = db_fetch($query)) {
1450
+      while ($row = db_fetch($query)) {
1451 1451
         $query_add = '';
1452 1452
         $quest_reward_list = explode(';', $row['quest_rewards']);
1453
-        foreach($quest_reward_list as &$quest_reward) {
1453
+        foreach ($quest_reward_list as &$quest_reward) {
1454 1454
           list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1455
-          if($reward_resource == RES_DARK_MATTER) {
1456
-            $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1455
+          if ($reward_resource == RES_DARK_MATTER) {
1456
+            $quest_reward = "{$reward_resource},".$reward_amount * 1000;
1457 1457
           }
1458 1458
         }
1459 1459
         $new_rewards = implode(';', $quest_reward_list);
1460
-        if($new_rewards != $row['quest_rewards']) {
1460
+        if ($new_rewards != $row['quest_rewards']) {
1461 1461
           classSupernova::$db->doUpdate("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1462 1462
         }
1463 1463
       }
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
     upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range));
1488 1488
     upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate));
1489 1489
 
1490
-    if(!isset($update_tables['payment'])) {
1490
+    if (!isset($update_tables['payment'])) {
1491 1491
       upd_alter_table('users', array(
1492 1492
         "ADD KEY `I_user_id_name` (`id`, `username`)",
1493 1493
       ), !$update_indexes['users']['I_user_id_name']);
@@ -1521,15 +1521,15 @@  discard block
 block discarded – undo
1521 1521
     upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price));
1522 1522
 
1523 1523
     // Updating category for Mercenaries
1524
-    upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1524
+    upd_do_query("UPDATE {{powerup}} SET powerup_category = ".UNIT_MERCENARIES." WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1525 1525
 
1526 1526
     // Convert Destructor to Death Star schematic
1527 1527
     upd_do_query("UPDATE {{powerup}}
1528
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . "
1528
+      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_DEATH_STAR."
1529 1529
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;");
1530 1530
     // Convert Assasin to SuperNova schematic
1531 1531
     upd_do_query("UPDATE {{powerup}}
1532
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . "
1532
+      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_SUPERNOVA."
1533 1533
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;");
1534 1534
 
1535 1535
     upd_alter_table('iraks', array(
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
     ), !$update_tables['iraks']['fleet_start_type']);
1539 1539
 
1540 1540
 
1541
-    if(!$update_tables['payment']['payment_status']) {
1541
+    if (!$update_tables['payment']['payment_status']) {
1542 1542
       upd_alter_table('payment', array(
1543 1543
         "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
1544 1544
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
       ), !$update_tables['payment']['payment_status']);
1554 1554
     }
1555 1555
 
1556
-    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";");
1556
+    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = ".UNIT_PLANS.";");
1557 1557
 
1558 1558
     upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date));
1559 1559
     upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures));
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
     upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium));
1567 1567
 
1568
-    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;");
1568
+    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;");
1569 1569
 
1570 1570
 
1571 1571
     upd_do_query('COMMIT;', true);
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
       "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1623 1623
     ), !$update_indexes['notes']['I_owner_priority_time']);
1624 1624
 
1625
-    if(!$update_tables['buddy']['BUDDY_ID']) {
1625
+    if (!$update_tables['buddy']['BUDDY_ID']) {
1626 1626
       upd_alter_table('buddy', array(
1627 1627
         "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy\Buddy table row ID'",
1628 1628
         "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy\Buddy request status'",
@@ -1643,16 +1643,16 @@  discard block
 block discarded – undo
1643 1643
 
1644 1644
       $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1645 1645
       $found = $lost = array();
1646
-      while($row = db_fetch($query)) {
1647
-        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1648
-        if(!isset($found[$index])) {
1646
+      while ($row = db_fetch($query)) {
1647
+        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']).';'.max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1648
+        if (!isset($found[$index])) {
1649 1649
           $found[$index] = $row['BUDDY_ID'];
1650 1650
         } else {
1651 1651
           $lost[] = $row['BUDDY_ID'];
1652 1652
         }
1653 1653
       }
1654 1654
       $lost = implode(',', $lost);
1655
-      if($lost) {
1655
+      if ($lost) {
1656 1656
         upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1657 1657
       }
1658 1658
 
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 
1674 1674
     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");
1675 1675
 
1676
-    if(!$update_tables['ube_report']) {
1676
+    if (!$update_tables['ube_report']) {
1677 1677
       upd_create_table('ube_report',
1678 1678
         "(
1679 1679
           `ube_report_id` SERIAL COMMENT 'Report ID',
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
       );
1715 1715
     }
1716 1716
 
1717
-    if(!$update_tables['ube_report_player']) {
1717
+    if (!$update_tables['ube_report_player']) {
1718 1718
       upd_create_table('ube_report_player',
1719 1719
         "(
1720 1720
           `ube_report_player_id` SERIAL COMMENT 'Record ID',
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
       );
1736 1736
     }
1737 1737
 
1738
-    if(!$update_tables['ube_report_fleet']) {
1738
+    if (!$update_tables['ube_report_fleet']) {
1739 1739
       upd_create_table('ube_report_fleet',
1740 1740
         "(
1741 1741
           `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID',
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
       );
1766 1766
     }
1767 1767
 
1768
-    if(!$update_tables['ube_report_unit']) {
1768
+    if (!$update_tables['ube_report_unit']) {
1769 1769
       // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1770 1770
       // Может сохранять имена удаленных кораблей долго?
1771 1771
 
@@ -1802,7 +1802,7 @@  discard block
 block discarded – undo
1802 1802
       );
1803 1803
     }
1804 1804
 
1805
-    if(!$update_tables['ube_report_outcome_fleet']) {
1805
+    if (!$update_tables['ube_report_outcome_fleet']) {
1806 1806
       upd_create_table('ube_report_outcome_fleet',
1807 1807
         "(
1808 1808
           `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID',
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
       );
1832 1832
     }
1833 1833
 
1834
-    if(!$update_tables['ube_report_outcome_unit']) {
1834
+    if (!$update_tables['ube_report_outcome_unit']) {
1835 1835
       upd_create_table('ube_report_outcome_unit',
1836 1836
         "(
1837 1837
           `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID',
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
       );
1853 1853
     }
1854 1854
 
1855
-    if(!$update_tables['unit']) {
1855
+    if (!$update_tables['unit']) {
1856 1856
       upd_create_table('unit',
1857 1857
         "(
1858 1858
           `unit_id` SERIAL COMMENT 'Record ID',
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
       );
1872 1872
     }
1873 1873
 
1874
-    if(!$update_tables['captain']) {
1874
+    if (!$update_tables['captain']) {
1875 1875
       upd_create_table('captain',
1876 1876
         "(
1877 1877
           `captain_id` SERIAL COMMENT 'Record ID',
@@ -1891,7 +1891,7 @@  discard block
 block discarded – undo
1891 1891
       );
1892 1892
     }
1893 1893
 
1894
-    if(!$update_tables['fleets']['fleet_start_planet_id']) {
1894
+    if (!$update_tables['fleets']['fleet_start_planet_id']) {
1895 1895
       upd_alter_table('fleets', array(
1896 1896
         "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
1897 1897
         "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`",
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 
1914 1914
     upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1915 1915
 
1916
-    if(!$update_tables['chat_player']) {
1916
+    if (!$update_tables['chat_player']) {
1917 1917
       upd_create_table('chat_player',
1918 1918
         "(
1919 1919
           `chat_player_id` SERIAL COMMENT 'Record ID',
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
       "DROP FOREIGN KEY `FK_payment_user`",
1976 1976
     ), $update_foreigns['payment']['FK_payment_user']);
1977 1977
 
1978
-    if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') {
1978
+    if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') {
1979 1979
       upd_alter_table('chat', array(
1980 1980
         "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
1981 1981
         "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`",
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
       "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2009 2009
     ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2010 2010
 
2011
-    if(!$update_tables['unit']['unit_time_start']) {
2011
+    if (!$update_tables['unit']['unit_time_start']) {
2012 2012
       upd_alter_table('unit', array(
2013 2013
         "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
2014 2014
         "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'",
@@ -2018,13 +2018,13 @@  discard block
 block discarded – undo
2018 2018
         "INSERT INTO {{unit}}
2019 2019
           (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish)
2020 2020
         SELECT
2021
-          `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2021
+          `powerup_user_id`, " . LOC_USER.", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2022 2022
           , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL)
2023 2023
         FROM {{powerup}}"
2024 2024
       );
2025 2025
     }
2026 2026
 
2027
-    if(!$update_tables['que']) {
2027
+    if (!$update_tables['que']) {
2028 2028
       upd_create_table('que',
2029 2029
         "(
2030 2030
           `que_id` SERIAL COMMENT 'Internal que id',
@@ -2056,25 +2056,25 @@  discard block
 block discarded – undo
2056 2056
     }
2057 2057
 
2058 2058
     // Конвертирум очередь исследований
2059
-    if($update_tables['users']['que']) {
2059
+    if ($update_tables['users']['que']) {
2060 2060
       $que_lines = array();
2061 2061
       $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2062
-      while($que_row = db_fetch($que_query)) {
2062
+      while ($que_row = db_fetch($que_query)) {
2063 2063
         $que_data = explode(',', $que_row['que']);
2064 2064
 
2065
-        if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) {
2065
+        if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) {
2066 2066
           continue;
2067 2067
         }
2068 2068
 
2069 2069
         $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2070 2070
         // Если планета пустая - ставим главку
2071 2071
         $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2072
-        if($que_data[QI_PLANET_ID]) {
2072
+        if ($que_data[QI_PLANET_ID]) {
2073 2073
           $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2074
-          if(!$que_planet_check['id']) {
2074
+          if (!$que_planet_check['id']) {
2075 2075
             $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2076 2076
             $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2077
-            if(!$que_planet_check['id']) {
2077
+            if (!$que_planet_check['id']) {
2078 2078
               $que_data[QI_PLANET_ID] = 'NULL';
2079 2079
             }
2080 2080
           }
@@ -2088,20 +2088,20 @@  discard block
 block discarded – undo
2088 2088
         $price_increase = pow($unit_factor, $unit_level);
2089 2089
         $unit_level++;
2090 2090
         $unit_cost = array();
2091
-        foreach($unit_info[P_COST] as $resource_id => $resource_amount) {
2092
-          if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) {
2091
+        foreach ($unit_info[P_COST] as $resource_id => $resource_amount) {
2092
+          if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) {
2093 2093
             continue;
2094 2094
           }
2095
-          $unit_cost[] = $resource_id . ',' . floor($resource_cost);
2095
+          $unit_cost[] = $resource_id.','.floor($resource_cost);
2096 2096
         }
2097 2097
         $unit_cost = implode(';', $unit_cost);
2098 2098
 
2099
-        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," .
2100
-          BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2099
+        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]},".QUE_RESEARCH.",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1,".
2100
+          BUILD_CREATE.",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2101 2101
       }
2102 2102
 
2103
-      if(!empty($que_lines)) {
2104
-        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));
2103
+      if (!empty($que_lines)) {
2104
+        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));
2105 2105
       }
2106 2106
 
2107 2107
       upd_alter_table('users', array(
@@ -2114,23 +2114,23 @@  discard block
 block discarded – undo
2114 2114
 
2115 2115
 
2116 2116
     // Ковертируем технологии в таблицы
2117
-    if($update_tables['users']['graviton_tech']) {
2118
-      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2117
+    if ($update_tables['users']['graviton_tech']) {
2118
+      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = ".UNIT_TECHNOLOGIES);
2119 2119
 
2120 2120
       $que_lines = array();
2121 2121
       $user_query = upd_do_query("SELECT * FROM {{users}}");
2122 2122
       upd_add_more_time(300);
2123 2123
       $sn_group_tech = sn_get_groups('tech');
2124
-      while($user_row = db_fetch($user_query)) {
2125
-        foreach($sn_group_tech as $tech_id) {
2126
-          if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
2127
-            $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2124
+      while ($user_row = db_fetch($user_query)) {
2125
+        foreach ($sn_group_tech as $tech_id) {
2126
+          if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
2127
+            $que_lines[] = "({$user_row['id']},".LOC_USER.",{$user_row['id']},".UNIT_TECHNOLOGIES.",{$tech_id},{$tech_level})";
2128 2128
           }
2129 2129
         }
2130 2130
       }
2131 2131
 
2132
-      if(!empty($que_lines)) {
2133
-        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));
2132
+      if (!empty($que_lines)) {
2133
+        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));
2134 2134
       }
2135 2135
 
2136 2136
       upd_alter_table('users', array(
@@ -2138,25 +2138,25 @@  discard block
 block discarded – undo
2138 2138
       ), $update_tables['users']['graviton_tech']);
2139 2139
     }
2140 2140
 
2141
-    if(!$update_indexes['unit']['I_unit_record_search']) {
2141
+    if (!$update_indexes['unit']['I_unit_record_search']) {
2142 2142
       upd_alter_table('unit', array(
2143 2143
         "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2144 2144
       ), !$update_indexes['unit']['I_unit_record_search']);
2145 2145
 
2146
-      foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
2146
+      foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
2147 2147
         $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2148 2148
       }
2149 2149
       $drop_index = array();
2150 2150
       $create_index = &$drop_index; // array();
2151
-      foreach($planet_units as $unit_name => $unit_create) {
2152
-        if($update_indexes['planets']['I_' . $unit_name]) {
2151
+      foreach ($planet_units as $unit_name => $unit_create) {
2152
+        if ($update_indexes['planets']['I_'.$unit_name]) {
2153 2153
           $drop_index[] = "DROP KEY I_{$unit_name}";
2154 2154
         }
2155
-        if($update_indexes['planets']['i_' . $unit_name]) {
2155
+        if ($update_indexes['planets']['i_'.$unit_name]) {
2156 2156
           $drop_index[] = "DROP KEY i_{$unit_name}";
2157 2157
         }
2158 2158
 
2159
-        if($unit_create) {
2159
+        if ($unit_create) {
2160 2160
           $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2161 2161
         }
2162 2162
       }
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
       "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2168 2168
     ), !$update_tables['users']['user_time_utc_offset']);
2169 2169
 
2170
-    if(!$update_foreigns['alliance']['FK_alliance_owner']) {
2170
+    if (!$update_foreigns['alliance']['FK_alliance_owner']) {
2171 2171
       upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})");
2172 2172
 
2173 2173
       upd_alter_table('alliance', array(
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
 
2188 2188
     upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer);
2189 2189
 
2190
-    if(!$update_tables['player_name_history']) {
2190
+    if (!$update_tables['player_name_history']) {
2191 2191
       upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost);
2192 2192
       upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
2193 2193
 
@@ -2213,10 +2213,10 @@  discard block
 block discarded – undo
2213 2213
 
2214 2214
     upd_alter_table('planets', array(
2215 2215
       "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'",
2216
-      "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2216
+      "ADD `density_index` TINYINT NOT NULL DEFAULT ".PLANET_DENSITY_STANDARD." COMMENT 'Planet cached density index'",
2217 2217
     ), !$update_tables['planets']['density_index']);
2218 2218
 
2219
-    if($update_tables['users']['player_artifact_list']) {
2219
+    if ($update_tables['users']['player_artifact_list']) {
2220 2220
       upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2221 2221
 
2222 2222
       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']);
@@ -2226,14 +2226,14 @@  discard block
 block discarded – undo
2226 2226
       $db_changeset = array();
2227 2227
 
2228 2228
       $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2229
-      while($row = db_fetch($query)) {
2229
+      while ($row = db_fetch($query)) {
2230 2230
         $artifact_list = explode(';', $row['player_artifact_list']);
2231
-        if(!$row['player_artifact_list'] || empty($artifact_list)) {
2231
+        if (!$row['player_artifact_list'] || empty($artifact_list)) {
2232 2232
           continue;
2233 2233
         }
2234
-        foreach($artifact_list as $key => &$value) {
2234
+        foreach ($artifact_list as $key => &$value) {
2235 2235
           $value = explode(',', $value);
2236
-          if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
2236
+          if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
2237 2237
             unset($artifact_list[$key]);
2238 2238
             continue;
2239 2239
           }
Please login to merge, or discard this patch.
includes/classes/RequestInfo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
     // Инфа об устройстве и браузере - общая для всех
88 88
     sn_db_transaction_start();
89 89
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
90
-    if($this->device_cypher) {
90
+    if ($this->device_cypher) {
91 91
       $cypher_safe = db_escape($this->device_cypher);
92 92
       $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
93
-      if(!empty($device_id['device_id'])) {
93
+      if (!empty($device_id['device_id'])) {
94 94
         $this->device_id = $device_id['device_id'];
95 95
       }
96 96
     }
97 97
 
98
-    if($this->device_id <= 0) {
98
+    if ($this->device_id <= 0) {
99 99
       do {
100 100
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
101 101
         $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
   public function db_counter_insert($user_id_unsafe) {
167 167
     global $sys_stop_log_hit;
168 168
 
169
-    if($sys_stop_log_hit || !classSupernova::$config->game_counter) {
169
+    if ($sys_stop_log_hit || !classSupernova::$config->game_counter) {
170 170
       return;
171 171
     }
172 172
 
Please login to merge, or discard this patch.
includes/classes/DbRowDirectOperator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
       ->setIdField($entity->getIdFieldName())
19 19
       ->field('*')
20 20
       ->from($entity->getTableName())
21
-      ->where($entity->getIdFieldName() . ' = "' . $entity->dbId . '"');
21
+      ->where($entity->getIdFieldName().' = "'.$entity->dbId.'"');
22 22
 
23 23
     return $stmt->selectRow();
24 24
   }
Please login to merge, or discard this patch.
includes/classes/SnDbCachedOperator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
           $query = $this->db->doSelect(
199 199
             "SELECT
200 200
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
201
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
202
-            ($filter ? ' WHERE ' . $filter : '') .
201
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
202
+            ($filter ? ' WHERE '.$filter : '').
203 203
             ($fetch ? ' LIMIT 1' : ''));
204
-          while($row = db_fetch($query)) {
204
+          while ($row = db_fetch($query)) {
205 205
             // Исключаем из списка родительских ИД уже заблокированные записи
206 206
             if (!$this->snCache->cache_lock_get($owner_location_type, $row['parent_id'])) {
207 207
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
           if ($indexes_str = implode(',', $parent_id_list)) {
213 213
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
214 214
             classSupernova::$gc->cacheOperator->db_get_record_list($owner_location_type,
215
-              $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
215
+              $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
216 216
           }
217 217
         }
218 218
       }
219 219
 
220 220
       $query = $this->db->doSelect(
221
-        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
221
+        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
222 222
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
223 223
         . " FOR UPDATE"
224 224
       );
225
-      while($row = db_fetch($query)) {
225
+      while ($row = db_fetch($query)) {
226 226
         // Caching record in row cache
227 227
         $this->snCache->cache_set($location_type, $row);
228 228
         // Making ref to cached record in query cache
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     $condition = trim($condition);
293 293
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
294 294
 
295
-    if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
295
+    if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) {
296 296
 
297 297
       if ($this->db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
298 298
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
   public function db_lock_tables($tables) {
364 364
     $tables = is_array($tables) ? $tables : array($tables => '');
365 365
     foreach ($tables as $table_name => $condition) {
366
-      $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
366
+      $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
367 367
     }
368 368
   }
369 369
 }
Please login to merge, or discard this patch.
includes/classes/DBStaticUnit.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     if (classSupernova::$gc->snCache->isUnitLocatorNotSet($location_type, $location_id)) {
27
-      $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions());
27
+      $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions());
28 28
       if (!empty($got_data) && is_array($got_data)) {
29 29
         foreach ($got_data as $unit_id => $unit_data) {
30 30
           classSupernova::$gc->snCache->setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data);
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
   public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) {
61 61
     $query = classSupernova::$db->doSelect(
62
-      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} " .
63
-      ($unit_type ? "AND `unit_type` = {$unit_type} " : '') .
64
-      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') .
62
+      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} ".
63
+      ($unit_type ? "AND `unit_type` = {$unit_type} " : '').
64
+      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '').
65 65
       'GROUP BY `unit_snid`'
66 66
     );
67 67
     $result = array();
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     WHERE
82 82
       f.fleet_owner = {$user_id} AND
83 83
       (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id})
84
-      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() .
85
-      " LIMIT 1" .
84
+      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions().
85
+      " LIMIT 1".
86 86
       ($for_update ? ' FOR UPDATE' : ''));
87 87
   }
88 88
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
   public static function db_unit_list_laboratories($user_id) {
91 91
     return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id`
92 92
     FROM {{unit}}
93
-    WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
93
+    WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");");
94 94
   }
95 95
 
96 96
   public static function db_unit_set_by_id($unit_id, $set) {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     return classSupernova::$db->doSelect(
125 125
       "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount
126 126
     FROM `{{unit}}`
127
-    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() .
127
+    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions().
128 128
       " GROUP BY unit_player_id, unit_type, unit_snid, unit_level"
129 129
     );
130 130
   }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
   public static function db_unit_list_admin_delete_mercenaries_finished() {
139 139
     return classSupernova::$db->doDeleteDeprecated(TABLE_UNIT, array(
140 140
       'unit_time_finish IS NOT NULL',
141
-      "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")",
141
+      "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")",
142 142
       'unit_type' => UNIT_MERCENARIES,
143 143
     ));
144 144
   }
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
     return classSupernova::$db->doUpdate(
148 148
       "UPDATE `{{unit}}`
149 149
     SET
150
-      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "),
151
-      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ")
150
+      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."),
151
+      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).")
152 152
     WHERE unit_type = " . UNIT_MERCENARIES
153 153
     );
154 154
   }
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 
174 174
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
175 175
     if (!empty($temp['unit_id'])) {
176
-      $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_list(
176
+      $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_list(
177 177
         LOC_UNIT, "`unit_level` = `unit_level` + ($unit_value)", "`unit_id` = {$temp['unit_id']}"
178 178
       );
179 179
     } else {
180 180
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
181 181
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
182
-      $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, array(
182
+      $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, array(
183 183
         'unit_player_id'     => $user['id'],
184
-        'unit_location_type' => (int)$unit_location,
184
+        'unit_location_type' => (int) $unit_location,
185 185
         'unit_location_id'   => $locationIdRendered,
186
-        'unit_type'          => (int)$unitType,
187
-        'unit_snid'          => (int)$unit_id,
188
-        'unit_level'         => (float)$unit_value,
186
+        'unit_type'          => (int) $unitType,
187
+        'unit_snid'          => (int) $unit_id,
188
+        'unit_level'         => (float) $unit_value,
189 189
       ));
190 190
     }
191 191
 
Please login to merge, or discard this patch.
includes/classes/DBRow.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @param db_mysql|null $db
87 87
    */
88 88
   public static function setDb($db = null) {
89
-    if(empty($db) || !($db instanceof db_mysql)) {
89
+    if (empty($db) || !($db instanceof db_mysql)) {
90 90
       $db = null;
91 91
     }
92 92
     static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
   public function dbLoad($dbId, $lockSkip = false) {
150 150
     $dbId = idval($dbId);
151 151
     if ($dbId <= 0) {
152
-      classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId);
152
+      classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId);
153 153
 
154 154
       return;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
       $this->dbGetLockById($this->_dbId);
162 162
     }
163 163
 
164
-    $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;");
164
+    $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;");
165 165
     if (empty($db_row)) {
166 166
       return;
167 167
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     if ($this->isNew()) {
194 194
       // No DB_ID - new unit
195 195
       if ($this->isEmpty()) {
196
-        classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
196
+        classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave');
197 197
       }
198 198
       $this->dbInsert();
199 199
     } else {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $this->dbDelete();
203 203
       } else {
204 204
         if (!sn_db_transaction_check(false)) {
205
-          classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
205
+          classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate');
206 206
         }
207 207
         $this->dbUpdate();
208 208
       }
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
   // TODO - protected
231 231
   public function dbInsert() {
232 232
     if (!$this->isNew()) {
233
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
233
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert');
234 234
     }
235 235
     $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet());
236 236
 
237 237
     if (empty($this->_dbId)) {
238
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
238
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert');
239 239
     }
240 240
 
241 241
     return $this->_dbId;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
   public function dbUpdate() {
249 249
     // TODO - Update
250 250
     if ($this->isNew()) {
251
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
251
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate');
252 252
     }
253 253
     $this->db_field_update($this->dbMakeFieldSet(true));
254 254
   }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
   // TODO - protected
260 260
   public function dbDelete() {
261 261
     if ($this->isNew()) {
262
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
262
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete');
263 263
     }
264 264
     classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId));
265 265
     $this->_dbId = 0;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
     $fields = implode(',', array_keys($field_set));
415 415
 
416 416
     $result = 0;
417
-    if (classSupernova::$db->doInsertComplex("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
417
+    if (classSupernova::$db->doInsertComplex("INSERT INTO `{{".static::$_table."}}` ({$fields}) VALUES ({$values});")) {
418 418
       $result = classSupernova::$db->db_insert_id();
419 419
     }
420 420
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 
451 451
     return empty($set_string)
452 452
       ? true
453
-      : classSupernova::$db->doUpdate("UPDATE `{{" . static::$_table . "}}` SET {$set_string} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId);
453
+      : classSupernova::$db->doUpdate("UPDATE `{{".static::$_table."}}` SET {$set_string} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId);
454 454
   }
455 455
 
456 456
 }
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
   public function load_db_settings($configFile = '') {
94 94
     $dbsettings = array();
95 95
 
96
-    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false;
96
+    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false;
97 97
 
98 98
     require $configFile;
99 99
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     }
114 114
 
115 115
     if (empty($this->dbsettings)) {
116
-      $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
116
+      $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
117 117
     }
118 118
 
119 119
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     $sql = $query;
166 166
     if (strpos($sql, '{{') !== false) {
167 167
       foreach ($this->table_list as $tableName) {
168
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
168
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
169 169
       }
170 170
     }
171 171
 
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 
239 239
     $queryResult = null;
240 240
     try {
241
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
241
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
242 242
       if (!$queryResult) {
243 243
         throw new Exception();
244 244
       }
245 245
     } catch (Exception $e) {
246
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
246
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
247 247
     }
248 248
 
249 249
     return $queryResult;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
     $safeFieldsAndValues = implode(',', $this->safeFieldsAndValues($fieldsAndValues));
313 313
 //    $command = $replace == DB_INSERT_REPLACE ? 'REPLACE' : 'INSERT';
314 314
 //    $command .= $replace == DB_INSERT_IGNORE ? ' IGNORE' : '';
315
-    switch($replace) {
315
+    switch ($replace) {
316 316
       case DB_INSERT_IGNORE:
317 317
         $command = 'INSERT IGNORE';
318 318
       break;
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 
464 464
 
465 465
   protected function castAsDbValue($value) {
466
-    switch(gettype($value)) {
466
+    switch (gettype($value)) {
467 467
       case TYPE_INTEGER:
468 468
       case TYPE_DOUBLE:
469 469
         // do nothing
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
       case TYPE_EMPTY:
487 487
         // No-type defaults to string
488 488
       default:
489
-        $value = "'" . $this->db_escape((string)$value) . "'";
489
+        $value = "'".$this->db_escape((string) $value)."'";
490 490
       break;
491 491
     }
492 492
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
       if (is_int($fieldName)) {
515 515
         $result[$fieldName] = $fieldValue;
516 516
       } else {
517
-        $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue);
517
+        $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue);
518 518
       }
519 519
     }
520 520
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
     }
546 546
 
547 547
     foreach ($fields as $key => $value) {
548
-      $result[$key] = "`" . $this->db_escape($value) . "`";
548
+      $result[$key] = "`".$this->db_escape($value)."`";
549 549
     }
550 550
 
551 551
     return $result;
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
       $this->isWatching = true;
602 602
       $msg = "\$query = \"{$query}\"\n\r";
603 603
       if (!empty($_POST)) {
604
-        $msg .= "\n\r" . dump($_POST, '$_POST');
604
+        $msg .= "\n\r".dump($_POST, '$_POST');
605 605
       }
606 606
       if (!empty($_GET)) {
607
-        $msg .= "\n\r" . dump($_GET, '$_GET');
607
+        $msg .= "\n\r".dump($_GET, '$_GET');
608 608
       }
609 609
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
610 610
       $this->isWatching = false;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 
620 620
     global $user, $dm_change_legit, $mm_change_legit;
621 621
 
622
-    switch(true) {
622
+    switch (true) {
623 623
       case stripos($query, 'RUNCATE TABL') != false:
624 624
       case stripos($query, 'ROP TABL') != false:
625 625
       case stripos($query, 'ENAME TABL') != false:
@@ -630,37 +630,37 @@  discard block
 block discarded – undo
630 630
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
631 631
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
632 632
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
633
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
633
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
634 634
         $report .= ">Database Inforamation\n";
635
-        $report .= "\tID - " . $user['id'] . "\n";
636
-        $report .= "\tUser - " . $user['username'] . "\n";
637
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
638
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
639
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
640
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
641
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
642
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
643
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
644
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
635
+        $report .= "\tID - ".$user['id']."\n";
636
+        $report .= "\tUser - ".$user['username']."\n";
637
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
638
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
639
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
640
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
641
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
642
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
643
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
644
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
645 645
         $report .= "\n";
646 646
 
647 647
         $report .= ">Query Information\n";
648
-        $report .= "\tQuery - " . $query . "\n";
648
+        $report .= "\tQuery - ".$query."\n";
649 649
         $report .= "\n";
650 650
 
651 651
         $report .= ">\$_SERVER Information\n";
652
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
653
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
654
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
655
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
656
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
657
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
658
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
659
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
652
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
653
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
654
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
655
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
656
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
657
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
658
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
659
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
660 660
 
661 661
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
662 662
 
663
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
663
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
664 664
         fwrite($fp, $report);
665 665
         fclose($fp);
666 666
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
     $prefix_length = strlen($this->db_prefix);
682 682
 
683 683
     $tl = array();
684
-    while($row = $this->db_fetch($query)) {
684
+    while ($row = $this->db_fetch($query)) {
685 685
       foreach ($row as $table_name) {
686 686
         if (strpos($table_name, $this->db_prefix) === 0) {
687 687
           $table_name = substr($table_name, $prefix_length);
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
     if (is_bool($query)) {
813 813
       throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?');
814 814
     }
815
-    while($row = db_fetch($query)) {
815
+    while ($row = db_fetch($query)) {
816 816
       $result[$row['Variable_name']] = $row['Value'];
817 817
     }
818 818
 
Please login to merge, or discard this patch.