Completed
Push — trunk ( 09520e...7ac6b6 )
by SuperNova.WS
03:48
created
fleet.php 1 patch
Switch Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -75,121 +75,121 @@  discard block
 block discarded – undo
75 75
 }
76 76
 
77 77
 switch ($fleet_page) {
78
-  case 3:
78
+    case 3:
79 79
 
80
-  case 2:
81
-    $fleet_group_mr = sys_get_param_id('fleet_group');
82
-    $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
83
-    $fleetarray = is_array($fleetarray) ? $fleetarray : array();
80
+    case 2:
81
+      $fleet_group_mr = sys_get_param_id('fleet_group');
82
+      $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
83
+      $fleetarray = is_array($fleetarray) ? $fleetarray : array();
84 84
 
85
-    foreach($fleetarray as $ship_id => &$ship_amount) {
86
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
87
-        $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
88
-        die();
89
-      }
90
-      $ship_amount = floatval($ship_amount);
91
-    }
92
-
93
-    $UsedPlanet = false;
94
-    $YourPlanet = false;
95
-    $missiontype = array();
96
-    if ($planet > SN::$config->game_maxPlanet) {
97
-      $target_mission = MT_EXPLORE;
98
-      $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
99
-    } elseif ($galaxy && $system && $planet) {
100
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
101
-
102
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
103
-
104
-      if ($TargetPlanet['id_owner']) {
105
-        $UsedPlanet = true;
106
-        if ($TargetPlanet['id_owner'] == $user['id']) {
107
-          $YourPlanet = true;
85
+      foreach($fleetarray as $ship_id => &$ship_amount) {
86
+        if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
87
+          $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
88
+          die();
108 89
         }
90
+        $ship_amount = floatval($ship_amount);
109 91
       }
110 92
 
111
-      if (!$UsedPlanet) {
112
-        if ($fleetarray[SHIP_COLONIZER]) {
113
-          $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
114
-          $target_mission = MT_COLONIZE;
115
-          $planet_type = PT_PLANET;
116
-        } else {
117
-          messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
118
-        }
119
-      } else {
120
-        $recyclers = 0;
121
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
122
-          $recyclers += $fleetarray[$recycler_id];
93
+      $UsedPlanet = false;
94
+      $YourPlanet = false;
95
+      $missiontype = array();
96
+      if ($planet > SN::$config->game_maxPlanet) {
97
+        $target_mission = MT_EXPLORE;
98
+        $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
99
+      } elseif ($galaxy && $system && $planet) {
100
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
101
+
102
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
103
+
104
+        if ($TargetPlanet['id_owner']) {
105
+          $UsedPlanet = true;
106
+          if ($TargetPlanet['id_owner'] == $user['id']) {
107
+            $YourPlanet = true;
108
+          }
123 109
         }
124
-        if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
125
-          $target_mission = MT_RECYCLE;
126
-          $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
127
-        } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
128
-          if ($YourPlanet) {
129
-            $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
130
-            $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
110
+
111
+        if (!$UsedPlanet) {
112
+          if ($fleetarray[SHIP_COLONIZER]) {
113
+            $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
114
+            $target_mission = MT_COLONIZE;
115
+            $planet_type = PT_PLANET;
131 116
           } else {
132
-            // Not Your Planet
133
-            if ($fleetarray[SHIP_SPY]) {
134
-              // Only spy missions if any spy
135
-              $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
117
+            messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
118
+          }
119
+        } else {
120
+          $recyclers = 0;
121
+          foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
122
+            $recyclers += $fleetarray[$recycler_id];
123
+          }
124
+          if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
125
+            $target_mission = MT_RECYCLE;
126
+            $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
127
+          } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
128
+            if ($YourPlanet) {
129
+              $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
130
+              $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
136 131
             } else {
137
-              // If no spies...
138
-              if ($fleet_group_mr) {
139
-                $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
132
+              // Not Your Planet
133
+              if ($fleetarray[SHIP_SPY]) {
134
+                // Only spy missions if any spy
135
+                $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
140 136
               } else {
141
-                $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
142
-                $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
143
-
144
-                $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
145
-
146
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
147
-                  $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
137
+                // If no spies...
138
+                if ($fleet_group_mr) {
139
+                  $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
140
+                } else {
141
+                  $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
142
+                  $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
143
+
144
+                  $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
145
+
146
+                  if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
147
+                    $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
148
+                  }
148 149
                 }
149 150
               }
150 151
             }
151 152
           }
152 153
         }
153 154
       }
154
-    }
155
-
156
-    if (!$target_mission && is_array($missiontype)) {
157
-      $target_mission = MT_ATTACK;
158
-    }
159
-
160
-//    $sn_group_missions = sn_get_groups('missions');
161
-//    foreach($sn_group_missions as $mission_id => $cork) {
162
-//      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
163
-//    }
164
-//
165
-//
166
-    ksort($missiontype);
167
-
168
-    $speed_percent = sys_get_param_int('speed', 10);
169
-    $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
170
-
171
-//    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
172
-    $fleet_speed   = $travel_data['fleet_speed'];
173
-    $distance      = $travel_data['distance'];
174
-    $duration      = $travel_data['duration'];
175
-    $consumption   = $travel_data['consumption'];
176
-  // No Break
177
-
178
-  case 1:
179
-    if ($galaxy && $system && $planet) {
180
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
181
-
182
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
183
-    }
184
-
185
-  case 0:
186
-    $template_result += array(
187
-      'thisgalaxy'      => $planetrow['galaxy'],
188
-      'thissystem'      => $planetrow['system'],
189
-      'thisplanet'      => $planetrow['planet'],
190
-      'thisplanet_type' => $planetrow['planet_type'],
191
-    );
192
-  // no break
155
+
156
+      if (!$target_mission && is_array($missiontype)) {
157
+        $target_mission = MT_ATTACK;
158
+      }
159
+
160
+  //    $sn_group_missions = sn_get_groups('missions');
161
+  //    foreach($sn_group_missions as $mission_id => $cork) {
162
+  //      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
163
+  //    }
164
+  //
165
+  //
166
+      ksort($missiontype);
167
+
168
+      $speed_percent = sys_get_param_int('speed', 10);
169
+      $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
170
+
171
+  //    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
172
+      $fleet_speed   = $travel_data['fleet_speed'];
173
+      $distance      = $travel_data['distance'];
174
+      $duration      = $travel_data['duration'];
175
+      $consumption   = $travel_data['consumption'];
176
+    // No Break
177
+
178
+    case 1:
179
+      if ($galaxy && $system && $planet) {
180
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
181
+
182
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
183
+      }
184
+
185
+    case 0:
186
+      $template_result += array(
187
+        'thisgalaxy'      => $planetrow['galaxy'],
188
+        'thissystem'      => $planetrow['system'],
189
+        'thisplanet'      => $planetrow['planet'],
190
+        'thisplanet_type' => $planetrow['planet_type'],
191
+      );
192
+    // no break
193 193
 
