Completed
Push — trunk ( 153731...fde30a )
by SuperNova.WS
04:15
created
classes/Fleet/RecordFleet.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
   public function __construct(GlobalContainer $services = null) {
77 77
     parent::__construct($services);
78 78
 
79
-    if(empty(static::$shipInfo)) {
80
-      foreach(sn_get_groups('fleet') as $unit_id) {
79
+    if (empty(static::$shipInfo)) {
80
+      foreach (sn_get_groups('fleet') as $unit_id) {
81 81
         static::$shipInfo[$unit_id] = get_unit_param($unit_id);
82 82
         static::$shipInfo[$unit_id][P_COST_METAL] = get_unit_cost_in(static::$shipInfo[$unit_id][P_COST]);
83 83
       }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
    * @inheritdoc
104 104
    */
105 105
   public function update() {
106
-    if($this->getShipCount() < 1) {
106
+    if ($this->getShipCount() < 1) {
107 107
       return $this->delete();
108 108
     } else {
109 109
       return parent::update();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
    */
128 128
   public function getCostInMetal() {
129 129
     $result = 0;
130
-    foreach($this->shipList as $shipId => $amount) {
130
+    foreach ($this->shipList as $shipId => $amount) {
131 131
       $result += $amount * $this->getShipCostInMetal($shipId);
132 132
     }
133 133
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
    */
149 149
   public function getCapacity() {
150 150
     $result = 0;
151
-    foreach($this->shipList as $shipId => $amount) {
151
+    foreach ($this->shipList as $shipId => $amount) {
152 152
       $result += $amount * $this->getShipCapacity($shipId);
153 153
     }
154 154
 
@@ -165,12 +165,12 @@  discard block
 block discarded – undo
165 165
    */
166 166
   public function changeShipCount($shipSnId, $shipCount) {
167 167
     !isset($this->shipList[$shipSnId]) ? $this->shipList[$shipSnId] = 0 : false;
168
-    if($this->shipList[$shipSnId] + $shipCount < 0) {
168
+    if ($this->shipList[$shipSnId] + $shipCount < 0) {
169 169
       throw new \Exception("Trying to deduct more ships [{$shipSnId}] '{$shipCount}' then fleet has {$this->shipList[$shipSnId]}");
170 170
     }
171 171
 
172 172
     $this->shipList[$shipSnId] += $shipCount;
173
-    if($this->shipList[$shipSnId] <= 0) {
173
+    if ($this->shipList[$shipSnId] <= 0) {
174 174
       unset($this->shipList[$shipSnId]);
175 175
     }
176 176
 
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
    * @throws \Exception
186 186
    */
187 187
   public function changeResource($resourceId, $resourceCount) {
188
-    if(!array_key_exists($resourceId, $this->resources) || empty($resourceCount)) {
188
+    if (!array_key_exists($resourceId, $this->resources) || empty($resourceCount)) {
189 189
       return;
190 190
     }
191 191
 
192
-    if($this->resources[$resourceId] + $resourceCount < 0) {
192
+    if ($this->resources[$resourceId] + $resourceCount < 0) {
193 193
       throw new \Exception("Trying to deduct more resources [{$resourceId}] '{$resourceCount}' then fleet has {$this->resources[$resourceId]}");
194 194
     }
195 195
 
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
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
     $this->secret_word = SN::$sn_secret_word;
92 92
 
93 93
     $snTableNames = $this->db->schema()->getSnTables();
94
-    foreach($this->table_check as $table_name) {
95
-      if(empty($snTableNames[$table_name])) {
94
+    foreach ($this->table_check as $table_name) {
95
+      if (empty($snTableNames[$table_name])) {
96 96
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
97 97
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
98 98
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
    */
117 117
   // OK v4.6
118 118
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
119
-    if(!$this->password_check($old_password_unsafe)) {
119
+    if (!$this->password_check($old_password_unsafe)) {
120 120
       return false;
121 121
     }
122 122
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
   // OK v4.5
138 138
   public function assign_from_db_row($row) {
139 139
     $this->reset();
140
-    if(empty($row) || !is_array($row)) {
140
+    if (empty($row) || !is_array($row)) {
141 141
       return false;
142 142
     }
143 143
     $this->account_id = $row['account_id'];
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     $this->reset();
203 203
 
204 204
     $email_safe = $this->db->db_escape($email_unsafe);
205
-    if($email_safe) {
205
+    if ($email_safe) {
206 206
       $account_row = $this->db->doquery("SELECT * FROM {{account}} WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true);
207 207
 
208 208
       return $this->assign_from_db_row($account_row);
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
         `account_email` = LOWER('{$email_safe}'),
276 276
         `account_language` = '{$language_safe}'"
277 277
     );
278
-    if(!$result) {
278
+    if (!$result) {
279 279
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
280 280
     }
281 281
 
282
-    if(!($account_id = $this->db->db_insert_id())) {
282
+    if (!($account_id = $this->db->db_insert_id())) {
283 283
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
284 284
     }
285 285
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
       WHERE `account_id` = '{$account_id_safe}'"
310 310
     ) ? true : false;
311 311
 
312
-    if($result) {
312
+    if ($result) {
313 313
       $result = $this->db_get_by_id($this->account_id);
314 314
     }
315 315
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
399 399
     global $debug, $mm_change_legit, $config;
400 400
 
401
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
401
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
402 402
       $debug->error('Ошибка при попытке манипуляции с ММ');
403 403
       return false;
404 404
     }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
     $mm_change_legit = true;
409 409
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
410
-    if($already_changed) {
410
+    if ($already_changed) {
411 411
       $metamatter_total_delta = 0;
412 412
       $result = -1;
413 413
     } else {
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
           ($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}'" : '') .
421 421
         " WHERE `account_id` = {$account_id_safe}"
422 422
       );
423
-      if(!$result) {
423
+      if (!$result) {
424 424
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
425 425
       }
426 426
       $result = SN::$db->db_affected_rows();
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
       $this->awardImmortal($metamatter, $config);
429 429
     }
430 430
 
431
-    if(empty(core_auth::$user['id'])) {
431
+    if (empty(core_auth::$user['id'])) {
432 432
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
433 433
       reset($user_list);
434 434
       $user_id_unsafe = key($user_list);
@@ -437,30 +437,30 @@  discard block
 block discarded – undo
437 437
     }
438 438
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
439 439
 
440
-    if(!$result) {
440
+    if (!$result) {
441 441
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
442 442
     }
443 443
 
444
-    if(!$already_changed) {
444
+    if (!$already_changed) {
445 445
       $this->account_metamatter += $metamatter;
446 446
       $this->account_metamatter_total += $metamatter_total_delta;
447 447
     }
448 448
 
449
-    if(is_array($comment)) {
449
+    if (is_array($comment)) {
450 450
       $comment = call_user_func_array('sprintf', $comment);
451 451
     }
452 452
 
453 453
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
454 454
 
455
-    if($metamatter > 0 && !empty($user_id_safe)) {
455
+    if ($metamatter > 0 && !empty($user_id_safe)) {
456 456
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
457
-      if($old_referral['id']) {
457
+      if ($old_referral['id']) {
458 458
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
459 459
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
460 460
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
461 461
 
462 462
         $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);
463
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
463
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
464 464
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
465 465
         }
466 466
       }
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
    * @throws Exception
477 477
    */
478 478
   public function cookieSet($rememberMe = false, $domain = null) {
479
-    if(!$this->is_exists) {
479
+    if (!$this->is_exists) {
480 480
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
481 481
     }
482 482
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
   // OK v4.1
496 496
   public function cookieClear($domain = null) {
497 497
     // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё
498
-    if(!empty($_COOKIE[$this->cookie_name_impersonate])) {
498
+    if (!empty($_COOKIE[$this->cookie_name_impersonate])) {
499 499
       sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain);
500 500
       sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain);
501 501
     } else {
@@ -505,14 +505,14 @@  discard block
 block discarded – undo
505 505
 
506 506
   public function cookieLogin(&$rememberMe = false) {
507 507
     // Пытаемся войти по куке
508
-    if(!empty($_COOKIE[$this->cookie_name])) {
509
-      if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
508
+    if (!empty($_COOKIE[$this->cookie_name])) {
509
+      if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
510 510
         list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]);
511 511
       } else {
512 512
         list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]);
513 513
       }
514 514
 
515
-      if(
515
+      if (
516 516
         $this->db_get_by_id($account_id_unsafe)
517 517
         && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted)
518 518
       ) {
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
    * @param classConfig $config
538 538
    */
539 539
   protected function awardImmortal($metamatter, $config) {
540
-    if(!is_object($awardModule = moduleAward())) {
540
+    if (!is_object($awardModule = moduleAward())) {
541 541
       return;
542 542
     }
543
-    if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal ) {
543
+    if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal) {
544 544
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list(ACCOUNT_PROVIDER_LOCAL, $this->account_id);
545 545
       if (!empty($account_translation)) {
546 546
         reset($account_translation);
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
    * @return bool|mysqli_result|null
563 563
    */
564 564
   public function getMetamatterSum($where = '', $group = '') {
565
-    if(is_array($where) && !empty($where)) {
565
+    if (is_array($where) && !empty($where)) {
566 566
       $where = implode(' AND ', $where);
567 567
     }
568
-    if(is_array($group) && !empty($group)) {
568
+    if (is_array($group) && !empty($group)) {
569 569
       $group = implode(',', $group);
570 570
     }
571 571
 
Please login to merge, or discard this patch.
admin/adm_metamatter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
19 19
 
20
-if(!SN::$gc->modules->countModulesInGroup('payment')) {
20
+if (!SN::$gc->modules->countModulesInGroup('payment')) {
21 21
   sys_redirect(SN_ROOT_VIRTUAL . 'admin/overview.php');
22 22
 }
23 23
 
Please login to merge, or discard this patch.
includes/includes/flt_page2.inc 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     'START_NAME'         => $planetrow['name'],
28 28
   );
29 29
 
30
-  if(!empty($TargetPlanet)) {
30
+  if (!empty($TargetPlanet)) {
31 31
     $template_route += array(
32 32
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
33 33
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
   $template->assign_block_vars('fleets', $template_route);
39 39
 
40 40
   $sn_groups_fleet = sn_get_groups('fleet');
41
-  foreach($fleetarray as $ship_id => $ship_count) {
42
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
41
+  foreach ($fleetarray as $ship_id => $ship_count) {
42
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
43 43
 //      $ship_base_data = get_ship_data($ship_id, $user);
44 44
       $template->assign_block_vars('fleets.ships', array(
45 45
         'ID'          => $ship_id,
@@ -57,11 +57,10 @@  discard block
 block discarded – undo
57 57
     $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count;
58 58
   }
59 59
 
60
-  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
61
-    (isset($missiontype[MT_HOLD]) ? 12 : 0);
62
-  if($max_duration) {
60
+  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0);
61
+  if ($max_duration) {
63 62
     $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1);
64
-    for($i = 1; $i <= $max_duration; $i++) {
63
+    for ($i = 1; $i <= $max_duration; $i++) {
65 64
       $template->assign_block_vars('duration', array(
66 65
         'ID' => $i,
67 66
         'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
   // $TableTitle = uni_render_planet_full($planetrow) . '&nbsp;=&gt;&nbsp;' . uni_render_planet_full($temp);
81 80
 
82 81
   $sn_group_resources = sn_get_groups('resources');
83
-  for($i = 0; $i<3; $i++) {
82
+  for ($i = 0; $i < 3; $i++) {
84 83
     $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0);
85 84
     $template->assign_block_vars('resources', array(
86 85
       'ID' => $i,
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
     ));
91 90
   }
92 91
 
93
-  if(is_object($captainModule = moduleCaptain()) && ($captain = $captainModule->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
92
+  if (is_object($captainModule = moduleCaptain()) && ($captain = $captainModule->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
94 93
     $template->assign_vars(array(
95 94
       'CAPTAIN_ID' => $captain['unit_id'],
96 95
       'CAPTAIN_LEVEL' => $captain['captain_level'],
@@ -112,9 +111,9 @@  discard block
 block discarded – undo
112 111
 
113 112
 
114 113
     'speedallsmin' => sys_get_param_float('speedallsmin'),
115
-    'speed' => sys_get_param_int('speed') ,
114
+    'speed' => sys_get_param_int('speed'),
116 115
 
117
-    'fleet_group' => sys_get_param_id('fleet_group') ,
116
+    'fleet_group' => sys_get_param_id('fleet_group'),
118 117
     'acs_target_mr' => sys_get_param_str('acs_target_mr'),
119 118
 
120 119
     'MAX_DURATION' => $max_duration,
Please login to merge, or discard this patch.
dark_matter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 include_once('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if(SN::$gc->modules->countModulesInGroup('payment') && !defined('SN_GOOGLE')) {
5
+if (SN::$gc->modules->countModulesInGroup('payment') && !defined('SN_GOOGLE')) {
6 6
   sys_redirect('metamatter.php');
7 7
 }
8 8
 
Please login to merge, or discard this patch.
admin/statbuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  * @copyright 2008 by Chlorel for XNova
10 10
  */
11 11
 
12
-define('INSIDE'  , true);
13
-define('INSTALL' , false);
12
+define('INSIDE', true);
13
+define('INSTALL', false);
14 14
 define('IN_ADMIN', true);
15 15
 require_once('../common.' . substr(strrchr(__FILE__, '.'), 1));
16 16
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR);
20 20
 
21
-if(SN_TIME_NOW >= SN::$config->pass()->var_stat_update_admin_forced && SN_TIME_NOW >= SN::$config->pass()->var_stat_update_end)
21
+if (SN_TIME_NOW >= SN::$config->pass()->var_stat_update_admin_forced && SN_TIME_NOW >= SN::$config->pass()->var_stat_update_end)
22 22
 {
23 23
   SN::$config->pass()->var_stat_update_admin_forced = SN_TIME_NOW + 120;
24 24
 
Please login to merge, or discard this patch.
classes/debug.php 1 patch
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * que esperabas!!! soy newbie!!! D':<
25 25
 */
26 26
 
27
-if(!defined('INSIDE')) {
27
+if (!defined('INSIDE')) {
28 28
   die("attemp hacking");
29 29
 }
30 30
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
   function log_file($message, $ident_change = 0) {
38 38
     static $ident = 0;
39 39
 
40
-    if(!defined('SN_DEBUG_LOG')) {
40
+    if (!defined('SN_DEBUG_LOG')) {
41 41
       return;
42 42
     }
43 43
 
44
-    if($this->log_file_handler === null) {
44
+    if ($this->log_file_handler === null) {
45 45
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
46 46
       @fwrite($this->log_file_handler, "\r\n\r\n");
47 47
     }
48 48
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
49
-    if($this->log_file_handler) {
49
+    if ($this->log_file_handler) {
50 50
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
51 51
     }
52 52
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     $result = array();
82 82
     $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++;
83 83
     $result[] = "tID {$transaction_id}";
84
-    foreach($backtrace as $a_trace) {
85
-      if(in_array($a_trace['function'], $exclude_functions)) {
84
+    foreach ($backtrace as $a_trace) {
85
+      if (in_array($a_trace['function'], $exclude_functions)) {
86 86
         continue;
87 87
       }
88 88
       $function =
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
       $line = !empty($a_trace['line']) ? $a_trace['line'] : '_UNDEFINED_';
100 100
       $result[] = "{$function} - '{$file}' Line {$line}";
101 101
 
102
-      if(!$long_comment) {
102
+      if (!$long_comment) {
103 103
         break;
104 104
       }
105 105
     }
@@ -108,26 +108,26 @@  discard block
 block discarded – undo
108 108
   }
109 109
 
110 110
   function dump($dump = false, $force_base = false, $deadlock = false) {
111
-    if($dump === false) {
111
+    if ($dump === false) {
112 112
       return;
113 113
     }
114 114
 
115 115
     $error_backtrace = array();
116 116
     $base_dump = false;
117 117
 
118
-    if($force_base === true) {
118
+    if ($force_base === true) {
119 119
       $base_dump = true;
120 120
     }
121 121
 
122
-    if($dump === true) {
122
+    if ($dump === true) {
123 123
       $base_dump = true;
124 124
     } else {
125
-      if(!is_array($dump)) {
125
+      if (!is_array($dump)) {
126 126
         $dump = array('var' => $dump);
127 127
       }
128 128
 
129
-      foreach($dump as $dump_var_name => $dump_var) {
130
-        if($dump_var_name == 'base_dump') {
129
+      foreach ($dump as $dump_var_name => $dump_var) {
130
+        if ($dump_var_name == 'base_dump') {
131 131
           $base_dump = $dump_var;
132 132
         } else {
133 133
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -135,24 +135,23 @@  discard block
 block discarded – undo
135 135
       }
136 136
     }
137 137
 
138
-    if($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) {
138
+    if ($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) {
139 139
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
140 140
       $error_backtrace['locks'] = _SnCacheInternal::$locks;
141 141
       $error_backtrace['cSN_data'] = _SnCacheInternal::$data;
142
-      foreach($error_backtrace['cSN_data'] as &$location) {
143
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
142
+      foreach ($error_backtrace['cSN_data'] as &$location) {
143
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
144 144
         {
145
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
146
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
145
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
147 146
         }
148 147
       }
149 148
     }
150 149
 
151
-    if($base_dump) {
152
-      if(!is_array($this->log_array) || empty($this->log_array)) {
150
+    if ($base_dump) {
151
+      if (!is_array($this->log_array) || empty($this->log_array)) {
153 152
         $this->log_array = [];
154 153
       } else {
155
-        foreach($this->log_array as $log) {
154
+        foreach ($this->log_array as $log) {
156 155
           $error_backtrace['queries'][] = $log;
157 156
         }
158 157
       }
@@ -164,17 +163,17 @@  discard block
 block discarded – undo
164 163
       // Converting object instances to object names
165 164
 
166 165
       foreach ($error_backtrace['backtrace'] as &$backtrace) {
167
-        if(is_object($backtrace['object'])) {
166
+        if (is_object($backtrace['object'])) {
168 167
           $backtrace['object'] = get_class($backtrace['object']);
169 168
         }
170 169
 
171
-        if(empty($backtrace['args'])) {
170
+        if (empty($backtrace['args'])) {
172 171
           continue;
173 172
         }
174 173
 
175 174
         // Doing same conversion for backtrace params
176
-        foreach($backtrace['args'] as &$arg) {
177
-          if(is_object($arg)) {
175
+        foreach ($backtrace['args'] as &$arg) {
176
+          if (is_object($arg)) {
178 177
             $arg = 'object::' . get_class($arg);
179 178
           }
180 179
         }
@@ -203,14 +202,14 @@  discard block
 block discarded – undo
203 202
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
204 203
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
205 204
 
206
-    if(empty(SN::$db->connected)) {
205
+    if (empty(SN::$db->connected)) {
207 206
       // TODO - писать ошибку в файл
208 207
       die('SQL server currently unavailable. Please contact Administration...');
209 208
     }
210 209
 
211 210
     sn_db_transaction_rollback();
212 211
 
213
-    if(SN::$config->debug == 1) {
212
+    if (SN::$config->debug == 1) {
214 213
       echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>";
215 214
       echo "<table>{$this->log}</table>";
216 215
     }
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
     $error_text = db_escape($message);
221 220
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
222 221
 
223
-    if(!$sys_log_disabled) {
222
+    if (!$sys_log_disabled) {
224 223
       $query = "INSERT INTO `{{logs}}` SET
225 224
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
226 225
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
       ob_start();
239 238
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
240 239
 
241
-      foreach($error_backtrace as $name => $value) {
240
+      foreach ($error_backtrace as $name => $value) {
242 241
         print('<hr>');
243 242
         pdump($value, $name);
244 243
       }
@@ -250,14 +249,14 @@  discard block
 block discarded – undo
250 249
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
251 250
     global $user, $lang, $sys_log_disabled;
252 251
 
253
-    if(empty(SN::$db->connected)) {
252
+    if (empty(SN::$db->connected)) {
254 253
       // TODO - писать ошибку в файл
255 254
       die('SQL server currently unavailable. Please contact Administration...');
256 255
     }
257 256
 
258 257
     $error_backtrace = $this->dump($dump, false);
259 258
 
260
-    if(!$sys_log_disabled) {
259
+    if (!$sys_log_disabled) {
261 260
       $query = "INSERT INTO `{{logs}}` SET
262 261
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
263 262
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -275,11 +274,11 @@  discard block
 block discarded – undo
275 274
 // Dump variables nicer then var_dump()
276 275
 
277 276
 function dump($value, $varname = null, $level = 0, $dumper = '') {
278
-  if(isset($varname)) {
277
+  if (isset($varname)) {
279 278
     $varname .= " = ";
280 279
   }
281 280
 
282
-  if($level == -1) {
281
+  if ($level == -1) {
283 282
     $trans[' '] = '&there4;';
284 283
     $trans["\t"] = '&rArr;';
285 284
     $trans["\n"] = '&para;;';
@@ -288,7 +287,7 @@  discard block
 block discarded – undo
288 287
 
289 288
     return strtr(htmlspecialchars($value), $trans);
290 289
   }
291
-  if($level == 0) {
290
+  if ($level == 0) {
292 291
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
293 292
     $dumper = mt_rand(10, 99) . '|' . $varname;
294 293
   }
@@ -296,22 +295,22 @@  discard block
 block discarded – undo
296 295
   $type = gettype($value);
297 296
   $dumper .= $type;
298 297
 
299
-  if($type == 'string') {
298
+  if ($type == 'string') {
300 299
     $dumper .= '(' . strlen($value) . ')';
301 300
     $value = dump($value, '', -1);
302
-  } elseif($type == 'boolean') {
301
+  } elseif ($type == 'boolean') {
303 302
     $value = ($value ? 'true' : 'false');
304
-  } elseif($type == 'object') {
303
+  } elseif ($type == 'object') {
305 304
     $props = get_class_vars(get_class($value));
306 305
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
307
-    foreach($props as $key => $val) {
306
+    foreach ($props as $key => $val) {
308 307
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
309 308
       $dumper .= dump($value->$key, '', $level + 1);
310 309
     }
311 310
     $value = '';
312
-  } elseif($type == 'array') {
311
+  } elseif ($type == 'array') {
313 312
     $dumper .= '(' . count($value) . ')';
314
-    foreach($value as $key => $val) {
313
+    foreach ($value as $key => $val) {
315 314
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
316 315
       $dumper .= dump($val, '', $level + 1);
317 316
     }
@@ -331,7 +330,7 @@  discard block
 block discarded – undo
331 330
 //  $backtrace = $backtrace[1];
332 331
 
333 332
   $caller = '';
334
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
333
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
335 334
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
336 335
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
337 336
       $backtrace[1]['function'] .
@@ -358,7 +357,7 @@  discard block
 block discarded – undo
358 357
 }
359 358
 
360 359
 function pr($prePrint = false) {
361
-  if($prePrint) {
360
+  if ($prePrint) {
362 361
     print("<br>");
363 362
   }
364 363
   print(mt_rand() . "<br>");
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
   global $_PRINT_COUNT_VALUE;
369 368
   $_PRINT_COUNT_VALUE++;
370 369
 
371
-  if($prePrint) {
370
+  if ($prePrint) {
372 371
     print("<br>");
373 372
   }
374 373
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
classes/Planet/DBStaticPlanet.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
     $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
69 69
     $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
70 70
     $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
71
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
72
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
71
+    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
73 72
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
74 73
 
75 74
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
Please login to merge, or discard this patch.
classes/Universe/Universe.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
   const MOON_MIN_SIZE = 1100;
9 9
   const MOON_MAX_SIZE = 8999;
10 10
 
11
-  const MOON_DEBRIS_MIN = 1000000;    // Minimum amount of debris to span a moon
12
-  const MOON_CHANCE_MIN_PERCENT = 1;  // Minimum chance to span a moon
11
+  const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon
12
+  const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon
13 13
   const MOON_CHANCE_MAX_PERCENT = 30; // Maximum chance to span a moon
14 14
 
15 15
   /**
Please login to merge, or discard this patch.