Completed
Push — work-fleets ( 7f5906...04acf9 )
by SuperNova.WS
06:14
created
includes/includes/flt_mission_spy.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  */
12 12
 // ----------------------------------------------------------------------------------------------------------------
13 13
 function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) {
14
-  foreach($unit_group as $unit_id) {
15
-    if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
14
+  foreach ($unit_group as $unit_id) {
15
+    if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
16 16
       $compress_data[$unit_id] = $unit_count;
17 17
     }
18 18
   }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
   $classLocale = classLocale::$lang;
23 23
 
24 24
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
25
-  foreach(sn_get_groups($group_name) as $unit_id) {
26
-    if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
25
+  foreach (sn_get_groups($group_name) as $unit_id) {
26
+    if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
27 27
       $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>";
28 28
     }
29 29
 
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 
56 56
   $objFleet = $mission_data->fleet;
57 57
 
58
-  if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) {
58
+  if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) {
59 59
     $objFleet->markReturnedAndSave();
60 60
 
61 61
     return $result;
62 62
   }
63 63
 
64 64
   $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY);
65
-  if($spy_probes > 0) {
65
+  if ($spy_probes > 0) {
66 66
     $TargetSpyLvl = GetSpyLevel($target_user_row);
67 67
     $CurrentSpyLvl = GetSpyLevel($spying_user_row);
68 68
     $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl;
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
     $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} ";
81 81
     $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target);
82 82
     $spy_message .= "</td></tr><tr>";
83
-    $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>";
84
-    $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>";
83
+    $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>";
84
+    $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>";
85 85
     $spy_message .= "</tr><tr>";
86
-    $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>";
87
-    $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>";
86
+    $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>";
87
+    $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>";
88 88
     $spy_message .= "</tr>";
89
-    if($spy_diff >= 2) {
90
-      $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>";
89
+    if ($spy_diff >= 2) {
90
+      $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>";
91 91
       coe_compress_add_units(Fleet::$snGroupFleet, $target_planet_row, $combat_pack[0]);
92 92
     }
93
-    if($spy_diff >= 3) {
94
-      $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>";
93
+    if ($spy_diff >= 3) {
94
+      $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>";
95 95
       coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]);
96 96
     }
97
-    if($spy_diff >= 5) {
98
-      $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>";
97
+    if ($spy_diff >= 5) {
98
+      $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>";
99 99
     }
100 100
 
101
-    if($spy_diff_empire >= 0) {
102
-      $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>";
101
+    if ($spy_diff_empire >= 0) {
102
+      $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>";
103 103
       coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row);
104 104
     }
105 105
     // TODO: Наемники, губернаторы, артефакты и прочее имперское
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D');
108 108
 
109 109
     $target_unit_list = 0;
110
-    foreach(Fleet::$snGroupFleet as $unit_id) {
110
+    foreach (Fleet::$snGroupFleet as $unit_id) {
111 111
       $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true));
112 112
     }
113 113
 
114 114
     $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl);
115 115
 
116
-    if(mt_rand(0, 99) > $spy_detected) {
116
+    if (mt_rand(0, 99) > $spy_detected) {
117 117
       $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected);
118 118
       $spy_detected = false;
119 119
     } else {
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 
131 131
     DBStaticMessages::msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message);
132 132
 
133
-    $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3);
134
-    $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row);
133
+    $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3);
134
+    $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row);
135 135
 
