Completed
Push — work-fleets ( 5437e0...4d76fa )
by SuperNova.WS
05:29
created
includes/db/db_helpers.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35 35
     $field = '`' . db_escape($field) . '`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41 41
       $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Gorlum
5
- * Date: 26.12.2015
6
- * Time: 17:19
7
- */
3
+   * Created by PhpStorm.
4
+   * User: Gorlum
5
+   * Date: 26.12.2015
6
+   * Time: 17:19
7
+   */
8 8
 
9 9
 /**
10 10
  * Normalize and make ID safe
Please login to merge, or discard this patch.
includes/db/db_queries.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) {
87 87
 // pdump($source);
88
-  if(!$source) {
88
+  if (!$source) {
89 89
     $source = array(
90 90
       'statpoints' => 'statpoints',
91 91
       'users'      => 'users',
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
     );
107 107
   }
108 108
 // pdump($source);
109
-  if($who == 1) {
110
-    if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
109
+  if ($who == 1) {
110
+    if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
111 111
       $query_str =
112 112
         "SELECT
113 113
       @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.*
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
192 192
   $current_value_safe = db_escape($current_value_unsafe);
193 193
   $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true);
194
-  if(!isset($value_id['id_field']) || !$value_id['id_field']) {
194
+  if (!isset($value_id['id_field']) || !$value_id['id_field']) {
195 195
     doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');");
196 196
     $variable_id = db_insert_id();
197 197
   } else {
Please login to merge, or discard this patch.
Doc Comments   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -188,6 +188,11 @@  discard block
 block discarded – undo
188 188
  */
189 189
 // OK v4
190 190
 // TODO - вынести в отдельный класс
191
+/**
192
+ * @param string $db_id_field_name
193
+ * @param string $db_table_name
194
+ * @param string $db_value_field_name
195
+ */
191 196
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
192 197
   $current_value_safe = db_escape($current_value_unsafe);
193 198
   $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true);
@@ -220,7 +225,7 @@  discard block
 block discarded – undo
220 225
 
221 226
 /**
222 227
  * @param $user
223
- * @param $username_safe
228
+ * @param string $username_safe
224 229
  */