194 194
 }
195 195
 
@@ -211,35 +211,35 @@  discard block
 block discarded – undo
211 211
 }
212 212
 
213 213
 switch($fleet_page) {
214
-  case 1:
215
-    require('includes/includes/flt_page1.inc');
216
-  break;
217
-
218
-  case 2:
219
-    require_once('includes/includes/flt_page2.inc');
220
-    sn_fleet_page2();
221
-  break;
222
-
223
-  case 3:
224
-    require_once('includes/includes/flt_page3.inc');
225
-    sn_fleet_page3();
226
-  break;
227
-
228
-  case 4:
229
-    require('includes/includes/flt_page4.inc');
230
-  break;
231
-
232
-  case 5:
233
-    $template = gettemplate('fleet5', true);
234
-    $pageFleet5Gathering = new \Deprecated\PageFleet5Gathering();
235
-    $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template);
236
-    // Building list of own planets & moons
237
-    $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template);
238
-  break;
239
-
240
-  default:
241
-    define('SN_RENDER_NAVBAR_PLANET', true);
242
-
243
-    require('includes/includes/flt_page0.inc');
244
-  break;
214
+    case 1:
215
+      require('includes/includes/flt_page1.inc');
216
+    break;
217
+
218
+    case 2:
219
+      require_once('includes/includes/flt_page2.inc');
220
+      sn_fleet_page2();
221
+    break;
222
+
223
+    case 3:
224
+      require_once('includes/includes/flt_page3.inc');
225
+      sn_fleet_page3();
226
+    break;
227
+
228
+    case 4:
229
+      require('includes/includes/flt_page4.inc');
230
+    break;
231
+
232
+    case 5:
233
+      $template = gettemplate('fleet5', true);
234
+      $pageFleet5Gathering = new \Deprecated\PageFleet5Gathering();
235
+      $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template);
236
+      // Building list of own planets & moons
237
+      $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template);
238
+    break;
239
+
240
+    default:
241
+      define('SN_RENDER_NAVBAR_PLANET', true);
242
+
243
+      require('includes/includes/flt_page0.inc');
244
+    break;
245 245
 }
Please login to merge, or discard this patch.
includes/db.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @copyright 2008-2015 Gorlum for Project "SuperNova.WS"
6 6
  */
7 7
 