136
-    if($spy_detected) {
136
+    if ($spy_detected) {
137 137
       $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet'];
138 138
 
139 139
       $spy_cost = get_unit_param(SHIP_SPY, P_COST);
140 140
 
141 141
       DBStaticPlanet::db_planet_set_by_id($debris_planet_id,
142
-        "`debris_metal` = `debris_metal` + " . floor($spy_probes * $spy_cost[RES_METAL] * 0.3) . ", `debris_crystal` = `debris_crystal` + " . floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
142
+        "`debris_metal` = `debris_metal` + ".floor($spy_probes * $spy_cost[RES_METAL] * 0.3).", `debris_crystal` = `debris_crystal` + ".floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
143 143
 
144 144
       $target_message .= "<br />{$classLocale['sys_mess_spy_destroyed_enemy']}";
145 145
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message);
151 151
   }
152 152
 
153
-  if($spy_detected) {
153
+  if ($spy_detected) {
154 154
     $objFleet->dbDelete();
155 155
   } else {
156 156
     $objFleet->markReturnedAndSave();
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
   $destination_planet = &$mission_data->dst_planet;
16 16
 
17
-  if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
17
+  if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
18 18
     $objFleet->markReturnedAndSave();
19 19
 
20 20
     return CACHE_FLEET;
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
       $fleet_resources[RES_METAL], classLocale::$lang['Metal'],
28 28
       $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'],
29 29
       $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium']
30
-    ) . '<br />' . classLocale::$lang['sys_relocate_mess_user'];
31
-  foreach($objFleet->shipsIterator() as $ship_id => $ship) {
32
-    $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship->count . '<br />';
30
+    ).'<br />'.classLocale::$lang['sys_relocate_mess_user'];
31
+  foreach ($objFleet->shipsIterator() as $ship_id => $ship) {
32
+    $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship->count.'<br />';
33 33
   }
34 34
   DBStaticMessages::msg_send_simple_message(
35 35
     $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT,
Please login to merge, or discard this patch.
includes/includes/flt_mission_explore.php 1 patch
Spacing   +33 added lines, -34 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
   // TODO - Currently $ship_data is one for all players
22 22
   static $shipCostInMetalPerPiece, $rates;
23 23
 
24
-  if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) {
24
+  if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) {
25 25
     return CACHE_NONE;
26 26
   }
27 27
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
   $outcome_value = &$result['$outcome_value'];
47 47
   $outcome_list = &$result['$outcome_list'];
48 48
 
49
-  if(!$shipCostInMetalPerPiece) {
49
+  if (!$shipCostInMetalPerPiece) {
50 50
     $rates = get_resource_exchange();
51 51
 
52
-    foreach(Fleet::$snGroupFleet as $unit_id) {
52
+    foreach (Fleet::$snGroupFleet as $unit_id) {
53 53
       $unit_info = get_unit_param($unit_id);
54
-      if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
54
+      if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
55 55
         continue;
56 56
       }
57 57
       $shipCostInMetalPerPiece[$unit_id] = get_unit_cost_in($unit_info[P_COST], RES_METAL);
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
   $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7));
72 72
 
73 73
   $chance_max = 0;
74
-  foreach($outcome_list as $key => &$value) {
75
-    if(!$value['chance']) {
74
+  foreach ($outcome_list as $key => &$value) {
75
+    if (!$value['chance']) {
76 76
       unset($outcome_list[$key]);
77 77
       continue;
78 78
     }
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
   }
81 81
   $outcome_value = mt_rand(0, $chance_max);
82 82
   $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE];
83
-  foreach($outcome_list as $key => &$value) {
84
-    if(!$value['chance']) {
83
+  foreach ($outcome_list as $key => &$value) {
84
+    if (!$value['chance']) {
85 85
       continue;
86 86
     }
87 87
     $mission_outcome = $key;
88 88
     $outcome_description = $value;
89
-    if($outcome_value <= $outcome_description['value']) {
89
+    if ($outcome_value <= $outcome_description['value']) {
90 90
       break;
91 91
     }
92 92
   }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 //  $outcome_mission_sub = -1;
104 104
 
105 105
   $fleet_found = array();
106
-  switch($mission_outcome) {
106
+  switch ($mission_outcome) {
107 107
     case FLT_EXPEDITION_OUTCOME_LOST_FLEET:
108 108
       $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000);
109 109
     break;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 
125 125
       // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля
126 126
       $can_be_found = array();
127
-      foreach($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) {
128
-        if($shipMetalCost < $max_metal_cost) {
127
+      foreach ($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) {
128
+        if ($shipMetalCost < $max_metal_cost) {
129 129
           $can_be_found[$ship_id] = $shipMetalCost;
130 130
         }
131 131
       }
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
       unset($can_be_found[SHIP_COLONIZER]);
134 134
       unset($can_be_found[SHIP_SPY]);
135 135
 
136
-      while(count($can_be_found) && $found_in_metal >= max($can_be_found)) {
136
+      while (count($can_be_found) && $found_in_metal >= max($can_be_found)) {
137 137
         $found_index = mt_rand(1, count($can_be_found)) - 1;
138 138
         $found_ship = array_slice($can_be_found, $found_index, 1, true);
139 139
         $found_ship_cost = reset($found_ship);
140 140
         $found_ship_id = key($found_ship);
141 141
 
142
-        if($found_ship_cost > $found_in_metal) {
142
+        if ($found_ship_cost > $found_in_metal) {
143 143
           unset($can_be_found[$found_ship_id]);
144 144
         } else {
145 145
           $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost));
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
         }
149 149
       }
150 150
 
151
-      if(empty($fleet_found)) {
151
+      if (empty($fleet_found)) {
152 152
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
153 153
       } else {
154
-        foreach($fleet_found as $unit_id => $unit_amount) {
154
+        foreach ($fleet_found as $unit_id => $unit_amount) {
155 155
           $objFleet->shipAdjustCount($unit_id, $unit_amount);
156 156
         }
157 157
       }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
       $objFleet->resourcesAdjust($resources_found);
177 177
 
178
-      if(array_sum($resources_found) == 0) {
178
+      if (array_sum($resources_found) == 0) {
179 179
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
180 180
       }
181 181
     break;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
       // Рассчитываем количество найденной ТМ
187 187
       $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000);
188 188
 
189
-      if(!$found_dark_matter) {
189
+      if (!$found_dark_matter) {
190 190
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
191 191
       }
192 192
     break;
@@ -200,46 +200,45 @@  discard block
 block discarded – undo
200 200
 
201 201
   mission_expedition_result_adjust($result, $objFleet);
202 202
 
203
-  if($found_dark_matter) {
203
+  if ($found_dark_matter) {
204 204
     rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus');
205 205
     $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter);
206 206
   }
207 207
 
208
-  if(!empty($fleet_lost)) {
208
+  if (!empty($fleet_lost)) {
209 209
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet'];
210
-    foreach($fleet_lost as $ship_id => $ship_amount) {
211
-      $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
210
+    foreach ($fleet_lost as $ship_id => $ship_amount) {
211
+      $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n";
212 212
     }
213 213
   }
214 214
 
215
-  if(!empty($fleet_found)) {
215
+  if (!empty($fleet_found)) {
216 216
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet'];
217
-    foreach($fleet_found as $ship_id => $ship_amount) {
218
-      $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
217
+    foreach ($fleet_found as $ship_id => $ship_amount) {
218
+      $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n";
219 219
     }
220 220
   }
221 221
 
222
-  if(!empty($resources_found) && array_sum($resources_found) > 0) {
222
+  if (!empty($resources_found) && array_sum($resources_found) > 0) {
223 223
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources'];
224
-    foreach($resources_found as $resource_id => $resource_amount) {
225
-      $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n";
224
+    foreach ($resources_found as $resource_id => $resource_amount) {
225
+      $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n";
226 226
     }
227 227
   }
228 228
 
229
-  if(!$msg_text) {
229
+  if (!$msg_text) {
230 230
     $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages'];
231
-    if($outcome_mission_sub >= 0 && is_array($messages)) {
231
+    if ($outcome_mission_sub >= 0 && is_array($messages)) {
232 232
       $messages = &$messages[$outcome_mission_sub];
233 233
     }
234 234
 
235
-    $msg_text = is_string($messages) ? $messages :
236
-      (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
235
+    $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
237 236
   }
238 237
 
239 238
   $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type();
240 239
 
241
-  $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) .
242
-    ($msg_text_addon ? "\r\n" . $msg_text_addon : '');
240
+  $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)).
241
+    ($msg_text_addon ? "\r\n".$msg_text_addon : '');
243 242
 
244 243
   DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text);
245 244
 
Please login to merge, or discard this patch.
includes/includes/market_fleeter.inc 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
5
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
6 6
   classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
7 7
 }
8 8
 
9
-$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"];
9
+$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"];
10 10
 
11 11
 $template = gettemplate('market_fleet', true);
12 12
 $template->assign_vars(array(
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
   'rpg_cost' => $rpg_cost,
15 15
 ));
16 16
 
17
-if(is_array($shipList)) {
18
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
17
+if (is_array($shipList)) {
18
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
19 19
     $intError = MARKET_NO_DM;
20 20
   }
21 21
 
@@ -28,34 +28,34 @@  discard block
 block discarded – undo
28 28
   // Блокируем запись о запасах кораблей у трейдера
29 29
   db_config_get_stockman_fleet();
30 30
 
31
-  $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>';
31
+  $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>';
32 32
   $qry = array();
33 33
   $total = array();
34 34
   $db_changeset = array();
35
-  foreach($shipList as $shipID => &$shipCount) {
35
+  foreach ($shipList as $shipID => &$shipCount) {
36 36
     $shipCount = ceil(floatval($shipCount));
37
-    if(!$shipCount) {
37
+    if (!$shipCount) {
38 38
       continue;
39 39
     }
40 40
 
41
-    if($shipCount < 0) {
41
+    if ($shipCount < 0) {
42 42
       classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
43 43
       $intError = MARKET_NEGATIVE_SHIPS;
44 44
       break;
45 45
     }
46 46
 
47
-    if($mode == MARKET_SCRAPPER) {
47
+    if ($mode == MARKET_SCRAPPER) {
48 48
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
49
-    } elseif($mode == MARKET_STOCKMAN) {
49
+    } elseif ($mode == MARKET_STOCKMAN) {
50 50
       $amount = $stock[$shipID];
51 51
     }
52 52
 
53
-    if($amount < $shipCount) {
53
+    if ($amount < $shipCount) {
54 54
       $intError = $error_no_stock;
55 55
       break;
56 56
     }
57 57
 
58
-    if(!in_array($shipID, Fleet::$snGroupFleet)) {
58
+    if (!in_array($shipID, Fleet::$snGroupFleet)) {
59 59
       classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
60 60
       $intError = MARKET_NOT_A_SHIP;
61 61
       break;
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
72 72
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
73 73
 
74
-    foreach($resTemp as $resID => $resCount) {
74
+    foreach ($resTemp as $resID => $resCount) {
75 75
       $total[$resID] += $resCount;
76 76
     }
77 77
 
78
-    $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount);
78
+    $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount);
79 79
   }
80 80
 
81
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
82
-    foreach($total as $resID => $resCount) {
83
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
81
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
82
+    foreach ($total as $resID => $resCount) {
83
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
84 84
         $intError = MARKET_NO_RESOURCES;
85 85
         classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
86 86
         break;
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 
91 91
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
92 92
 
93
-  if($intError == MARKET_DEAL) {
94
-    $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>';
95
-    foreach($total as $resID => $resCount) {
96
-      if(!$resCount) {
93
+  if ($intError == MARKET_DEAL) {
94
+    $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>';
95
+    foreach ($total as $resID => $resCount) {
96
+      if (!$resCount) {
97 97
         continue;
98 98
       }
99 99
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
       // $newrow[$resID] = $planetrow[$resID] + $resCount * (-$multiplier);
102 102
       $qry[] = "`{$resource_name}` = `{$resource_name}` + ({$resCount})";
103 103
 
104
-      $message .= "<li>" . classLocale::$lang['sys_' . $resource_name] . ": " . pretty_number(abs($resCount));
104
+      $message .= "<li>".classLocale::$lang['sys_'.$resource_name].": ".pretty_number(abs($resCount));
105 105
     }
106 106
     $message .= "</ul>";
107 107
 
@@ -127,38 +127,38 @@  discard block
 block discarded – undo
127 127
       'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError],
128 128
     ));
129 129
 
130
-    foreach($shipList as $shipID => $shipCount) {
130
+    foreach ($shipList as $shipID => $shipCount) {
131 131
       $data['ships'][$shipID] = max(0, intval($shipCount));
132 132
     }
133 133
   }
134 134
 }
135 135
 $message = '';
136 136
 
137
-if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
138
-  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, Fleet::$snGroupFleet)));
137
+if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
138
+  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, Fleet::$snGroupFleet)));
139 139
 }
140 140
 
141 141
 tpl_set_resource_info($template, $planetrow, array());
142 142
 
143
-if(!$array) {
143
+if (!$array) {
144 144
   $array = array();
145 145
 }
146 146
 
147 147
 $group_fleet = Fleet::$snGroupFleet;
148
-foreach($array as $key => $value) {
149
-  if($mode == MARKET_SCRAPPER) {
148
+foreach ($array as $key => $value) {
149
+  if ($mode == MARKET_SCRAPPER) {
150 150
     $shipID = $value;
151 151
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
152
-  } elseif($mode == MARKET_STOCKMAN) {
152
+  } elseif ($mode == MARKET_STOCKMAN) {
153 153
     $shipID = $key;
154 154
     $amount = $value;
155 155
   }
156 156
 
157
-  if(!in_array($shipID, $group_fleet)) {
157
+  if (!in_array($shipID, $group_fleet)) {
158 158
     continue;
159 159
   }
160 160
 
161
-  if($amount > 0) {
161
+  if ($amount > 0) {
162 162
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
163 163
     $template->assign_block_vars('ships', array(
164 164
       'ID'        => $shipID,
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +30 added lines, -30 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
   classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg);
48
-  if($next_step) {
48
+  if ($next_step) {
49 49
     classSupernova::$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 = DBStaticUser::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 = DBStaticPlanet::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,14 +151,14 @@  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
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
158
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
159 159
       $counts[$user_id][UNIT_SHIPS] += $unit->count;
160 160
 
161
-      if(!isset($unit_cost_cache[$unit_id][0])) {
161
+      if (!isset($unit_cost_cache[$unit_id][0])) {
162 162
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
163 163
       }
164 164
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
   $i = 0;
179 179
   $query = DBStaticUnit::db_unit_list_stat_calculate();
180 180
   $row_num = db_num_rows($query);
181
-  while($unit = db_fetch($query)) {
182
-    if($i++ % 100 == 0) {
181
+  while ($unit = db_fetch($query)) {
182
+    if ($i++ % 100 == 0) {
183 183
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
184 184
     }
185
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
185
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
186 186
       continue;
187 187
     }
188 188
 
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
   $i = 0;
197 197
   $query = DBStaticQue::db_que_list_stat();
198 198
   $row_num = db_num_rows($query);
199
-  while($que_item = db_fetch($query)) {
200
-    if($i++ % 100 == 0) {
199
+  while ($que_item = db_fetch($query)) {
200
+    if ($i++ % 100 == 0) {
201 201
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
202 202
     }
203
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
203
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
204 204
       continue;
205 205
     }
206 206
     $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]);
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
     $user_points = array_sum($points[$user_id]);
232 232
     $user_counts = array_sum($counts[$user_id]);
233 233
 
234
-    $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}'," .
235
-      "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}'," .
236
-      "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}'," .
237
-      "{$user_points},{$user_counts}," . SN_TIME_NOW . ")";
234
+    $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}',".
235
+      "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}',".
236
+      "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}',".
237
+      "{$user_points},{$user_counts},".SN_TIME_NOW.")";
238 238
 
239 239
     sys_stat_calculate_flush($data);
240 240
   }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`,
255 255
         SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`,
256 256
         SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`,
257
-        " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1,
257
+        " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1,
258 258
         a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank
259 259
       FROM {{statpoints}} AS u
260 260
         JOIN {{alliance}} AS al ON al.id = u.id_ally
@@ -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.
galaxy.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Galaxy view
7 7
  */
8 8
 
9
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
9
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
10 10
 
11 11
 lng_include('universe');
12 12
 lng_include('stat');
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $uni_system = sys_get_param_int('system', $planetrow['system']);
17 17
 $planet = sys_get_param_int('planet', $planetrow['planet']);
18 18
 
19
-if($mode == 'name') {
19
+if ($mode == 'name') {
20 20
   require_once('includes/includes/uni_rename.php');
21 21
 }
22 22
 
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 $flying_fleet_count = FleetList::fleet_count_flying($user['id']);
39 39
 
40
-if($mode == 1) {
41
-} elseif($mode == 2 || $mode == 3) {
40
+if ($mode == 1) {
41
+} elseif ($mode == 2 || $mode == 3) {
42 42
   $planet = $planetrow['planet'];
43 43
 } else {
44 44
   $uni_galaxy = $planetrow['galaxy'];
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
   $planet = $planetrow['planet'];
47 47
 }
48 48
 
49
-$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies? Vector::$knownGalaxies: $uni_galaxy);
49
+$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies ? Vector::$knownGalaxies : $uni_galaxy);
50 50
 $uni_system = $uni_system < 1 ? 1 : ($uni_system > Vector::$knownSystems ? Vector::$knownSystems : $uni_system);
51 51
 $planet = $planet < 1 ? 1 : ($planet > Vector::$knownPlanets + 1 ? Vector::$knownPlanets + 1 : $planet);
52 52
 
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 $PhalanxRange = GetPhalanxRange($HavePhalanx);
65 65
 
66 66
 $planet_precache_query = DBStaticPlanet::db_planet_list_in_system($uni_galaxy, $uni_system);
67
-if(!empty($planet_precache_query)) {
68
-  foreach($planet_precache_query as $planet_row) {
67
+if (!empty($planet_precache_query)) {
68
+  foreach ($planet_precache_query as $planet_row) {
69 69
     $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row;
70 70
   }
71 71
 }
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
  * @var Fleet[][][] $fleet_list
84 84
  */
85 85
 $fleet_list = array();
86
-foreach($system_fleet_list->_container as $objFleetSystem) {
87
-  if(!$objFleetSystem->isReturning()) {
86
+foreach ($system_fleet_list->_container as $objFleetSystem) {
87
+  if (!$objFleetSystem->isReturning()) {
88 88
     $fleet_planet = $objFleetSystem->fleet_end_planet;
89 89
     $fleet_type = $objFleetSystem->fleet_end_type;
90 90
   } else {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 $recycler_info = array();
100 100
 $planet_recyclers_orbiting = 0;
101 101
 $recyclers_fleet = array();
102
-foreach(Fleet::$snGroupRecyclers as $recycler_id) {
102
+foreach (Fleet::$snGroupRecyclers as $recycler_id) {
103 103
   $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user);
104 104
   $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id);
105 105
   $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id];
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 $fleet_id = 1;
110 110
 $fleets = array();
111 111
 $config_game_max_planet = Vector::$knownPlanets + 1;
112
-for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
112
+for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
113 113
   unset($uni_galaxyRowPlanet);
114 114
   unset($uni_galaxyRowMoon);
115 115
   unset($uni_galaxyRowUser);
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
   $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET];
120 120
 
121 121
   $planet_fleet_id = 0;
122
-  if($uni_galaxyRowPlanet['destruyed']) {
122
+  if ($uni_galaxyRowPlanet['destruyed']) {
123 123
     CheckAbandonPlanetState($uni_galaxyRowPlanet);
124
-  } elseif($uni_galaxyRowPlanet['id']) {
125
-    if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
124
+  } elseif ($uni_galaxyRowPlanet['id']) {
125
+    if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
126 126
       $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']];
127 127
     } else {
128 128
       $uni_galaxyRowUser = DBStaticUser::db_user_by_id($uni_galaxyRowPlanet['id_owner']);
129 129
       $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser;
130 130
     }
131 131
 
132
-    if(!$uni_galaxyRowUser['id']) {
132
+    if (!$uni_galaxyRowUser['id']) {
133 133
       classSupernova::$debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503);
134 134
       $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24;
135 135
       $uni_galaxyRowPlanet['id_owner'] = 0;
136 136
       DBStaticPlanet::db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}");
137 137
     }
138 138
 
139
-    if($uni_galaxyRowUser['id']) {
139
+    if ($uni_galaxyRowUser['id']) {
140 140
       $planetcount++;
141
-      if($uni_galaxyRowUser['ally_id']) {
142
-        if($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
141
+      if ($uni_galaxyRowUser['ally_id']) {
142
+        if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
143 143
           $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']];
144 144
         } else {
145 145
           $allyquery = DBStaticAlly::db_ally_get_by_id($uni_galaxyRowUser['ally_id']);
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
       }
149 149
 
150 150
       $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]);
151
-      if(!empty($fleets_to_planet['own']['count'])) {
151
+      if (!empty($fleets_to_planet['own']['count'])) {
152 152
         $planet_fleet_id = $fleet_id;
153 153
         $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
154 154
         $fleet_id++;
155 155
       }
156 156
 
157 157
       $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON];
158
-      if($uni_galaxyRowMoon['destruyed']) {
158
+      if ($uni_galaxyRowMoon['destruyed']) {
159 159
         CheckAbandonPlanetState($uni_galaxyRowMoon);
160 160
       } else {
161 161
         $moon_fleet_id = 0;
162 162
         $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]);
163
-        if(!empty($fleets_to_planet['own']['count'])) {
163
+        if (!empty($fleets_to_planet['own']['count'])) {
164 164
           $moon_fleet_id = $fleet_id;
165 165
           $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
166 166
           $fleet_id++;
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 
172 172
   $recyclers_incoming_capacity = 0;
173 173
   $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal'];
174
-  if($uni_galaxyRowPlanet['debris']) {
175
-    if(!empty($fleet_list[$Planet][PT_DEBRIS])) {
176
-      foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
177
-        if($objFleetToDebris->playerOwnerId == $user['id']) {
174
+  if ($uni_galaxyRowPlanet['debris']) {
175
+    if (!empty($fleet_list[$Planet][PT_DEBRIS])) {
176
+      foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
177
+        if ($objFleetToDebris->playerOwnerId == $user['id']) {
178 178
           $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info);
179 179
         }
180 180
       }
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
 
252 252
 tpl_assign_fleet($template, $fleets);
253 253
 
254
-foreach(sn_get_groups('defense_active') as $unit_id) {
254
+foreach (sn_get_groups('defense_active') as $unit_id) {
255 255
   $template->assign_block_vars('defense_active', array(
256 256
     'ID'   => $unit_id,
257 257
     'NAME' => classLocale::$lang['tech'][$unit_id],
258 258
   ));
259 259
 }
260 260
 
261
-foreach($cached['users'] as $PlanetUser) {
262
-  if(!$PlanetUser) {
261
+foreach ($cached['users'] as $PlanetUser) {
262
+  if (!$PlanetUser) {
263 263
     continue;
264 264
   }
265 265
 
266 266
   $user_ally = $cached['allies'][$PlanetUser['ally_id']];
267
-  if(isset($user_ally)) {
268
-    if($PlanetUser['id'] == $user_ally['ally_owner']) {
267
+  if (isset($user_ally)) {
268
+    if ($PlanetUser['id'] == $user_ally['ally_owner']) {
269 269
       $user_rank_title = $user_ally['ally_owner_range'];
270 270
     } else {
271 271
       $ally_ranks = explode(';', $user_ally['ranklist']);
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
   ));
289 289
 }
290 290
 
291
-foreach($cached['allies'] as $PlanetAlly) {
292
-  if($PlanetAlly) {
291
+foreach ($cached['allies'] as $PlanetAlly) {
292
+  if ($PlanetAlly) {
293 293
     $template->assign_block_vars('alliances', array(
294 294
       'ID'      => $PlanetAlly['id'],
295 295
       'NAME_JS' => js_safe_string($PlanetAlly['ally_name']),
Please login to merge, or discard this patch.
overview.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 //define('SN_RENDER_NAVBAR_PLANET', false);
32 32
 
33
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
33
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
34 34
 
35 35
 //
36 36
 ////$player = new Player();
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 $result = array();
80 80
 
81
-switch($mode = sys_get_param_str('mode')) {
81
+switch ($mode = sys_get_param_str('mode')) {
82 82
   case 'manage':
83 83
     sn_sys_sector_buy('overview.php?mode=manage');
84 84
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
     $template  = gettemplate('planet_manage', true);
89 89
     $planet_id = sys_get_param_id('planet_id');
90 90
 
91
-    if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
91
+    if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
92 92
       $planetrow['name'] = $new_name;
93 93
 //      $new_name = db_escape($new_name);
94 94
       DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name}'");
95
-    } elseif(sys_get_param_str('action') == 'make_capital') {
95
+    } elseif (sys_get_param_str('action') == 'make_capital') {
96 96
       try {
97 97
         sn_db_transaction_start();
98 98
         $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 //        $user = $global_data['user'];
102 102
 //        $planetrow = $global_data['planet'];
103 103
 
104
-        if($planetrow['planet_type'] != PT_PLANET) {
104
+        if ($planetrow['planet_type'] != PT_PLANET) {
105 105
           throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR);
106 106
         }
107 107
 
108
-        if($planetrow['id'] == $user['id_planet']) {
108
+        if ($planetrow['id'] == $user['id_planet']) {
109 109
           throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR);
110 110
         }
111 111
 
112
-        if($user_dark_matter < classSupernova::$config->planet_capital_cost) {
112
+        if ($user_dark_matter < classSupernova::$config->planet_capital_cost) {
113 113
           throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR);
114 114
         }
115 115
 
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
         );
127 127
         sn_db_transaction_commit();
128 128
         sys_redirect('overview.php?mode=manage');
129
-      } catch(exception $e) {
129
+      } catch (exception $e) {
130 130
         sn_db_transaction_rollback();
131 131
         $result[] = array(
132 132
           'STATUS'  => $e->getCode(),
133 133
           'MESSAGE' => $e->getMessage(),
134 134
         );
135 135
       }
136
-    } elseif(sys_get_param_str('action') == 'planet_teleport') {
136
+    } elseif (sys_get_param_str('action') == 'planet_teleport') {
137 137
       try {
138
-        if(!uni_coordinates_valid($new_coordinates = array(
138
+        if (!uni_coordinates_valid($new_coordinates = array(
139 139
           'galaxy' => sys_get_param_int('new_galaxy'),
140 140
           'system' => sys_get_param_int('new_system'),
141 141
           'planet' => sys_get_param_int('new_planet')))
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 //        $planetrow = $global_data['planet'];
153 153
 
154 154
         $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates);
155
-        if($can_teleport['result'] != ERR_NONE) {
155
+        if ($can_teleport['result'] != ERR_NONE) {
156 156
           throw new exception($can_teleport['message'], $can_teleport['result']);
157 157
         }
158 158
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         DBStaticPlanet::db_planet_set_by_gspt($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], PT_ALL,
164 164
           "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}, planet_teleport_next = {$planet_teleport_next}");
165 165
 
166
-        if($planetrow['id'] == $user['id_planet']) {
166
+        if ($planetrow['id'] == $user['id_planet']) {
167 167
           DBStaticUser::db_user_set_by_id($user['id'], "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}");
168 168
         }
169 169
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
           'MESSAGE' => classLocale::$lang['ov_teleport_err_none'],
177 177
         );
178 178
         sys_redirect('overview.php?mode=manage');
179
-      } catch(exception $e) {
179
+      } catch (exception $e) {
180 180
         sn_db_transaction_rollback();
181 181
         $result[] = array(
182 182
           'STATUS'  => $e->getCode(),
183 183
           'MESSAGE' => $e->getMessage(),
184 184
         );
185 185
       }
186
-    } elseif(sys_get_param_str('action') == 'planet_abandon') {
186
+    } elseif (sys_get_param_str('action') == 'planet_abandon') {
187 187
       // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) {
188
-      if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
189
-        if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
188
+      if (classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
189
+        if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
190 190
           $destroyed = SN_TIME_NOW + 60 * 60 * 24;
191 191
           DBStaticPlanet::db_planet_set_by_id($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0");
192 192
           DBStaticPlanet::db_planet_set_by_parent($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0");
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
           message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
197 197
         }
198 198
       } else {
199
-        message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
199
+        message(classLocale::$lang['ov_delete_wrong_pass'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
200 200
       }
201
-    } elseif(
201
+    } elseif (
202 202
       ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors'))
203 203
       && (
204 204
         !get_unit_param($hire, P_MAX_STACK) ||
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
       $user = DBStaticUser::db_user_by_id($user['id'], true);
214 214
       $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
215 215
       $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0);
216
-      if($build_data['CAN'][BUILD_CREATE]) {
217
-        if($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
216
+      if ($build_data['CAN'][BUILD_CREATE]) {
217
+        if ($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
218 218
           $planetrow['PLANET_GOVERNOR_LEVEL']++;
219 219
           $query = '`PLANET_GOVERNOR_LEVEL` + 1';
220 220
         } else {
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 
241 241
     lng_include('mrc_mercenary');
242 242
     int_planet_pretemplate($planetrow, $template);
243
-    foreach(sn_get_groups('governors') as $governor_id) {
244
-      if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
243
+    foreach (sn_get_groups('governors') as $governor_id) {
244
+      if ($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
245 245
         continue;
246 246
       }
247 247
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
       'PAGE_HINT'   => classLocale::$lang['ov_manage_page_hint'],
294 294
     ));
295 295
 
296
-    foreach($result as &$a_result) {
296
+    foreach ($result as &$a_result) {
297 297
       $template->assign_block_vars('result', $a_result);
298 298
     }
299 299
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
   default:
304 304
     sn_sys_sector_buy();
305 305
 
306
-    if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
306
+    if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
307 307
       $planetrow['name'] = $new_name;
308 308
       $new_name_safe = db_escape($new_name);
309 309
       DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name_safe}'");
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
     $planet_count = 0;
335 335
     $planets_query = DBStaticPlanet::db_planet_list_sorted($user, false, '*');
336
-    foreach($planets_query as $an_id => $UserPlanet) {
336
+    foreach ($planets_query as $an_id => $UserPlanet) {
337 337
       sn_db_transaction_start();
338 338
       $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true);
339 339
       sn_db_transaction_commit();
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
 
345 345
       $planet_fleet_id = 0;
346 346
       $fleet_list = $template_planet['fleet_list'];
347
-      if($fleet_list['own']['count']) {
347
+      if ($fleet_list['own']['count']) {
348 348
         $planet_fleet_id = "p{$UserPlanet['id']}";
349 349
         $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
350 350
 //        $fleet_id++;tpl_parse_fleet_sn
351 351
       }
352
-      if($UserPlanet['planet_type'] == PT_MOON) {
352
+      if ($UserPlanet['planet_type'] == PT_MOON) {
353 353
         continue;
354 354
       }
355 355
       $moon = DBStaticPlanet::db_planet_by_parent($UserPlanet['id']);
356
-      if($moon) {
356
+      if ($moon) {
357 357
         $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100));
358 358
       } else {
359 359
         $moon_fill = 0;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     tpl_assign_fleet($template, $fleets);
394 394
 
395 395
     $lune = $planetrow['planet_type'] == PT_PLANET ? DBStaticPlanet::db_planet_by_parent($planetrow['id']) : DBStaticPlanet::db_planet_by_id($planetrow['parent_planet']);
396
-    if($lune) {
396
+    if ($lune) {
397 397
       $template->assign_vars(array(
398 398
         'MOON_ID' => $lune['id'],
399 399
         'MOON_IMG' => $lune['image'],
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
     $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
406 406
 
407 407
     $planet_recyclers_orbiting = 0;
408
-    foreach(Fleet::$snGroupRecyclers as $recycler_id) {
408
+    foreach (Fleet::$snGroupRecyclers as $recycler_id) {
409 409
       $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id);
410 410
     }
411 411
 
412 412
     int_planet_pretemplate($planetrow, $template);
413 413
 
414 414
     $sn_group_ques = sn_get_groups('ques');
415
-    if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
416
-      foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
415
+    if (!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
416
+      foreach (array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
417 417
         $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']];
418 418
         $template->assign_block_vars('ques', array(
419 419
           'ID'     => $que_id,
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
           'LENGTH' => empty($this_que) ? 0 : count($this_que),
422 422
         ));
423 423
 
424
-        if(!empty($this_que)) {
425
-          foreach($this_que as $que_item) {
424
+        if (!empty($this_que)) {
425
+          foreach ($this_que as $que_item) {
426 426
             $template->assign_block_vars('que', que_tpl_parse_element($que_item));
427 427
           }
428 428
         }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
       'LENGTH' => $que_hangar_length,
437 437
     ));
438 438
 
439
-    if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
439
+    if (!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
440 440
       $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE);
441 441
       $template->assign_block_vars('ques', array(
442 442
         'ID'     => SUBQUE_DEFENSE,
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
     $overview_planet_rows = $user['opt_int_overview_planet_rows'];
449 449
     $overview_planet_columns = $user['opt_int_overview_planet_columns'];
450 450
 
451
-    if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
451
+    if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
452 452
       $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows'];
453 453
       $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns'];
454 454
     }
455 455
 
456
-    if($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
456
+    if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
457 457
       $overview_planet_columns = ceil($planet_count / $overview_planet_rows);
458 458
     }
459 459
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
     ));
511 511
     tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2);
512 512
 
513
-    foreach($result as &$a_result) {
513
+    foreach ($result as &$a_result) {
514 514
       $template->assign_block_vars('result', $a_result);
515 515
     }
516 516
 
Please login to merge, or discard this patch.
includes/functions/sys_bbcode.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -103,23 +103,23 @@
 block discarded – undo
103 103
 
104 104
   !empty(classSupernova::$config->url_faq) ? $msg = str_replace('faq://', classSupernova::$config->url_faq, $msg) : false;
105 105
 
106
-  foreach(classSupernova::$design['bbcodes'] as $auth_level => $replaces) {
107
-    if($auth_level > $author_auth) {
106
+  foreach (classSupernova::$design['bbcodes'] as $auth_level => $replaces) {
107
+    if ($auth_level > $author_auth) {
108 108
       continue;
109 109
     }
110 110
 
111
-    foreach($replaces as $key => $html) {
111
+    foreach ($replaces as $key => $html) {
112 112
       $msg = preg_replace(''.$key.'', $html, $msg);
113 113
     }
114 114
   }
115 115
 
116
-  foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) {
117
-    if($auth_level > $author_auth) {
116
+  foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) {
117
+    if ($auth_level > $author_auth) {
118 118
       continue;
119 119
     }
120 120
 
121
-    foreach($replaces as $key => $imgName) {
122
-      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU","<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">",$msg);
121
+    foreach ($replaces as $key => $imgName) {
122
+      $msg = preg_replace("#".addcslashes($key, '()[]{}')."#isU", "<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">", $msg);
123 123
     }
124 124
   }
125 125
 
Please login to merge, or discard this patch.
includes/pages/chat.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
   $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS;
37 37
 
38 38
   $mode = sys_get_param_int('mode');
39
-  switch($mode) {
39
+  switch ($mode) {
40 40
     case CHAT_MODE_ALLY:
41 41
       $template_result['ALLY'] = intval($user['ally_id']);
42 42
       $page_title = classLocale::$lang['chat_ally'];
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
   }
50 50
 
51 51
   $template_result['.']['smiles'] = array();
52
-  foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) {
53
-    if($auth_level > $user_auth_level) {
52
+  foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) {
53
+    if ($auth_level > $user_auth_level) {
54 54
       continue;
55 55
     }
56 56
 
57
-    foreach($replaces as $bbcode => $filename) {
57
+    foreach ($replaces as $bbcode => $filename) {
58 58
       $template_result['.']['smiles'][] = array(
59 59
         'BBCODE'   => $bbcode,
60 60
         'FILENAME' => $filename,
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
   define('IN_AJAX', true);
78 78
   $skip_fleet_update = true;
79 79
 
80
-  if(classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
80
+  if (classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
81 81
     die();
82 82
   }
83 83
 
84
-  if(($message = sys_get_param_str('message')) && $user['username']) {
84
+  if (($message = sys_get_param_str('message')) && $user['username']) {
85 85
     $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
86 86
     $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))));
87 87
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
   $skip_fleet_update = true;
104 104
 
105 105
   $history = sys_get_param_str('history');
106
-  if(!$history) {
106
+  if (!$history) {
107 107
     classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
108 108
   }
109 109
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
   $last_message = '';
112 112
   $alliance = 0;
113 113
   $template_result['.']['chat'] = array();
114
-  if(!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
114
+  if (!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
115 115
     $result['disable'] = true;
116 116
     $template_result['.']['chat'][] = array(
117 117
       'TIME'    => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')),
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 
125 125
     $where_add = '';
126 126
     $last_message = 0;
127
-    if($history) {
127
+    if ($history) {
128 128
       $rows = DBStaticChat::db_chat_message_count_by_ally($alliance);
129 129
       $page_count = ceil($rows['CNT'] / $page_limit);
130 130
 
131
-      for($i = 0; $i < $page_count; $i++) {
131
+      for ($i = 0; $i < $page_count; $i++) {
132 132
         $template_result['.']['page'][] = array(
133 133
           'NUMBER' => $i
134 134
         );
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 
143 143
     $start_row = $page * $page_limit;
144 144
     $query = DBStaticChat::db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit);
145
-    while($chat_row = db_fetch($query)) {
145
+    while ($chat_row = db_fetch($query)) {
146 146
       // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
147 147
       $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
148 148
       $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8');
149 149
       $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']);
150
-      if(!$history) {
150
+      if (!$history) {
151 151
         $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>";
152 152
       }
153 153
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
   $template = gettemplate('chat_messages', $template);
173 173
   $template->assign_recursive($template_result);
174 174
 
175
-  if($history) {
175
+  if ($history) {
176 176
     display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
177 177
   } else {
178 178
     $result['last_message'] = $last_message;
Please login to merge, or discard this patch.