225 230
 function db_player_name_history_replace($user, $username_safe) {
226 231
   doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'");
@@ -228,7 +233,7 @@  discard block
 block discarded – undo
228 233
 
229 234
 
230 235
 /**
231
- * @param $username_safe
236
+ * @param string $username_safe
232 237
  *
233 238
  * @return array|bool|mysqli_result|null
234 239
  */
@@ -485,12 +490,12 @@  discard block
 block discarded – undo
485 490
 
486 491
 
487 492
 /**
488
- * @param $user_id
489
- * @param $change_type
493
+ * @param integer $user_id
494
+ * @param integer $change_type
490 495
  * @param $dark_matter
491
- * @param $comment
496
+ * @param string $comment
492 497
  * @param $row
493
- * @param $page_url
498
+ * @param string $page_url
494 499
  */
495 500
 function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url) {
496 501
   doquery(
@@ -506,7 +511,7 @@  discard block
 block discarded – undo
506 511
 /**
507 512
  * @param $user_id_safe
508 513
  *
509
- * @return array|bool|mysqli_result|null
514
+ * @return integer
510 515
  */
511 516
 function db_referral_get_by_id($user_id_safe) {
512 517
   $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", true);
@@ -534,9 +539,9 @@  discard block
 block discarded – undo
534 539
 
535 540
 // Quests ***********************************************************************************************************
536 541
 /**
537
- * @param $query_add_select
542
+ * @param string $query_add_select
538 543
  * @param $query_add_from
539
- * @param $query_add_where
544
+ * @param string $query_add_where
540 545
  *
541 546
  * @return array|bool|mysqli_result|null
542 547
  */
@@ -580,11 +585,11 @@  discard block
 block discarded – undo
580 585
 }
581 586
 
582 587
 /**
583
- * @param $quest_name
584
- * @param $quest_type
585
- * @param $quest_description
588
+ * @param string $quest_name
589
+ * @param integer $quest_type
590
+ * @param string $quest_description
586 591
  * @param $quest_conditions
587
- * @param $quest_rewards
592
+ * @param string $quest_rewards
588 593
  * @param $quest_id
589 594
  */
590 595
 function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) {
@@ -607,7 +612,7 @@  discard block
 block discarded – undo
607 612
 /**
608 613
  * @param $banner
609 614
  * @param $banned
610
- * @param $reason
615
+ * @param string $reason
611 616
  * @param $ban_until
612 617
  */
613 618
 function db_ban_insert($banner, $banned, $reason, $ban_until) {
@@ -630,7 +635,7 @@  discard block
 block discarded – undo
630 635
 /**
631 636
  * @param $banner
632 637
  * @param $banned
633
- * @param $reason
638
+ * @param string $reason
634 639
  */
635 640
 function db_ban_insert_unset($banner, $banned, $reason) {
636 641
   doquery(
Please login to merge, or discard this patch.
includes/db/db_queries_users.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@
 block discarded – undo
161 161
   !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false;
162 162
 
163 163
   $user_list = array();
164
-  foreach($user_id_list as $user_id_unsafe) {
164
+  foreach ($user_id_list as $user_id_unsafe) {
165 165
     $user = db_user_by_id($user_id_unsafe);
166 166
     !empty($user) ? $user_list[$user_id_unsafe] = $user : false;
167 167
   }
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -47,6 +47,9 @@  discard block
 block discarded – undo
47 47
 }
48 48
 
49 49
 
50
+/**
51
+ * @param boolean $player
52
+ */
50 53
 function db_user_by_id($user_id_unsafe, $for_update = false, $fields = '*', $player = null) {
51 54
   return classSupernova::db_get_user_by_id($user_id_unsafe, $for_update, $fields, $player);
52 55
 }
@@ -105,6 +108,9 @@  discard block
 block discarded – undo
105 108
   return isset($result['user_count']) ? $result['user_count'] : 0;
106 109
 }
107 110
 
111
+/**
112
+ * @param integer $config_user_birthday_range
113
+ */
108 114
 function db_user_list_to_celebrate($config_user_birthday_range) {
109 115
   return doquery(
110 116
     "SELECT
Please login to merge, or discard this patch.
includes/db/db_queries_fleet.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DB ACS functions
4
- */
3
+   * DB ACS functions
4
+   */
5 5
 
6 6
 /* ACS ****************************************************************************************************************/
7 7
 /**
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,6 +22,10 @@  discard block
 block discarded – undo
22 22
   doquery('DELETE FROM `{{aks}}` WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM `{{fleets}}`);');
23 23
 }
24 24
 
25
+/**
26
+ * @param double $arrival
27
+ * @param integer $target_structure
28
+ */
25 29
 function db_missile_insert($target_coord, $user, $planetrow, $arrival, $fleet_ship_count, $target_structure) {
26 30
   doquery(
27 31
     "INSERT INTO `{{iraks}}` SET
@@ -52,7 +56,7 @@  discard block
 block discarded – undo
52 56
 /**
53 57
  * @param $user
54 58
  * @param $planet_dst
55
- * @param $time_limit
59
+ * @param integer $time_limit
56 60
  *
57 61
  * @return array|bool|mysqli_result|null
58 62
  */
@@ -113,14 +117,14 @@  discard block
 block discarded – undo
113 117
 
114 118
 
115 119
 /**
116
- * @param $fleet_group_id_list
120
+ * @param string $fleet_group_id_list
117 121
  */
118 122
 function db_acs_delete_by_list($fleet_group_id_list) {
119 123
   doquery("DELETE FROM {{aks}} WHERE `id` IN ({$fleet_group_id_list})");
120 124
 }
121 125
 
122 126
 /**
123
- * @param $bashing_list
127
+ * @param string $bashing_list
124 128
  */
125 129
 function db_bashing_insert($bashing_list) {
126 130
   doquery("INSERT INTO {{bashing}} (bashing_user_id, bashing_planet_id, bashing_time) VALUES {$bashing_list};");
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.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
  * @copyright 2008 by Gorlum for Project "SuperNova.WS"
11 11
  */
12 12
 function flt_mission_hold($mission_data) {
13
-  if($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) {
13
+  if ($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) {
14 14
     $mission_data->fleet->mark_fleet_as_returned_and_save();
15 15
 
16 16
     return CACHE_FLEET;
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
   $destination_planet = &$mission_data->dst_planet;
18 18
 
19
-  if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
19
+  if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
20 20
     $objFleet->mark_fleet_as_returned_and_save();
21 21
 
22 22
     return CACHE_FLEET;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
       $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']
32 32
     ) . '<br />' . $lang['sys_relocate_mess_user'];
33 33
   $fleet_real_array = $objFleet->get_unit_list();
34
-  foreach($fleet_real_array as $ship_id => $ship_count) {
34
+  foreach ($fleet_real_array as $ship_id => $ship_count) {
35 35
     $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />';
36 36
   }
37 37
   msg_send_simple_message(
Please login to merge, or discard this patch.
includes/includes/flt_mission_transport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   $source_planet = &$mission_data->src_planet;
17 17
   $destination_planet = &$mission_data->dst_planet;
18 18
 
19
-  if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) {
19
+  if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) {
20 20
     $objFleet->mark_fleet_as_returned_and_save();
21 21
 
22 22
     return CACHE_FLEET;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']);
32 32
   msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
33 33
 
34
-  if($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
34
+  if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
35 35
     msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
36 36
   }
37 37
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 /**
32 32
  * Fleet mission "Relocate"
33 33
  *
34
- * @param $mission_data Mission
34
+ * @param Mission $mission_data Mission
35 35
  *
36 36
  * @return int
37 37
  *
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
   $destination_planet = &$mission_data->dst_planet;
22 22
 
23
-  if(empty($destination_planet['id'])) {
23
+  if (empty($destination_planet['id'])) {
24 24
     $objFleet->mark_fleet_as_returned();
25 25
     $objFleet->flush_changes_to_db();
26 26
 
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
   $OtherFleetCapacity = 0;
32 32
 
33 33
   $fleet_array = $objFleet->get_unit_list();
34
-  foreach($fleet_array as $unit_id => $unit_count) {
35
-    if(in_array($unit_id, sn_get_groups('fleet'))) {
34
+  foreach ($fleet_array as $unit_id => $unit_count) {
35
+    if (in_array($unit_id, sn_get_groups('fleet'))) {
36 36
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
37
-      if(in_array($unit_id, sn_get_groups('flt_recyclers'))) {
37
+      if (in_array($unit_id, sn_get_groups('flt_recyclers'))) {
38 38
         $RecyclerCapacity += $capacity;
39 39
       } else {
40 40
         $OtherFleetCapacity += $capacity;
@@ -43,33 +43,33 @@  discard block
 block discarded – undo
43 43
   }
44 44
 
45 45
   $fleet_resources_amount = $objFleet->get_resources_amount();
46
-  if($fleet_resources_amount > $OtherFleetCapacity) {
46
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
47 47
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
48 48
     // Уменьшаем ёмкость переработчиков на указанную величину
49 49
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
50 50
   }
51 51
 
52 52
   $resources_recycled = array();
53
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
53
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
54 54
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
55 55
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
56 56
   } else {
57
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
57
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
58 58
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
59 59
     ) {
60 60
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
61 61
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
62 62
     } else {
63
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
63
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
64 64
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
65
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
65
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
66 66
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
67 67
         } else {
68 68
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
69 69
         }
70 70
       } else {
71 71
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
72
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
72
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
73 73
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
74 74
         } else {
75 75
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
 
40 40
   $sta_update_msg = db_escape($sta_update_msg);
41 41
 
42
-  if($next_step) {
42
+  if ($next_step) {
43 43
     $sta_update_step++;
44 44
   }
45 45
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
46 46
 
47 47
   $config->db_saveItem('var_stat_update_msg', $sta_update_msg);
48
-  if($next_step) {
48
+  if ($next_step) {
49 49
     $debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
50 50
   }
51 51
 }
52 52
 
53 53
 function sys_stat_calculate_flush(&$data, $force = false) {
54
-  if(count($data) < 25 && !$force) {
54
+  if (count($data) < 25 && !$force) {
55 55
     return;
56 56
   }
57 57
 
58
-  if(!empty($data)) {
58
+  if (!empty($data)) {
59 59
     doquery('REPLACE INTO {{statpoints}}
60 60
       (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`,
61 61
        `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`,
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
   $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
96 96
   $row_num = count($user_list);
97 97
   // while($player = db_fetch($query))
98
-  foreach($user_list as $player) {
99
-    if($i++ % 100 == 0) {
98
+  foreach ($user_list as $player) {
99
+    if ($i++ % 100 == 0) {
100 100
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
101 101
     }
102
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
102
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
103 103
       continue;
104 104
     }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     // $points[$user_id][UNIT_RESOURCES] += $resources;
110 110
 
111 111
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
112
-    if(!isset($user_skip_list[$user_id])) {
112
+    if (!isset($user_skip_list[$user_id])) {
113 113
       $user_allies[$user_id] = $player['ally_id'];
114 114
     }
115 115
   }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
   $i = 0;
124 124
   $query = db_planet_list_resources_by_owner();
125 125
   $row_num = db_num_rows($query);
126
-  while($planet = db_fetch($query)) {
127
-    if($i++ % 100 == 0) {
126
+  while ($planet = db_fetch($query)) {
127
+    if ($i++ % 100 == 0) {
128 128
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
129 129
     }
130
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
130
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
131 131
       continue;
132 132
     }
133 133
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
   $i = 0;
143 143
   $query = FleetList::dbQueryAllId();
144 144
   $row_num = db_num_rows($query);
145
-  while($fleet_row = db_fetch($query)) {
146
-    if($i++ % 100 == 0) {
145
+  while ($fleet_row = db_fetch($query)) {
146
+    if ($i++ % 100 == 0) {
147 147
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
148 148
     }
149 149
     $objFleet = new Fleet();
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
152 152
     // $objFleet->_reset();
153 153
     $objFleet->dbRowParse($fleet_row);
154
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
154
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
155 155
       continue;
156 156
     }
157 157
 
158 158
     $fleet = $objFleet->get_unit_list();
159
-    foreach($fleet as $unit_id => $unit_amount) {
159
+    foreach ($fleet as $unit_id => $unit_amount) {
160 160
       $counts[$user_id][UNIT_SHIPS] += $unit_amount;
161 161
 
162
-      if(!isset($unit_cost_cache[$unit_id][0])) {
162
+      if (!isset($unit_cost_cache[$unit_id][0])) {
163 163
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
164 164
       }
165 165
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
   $i = 0;
180 180
   $query = db_unit_list_stat_calculate();
181 181
   $row_num = db_num_rows($query);
182
-  while($unit = db_fetch($query)) {
183
-    if($i++ % 100 == 0) {
182
+  while ($unit = db_fetch($query)) {
183
+    if ($i++ % 100 == 0) {
184 184
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
185 185
     }
186
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
186
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
187 187
       continue;
188 188
     }
189 189
 
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
   $i = 0;
198 198
   $query = db_que_list_stat();
199 199
   $row_num = db_num_rows($query);
200
-  while($que_item = db_fetch($query)) {
201
-    if($i++ % 100 == 0) {
200
+  while ($que_item = db_fetch($query)) {
201
+    if ($i++ % 100 == 0) {
202 202
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
203 203
     }
204
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
204
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
205 205
       continue;
206 206
     }
207 207
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
   sta_set_time_limit('posting new user stats to DB');
221 221
   $data = array();
222
-  foreach($user_allies as $user_id => $ally_id) {
222
+  foreach ($user_allies as $user_id => $ally_id) {
223 223
     // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000
224 224
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
225 225
     $points[$user_id] = array_map('floor', $points[$user_id]);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
   // Updating player's ranks
277 277
   sta_set_time_limit("updating ranks for players");
278
-  foreach($rankNames as $rankName) {
278
+  foreach ($rankNames as $rankName) {
279 279
     sta_set_time_limit("updating player rank '{$rankName}'", false);
280 280
     doquery($qryResetRowNum);
281 281
     doquery(sprintf($qryFormat, $rankName, 1));
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
   sta_set_time_limit("updating ranks for Alliances");
285 285
   // --- Updating Allie's ranks
286
-  foreach($rankNames as $rankName) {
286
+  foreach ($rankNames as $rankName) {
287 287
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
288 288
     doquery($qryResetRowNum);
289 289
     doquery(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.