8
-if(!defined('INSIDE')) {
8
+if (!defined('INSIDE')) {
9 9
   die();
10 10
 }
11 11
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 function db_change_units_perform($query, $tablename, $object_id) {
15 15
   $query = implode(',', $query);
16
-  if($query && $object_id) {
16
+  if ($query && $object_id) {
17 17
     return SN::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query);
18 18
   }
19 19
 }
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 
30 30
   $group = sn_get_groups('resources_loot');
31 31
 
32
-  foreach($unit_list as $unit_id => $unit_amount) {
33
-    if(!in_array($unit_id, $group)) {
32
+  foreach ($unit_list as $unit_id => $unit_amount) {
33
+    if (!in_array($unit_id, $group)) {
34 34
       // TODO - remove later
35 35
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>');
36 36
       pdump(debug_backtrace());
37 37
       die('db_change_units() вызван для не-ресурсов!');
38 38
     }
39 39
 
40
-    if(!$unit_amount) {
40
+    if (!$unit_amount) {
41 41
       continue;
42 42
     }
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     $unit_location = sys_get_unit_location($user, $planet, $unit_id);
47 47
 
48 48
     // Changing value in object
49
-    switch($unit_location) {
49
+    switch ($unit_location) {
50 50
       case LOC_USER:
51 51
         $user[$unit_db_name] += $unit_amount;
52 52
         break;
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use \Core\SnBootstrap;
4 4
 
5 5
 // Защита от двойного инита
6
-if(defined('INIT')) {
6
+if (defined('INIT')) {
7 7
   return;
8 8
 }
9 9
 
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 // Но нужно, пока у нас есть не MVC-страницы
120 120
 $sn_page_data = $sn_mvc['pages'][$sn_page_name];
121 121
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
122
-if($sn_page_name) {
122
+if ($sn_page_name) {
123 123
   // Merging page options to global option pull
124
-  if(is_array($sn_page_data['options'])) {
124
+  if (is_array($sn_page_data['options'])) {
125 125
     SN::$options = array_merge(SN::$options, $sn_page_data['options']);
126 126
   }
127 127
 
128
-  if(isset($sn_page_data) && file_exists($sn_page_name_file)) {
128
+  if (isset($sn_page_data) && file_exists($sn_page_name_file)) {
129 129
     require_once($sn_page_name_file);
130 130
   }
131 131
 }
132 132
 
133
-if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
133
+if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
134 134
   SN::$options['fleet_update_skip'] = true;
135 135
 }
136 136
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 $load_order = array();
145 145
 $sn_req = array();
146 146
 
147
-foreach($sn_module as $loaded_module_name => $module_data) {
147
+foreach ($sn_module as $loaded_module_name => $module_data) {
148 148
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
149
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
150
-    foreach($module_data->manifest['require'] as $require_name) {
149
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
150
+    foreach ($module_data->manifest['require'] as $require_name) {
151 151
       $sn_req[$loaded_module_name][$require_name] = 0;
152 152
     }
153 153
   }
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 do {
159 159
   $prev_order = $load_order;
160 160
 
161
-  foreach($sn_req as $loaded_module_name => &$req_data) {
161
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
162 162
     $level = 1;
163
-    foreach($req_data as $req_name => &$req_level) {
164
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
163
+    foreach ($req_data as $req_name => &$req_level) {
164
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
165 165
         $level = $req_level = -1;
166 166
         break;
167 167
       } else {
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
       }
170 170
       $req_level = $load_order[$req_name];
171 171
     }
172
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
172
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
173 173
       $load_order[$loaded_module_name] = $level;
174 174
     }
175 175
   }
176 176
 }
177
-while($prev_order != $load_order);
177
+while ($prev_order != $load_order);
178 178
 
179 179
 asort($load_order);
180 180
 
181 181
 // Инициализируем модули
182 182
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
183
-foreach($load_order as $loaded_module_name => $load_order_order) {
184
-  if($load_order_order >= 0) {
183
+foreach ($load_order as $loaded_module_name => $load_order_order) {
184
+  if ($load_order_order >= 0) {
185 185
     $sn_module[$loaded_module_name]->check_status();
186
-    if(!$sn_module[$loaded_module_name]->manifest['active']) {
186
+    if (!$sn_module[$loaded_module_name]->manifest['active']) {
187 187
       unset($sn_module[$loaded_module_name]);
188 188
       continue;
189 189
     }
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
 
202 202
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
203 203
 // TODO - костыль, что бы работали старые модули. Убрать!
204
-if(is_array($sn_data['pages'])) {
204
+if (is_array($sn_data['pages'])) {
205 205
   $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']);
206 206
 }
207
-if(!isset($sn_mvc['pages'][$sn_page_name])) {
207
+if (!isset($sn_mvc['pages'][$sn_page_name])) {
208 208
   $sn_page_name = '';
209 209
 }
210 210
 
211 211
 $lang->lng_switch(sys_get_param_str('lang'));
212 212
 
213 213
 
214
-if(SN::$config->server_updater_check_auto && SN::$config->server_updater_check_last + SN::$config->server_updater_check_period <= SN_TIME_NOW) {
214
+if (SN::$config->server_updater_check_auto && SN::$config->server_updater_check_last + SN::$config->server_updater_check_period <= SN_TIME_NOW) {
215 215
   \Tools\VersionCheckerDeprecated::performCheckVersion();
216 216
 }
217 217
 
218
-if(SN::$config->user_birthday_gift && SN_TIME_NOW - SN::$config->user_birthday_celebrate > PERIOD_DAY) {
218
+if (SN::$config->user_birthday_gift && SN_TIME_NOW - SN::$config->user_birthday_celebrate > PERIOD_DAY) {
219 219
   require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php');
220 220
   sn_user_birthday_celebrate();
221 221
 }
222 222
 
223
-if(!SN::$config->var_online_user_count || SN::$config->var_online_user_time + 30 < SN_TIME_NOW) {
223
+if (!SN::$config->var_online_user_count || SN::$config->var_online_user_time + 30 < SN_TIME_NOW) {
224 224
   SN::$config->db_saveItem('var_online_user_count', db_user_count(true));
225 225
   SN::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
226
-  if(SN::$config->server_log_online) {
226
+  if (SN::$config->server_log_online) {
227 227
     doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . SN::$config->var_online_user_count . ";");
228 228
   }
229 229
 }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
248 248
 
249
-if(!empty($user['id'])) {
249
+if (!empty($user['id'])) {
250 250
   SN::$user_options->user_change($user['id']);
251 251
 }
252 252
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         : false
260 260
       );
261 261
 
262
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
262
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
263 263
   $prohibited_characters = array_map(function($value) {
264 264
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
265 265
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 }
268 268
 
269 269
 
270
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
270
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
271 271
   pdump('Отключи отладку перед продакшном!');
272 272
 }
273 273
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 
282 282
 StatUpdateLauncher::unlock();
283 283
 
284
-if($template_result[F_GAME_DISABLE] = SN::$config->game_disable) {
284
+if ($template_result[F_GAME_DISABLE] = SN::$config->game_disable) {
285 285
   $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br(
286 286
     SN::$config->game_disable == GAME_DISABLE_REASON
287 287
       ? SN::$config->game_disable_reason
288 288
       : $lang['sys_game_disable_reason'][SN::$config->game_disable]
289 289
   );
290
-  if(defined('IN_API')) {
290
+  if (defined('IN_API')) {
291 291
     return;
292 292
   }
293 293
 
294
-  if(
294
+  if (
295 295
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
296 296
     &&
297 297
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 
305 305
 // TODO ban
306 306
 // TODO $skip_ban_check
307
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
308
-  if(defined('IN_API')) {
307
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
308
+  if (defined('IN_API')) {
309 309
     return;
310 310
   }
311 311
 
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
 $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']);
320 320
 
321 321
 
322
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
322
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
323 323
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
324
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
325
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
324
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
325
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
326 326
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
327 327
 }
328 328
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
   'fleet_update_last',
346 346
   SN::$config->fleet_update_interval,
347 347
   // Promise
348
-  function () {SN::$gc->fleetDispatcher->dispatch();},
348
+  function() {SN::$gc->fleetDispatcher->dispatch(); },
349 349
   WATCHDOG_TIME_SQL,
350 350
   false
351 351
 );
Please login to merge, or discard this patch.
includes/pages/imperator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 //    $same_user = false;
48 48
 //  }
49 49
 
50
-  if(!$user_data) {
50
+  if (!$user_data) {
51 51
     messageBox($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
52 52
     die();
53 53
   }
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
   $stat_array = array();
59 59
   $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
60 60
   $stat_count = SN::$db->db_affected_rows();
61
-  while($row = db_fetch($query)) {
62
-    foreach($stat_fields as $field_db_name => $field_template_name) {
61
+  while ($row = db_fetch($query)) {
62
+    foreach ($stat_fields as $field_db_name => $field_template_name) {
63 63
       // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
64 64
       $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
65 65
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
   $stat_array_date = $stat_array['STAT_DATE'];
69 69
   empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false;
70
-  foreach($stat_array_date['DATA'] as $key => $value) {
70
+  foreach ($stat_array_date['DATA'] as $key => $value) {
71 71
     $template->assign_block_vars('stat_date', array(
72 72
       'ID' => $key,
73 73
       'VALUE' => $value,
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 
78 78
   unset($stat_array['STAT_DATE']);
79 79
   $template_data = array();
80
-  foreach($stat_array as $stat_type => &$stat_type_data) {
80
+  foreach ($stat_array as $stat_type => &$stat_type_data) {
81 81
     $reverse_min_max = strpos($stat_type, '_RANK') !== false;
82 82
     $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
83 83
     $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
84 84
     $stat_type_data['AVG'] = average($stat_type_data['DATA']);
85
-    foreach($stat_type_data['DATA'] as $key => $value) {
85
+    foreach ($stat_type_data['DATA'] as $key => $value) {
86 86
       $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
87 87
       $template_data[$stat_type][$key]['ID'] = $key;
88 88
       $template_data[$stat_type][$key]['VALUE'] = $value;
89
-      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN']  - $value : $value - $stat_type_data['MAX']);
89
+      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']);
90 90
       $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
91 91
     }
92 92
   }
93 93
 
94
-  foreach($template_data as $stat_type => $stat_type_data) {
94
+  foreach ($template_data as $stat_type => $stat_type_data) {
95 95
     $template->assign_block_vars('stat', array(
96 96
       'TYPE' => $stat_type,
97 97
       'TEXT' => $lang['imp_stat_types'][$stat_type],
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
       'MAX' => $stat_array[$stat_type]['MAX'],
100 100
       'AVG' => $stat_array[$stat_type]['AVG'],
101 101
     ));
102
-    foreach($stat_type_data as $stat_entry) {
102
+    foreach ($stat_type_data as $stat_entry) {
103 103
       $template->assign_block_vars('stat.entry', $stat_entry);
104 104
     }
105 105
   }
106 106
 
107 107
 
108
-  if($same_user) {
108
+  if ($same_user) {
109 109
     rpg_level_up($user, RPG_STRUCTURE);
110 110
     rpg_level_up($user, RPG_RAID);
111 111
     rpg_level_up($user, RPG_TECH);
@@ -142,29 +142,29 @@  discard block
 block discarded – undo
142 142
     'builder_xp'           => HelperString::numberFloorAndFormat($user_data['xpminier']),
143 143
     'builder_lvl'          => HelperString::numberFloorAndFormat($user_data['lvl_minier']),
144 144
     'builder_lvl_st'       => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'])),
145
-    'builder_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier']+1)),
145
+    'builder_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'] + 1)),
146 146
     'raid_xp'              => HelperString::numberFloorAndFormat($user_data['xpraid']),
147 147
     'raid_lvl'             => HelperString::numberFloorAndFormat($user_data['lvl_raid']),
148
-    'raid_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid']+1)),
148
+    'raid_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid'] + 1)),
149 149
     'raids'                => HelperString::numberFloorAndFormat($user_data['raids']),
150 150
     'raidswin'             => HelperString::numberFloorAndFormat($user_data['raidswin']),
151 151
     'raidsloose'           => HelperString::numberFloorAndFormat($user_data['raidsloose']),
152 152
     'tech_xp'              => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_xp']),
153 153
     'tech_lvl'             => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_level']),
154 154
     'tech_lvl_st'          => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'])),
155
-    'tech_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)),
155
+    'tech_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)),
156 156
 
157 157
     'explore_xp'           => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_xp']),
158 158
     'explore_lvl'          => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_level']),
159 159
     'explore_lvl_st'       => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'])),
160
-    'explore_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)),
161
-
162
-    'build_points'         => HelperString::numberFloorAndFormat( $StatRecord['build_points'] ),
163
-    'tech_points'          => HelperString::numberFloorAndFormat( $StatRecord['tech_points'] ),
164
-    'fleet_points'         => HelperString::numberFloorAndFormat( $StatRecord['fleet_points'] ),
165
-    'defs_points'          => HelperString::numberFloorAndFormat( $StatRecord['defs_points'] ),
166
-    'res_points'           => HelperString::numberFloorAndFormat( $StatRecord['res_points'] ),
167
-    'total_points'         => HelperString::numberFloorAndFormat( $StatRecord['total_points'] ),
160
+    'explore_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)),
161
+
162
+    'build_points'         => HelperString::numberFloorAndFormat($StatRecord['build_points']),
163
+    'tech_points'          => HelperString::numberFloorAndFormat($StatRecord['tech_points']),
164
+    'fleet_points'         => HelperString::numberFloorAndFormat($StatRecord['fleet_points']),
165
+    'defs_points'          => HelperString::numberFloorAndFormat($StatRecord['defs_points']),
166
+    'res_points'           => HelperString::numberFloorAndFormat($StatRecord['res_points']),
167
+    'total_points'         => HelperString::numberFloorAndFormat($StatRecord['total_points']),
168 168
     'user_rank'            => $StatRecord['total_rank'],
169 169
     'RANK_DIFF'            => $StatRecord['total_old_rank'] - $StatRecord['total_rank'],
170 170
 
Please login to merge, or discard this patch.
includes/pages/chat.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
   $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS;
15 15
 
16 16
   $mode = sys_get_param_int('mode');
17
-  switch($mode)
17
+  switch ($mode)
18 18
   {
19 19
     case CHAT_MODE_ALLY:
20 20
       $template_result['ALLY'] = intval($user['ally_id']);
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
   }
29 29
 
30 30
   $template_result['.']['smiles'] = array();
31
-  foreach(SN::$gc->design->getSmilesList() as $auth_level => $replaces) {
32
-    if($auth_level > $user_auth_level) {
31
+  foreach (SN::$gc->design->getSmilesList() as $auth_level => $replaces) {
32
+    if ($auth_level > $user_auth_level) {
33 33
       continue;
34 34
     }
35 35
 
36
-    foreach($replaces as $bbcode => $filename)
36
+    foreach ($replaces as $bbcode => $filename)
37 37
     {
38 38
       $template_result['.']['smiles'][] = array(
39 39
         'BBCODE' => $bbcode,
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 
58 58
   define('IN_AJAX', true);
59 59
 
60
-  if($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
60
+  if ($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
61 61
   {
62 62
     die();
63 63
   }
64 64
 
65
-  if(($message = sys_get_param_str('message')) && $user['username'])
65
+  if (($message = sys_get_param_str('message')) && $user['username'])
66 66
   {
67 67
     $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
68 68
     $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))));
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
   define('IN_AJAX', true);
88 88
 
89 89
   $history = sys_get_param_str('history');
90
-  if(!$history)
90
+  if (!$history)
91 91
   {
92 92
     $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
93 93
   }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   $last_message = '';
97 97
   $alliance = 0;
98 98
   $template_result['.']['chat'] = array();
99
-  if(!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
99
+  if (!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
100 100
   {
101 101
     $result['disable'] = true;
102 102
     $template_result['.']['chat'][] = array(
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
     $where_add = '';
114 114
     $last_message = 0;
115
-    if($history)
115
+    if ($history)
116 116
     {
117 117
       $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true);
118 118
       $page_count = ceil($rows['CNT'] / $page_limit);
119 119
 
120
-      for($i = 0; $i < $page_count; $i++)
120
+      for ($i = 0; $i < $page_count; $i++)
121 121
       {
122 122
         $template_result['.']['page'][] = array(
123 123
           'NUMBER' => $i
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         {{chat}} AS c
140 140
         LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id
141 141
       WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};");
142
-    while($chat_row = db_fetch($query))
142
+    while ($chat_row = db_fetch($query))
143 143
     {
144 144
       // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
145 145
       $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
   $template = gettemplate('chat_messages', $template);
169 169
   $template->assign_recursive($template_result);
170 170
 
171
-  if($history)
171
+  if ($history)
172 172
   {
173 173
     $pageTitle = "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}";
174 174
     display($template, $pageTitle);
Please login to merge, or discard this patch.
includes/pages/options.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
   $language_new = sys_get_param_str('langer', $user['lang']);
13 13
 
14
-  if($language_new != $user['lang']) {
14
+  if ($language_new != $user['lang']) {
15 15
     $lang->lng_switch($language_new);
16 16
   }
17 17
 
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
 
21 21
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
22 22
 
23
-  if(sys_get_param_str('mode') == 'change') {
24
-    if($user['authlevel'] > 0) {
23
+  if (sys_get_param_str('mode') == 'change') {
24
+    if ($user['authlevel'] > 0) {
25 25
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
26 26
       DBStaticPlanet::db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'");
27 27
       db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'");
28 28
       $user['admin_protection'] = $planet_protection;
29 29
     }
30 30
 
31
-    if(sys_get_param_int('vacation') && !$config->user_vacation_disable) {
31
+    if (sys_get_param_int('vacation') && !$config->user_vacation_disable) {
32 32
       sn_db_transaction_start();
33
-      if($user['authlevel'] < 3) {
34
-        if($user['vacation_next'] > SN_TIME_NOW) {
33
+      if ($user['authlevel'] < 3) {
34
+        if ($user['vacation_next'] > SN_TIME_NOW) {
35 35
           messageBox($lang['opt_vacation_err_timeout'], $lang['Error'], 'index.php?page=options', 5);
36 36
           die();
37 37
         }
38 38
 
39
-        if(fleet_count_flying($user['id'])) {
39
+        if (fleet_count_flying($user['id'])) {
40 40
           messageBox($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5);
41 41
           die();
42 42
         }
43 43
 
44 44
         $que = que_get($user['id'], false);
45
-        if(!empty($que)) {
45
+        if (!empty($que)) {
46 46
           messageBox($lang['opt_vacation_err_que'], $lang['Error'], 'index.php?page=options', 5);
47 47
           die();
48 48
         }
49 49
 
50 50
         $query = SN::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
51
-        foreach($query as $planet) {
51
+        foreach ($query as $planet) {
52 52
           DBStaticPlanet::db_planet_set_by_id($planet['id'],
53 53
             "last_update = " . SN_TIME_NOW . ", energy_used = '0', energy_max = '0',
54 54
             metal_perhour = '{$config->metal_basic_income}', crystal_perhour = '{$config->crystal_basic_income}', deuterium_perhour = '{$config->deuterium_basic_income}',
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
       sn_db_transaction_commit();
64 64
     }
65 65
 
66
-    foreach($user_option_list as $option_group_id => $option_group) {
67
-      foreach($option_group as $option_name => $option_value) {
68
-        if($user[$option_name] !== null) {
66
+    foreach ($user_option_list as $option_group_id => $option_group) {
67
+      foreach ($option_group as $option_name => $option_value) {
68
+        if ($user[$option_name] !== null) {
69 69
           $user[$option_name] = sys_get_param_str($option_name);
70 70
         } else {
71 71
           $user[$option_name] = $option_value;
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 
77 77
 
78 78
     $player_options = sys_get_param('options');
79
-    if(!empty($player_options)) {
80
-      if($player_options[PLAYER_OPTION_TUTORIAL_CURRENT] == SN::$config->tutorial_first_item) {
79
+    if (!empty($player_options)) {
80
+      if ($player_options[PLAYER_OPTION_TUTORIAL_CURRENT] == SN::$config->tutorial_first_item) {
81 81
         $player_options[PLAYER_OPTION_TUTORIAL_FINISHED] = 0;
82 82
       }
83 83
 
84
-      array_walk($player_options, function (&$value) {
84
+      array_walk($player_options, function(&$value) {
85 85
         // TODO - Когда будет больше параметров - сделать больше проверок
86 86
         $value = intval($value);
87 87
       });
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 
91 91
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
92 92
     $username_safe = db_escape($username);
93
-    if($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
93
+    if ($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
94 94
       // проверка на корректность
95 95
       sn_db_transaction_start();
96 96
       $name_check = doquery("SELECT * FROM `{{player_name_history}}` WHERE `player_name` LIKE \"{$username_safe}\" LIMIT 1 FOR UPDATE;", true);
97
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
97
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
98 98
         $user = db_user_by_id($user['id'], true);
99
-        switch($config->game_user_changename) {
99
+        switch ($config->game_user_changename) {
100 100
           case SERVER_PLAYER_NAME_CHANGE_PAY:
101
-            if(mrc_get_level($user, [], RES_DARK_MATTER) < $config->game_user_changename_cost) {
101
+            if (mrc_get_level($user, [], RES_DARK_MATTER) < $config->game_user_changename_cost) {
102 102
               $template_result['.']['result'][] = array(
103 103
                 'STATUS'  => ERR_ERROR,
104 104
                 'MESSAGE' => $lang['opt_msg_name_change_err_no_dm'],
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
       sn_db_transaction_commit();
129 129
     }
130 130
 
131
-    if($new_password = sys_get_param('newpass1')) {
131
+    if ($new_password = sys_get_param('newpass1')) {
132 132
       try {
133
-        if($new_password != sys_get_param('newpass2')) {
133
+        if ($new_password != sys_get_param('newpass2')) {
134 134
           throw new Exception($lang['opt_err_pass_unmatched'], ERR_WARNING);
135 135
         }
136 136
 
137
-        if(!SN::$auth->password_change(sys_get_param('db_password'), $new_password)) {
137
+        if (!SN::$auth->password_change(sys_get_param('db_password'), $new_password)) {
138 138
           throw new Exception($lang['opt_err_pass_wrong'], ERR_WARNING);
139 139
         }
140 140
 
141 141
         throw new Exception($lang['opt_msg_pass_changed'], ERR_NONE);
142
-      } catch(Exception $e) {
142
+      } catch (Exception $e) {
143 143
         $template_result['.']['result'][] = array(
144 144
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
145 145
           'MESSAGE' => $e->getMessage()
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
161 161
 
162 162
     try {
163
-      if($user['birthday']) {
163
+      if ($user['birthday']) {
164 164
         throw new exception();
165 165
       }
166 166
 
167 167
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
168
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
168
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
169 169
         throw new exception();
170 170
       }
171 171
 
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
       $pos['Y'] = strpos(FMT_DATE, 'Y');
176 176
       asort($pos);
177 177
       $i = 0;
178
-      foreach($pos as &$position) {
178
+      foreach ($pos as &$position) {
179 179
         $position = ++$i;
180 180
       }
181 181
 
182 182
       $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
183
-      if(!preg_match($regexp, $user_birthday, $match)) {
183
+      if (!preg_match($regexp, $user_birthday, $match)) {
184 184
         throw new exception();
185 185
       }
186 186
 
187
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
187
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
188 188
         throw new exception();
189 189
       }
190 190
 
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
193 193
 
194 194
       $year = date('Y', SN_TIME_NOW);
195
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
195
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
196 196
         $year--;
197 197
       }
198 198
       $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}");
199 199
 
200 200
       $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'";
201
-    } catch(exception $e) {
201
+    } catch (exception $e) {
202 202
       $user_birthday = '';
203 203
     }
204 204
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
     $template_result['.']['result'][] = $avatar_upload_result;
209 209
 
210 210
     $user_time_diff = playerTimeDiff::user_time_diff_get();
211
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
211
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
212 212
       playerTimeDiff::user_time_diff_set(array(
213 213
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
214 214
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
215 215
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
216 216
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
217 217
       ));
218
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
218
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
219 219
       playerTimeDiff::user_time_diff_set(array(
220 220
         PLAYER_OPTION_TIME_DIFF              => '',
221 221
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
       'STATUS'  => ERR_NONE,
236 236
       'MESSAGE' => $lang['opt_msg_saved']
237 237
     );
238
-  } elseif(sys_get_param_str('result') == 'ok') {
238
+  } elseif (sys_get_param_str('result') == 'ok') {
239 239
     $template_result['.']['result'][] = array(
240 240
       'STATUS'  => ERR_NONE,
241 241
       'MESSAGE' => $lang['opt_msg_saved']
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
   $template = gettemplate('options', $template);
259 259
 
260 260
   $dir = dir(SN_ROOT_PHYSICAL . 'skins');
261
-  while(($entry = $dir->read()) !== false) {
262
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
261
+  while (($entry = $dir->read()) !== false) {
262
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
263 263
       $template_result['.']['skin_list'][] = array(
264 264
         'VALUE'    => $entry,
265 265
         'NAME'     => $entry,
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
   }
270 270
   $dir->close();
271 271
 
272
-  foreach($lang['opt_planet_sort_options'] as $key => &$value) {
272
+  foreach ($lang['opt_planet_sort_options'] as $key => &$value) {
273 273
     $template_result['.']['planet_sort_options'][] = array(
274 274
       'VALUE'    => $key,
275 275
       'NAME'     => $value,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     );
278 278
   }
279 279
 
280
-  foreach($lang['sys_gender_list'] as $key => $value) {
280
+  foreach ($lang['sys_gender_list'] as $key => $value) {
281 281
     $template_result['.']['gender_list'][] = array(
282 282
       'VALUE'    => $key,
283 283
       'NAME'     => $value,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
   }
287 287
 
288 288
   $lang_list = lng_get_list();
289
-  foreach($lang_list as $lang_id => $lang_data) {
289
+  foreach ($lang_list as $lang_id => $lang_data) {
290 290
     $template_result['.']['languages'][] = array(
291 291
       'VALUE'    => $lang_id,
292 292
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
   }
296 296
 
297 297
 
298
-  if(isset($lang['menu_customize_show_hide_button_state'])) {
299
-    foreach($lang['menu_customize_show_hide_button_state'] as $key => $value) {
298
+  if (isset($lang['menu_customize_show_hide_button_state'])) {
299
+    foreach ($lang['menu_customize_show_hide_button_state'] as $key => $value) {
300 300
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
301 301
         'ID'   => $key,
302 302
         'NAME' => $value,
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
     'PAGE_HEADER' => $lang['opt_header'],
408 408
   ));
409 409
 
410
-  foreach($user_option_list as $option_group_id => $option_group) {
411
-    if($option_group_id == OPT_MESSAGE) {
412
-      foreach($sn_message_class_list as $message_class_id => $message_class_data) {
413
-        if($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
410
+  foreach ($user_option_list as $option_group_id => $option_group) {
411
+    if ($option_group_id == OPT_MESSAGE) {
412
+      foreach ($sn_message_class_list as $message_class_id => $message_class_data) {
413
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
414 414
           $option_name = $message_class_data['name'];
415 415
 
416 416
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
         }
423 423
       }
424 424
     } else {
425
-      foreach($option_group as $option_name => $option_value) {
426
-        if(array_key_exists($option_name, $user_option_types)) {
425
+      foreach ($option_group as $option_name => $option_value) {
426
+        if (array_key_exists($option_name, $user_option_types)) {
427 427
           $option_type = $user_option_types[$option_name];
428 428
         } else {
429 429
           $option_type = 'switch';
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(SN_IN_FLEET !== true) {
3
+if (SN_IN_FLEET !== true) {
4 4
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
5 5
 }
6 6
 
7 7
 $fleetid = sys_get_param_id('fleetid');
8 8
 
9
-if(!is_numeric($fleetid) || empty($fleetid)) {
9
+if (!is_numeric($fleetid) || empty($fleetid)) {
10 10
   sys_redirect("fleet.php");
11 11
 }
12 12
 
13 13
 $fleet = db_fleet_get($fleetid);
14
-if(!$fleet) {
14
+if (!$fleet) {
15 15
   messageBox($lang['fl_fleet_not_exists'], $lang['fl_error']);
16 16
 }
17 17
 //$query = doquery("SELECT * FROM `{{fleets}}` WHERE fleet_id = '{$fleetid}'");
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
   messageBox($lang['fl_isback'], $lang['fl_error']);
26 26
 }
27 27
 
28
-if($fleet['fleet_owner'] != $user['id']) {
29
-  $debug->warning($lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301);
28
+if ($fleet['fleet_owner'] != $user['id']) {
29
+  $debug->warning($lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
30 30
   messageBox($lang['fl_aks_hack_wrong_fleet'], $lang['fl_error']);
31 31
 }
32 32
 
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
 
37 37
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
38 38
 
39
-if($userToAdd_unsafe) {
39
+if ($userToAdd_unsafe) {
40 40
   $userToAdd = db_escape($userToAdd_unsafe);
41 41
   $userToAddID = db_user_by_username($userToAdd_unsafe, true);
42 42
   $userToAddID = $userToAddID['id'];
43 43
 
44
-  if($fleet['fleet_target_owner'] == $userToAddID) {
44
+  if ($fleet['fleet_target_owner'] == $userToAddID) {
45 45
     messageBox($lang['flt_aks_player_same'], $lang['fl_error']);
46 46
   }
47 47
 
48
-  if($userToAddID) {
49
-    if(!$aks) {
48
+  if ($userToAddID) {
49
+    if (!$aks) {
50 50
       // No AСS exists - making one
51
-      if(!$fleet['fleet_group']) {
51
+      if (!$fleet['fleet_group']) {
52 52
         doquery("INSERT INTO {{aks}} SET
53 53
           `name` = '" . db_escape($lang['flt_acs_prefix'] . $fleetid) . "',
54 54
           `teilnehmer` = '" . $user['id'] . "',
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
           `planet` = '" . $fleet['fleet_end_planet'] . "',
60 60
           `planet_type` = '" . $fleet['fleet_end_type'] . "',
61 61
           `eingeladen` = '" . $user['id'] . "',
62
-          `fleet_end_time` = '" . $fleet['fleet_end_time']. "'");
62
+          `fleet_end_time` = '" . $fleet['fleet_end_time'] . "'");
63 63
 
64 64
         $aks = doquery("SELECT * FROM {{aks}} WHERE `flotten` = {$fleetid} LIMIT 1;", true);
65 65
 
@@ -77,26 +77,26 @@  discard block
 block discarded – undo
77 77
 
78 78
     $isUserExists = false;
79 79
     $invited_ar = explode(",", $aks['eingeladen']);
80
-    foreach($invited_ar as $inv) {
80
+    foreach ($invited_ar as $inv) {
81 81
       if ($userToAddID == $inv) {
82 82
         $isUserExists = true;
83 83
       }
84 84
     }
85 85
 
86
-    if(count($invited_ar) >= 5) {
86
+    if (count($invited_ar) >= 5) {
87 87
       messageBox($lang['flt_aks_error_too_much_players'], $lang['fl_error']);
88 88
     }
89 89
 
90
-    if($isUserExists) {
90
+    if ($isUserExists) {
91 91
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf($lang['fl_aks_player_invited_already'], $userToAdd) : false;
92 92
     } else {
93 93
       $add_user_message_mr = sprintf($lang['fl_aks_player_invited'], $userToAdd);
94 94
       doquery("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};")
95
-        or die(sprintf($lang['fl_aks_adding_error'],db_error()));
95
+        or die(sprintf($lang['fl_aks_adding_error'], db_error()));
96 96
       $aks['eingeladen'] .= ',' . $userToAddID;
97 97
     }
98
-    msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
99
-      $lang['fl_aks_invite_message_header'], sprintf( $lang['fl_aks_invite_message'], $user['username']));
98
+    msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
99
+      $lang['fl_aks_invite_message_header'], sprintf($lang['fl_aks_invite_message'], $user['username']));
100 100
   } else {
101 101
     $add_user_message_mr = sprintf($lang['fl_aks_player_error'], $userToAdd);
102 102
   }
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
   'MISSION_NAME' => $lang['type_mission'][MT_AKS],
111 111
 ));
112 112
 
113
-if($aks['eingeladen'] && is_array($members = SN::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
114
-  foreach($members as $row) {
113
+if ($aks['eingeladen'] && is_array($members = SN::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
114
+  foreach ($members as $row) {
115 115
     $template->assign_block_vars('invited', array(
116 116
       'NAME' => $row['username'],
117 117
     ));
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 $i++;
122 122
 $fleet_row = db_fleet_get($fleetid);
123 123
 
124
-if(is_array($fleet_row) && !empty($fleet_row)) {
124
+if (is_array($fleet_row) && !empty($fleet_row)) {
125 125
 $planet_start = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_start_planet_id']);
126 126
 $fleet_row['fleet_start_name'] = !empty($planet_start['name']) ? $planet_start['name'] : '';
127 127
 $planet_end = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_end_planet_id']);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
 $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user);
131 131
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
132
-foreach($fleet_data['ships'] as $ship_data) {
132
+foreach ($fleet_data['ships'] as $ship_data) {
133 133
   $template->assign_block_vars('fleets.ships', $ship_data);
134 134
 }
135 135
 }
Please login to merge, or discard this patch.
includes/includes/eco_bld_structures.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 function sn_eco_build($que_type, &$auser, &$planet) {
19 19
   global $lang, $config, $template_result;
20 20
 
21
-  if($ally_id = sys_get_param_id('ally_id')) {
21
+  if ($ally_id = sys_get_param_id('ally_id')) {
22 22
     define('SN_IN_ALLY', true);
23 23
     $ranks = \Alliance\Alliance::ally_get_ranks($auser['ally']);
24
-    if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
24
+    if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
25 25
       $user = &$auser['ally']['player'];
26 26
       $planet = array(
27 27
         'metal'     => $user['metal'],
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     }
32 32
   }
33 33
 
34
-  if(!$user) {
34
+  if (!$user) {
35 35
     $user = &$auser;
36 36
   }
37 37
 
38
-  switch($action = sys_get_param_escaped('action')) {
38
+  switch ($action = sys_get_param_escaped('action')) {
39 39
     case 'create': // Add unit to que for build
40 40
     case 'create_autoconvert': // Add unit to que for build
41 41
     case 'destroy': // Add unit to que for remove
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 
53 53
   $group_missile = sn_get_groups('missile');
54 54
   $silo_capacity_free = 0;
55
-  if($que_type == QUE_STRUCTURES) {
55
+  if ($que_type == QUE_STRUCTURES) {
56 56
     $build_unit_list = sn_get_groups('build_allow');
57 57
     $build_unit_list = $build_unit_list[$planet['planet_type']];
58 58
     $artifact_id = ART_NANO_BUILDER;
59 59
     $page_header = $lang['tech'][UNIT_STRUCTURES];
60
-  } elseif($que_type == QUE_RESEARCH) {
61
-    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
60
+  } elseif ($que_type == QUE_RESEARCH) {
61
+    if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
62 62
       messageBox($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
63 63
     }
64 64
 
65
-    if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
65
+    if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
66 66
       messageBox($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]);
67 67
     }
68 68
     $build_unit_list = sn_get_groups('tech');
69 69
     $artifact_id = ART_HEURISTIC_CHIP;
70 70
     $page_header = $lang['eco_bld_research_page_name'] . ($user['user_as_ally'] ? "&nbsp;{$lang['sys_of_ally']}&nbsp;{$user['username']}" : '');
71
-  } elseif($que_type == QUE_MERCENARY) {
71
+  } elseif ($que_type == QUE_MERCENARY) {
72 72
 //    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
73 73
 //      messageBox($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
74 74
 //    }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     $artifact_id = 0;
81 81
     $page_header = $lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? "&nbsp;{$lang['sys_of_ally']}&nbsp;{$user['username']}" : '');
82 82
   } else {
83
-    if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
83
+    if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
84 84
       messageBox($lang['need_hangar'], $lang['tech'][STRUC_FACTORY_HANGAR]);
85 85
     }
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     $artifact_id = 0;
90 90
 
91 91
     $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY);
92
-    foreach($group_missile as $unit_id) {
92
+    foreach ($group_missile as $unit_id) {
93 93
       $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE);
94 94
     }
95 95
     $silo_capacity_free = max(0, $silo_capacity_free);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
   */
107 107
 
108 108
   $template = gettemplate('buildings_builds', true);
109
-  if(!empty($operation_result)) {
109
+  if (!empty($operation_result)) {
110 110
     $template_result['.']['result'][] = $operation_result;
111 111
   }
112 112
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
   $record_index = 0;
138 138
 
139
-  foreach($build_unit_list as $unit_id) {
139
+  foreach ($build_unit_list as $unit_id) {
140 140
     $level_base = mrc_get_level($user, $planet, $unit_id, false, true);
141 141
     $level_effective = mrc_get_level($user, $planet, $unit_id);
142 142
     $level_in_que = $in_que[$unit_id];
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE];
160 160
     // Restricting $can_build by free silo capacity
161 161
     $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build;
162
-    if(!$can_build) {
163
-      if(!$build_data['CAN'][BUILD_CREATE]) {
162
+    if (!$can_build) {
163
+      if (!$build_data['CAN'][BUILD_CREATE]) {
164 164
         $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES;
165
-      } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
165
+      } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
166 166
         $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL;
167
-      } elseif($unit_info[P_MAX_STACK]) {
167
+      } elseif ($unit_info[P_MAX_STACK]) {
168 168
         $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED;
169 169
       }
170 170
     }
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
       'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]),
233 233
     );
234 234
 
235
-    if($unit_stackable) {
235
+    if ($unit_stackable) {
236 236
       $level_production_base = array(
237 237
         'ACTUAL_SHIELD' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])),
238 238
         'ACTUAL_ARMOR'  => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])),
239 239
         'ACTUAL_WEAPON' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])),
240 240
       );
241 241
 
242
-      if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
242
+      if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
243 243
         $ship_data = get_ship_data($unit_id, $user);
244 244
 
245 245
         $level_production_base += array(
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
         );
250 250
       }
251 251
 
252
-      if($unit_info[P_UNIT_PRODUCTION]) {
253
-        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
254
-          if($resource_income =
252
+      if ($unit_info[P_UNIT_PRODUCTION]) {
253
+        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
254
+          if ($resource_income =
255 255
             floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet)
256 256
               * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
257 257
               * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
         }
262 262
       }
263 263
       $production['.']['resource'][] = $level_production_base;
264
-    } elseif($unit_info[P_UNIT_PRODUCTION]) {
264
+    } elseif ($unit_info[P_UNIT_PRODUCTION]) {
265 265
       $level_production_base = array();
266 266
       $element_level_start = $level_effective + $in_que[$unit_id];
267
-      foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
268
-        if($resource_income =
267
+      foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
268
+        if ($resource_income =
269 269
           floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet)
270 270
             * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
271 271
             * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -275,24 +275,24 @@  discard block
 block discarded – undo
275 275
       }
276 276
 
277 277
       $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
278
-      for($i = 0; $i < 6; $i++) {
278
+      for ($i = 0; $i < 6; $i++) {
279 279
         $level_production = array('LEVEL' => $level_start + $i);
280
-        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
281
-          if(
280
+        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
281
+          if (
282 282
           $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet)
283 283
             * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
284 284
             * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
285 285
           ) {
286 286
             $level_production['R' . $resource_id] = $resource_income;
287 287
             $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id];
288
-            if($level_production['D' . $resource_id] == 0) {
288
+            if ($level_production['D' . $resource_id] == 0) {
289 289
               $level_production['D' . $resource_id] = '-';
290 290
             }
291 291
           }
292 292
         }
293 293
         $production['.']['resource'][] = $level_production;
294 294
       }
295
-    } elseif($unit_id == TECH_ASTROTECH) {
295
+    } elseif ($unit_id == TECH_ASTROTECH) {
296 296
       $element_level_start = $level_effective + $in_que[$unit_id];
297 297
       $level_production_base = array(
298 298
         UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start),
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
       );
301 301
 
302 302
       $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
303
-      for($i = 0; $i < 6; $i++) {
303
+      for ($i = 0; $i < 6; $i++) {
304 304
         $level_production = array('LEVEL' => $level_start + $i);
305 305
         $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i);
306 306
         $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX];
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     $template_result['.']['production'][] = $production;
322 322
   }
323 323
 
324
-  foreach($lang['player_option_building_sort'] as $sort_id => $sort_text) {
324
+  foreach ($lang['player_option_building_sort'] as $sort_id => $sort_text) {
325 325
     $template->assign_block_vars('sort_values', array(
326 326
       'VALUE' => $sort_id,
327 327
       'TEXT'  => $sort_text,
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 
331 331
   $sort_option = SN::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $que_type)];
332 332
   $sort_option_inverse = SN::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $que_type)];
333
-  if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
334
-    switch($sort_option) {
333
+  if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
334
+    switch ($sort_option) {
335 335
       case PLAYER_OPTION_SORT_NAME:
336 336
         $sort_option_field = 'NAME';
337 337
       break;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
       break;
347 347
     }
348 348
     $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1;
349
-    usort($template_result['.']['production'], function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
349
+    usort($template_result['.']['production'], function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
350 350
       return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : (
351 351
       $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0
352 352
       );
Please login to merge, or discard this patch.
includes/includes/flt_page0.inc 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 // @version 1.0
6 6
 // @copyright 2008 by Chlorel for XNova
7 7
 
8
-if($fleet_ship_sort = sys_get_param_id('sort_elements')) {
8
+if ($fleet_ship_sort = sys_get_param_id('sort_elements')) {
9 9
   define('IN_AJAX', true);
10
-  if(!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) {
10
+  if (!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) {
11 11
     // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT, $fleet_ship_sort);
12 12
     // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE, sys_get_param_id('fleet_ship_sort_inverse', 0));
13 13
     SN::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT] = $fleet_ship_sort;
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
   die();
17 17
 }
18 18
 
19
-if(SN_IN_FLEET !== true) {
19
+if (SN_IN_FLEET !== true) {
20 20
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
21 21
 }
22 22
 
23 23
 lng_include('overview');
24 24
 
25
-if(!$planetrow) {
25
+if (!$planetrow) {
26 26
   messageBox($lang['fl_noplanetrow'], $lang['fl_error']);
27 27
 }
28 28
 
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 
31 31
 $record_index = 0;
32 32
 $ship_list = array();
33
-foreach(sn_get_groups('fleet') as $n => $unit_id) {
33
+foreach (sn_get_groups('fleet') as $n => $unit_id) {
34 34
   $unit_level = mrc_get_level($user, $planetrow, $unit_id, false, true);
35
-  if($unit_level > 0) {
35
+  if ($unit_level > 0) {
36 36
     $ship_data = get_ship_data($unit_id, $user);
37 37
     $ship_list[$unit_id] = array(
38 38
       '__INDEX'     => $record_index++,
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 
53 53
 $fleet_ship_sort = SN::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT];
54 54
 $fleet_ship_sort_inverse = SN::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE];
55
-if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
56
-  switch($fleet_ship_sort) {
55
+if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
56
+  switch ($fleet_ship_sort) {
57 57
     case PLAYER_OPTION_SORT_NAME: $fleet_ship_sort_field = 'NAME'; break;
58 58
     case PLAYER_OPTION_SORT_SPEED: $fleet_ship_sort_field = 'SPEED'; break;
59 59
     case PLAYER_OPTION_SORT_COUNT: $fleet_ship_sort_field = 'AMOUNT'; break;
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
   });
69 69
 }
70 70
 
71
-foreach($ship_list as $ship_data) {
71
+foreach ($ship_list as $ship_data) {
72 72
   $template->assign_block_vars('ships', $ship_data);
73 73
 }
74 74
 
75
-foreach($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
75
+foreach ($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
76 76
   $template->assign_block_vars('ship_sort_list', array(
77 77
     'VALUE' => $sort_id,
78 78
     'TEXT' => $sort_text,
Please login to merge, or discard this patch.