Completed
Push — trunk ( e1d59e...0e0d9a )
by SuperNova.WS
04:35
created
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.
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.
classes/Fleet/FleetDispatcher.php 1 patch
Spacing   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -465,15 +465,11 @@
 block discarded – undo
465 465
   protected function flt_flyingFleetsSort($a, $b) {
466 466
     return
467 467
       // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
468
-      $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
469
-        // Если время - одинаковое, сравниваем события флотов
468
+      $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
470 469
         // Если события - одинаковые, то флоты равны
471
-        ($a['fleet_event'] == $b['fleet_event'] ? 0 :
472
-          // Если события разные - первыми считаем прибывающие флоты
473
-          ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
474
-            // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
475
-            ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
476
-              // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
470
+        ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
471
+          ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
472
+            ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
477 473
               // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
478 474
               (
479 475
               0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
Please login to merge, or discard this patch.
classes/DBAL/OldDbChangeSet.php 1 patch
Spacing   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -142,9 +142,7 @@
 block discarded – undo
142 142
           // Простое условие - $field_id = $field_value
143 143
           if (is_string($field_id)) {
144 144
             $field_value =
145
-              $field_value === null ? 'NULL' :
146
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
147
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
145
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value));
148 146
             $the_conditions[] = "`{$field_id}` = {$field_value}";
149 147
           } else {
150 148
             die('Неподдерживаемый тип условия');
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_request.inc 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Alliance\DBStaticAlly;
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 }
12 12
 
13 13
 $d = sys_get_param_id('d');
14
-if($d) {
14
+if ($d) {
15 15
   doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '{$lang['ali_req_deny_reason']}' WHERE `id_user`= {$d} LIMIT 1;");
16 16
 }
17 17
 
18 18
 $id_user = sys_get_param_id('id_user');
19
-if($id_user) {
19
+if ($id_user) {
20 20
   $ally_name_safe = db_escape($ally['ally_name']);
21 21
   $ally_tag_safe = db_escape($ally['ally_tag']);
22 22
   db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0");
Please login to merge, or discard this patch.