Completed
Push — trunk ( 8e3c77...4322e5 )
by SuperNova.WS
04:12
created
admin/ajax_maintenance.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1));
6 6
 
7
-if($user['authlevel'] < 3)
7
+if ($user['authlevel'] < 3)
8 8
 {
9 9
   messageBox($lang['sys_noalloaw'], $lang['sys_noaccess']);
10 10
   die();
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
 // [#] info_best_battles 1b0
21 21
 $best_reports = array();
22
-if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) {
22
+if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) {
23 23
   $query = doquery(MODULE_INFO_BEST_BATTLES_QUERY);
24
-  while($row = db_fetch($query)) {
24
+  while ($row = db_fetch($query)) {
25 25
     $best_reports[] = $row['ube_report_id'];
26 26
   }
27 27
 }
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 
189 189
 function sn_maintenance_pack_user_list($user_list) {
190 190
   $user_list = explode(',', $user_list);
191
-  foreach($user_list as $key => $user_id) {
192
-    if(!is_numeric($user_id)) {
191
+  foreach ($user_list as $key => $user_id) {
192
+    if (!is_numeric($user_id)) {
193 193
       unset($user_list[$key]);
194 194
     }
195 195
   }
196 196
 
197 197
   $result = array();
198
-  if(!empty($user_list)) {
198
+  if (!empty($user_list)) {
199 199
     $query = doquery("SELECT `id` FROM `{{users}}` WHERE `id` in (" . implode(',', $user_list) . ")");
200
-    while($row = db_fetch($query)) {
200
+    while ($row = db_fetch($query)) {
201 201
       $result[] = $row['id'];
202 202
     }
203 203
   }
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 $old_server_status == GAME_DISABLE_NONE ? SN::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false;
213 213
 sn_db_transaction_commit();
214 214
 
215
-foreach($ques as $que_transaction) {
215
+foreach ($ques as $que_transaction) {
216 216
   sn_db_transaction_start();
217 217
 
218 218
   !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false;
219
-  foreach($que_transaction as $que) {
219
+  foreach ($que_transaction as $que) {
220 220
     set_time_limit(120);
221 221
     $QryResult = doquery($que);
222 222
     //$msg .= '<hr>' . $que . '<hr>';
Please login to merge, or discard this patch.
classes/Account.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     $this->secret_word = SN::$sn_secret_word;
93 93
 
94 94
     $snTableNames = $this->db->schema()->getSnTables();
95
-    foreach($this->table_check as $table_name) {
96
-      if(empty($snTableNames[$table_name])) {
95
+    foreach ($this->table_check as $table_name) {
96
+      if (empty($snTableNames[$table_name])) {
97 97
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
98 98
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
99 99
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
    */
118 118
   // OK v4.6
119 119
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
120
-    if(!$this->password_check($old_password_unsafe)) {
120
+    if (!$this->password_check($old_password_unsafe)) {
121 121
       return false;
122 122
     }
123 123
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
   // OK v4.5
139 139
   public function assign_from_db_row($row) {
140 140
     $this->reset();
141
-    if(empty($row) || !is_array($row)) {
141
+    if (empty($row) || !is_array($row)) {
142 142
       return false;
143 143
     }
144 144
     $this->account_id = $row['account_id'];
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     $this->reset();
204 204
 
205 205
     $email_safe = $this->db->db_escape($email_unsafe);
206
-    if($email_safe) {
206
+    if ($email_safe) {
207 207
       $account_row = $this->db->doquery("SELECT * FROM `{{account}}` WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true);
208 208
 
209 209
       return $this->assign_from_db_row($account_row);
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
         `account_email` = LOWER('{$email_safe}'),
277 277
         `account_language` = '{$language_safe}'"
278 278
     );
279
-    if(!$result) {
279
+    if (!$result) {
280 280
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
281 281
     }
282 282
 
283
-    if(!($account_id = $this->db->db_insert_id())) {
283
+    if (!($account_id = $this->db->db_insert_id())) {
284 284
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
285 285
     }
286 286
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
       WHERE `account_id` = '{$account_id_safe}'"
311 311
     ) ? true : false;
312 312
 
313
-    if($result) {
313
+    if ($result) {
314 314
       $result = $this->db_get_by_id($this->account_id);
315 315
     }
316 316
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
400 400
     global $debug, $mm_change_legit, $config;
401 401
 
402
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
402
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
403 403
       $debug->error('Ошибка при попытке манипуляции с ММ');
404 404
       return false;
405 405
     }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
     $mm_change_legit = true;
410 410
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
411
-    if($already_changed) {
411
+    if ($already_changed) {
412 412
       $metamatter_total_delta = 0;
413 413
       $result = -1;
414 414
     } else {
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
           ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal} AND `account_immortal` IS NULL, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
422 422
         " WHERE `account_id` = {$account_id_safe}"
423 423
       );
424
-      if(!$result) {
424
+      if (!$result) {
425 425
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
426 426
       }
427 427
       $result = SN::$db->db_affected_rows();
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
       $this->awardImmortal($metamatter, $config);
430 430
     }
431 431
 
432
-    if(empty(core_auth::$user['id'])) {
432
+    if (empty(core_auth::$user['id'])) {
433 433
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
434 434
       reset($user_list);
435 435
       $user_id_unsafe = key($user_list);
@@ -438,30 +438,30 @@  discard block
 block discarded – undo
438 438
     }
439 439
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
440 440
 
441
-    if(!$result) {
441
+    if (!$result) {
442 442
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
443 443
     }
444 444
 
445
-    if(!$already_changed) {
445
+    if (!$already_changed) {
446 446
       $this->account_metamatter += $metamatter;
447 447
       $this->account_metamatter_total += $metamatter_total_delta;
448 448
     }
449 449
 
450
-    if(is_array($comment)) {
450
+    if (is_array($comment)) {
451 451
       $comment = call_user_func_array('sprintf', $comment);
452 452
     }
453 453
 
454 454
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
455 455
 
456
-    if($metamatter > 0 && !empty($user_id_safe)) {
456
+    if ($metamatter > 0 && !empty($user_id_safe)) {
457 457
       $old_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
458
-      if($old_referral['id']) {
458
+      if ($old_referral['id']) {
459 459
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
460 460
         doquery("UPDATE `{{referrals}}` SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
461 461
         $new_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
462 462
 
463 463
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
464
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
464
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
465 465
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
466 466
         }
467 467
       }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
    * @throws Exception
478 478
    */
479 479
   public function cookieSet($rememberMe = false, $domain = null) {
480
-    if(!$this->is_exists) {
480
+    if (!$this->is_exists) {
481 481
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
482 482
     }
483 483
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
   // OK v4.1
497 497
   public function cookieClear($domain = null) {
498 498
     // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё
499
-    if(!empty($_COOKIE[$this->cookie_name_impersonate])) {
499
+    if (!empty($_COOKIE[$this->cookie_name_impersonate])) {
500 500
       sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain);
501 501
       sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain);
502 502
     } else {
@@ -506,14 +506,14 @@  discard block
 block discarded – undo
506 506
 
507 507
   public function cookieLogin(&$rememberMe = false) {
508 508
     // Пытаемся войти по куке
509
-    if(!empty($_COOKIE[$this->cookie_name])) {
510
-      if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
509
+    if (!empty($_COOKIE[$this->cookie_name])) {
510
+      if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
511 511
         list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]);
512 512
       } else {
513 513
         list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]);
514 514
       }
515 515
 
516
-      if(
516
+      if (
517 517
         $this->db_get_by_id($account_id_unsafe)
518 518
         && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted)
519 519
       ) {
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
    * @param classConfig $config
539 539
    */
540 540
   protected function awardImmortal($metamatter, $config) {
541
-    if(!is_object($awardModule = moduleAward())) {
541
+    if (!is_object($awardModule = moduleAward())) {
542 542
       return;
543 543
     }
544
-    if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal ) {
544
+    if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal) {
545 545
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list(ACCOUNT_PROVIDER_LOCAL, $this->account_id);
546 546
       if (!empty($account_translation)) {
547 547
         reset($account_translation);
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
    * @return bool|mysqli_result|null
564 564
    */
565 565
   public function getMetamatterSum($where = '', $group = '') {
566
-    if(is_array($where) && !empty($where)) {
566
+    if (is_array($where) && !empty($where)) {
567 567
       $where = implode(' AND ', $where);
568 568
     }
569
-    if(is_array($group) && !empty($group)) {
569
+    if (is_array($group) && !empty($group)) {
570 570
       $group = implode(',', $group);
571 571
     }
572 572
 
Please login to merge, or discard this patch.
classes/Core/GlobalContainer.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -91,99 +91,99 @@
 block discarded – undo
91 91
 
92 92
     // Services --------------------------------------------------------------------------------------------------------
93 93
     // Default db
94
-    $gc->db = function (GlobalContainer $c) {
94
+    $gc->db = function(GlobalContainer $c) {
95 95
       SN::$db = new \DBAL\db_mysql($c);
96 96
 
97 97
       return SN::$db;
98 98
     };
99 99
 
100
-    $gc->debug = function (/** @noinspection PhpUnusedParameterInspection */
100
+    $gc->debug = function(/** @noinspection PhpUnusedParameterInspection */
101 101
       GlobalContainer $c) {
102 102
       return new \debug();
103 103
     };
104 104
 
105
-    $gc->cache = function (GlobalContainer $gc) {
105
+    $gc->cache = function(GlobalContainer $gc) {
106 106
       return new \classCache($gc->cachePrefix);
107 107
     };
108 108
 
109
-    $gc->config = function (GlobalContainer $gc) {
109
+    $gc->config = function(GlobalContainer $gc) {
110 110
       return new \classConfig($gc->cachePrefix);
111 111
     };
112 112
 
113 113
 
114
-    $gc->repository = function (GlobalContainer $gc) {
114
+    $gc->repository = function(GlobalContainer $gc) {
115 115
       return new Repository($gc);
116 116
     };
117 117
 
118
-    $gc->storage = function (GlobalContainer $gc) {
118
+    $gc->storage = function(GlobalContainer $gc) {
119 119
       return new \Storage($gc);
120 120
     };
121 121
 
122
-    $gc->repoV2 = function (GlobalContainer $gc) {
122
+    $gc->repoV2 = function(GlobalContainer $gc) {
123 123
       return new RepoV2($gc);
124 124
     };
125 125
 
126
-    $gc->storageV2 = function (GlobalContainer $gc) {
126
+    $gc->storageV2 = function(GlobalContainer $gc) {
127 127
       return new StorageV2($gc);
128 128
     };
129 129
 
130
-    $gc->design = function (GlobalContainer $gc) {
130
+    $gc->design = function(GlobalContainer $gc) {
131 131
       return new \Design($gc);
132 132
     };
133 133
 
134
-    $gc->bbCodeParser = function (GlobalContainer $gc) {
134
+    $gc->bbCodeParser = function(GlobalContainer $gc) {
135 135
       return new \BBCodeParser($gc);
136 136
     };
137 137
 
138
-    $gc->fleetDispatcher = function (GlobalContainer $gc) {
138
+    $gc->fleetDispatcher = function(GlobalContainer $gc) {
139 139
       return new \Fleet\FleetDispatcher($gc);
140 140
     };
141 141
 
142
-    $gc->watchdog = function (GlobalContainer $gc) {
142
+    $gc->watchdog = function(GlobalContainer $gc) {
143 143
       return new Watchdog($gc);
144 144
     };
145 145
 
146
-    $gc->valueStorage = function (GlobalContainer $gc) {
146
+    $gc->valueStorage = function(GlobalContainer $gc) {
147 147
       return new ValueStorage([]);
148 148
     };
149 149
 
150
-    $gc->bonusCatalog = function (GlobalContainer $gc) {
150
+    $gc->bonusCatalog = function(GlobalContainer $gc) {
151 151
       return new BonusCatalog($gc);
152 152
     };
153 153
 
154
-    $gc->general = function (GlobalContainer $gc) {
154
+    $gc->general = function(GlobalContainer $gc) {
155 155
       return new General($gc);
156 156
     };
157 157
 
158
-    $gc->economicHelper = function (GlobalContainer $gc) {
158
+    $gc->economicHelper = function(GlobalContainer $gc) {
159 159
       return new EconomicHelper($gc);
160 160
     };
161 161
 
162
-    $gc->playerLevelHelper = function (GlobalContainer $gc) {
162
+    $gc->playerLevelHelper = function(GlobalContainer $gc) {
163 163
       return new PlayerLevelHelper($gc);
164 164
     };
165 165
 
166
-    $gc->pimp = function (GlobalContainer $gc) {
166
+    $gc->pimp = function(GlobalContainer $gc) {
167 167
       return new SnPimp($gc);
168 168
     };
169 169
 
170
-    $gc->modules = function (GlobalContainer $gc) {
170
+    $gc->modules = function(GlobalContainer $gc) {
171 171
       return new ModulesManager($gc);
172 172
     };
173 173
 
174 174
     // Dummy objects ---------------------------------------------------------------------------------------------------
175
-    $gc->theUser = function (GlobalContainer $gc) {
175
+    $gc->theUser = function(GlobalContainer $gc) {
176 176
       return new \TheUser($gc);
177 177
     };
178 178
 
179 179
 
180 180
     // Models ----------------------------------------------------------------------------------------------------------
181 181
     $gc->skinEntityClass = \SkinV2::class;
182
-    $gc->skinModel = function (GlobalContainer $gc) {
182
+    $gc->skinModel = function(GlobalContainer $gc) {
183 183
       return new \SkinModel($gc);
184 184
     };
185 185
 
186
-    $gc->textModel = function (GlobalContainer $gc) {
186
+    $gc->textModel = function(GlobalContainer $gc) {
187 187
       return new \TextModel($gc);
188 188
     };
189 189
 
Please login to merge, or discard this patch.
classes/Core/SnBootstrap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 class SnBootstrap {
13 13
 
14 14
   public static function install_benchmark() {
15
-    register_shutdown_function(function () {
15
+    register_shutdown_function(function() {
16 16
       if (defined('IN_AJAX')) {
17 17
         return;
18 18
       }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         ];
62 62
         file_put_contents($fName, implode("\n", $output), FILE_APPEND | LOCK_EX);
63 63
 
64
-        if(!empty($error['file']) && strpos($error['file'], 'classCache.php') !== false) {
64
+        if (!empty($error['file']) && strpos($error['file'], 'classCache.php') !== false) {
65 65
           print('<span style="color: red">Looks like cache clearing takes too long... Try to restart your web-server and/or cache engine</span>');
66 66
         }
67 67
       }
Please login to merge, or discard this patch.
includes/includes/flt_mission_explore.php 1 patch
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 
15 15
   $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000;
16 16
   $fleet_lost = array();
17
-  foreach($fleet as $unit_id => &$unit_amount) {
17
+  foreach ($fleet as $unit_id => &$unit_amount) {
18 18
     $ships_left = floor($unit_amount * $fleet_left);
19 19
     $fleet_lost[$unit_id] = $unit_amount - $ships_left;
20 20
     $unit_amount = $ships_left;
21
-    if(!$unit_amount) {
21
+    if (!$unit_amount) {
22 22
       unset($fleet[$unit_id]);
23 23
     }
24 24
   }
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 //  $fleet = array();
32 32
 }
33 33
 
34
-function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));}
34
+function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); }
35 35
 function sn_flt_mission_explore_addon(&$result) {
36 36
   return $result;
37 37
 }
38 38
 
39 39
 
40 40
 function flt_mission_explore(&$mission_data) {
41
-  if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) {
41
+  if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) {
42 42
     return CACHE_NONE;
43 43
   }
44 44
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
   $outcome_list = &$result['$outcome_list'];
72 72
   $fleet_metal_points = &$result['$fleet_metal_points'];
73 73
 
74
-  if(!$ship_data) {
75
-    foreach(sn_get_groups('fleet') as $unit_id) {
74
+  if (!$ship_data) {
75
+    foreach (sn_get_groups('fleet') as $unit_id) {
76 76
       $unit_info = get_unit_param($unit_id);
77
-      if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
77
+      if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
78 78
         continue;
79 79
       }
80 80
       $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
   $fleet = sys_unit_str2arr($fleet_row['fleet_array']);
87 87
   $fleet_capacity = 0;
88 88
   $fleet_metal_points = 0;
89
-  foreach($fleet as $ship_id => $ship_amount) {
89
+  foreach ($fleet as $ship_id => $ship_amount) {
90 90
     $unit_info = get_unit_param($ship_id);
91 91
     $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY];
92 92
     $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL];
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
   $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1);
97 97
 
98 98
   $outcome_list = sn_get_groups(GROUP_MISSION_EXPLORE_OUTCOMES);
99
-  $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7));
99
+  $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7));
100 100
 
101 101
   $chance_max = 0;
102
-  foreach($outcome_list as $key => &$value) {
103
-    if(!$value['chance']) {
102
+  foreach ($outcome_list as $key => &$value) {
103
+    if (!$value['chance']) {
104 104
       unset($outcome_list[$key]);
105 105
       continue;
106 106
     }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
   $outcome_value = mt_rand(0, $chance_max);
110 110
 // $outcome_value = 409;
111 111
   $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE];
112
-  foreach($outcome_list as $key => &$value) {
113
-    if(!$value['chance']) {
112
+  foreach ($outcome_list as $key => &$value) {
113
+    if (!$value['chance']) {
114 114
       continue;
115 115
     }
116 116
     $mission_outcome = $key;
117 117
     $outcome_description = $value;
118
-    if($outcome_value <= $outcome_description['value']) {
118
+    if ($outcome_value <= $outcome_description['value']) {
119 119
       break;
120 120
     }
121 121
   }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
   $found_dark_matter = 0;
132 132
 //  $outcome_mission_sub = -1;
133 133
 
134
-  switch($mission_outcome) {
134
+  switch ($mission_outcome) {
135 135
 //  switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG!
136 136
     case FLT_EXPEDITION_OUTCOME_LOST_FLEET:
137 137
       flt_mission_explore_outcome_lost_fleet($result);
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 
167 167
       // Рассчитываем стоимость самого дорого корабля в металле
168 168
       $max_metal_cost = 0;
169
-      foreach($fleet as $ship_id => $ship_amount) {
169
+      foreach ($fleet as $ship_id => $ship_amount) {
170 170
         $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']);
171 171
       }
172 172
 
173 173
       // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля
174 174
       $can_be_found = array();
175
-      foreach($ship_data as $ship_id => $ship_info) {
176
-        if(
175
+      foreach ($ship_data as $ship_id => $ship_info) {
176
+        if (
177 177
           $ship_info['metal_cost'] < $max_metal_cost
178 178
           // and not race ship
179 179
           && empty(get_unit_param($ship_id, 'player_race'))
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
       unset($can_be_found[SHIP_SPY]);
189 189
 
190 190
       $fleet_found = array();
191
-      while(count($can_be_found) && $found_in_metal >= max($can_be_found)) {
191
+      while (count($can_be_found) && $found_in_metal >= max($can_be_found)) {
192 192
         $found_index = mt_rand(1, count($can_be_found)) - 1;
193 193
         $found_ship = array_slice($can_be_found, $found_index, 1, true);
194 194
         $found_ship_cost = reset($found_ship);
195 195
         $found_ship_id = key($found_ship);
196 196
 
197
-        if($found_ship_cost > $found_in_metal) {
197
+        if ($found_ship_cost > $found_in_metal) {
198 198
           unset($can_be_found[$found_ship_id]);
199 199
         } else {
200 200
           $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost));
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
         }
204 204
       }
205 205
 
206
-      if(empty($fleet_found)) {
206
+      if (empty($fleet_found)) {
207 207
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
208 208
       } else {
209
-        foreach($fleet_found as $unit_id => $unit_amount) {
209
+        foreach ($fleet_found as $unit_id => $unit_amount) {
210 210
           $fleet[$unit_id] += $unit_amount;
211 211
         }
212 212
       }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
       $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL];
233 233
       $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM];
234 234
 
235
-      if(array_sum($resources_found) == 0) {
235
+      if (array_sum($resources_found) == 0) {
236 236
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
237 237
       }
238 238
     break;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
       // Рассчитываем количество найденной ТМ
244 244
       $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000);
245 245
 
246
-      if(!$found_dark_matter) {
246
+      if (!$found_dark_matter) {
247 247
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
248 248
       }
249 249
     break;
@@ -257,31 +257,31 @@  discard block
 block discarded – undo
257 257
 
258 258
   flt_mission_explore_addon($result);
259 259
 
260
-  if($found_dark_matter) {
260
+  if ($found_dark_matter) {
261 261
     rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus');
262 262
     $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter);
263 263
   }
264 264
 
265
-  if(!empty($fleet_lost)) {
265
+  if (!empty($fleet_lost)) {
266 266
     $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet'];
267
-    foreach($fleet_lost as $ship_id => $ship_amount) {
267
+    foreach ($fleet_lost as $ship_id => $ship_amount) {
268 268
       $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
269 269
     }
270 270
   }
271 271
 
272 272
   $fleet_row['fleet_amount'] = array_sum($fleet);
273
-  if(!empty($fleet) && $fleet_row['fleet_amount']) {
274
-    if(!empty($fleet_found)) {
273
+  if (!empty($fleet) && $fleet_row['fleet_amount']) {
274
+    if (!empty($fleet_found)) {
275 275
       $msg_text_addon = $lang['flt_mission_expedition']['found_fleet'];
276
-      foreach($fleet_found as $ship_id => $ship_amount) {
276
+      foreach ($fleet_found as $ship_id => $ship_amount) {
277 277
         $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
278 278
       }
279 279
     }
280 280
 
281 281
     $query_delta = array();
282
-    if(!empty($resources_found) && array_sum($resources_found) > 0) {
282
+    if (!empty($resources_found) && array_sum($resources_found) > 0) {
283 283
       $msg_text_addon = $lang['flt_mission_expedition']['found_resources'];
284
-      foreach($resources_found as $ship_id => $ship_amount) {
284
+      foreach ($resources_found as $ship_id => $ship_amount) {
285 285
         $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
286 286
       }
287 287
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     }
295 295
 
296 296
     $query_data = array();
297
-    if(!empty($fleet_lost) || !empty($fleet_found)) {
297
+    if (!empty($fleet_lost) || !empty($fleet_found)) {
298 298
       $fleet_row['fleet_array'] = sys_unit_arr2str($fleet);
299 299
 
300 300
 //      $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}";
@@ -322,17 +322,16 @@  discard block
 block discarded – undo
322 322
 
323 323
   db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1");
324 324
 
325
-  if(!$msg_text) {
325
+  if (!$msg_text) {
326 326
     $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages'];
327
-    if($outcome_mission_sub >= 0 && is_array($messages)) {
327
+    if ($outcome_mission_sub >= 0 && is_array($messages)) {
328 328
       $messages = &$messages[$outcome_mission_sub];
329 329
     }
330 330
 
331
-    $msg_text = is_string($messages) ? $messages :
332
-      (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
331
+    $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
333 332
   }
334 333
   $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) .
335
-    ($msg_text_addon ? "\r\n" . $msg_text_addon: '');
334
+    ($msg_text_addon ? "\r\n" . $msg_text_addon : '');
336 335
 
337 336
   msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text);
338 337
 
Please login to merge, or discard this patch.
admin/adm_flying_fleets.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 //while($CurrentFleet = db_fetch($FlyingFleets))
24 24
 
25 25
 $all_flying_fleets = DbFleetStatic::db_fleet_list('', DB_SELECT_PLAIN);
26
-foreach($all_flying_fleets as $fleet_id => $CurrentFleet) {
26
+foreach ($all_flying_fleets as $fleet_id => $CurrentFleet) {
27 27
   $FleetOwner = db_user_by_id($CurrentFleet['fleet_owner']);
28 28
   $TargetOwner = db_user_by_id($CurrentFleet['fleet_target_owner']);
29 29
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
   $fleet_data['fleet']['STAY_TIME_INT'] = $CurrentFleet['fleet_end_stay'];
35 35
 
36 36
   $template->assign_block_vars('fleets', $fleet_data['fleet']);
37
-  foreach($fleet_data['ships'] as $ship_data) {
37
+  foreach ($fleet_data['ships'] as $ship_data) {
38 38
     $template->assign_block_vars('fleets.ships', $ship_data);
39 39
   }
40 40
 }
Please login to merge, or discard this patch.
includes/includes/flt_mission_destroy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 function flt_mission_destroy($mission_data) {
11 11
   $fleet_row = $mission_data['fleet'];
12 12
   $destination_planet = $mission_data['dst_planet'];
13
-  if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) {
13
+  if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) {
14 14
     DbFleetStatic::fleet_send_back($fleet_row);
15 15
 
16 16
     return CACHE_FLEET;
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 function flt_mission_hold(&$mission_data)
6 6
 {
7
-  if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
7
+  if ($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
8 8
   {
9 9
     DbFleetStatic::fleet_send_back($mission_data['fleet']);
10 10
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use Fleet\DbFleetStatic;
4 4
 
5
-function flt_mission_hold(&$mission_data)
6
-{
5
+function flt_mission_hold(&$mission_data) {
7 6
   if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
8 7
   {
9 8
     DbFleetStatic::fleet_send_back($mission_data['fleet']);
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@  discard block
 block discarded – undo
3 3
 use Fleet\DbFleetStatic;
4 4
 use Planet\DBStaticPlanet;
5 5
 
6
-if(SN_IN_FLEET !== true) {
6
+if (SN_IN_FLEET !== true) {
7 7
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
8 8
 }
9 9
 
10 10
 $fleetid = sys_get_param_id('fleetid');
11 11
 
12
-if(!is_numeric($fleetid) || empty($fleetid)) {
12
+if (!is_numeric($fleetid) || empty($fleetid)) {
13 13
   sys_redirect("fleet.php");
14 14
 }
15 15
 
16 16
 $fleet = DbFleetStatic::db_fleet_get($fleetid);
17
-if(!$fleet) {
17
+if (!$fleet) {
18 18
   messageBox($lang['fl_fleet_not_exists'], $lang['fl_error']);
19 19
 }
20 20
 //$query = doquery("SELECT * FROM `{{fleets}}` WHERE fleet_id = '{$fleetid}'");
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
   messageBox($lang['fl_isback'], $lang['fl_error']);
29 29
 }
30 30
 
31
-if($fleet['fleet_owner'] != $user['id']) {
32
-  $debug->warning($lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301);
31
+if ($fleet['fleet_owner'] != $user['id']) {
32
+  $debug->warning($lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
33 33
   messageBox($lang['fl_aks_hack_wrong_fleet'], $lang['fl_error']);
34 34
 }
35 35
 
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 
40 40
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
41 41
 
42
-if($userToAdd_unsafe) {
42
+if ($userToAdd_unsafe) {
43 43
   $userToAdd = db_escape($userToAdd_unsafe);
44 44
   $userToAddID = db_user_by_username($userToAdd_unsafe, true);
45 45
   $userToAddID = $userToAddID['id'];
46 46
 
47
-  if($fleet['fleet_target_owner'] == $userToAddID) {
47
+  if ($fleet['fleet_target_owner'] == $userToAddID) {
48 48
     messageBox($lang['flt_aks_player_same'], $lang['fl_error']);
49 49
   }
50 50
 
51
-  if($userToAddID) {
52
-    if(!$aks) {
51
+  if ($userToAddID) {
52
+    if (!$aks) {
53 53
       // No AСS exists - making one
54
-      if(!$fleet['fleet_group']) {
54
+      if (!$fleet['fleet_group']) {
55 55
         doquery("INSERT INTO {{aks}} SET
56 56
           `name` = '" . db_escape($lang['flt_acs_prefix'] . $fleetid) . "',
57 57
           `teilnehmer` = '" . $user['id'] . "',
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
           `planet` = '" . $fleet['fleet_end_planet'] . "',
63 63
           `planet_type` = '" . $fleet['fleet_end_type'] . "',
64 64
           `eingeladen` = '" . $user['id'] . "',
65
-          `fleet_end_time` = '" . $fleet['fleet_end_time']. "'");
65
+          `fleet_end_time` = '" . $fleet['fleet_end_time'] . "'");
66 66
 
67 67
         $aks = doquery("SELECT * FROM {{aks}} WHERE `flotten` = {$fleetid} LIMIT 1;", true);
68 68
 
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
 
81 81
     $isUserExists = false;
82 82
     $invited_ar = explode(",", $aks['eingeladen']);
83
-    foreach($invited_ar as $inv) {
83
+    foreach ($invited_ar as $inv) {
84 84
       if ($userToAddID == $inv) {
85 85
         $isUserExists = true;
86 86
       }
87 87
     }
88 88
 
89
-    if(count($invited_ar) >= 5) {
89
+    if (count($invited_ar) >= 5) {
90 90
       messageBox($lang['flt_aks_error_too_much_players'], $lang['fl_error']);
91 91
     }
92 92
 
93
-    if($isUserExists) {
93
+    if ($isUserExists) {
94 94
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf($lang['fl_aks_player_invited_already'], $userToAdd) : false;
95 95
     } else {
96 96
       $add_user_message_mr = sprintf($lang['fl_aks_player_invited'], $userToAdd);
97 97
       doquery("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};")
98
-        or die(sprintf($lang['fl_aks_adding_error'],db_error()));
98
+        or die(sprintf($lang['fl_aks_adding_error'], db_error()));
99 99
       $aks['eingeladen'] .= ',' . $userToAddID;
100 100
     }
101
-    msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
102
-      $lang['fl_aks_invite_message_header'], sprintf( $lang['fl_aks_invite_message'], $user['username']));
101
+    msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
102
+      $lang['fl_aks_invite_message_header'], sprintf($lang['fl_aks_invite_message'], $user['username']));
103 103
   } else {
104 104
     $add_user_message_mr = sprintf($lang['fl_aks_player_error'], $userToAdd);
105 105
   }
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
   'MISSION_NAME' => $lang['type_mission'][MT_AKS],
114 114
 ));
115 115
 
116
-if($aks['eingeladen'] && is_array($members = SN::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
117
-  foreach($members as $row) {
116
+if ($aks['eingeladen'] && is_array($members = SN::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
117
+  foreach ($members as $row) {
118 118
     $template->assign_block_vars('invited', array(
119 119
       'NAME' => $row['username'],
120 120
     ));
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 $i++;
125 125
 $fleet_row = DbFleetStatic::db_fleet_get($fleetid);
126 126
 
127
-if(is_array($fleet_row) && !empty($fleet_row)) {
127
+if (is_array($fleet_row) && !empty($fleet_row)) {
128 128
 $planet_start = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_start_planet_id']);
129 129
 $fleet_row['fleet_start_name'] = !empty($planet_start['name']) ? $planet_start['name'] : '';
130 130
 $planet_end = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_end_planet_id']);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user);
134 134
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
135
-foreach($fleet_data['ships'] as $ship_data) {
135
+foreach ($fleet_data['ships'] as $ship_data) {
136 136
   $template->assign_block_vars('fleets.ships', $ship_data);
137 137
 }
138 138
 }
Please login to merge, or discard this patch.