@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use \Core\SnBootstrap; |
4 | 4 | |
5 | 5 | // Защита от двойного инита |
6 | -if(defined('INIT')) { |
|
6 | +if (defined('INIT')) { |
|
7 | 7 | return; |
8 | 8 | } |
9 | 9 | |
@@ -116,18 +116,18 @@ discard block |
||
116 | 116 | // Но нужно, пока у нас есть не MVC-страницы |
117 | 117 | $sn_page_data = $sn_mvc['pages'][$sn_page_name]; |
118 | 118 | $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
119 | -if($sn_page_name) { |
|
119 | +if ($sn_page_name) { |
|
120 | 120 | // Merging page options to global option pull |
121 | - if(is_array($sn_page_data['options'])) { |
|
121 | + if (is_array($sn_page_data['options'])) { |
|
122 | 122 | classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']); |
123 | 123 | } |
124 | 124 | |
125 | - if(isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
125 | + if (isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
126 | 126 | require_once($sn_page_name_file); |
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | -if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) { |
|
130 | +if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) { |
|
131 | 131 | classSupernova::$options['fleet_update_skip'] = true; |
132 | 132 | } |
133 | 133 | |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | $load_order = array(); |
142 | 142 | $sn_req = array(); |
143 | 143 | |
144 | -foreach($sn_module as $loaded_module_name => $module_data) { |
|
144 | +foreach ($sn_module as $loaded_module_name => $module_data) { |
|
145 | 145 | $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
146 | - if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
147 | - foreach($module_data->manifest['require'] as $require_name) { |
|
146 | + if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
147 | + foreach ($module_data->manifest['require'] as $require_name) { |
|
148 | 148 | $sn_req[$loaded_module_name][$require_name] = 0; |
149 | 149 | } |
150 | 150 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | do { |
156 | 156 | $prev_order = $load_order; |
157 | 157 | |
158 | - foreach($sn_req as $loaded_module_name => &$req_data) { |
|
158 | + foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
159 | 159 | $level = 1; |
160 | - foreach($req_data as $req_name => &$req_level) { |
|
161 | - if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
160 | + foreach ($req_data as $req_name => &$req_level) { |
|
161 | + if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
162 | 162 | $level = $req_level = -1; |
163 | 163 | break; |
164 | 164 | } else { |
@@ -166,21 +166,21 @@ discard block |
||
166 | 166 | } |
167 | 167 | $req_level = $load_order[$req_name]; |
168 | 168 | } |
169 | - if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
169 | + if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
170 | 170 | $load_order[$loaded_module_name] = $level; |
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
174 | -while($prev_order != $load_order); |
|
174 | +while ($prev_order != $load_order); |
|
175 | 175 | |
176 | 176 | asort($load_order); |
177 | 177 | |
178 | 178 | // Инициализируем модули |
179 | 179 | // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
180 | -foreach($load_order as $loaded_module_name => $load_order_order) { |
|
181 | - if($load_order_order >= 0) { |
|
180 | +foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
181 | + if ($load_order_order >= 0) { |
|
182 | 182 | $sn_module[$loaded_module_name]->check_status(); |
183 | - if(!$sn_module[$loaded_module_name]->manifest['active']) { |
|
183 | + if (!$sn_module[$loaded_module_name]->manifest['active']) { |
|
184 | 184 | unset($sn_module[$loaded_module_name]); |
185 | 185 | continue; |
186 | 186 | } |
@@ -198,29 +198,29 @@ discard block |
||
198 | 198 | |
199 | 199 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
200 | 200 | // TODO - костыль, что бы работали старые модули. Убрать! |
201 | -if(is_array($sn_data['pages'])) { |
|
201 | +if (is_array($sn_data['pages'])) { |
|
202 | 202 | $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']); |
203 | 203 | } |
204 | -if(!isset($sn_mvc['pages'][$sn_page_name])) { |
|
204 | +if (!isset($sn_mvc['pages'][$sn_page_name])) { |
|
205 | 205 | $sn_page_name = ''; |
206 | 206 | } |
207 | 207 | |
208 | 208 | $lang->lng_switch(sys_get_param_str('lang')); |
209 | 209 | |
210 | 210 | |
211 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
211 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
212 | 212 | \Tools\VersionCheckerDeprecated::performCheckVersion(); |
213 | 213 | } |
214 | 214 | |
215 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
215 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
216 | 216 | require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php'); |
217 | 217 | sn_user_birthday_celebrate(); |
218 | 218 | } |
219 | 219 | |
220 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
220 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
221 | 221 | classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true)); |
222 | 222 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
223 | - if(classSupernova::$config->server_log_online) { |
|
223 | + if (classSupernova::$config->server_log_online) { |
|
224 | 224 | doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count . ";"); |
225 | 225 | } |
226 | 226 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
245 | 245 | |
246 | -if(!empty($user['id'])) { |
|
246 | +if (!empty($user['id'])) { |
|
247 | 247 | classSupernova::$user_options->user_change($user['id']); |
248 | 248 | } |
249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | : false |
257 | 257 | ); |
258 | 258 | |
259 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
259 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
260 | 260 | $prohibited_characters = array_map(function($value) { |
261 | 261 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
262 | 262 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | |
267 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
267 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
268 | 268 | pdump('Отключи отладку перед продакшном!'); |
269 | 269 | } |
270 | 270 | |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | |
279 | 279 | StatUpdateLauncher::unlock(); |
280 | 280 | |
281 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
281 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
282 | 282 | $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br( |
283 | 283 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
284 | 284 | ? classSupernova::$config->game_disable_reason |
285 | 285 | : $lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
286 | 286 | ); |
287 | - if(defined('IN_API')) { |
|
287 | + if (defined('IN_API')) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | - if( |
|
291 | + if ( |
|
292 | 292 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
293 | 293 | && |
294 | 294 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | |
302 | 302 | // TODO ban |
303 | 303 | // TODO $skip_ban_check |
304 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
305 | - if(defined('IN_API')) { |
|
304 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
305 | + if (defined('IN_API')) { |
|
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']); |
317 | 317 | |
318 | 318 | |
319 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
319 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
320 | 320 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
321 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
322 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
321 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
322 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
323 | 323 | sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
324 | 324 | } |
325 | 325 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | 'fleet_update_last', |
344 | 344 | classSupernova::$config->fleet_update_interval, |
345 | 345 | // Promise |
346 | - function () {classSupernova::$gc->fleetDispatcher->dispatch();}, |
|
346 | + function() {classSupernova::$gc->fleetDispatcher->dispatch(); }, |
|
347 | 347 | WATCHDOG_TIME_SQL, |
348 | 348 | false |
349 | 349 | ); |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | |
16 | 16 | $constants = get_defined_constants(true); |
17 | 17 | $rpgConstants = array(); |
18 | -foreach($constants['user'] as $constantName => $constantValue) { |
|
19 | - if(substr($constantName, 0, 4) == 'RPG_') { |
|
18 | +foreach ($constants['user'] as $constantName => $constantValue) { |
|
19 | + if (substr($constantName, 0, 4) == 'RPG_') { |
|
20 | 20 | $rpgConstants[$constantValue] = $constantName; |
21 | 21 | } |
22 | 22 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC; |
34 | 34 | "); |
35 | 35 | |
36 | -while($row = classSupernova::$db->db_fetch($result)) { |
|
36 | +while ($row = classSupernova::$db->db_fetch($result)) { |
|
37 | 37 | $row['CONSTANT'] = $rpgConstants[$row['REASON']]; |
38 | 38 | |
39 | 39 | $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']); |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC; |
56 | 56 | "); |
57 | 57 | |
58 | -while($row = classSupernova::$db->db_fetch($result)) { |
|
59 | - if(empty($spent[$row['BALANCE']])) { |
|
58 | +while ($row = classSupernova::$db->db_fetch($result)) { |
|
59 | + if (empty($spent[$row['BALANCE']])) { |
|
60 | 60 | $spent[$row['BALANCE']] = array(); |
61 | 61 | } |
62 | 62 | |
@@ -66,16 +66,15 @@ discard block |
||
66 | 66 | $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row); |
67 | 67 | } |
68 | 68 | |
69 | -foreach($spent as &$row) { |
|
69 | +foreach ($spent as &$row) { |
|
70 | 70 | @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT']; |
71 | 71 | @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT']; |
72 | 72 | @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']); |
73 | 73 | @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']); |
74 | 74 | } |
75 | 75 | |
76 | -usort($spent, function ($a, $b) { |
|
77 | - return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : |
|
78 | - ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0); |
|
76 | +usort($spent, function($a, $b) { |
|
77 | + return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0); |
|
79 | 78 | }); |
80 | 79 | |
81 | 80 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
|
3 | +function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list)); } |
|
4 | 4 | function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
5 | 5 | { |
6 | 6 | global $lang; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | return $mode; |
20 | 20 | } |
21 | 21 | |
22 | -function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));} |
|
22 | +function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode)); } |
|
23 | 23 | /** |
24 | 24 | * @param template $template |
25 | 25 | * @param $edit_planet_row |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | global $lang; |
31 | 31 | |
32 | 32 | $unit_list = sn_get_groups($mode); |
33 | - if(empty($unit_list)) |
|
33 | + if (empty($unit_list)) |
|
34 | 34 | { |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | $name_list = $lang['tech']; |
38 | 38 | |
39 | - foreach($unit_list as $unit_id) |
|
39 | + foreach ($unit_list as $unit_id) |
|
40 | 40 | { |
41 | 41 | $template->assign_block_vars('unit', array( |
42 | 42 | 'ID' => $unit_id, |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | -function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
|
50 | +function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode)); } |
|
51 | 51 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
52 | 52 | { |
53 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
53 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
54 | 54 | { |
55 | 55 | $unit_amount = round($unit_amount); |
56 | 56 | $unit_name = get_unit_param($unit_id, P_NAME); |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | $fleet_row = &$mission_data['fleet']; |
13 | 13 | $destination_planet = &$mission_data['dst_planet']; |
14 | 14 | |
15 | - if(!$fleet_row) |
|
15 | + if (!$fleet_row) |
|
16 | 16 | { |
17 | 17 | return CACHE_NOTHING; |
18 | 18 | } |
19 | 19 | |
20 | - if(!isset($destination_planet['id'])) |
|
20 | + if (!isset($destination_planet['id'])) |
|
21 | 21 | { |
22 | 22 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
23 | 23 | fleet_send_back($mission_data['fleet']); |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | $RecyclerCapacity = 0; |
30 | 30 | $OtherFleetCapacity = 0; |
31 | 31 | $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']); |
32 | - foreach($fleet_array as $unit_id => $unit_count) |
|
32 | + foreach ($fleet_array as $unit_id => $unit_count) |
|
33 | 33 | { |
34 | - if(in_array($unit_id, sn_get_groups('fleet'))) |
|
34 | + if (in_array($unit_id, sn_get_groups('fleet'))) |
|
35 | 35 | { |
36 | 36 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count; |
37 | - if(in_array($unit_id, sn_get_groups('flt_recyclers'))) |
|
37 | + if (in_array($unit_id, sn_get_groups('flt_recyclers'))) |
|
38 | 38 | { |
39 | 39 | $RecyclerCapacity += $capacity; |
40 | 40 | } |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"]; |
49 | - if($IncomingFleetGoods > $OtherFleetCapacity) |
|
49 | + if ($IncomingFleetGoods > $OtherFleetCapacity) |
|
50 | 50 | { |
51 | 51 | $RecyclerCapacity -= ($IncomingFleetGoods - $OtherFleetCapacity); |
52 | 52 | } |
53 | 53 | |
54 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) |
|
54 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) |
|
55 | 55 | { |
56 | 56 | $RecycledGoods["metal"] = $destination_planet["debris_metal"]; |
57 | 57 | $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; |
58 | 58 | } |
59 | 59 | else |
60 | 60 | { |
61 | - if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
61 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
62 | 62 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)) |
63 | 63 | { |
64 | 64 | $RecycledGoods["metal"] = $RecyclerCapacity / 2; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | - $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; |
|
95 | + $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; |
|
96 | 96 | $NewCargo['Crystal'] = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"]; |
97 | 97 | $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"]; |
98 | 98 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | HelperString::numberFloorAndFormat($RecycledGoods["metal"]), $lang['Metal'], |
106 | 106 | HelperString::numberFloorAndFormat($RecycledGoods["crystal"]), $lang['Crystal'] |
107 | 107 | ); |
108 | - msg_send_simple_message ( $fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); |
|
108 | + msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); |
|
109 | 109 | |
110 | 110 | // $QryUpdateFleet = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' "; |
111 | 111 | // $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
3 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
4 | 4 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | 'rpg_cost' => $rpg_cost, |
13 | 13 | )); |
14 | 14 | |
15 | -if(is_array($shipList)) { |
|
16 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
15 | +if (is_array($shipList)) { |
|
16 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
17 | 17 | $intError = MARKET_NO_DM; |
18 | 18 | } |
19 | 19 | |
@@ -30,30 +30,30 @@ discard block |
||
30 | 30 | $qry = array(); |
31 | 31 | $total = array(); |
32 | 32 | $db_changeset = array(); |
33 | - foreach($shipList as $shipID => &$shipCount) { |
|
33 | + foreach ($shipList as $shipID => &$shipCount) { |
|
34 | 34 | $shipCount = ceil(floatval($shipCount)); |
35 | - if(!$shipCount) { |
|
35 | + if (!$shipCount) { |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
39 | - if($shipCount < 0) { |
|
39 | + if ($shipCount < 0) { |
|
40 | 40 | $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
41 | 41 | $intError = MARKET_NEGATIVE_SHIPS; |
42 | 42 | break; |
43 | 43 | } |
44 | 44 | |
45 | - if($mode == MARKET_SCRAPPER) { |
|
45 | + if ($mode == MARKET_SCRAPPER) { |
|
46 | 46 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
47 | - } elseif($mode == MARKET_STOCKMAN) { |
|
47 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
48 | 48 | $amount = $stock[$shipID]; |
49 | 49 | } |
50 | 50 | |
51 | - if($amount < $shipCount) { |
|
51 | + if ($amount < $shipCount) { |
|
52 | 52 | $intError = $error_no_stock; |
53 | 53 | break; |
54 | 54 | } |
55 | 55 | |
56 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
56 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
57 | 57 | $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
58 | 58 | $intError = MARKET_NOT_A_SHIP; |
59 | 59 | break; |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
70 | 70 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
71 | 71 | |
72 | - foreach($resTemp as $resID => $resCount) { |
|
72 | + foreach ($resTemp as $resID => $resCount) { |
|
73 | 73 | $total[$resID] += $resCount; |
74 | 74 | } |
75 | 75 | |
76 | 76 | $message .= "<li>{$lang['tech'][$shipID]}: " . HelperString::numberFloorAndFormat($shipCount); |
77 | 77 | } |
78 | 78 | |
79 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
80 | - foreach($total as $resID => $resCount) { |
|
81 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
79 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
80 | + foreach ($total as $resID => $resCount) { |
|
81 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
82 | 82 | $intError = MARKET_NO_RESOURCES; |
83 | 83 | $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
84 | 84 | break; |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | |
89 | 89 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
90 | 90 | |
91 | - if($intError == MARKET_DEAL) { |
|
91 | + if ($intError == MARKET_DEAL) { |
|
92 | 92 | $message .= '</ul>' . $lang["eco_mrk_{$submode}_res"] . '<ul>'; |
93 | - foreach($total as $resID => $resCount) { |
|
94 | - if(!$resCount) { |
|
93 | + foreach ($total as $resID => $resCount) { |
|
94 | + if (!$resCount) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
@@ -125,38 +125,38 @@ discard block |
||
125 | 125 | 'MESSAGE' => $lang['eco_mrk_errors'][$intError], |
126 | 126 | )); |
127 | 127 | |
128 | - foreach($shipList as $shipID => $shipCount) { |
|
128 | + foreach ($shipList as $shipID => $shipCount) { |
|
129 | 129 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
133 | 133 | $message = ''; |
134 | 134 | |
135 | -if(!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) { |
|
136 | - $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
135 | +if (!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) { |
|
136 | + $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | tpl_set_resource_info($template, $planetrow, array()); |
140 | 140 | |
141 | -if(!$array) { |
|
141 | +if (!$array) { |
|
142 | 142 | $array = array(); |
143 | 143 | } |
144 | 144 | |
145 | 145 | $group_fleet = sn_get_groups('fleet'); |
146 | -foreach($array as $key => $value) { |
|
147 | - if($mode == MARKET_SCRAPPER) { |
|
146 | +foreach ($array as $key => $value) { |
|
147 | + if ($mode == MARKET_SCRAPPER) { |
|
148 | 148 | $shipID = $value; |
149 | 149 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
150 | - } elseif($mode == MARKET_STOCKMAN) { |
|
150 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
151 | 151 | $shipID = $key; |
152 | 152 | $amount = $value; |
153 | 153 | } |
154 | 154 | |
155 | - if(!in_array($shipID, $group_fleet)) { |
|
155 | + if (!in_array($shipID, $group_fleet)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | - if($amount > 0) { |
|
159 | + if ($amount > 0) { |
|
160 | 160 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
161 | 161 | $template->assign_block_vars('ships', array( |
162 | 162 | 'ID' => $shipID, |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | // @version 1.0 |
4 | 4 | // @copyright 2008 by Chlorel for XNova |
5 | 5 | |
6 | -if(SN_IN_FLEET !== true) { |
|
6 | +if (SN_IN_FLEET !== true) { |
|
7 | 7 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
8 | 8 | } |
9 | 9 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $errorlist .= $lang['fl_limit_galaxy']; |
23 | 23 | if (!$system || $system > $config->game_maxSystem || $system < 1) |
24 | 24 | $errorlist .= $lang['fl_limit_system']; |
25 | - if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE )) |
|
25 | + if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) |
|
26 | 26 | $errorlist .= $lang['fl_limit_planet']; |
27 | 27 | if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) |
28 | 28 | $errorlist .= $lang['fl_ownpl_err']; |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
50 | 50 | |
51 | 51 | if ($target_mission == MT_EXPLORE) { |
52 | - if ($MaxExpeditions == 0 ) { |
|
52 | + if ($MaxExpeditions == 0) { |
|
53 | 53 | $errorlist .= $lang['fl_expe_notech']; |
54 | - } elseif ($FlyingExpeditions >= $MaxExpeditions ) { |
|
54 | + } elseif ($FlyingExpeditions >= $MaxExpeditions) { |
|
55 | 55 | $errorlist .= $lang['fl_expe_max']; |
56 | 56 | } |
57 | 57 | } else { |
58 | - if ($TargetPlanet['id_owner']){ |
|
58 | + if ($TargetPlanet['id_owner']) { |
|
59 | 59 | if ($target_mission == MT_COLONIZE) |
60 | 60 | $errorlist .= $lang['fl_colonized']; |
61 | 61 | |
62 | - if ($TargetPlanet['id_owner'] == $planetrow['id_owner']){ |
|
62 | + if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
63 | 63 | if ($target_mission == MT_ATTACK) |
64 | 64 | $errorlist .= $lang['fl_no_self_attack']; |
65 | 65 | |
66 | 66 | if ($target_mission == MT_SPY) |
67 | 67 | $errorlist .= $lang['fl_no_self_spy']; |
68 | - }else{ |
|
68 | + } else { |
|
69 | 69 | if ($target_mission == MT_RELOCATE) |
70 | 70 | $errorlist .= $lang['fl_only_stay_at_home']; |
71 | 71 | } |
72 | - }else{ |
|
73 | - if ($target_mission < MT_COLONIZE){ |
|
72 | + } else { |
|
73 | + if ($target_mission < MT_COLONIZE) { |
|
74 | 74 | $errorlist .= $lang['fl_unknow_target']; |
75 | - }else{ |
|
75 | + } else { |
|
76 | 76 | if ($target_mission == MT_DESTROY) |
77 | 77 | $errorlist .= $lang['fl_nomoon']; |
78 | 78 | |
79 | - if ($target_mission == MT_RECYCLE){ |
|
80 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) |
|
79 | + if ($target_mission == MT_RECYCLE) { |
|
80 | + if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) |
|
81 | 81 | $errorlist .= $lang['fl_nodebris']; |
82 | 82 | } |
83 | 83 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | |
88 | - if($sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
88 | + if ($sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
89 | 89 | $captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id']); |
90 | 90 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); |
91 | - if(!$captain) { |
|
91 | + if (!$captain) { |
|
92 | 92 | $errorlist .= $lang['module_unit_captain_error_no_captain']; |
93 | - } elseif($captain['unit_location_type'] == LOC_PLANET) { |
|
94 | - if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
93 | + } elseif ($captain['unit_location_type'] == LOC_PLANET) { |
|
94 | + if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
95 | 95 | $errorlist .= $lang['module_unit_captain_error_captain_already_bound']; |
96 | 96 | } |
97 | 97 | } else { |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | |
102 | 102 | if ($errorlist) { |
103 | 103 | sn_db_transaction_rollback(); |
104 | - messageBox ("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
|
104 | + messageBox("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // On verifie s'il y a assez de vaisseaux sur la planete ! |
108 | 108 | foreach ($fleetarray as $Ship => $Count) { |
109 | 109 | if ($Count > mrc_get_level($user, $planetrow, $Ship)) { |
110 | - messageBox ("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
110 | + messageBox("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | $fleet_group = max(0, intval($_POST['fleet_group'])); |
116 | 116 | //But is it acs?? |
117 | 117 | //Well all acs fleets must have a fleet code. |
118 | - if($fleet_group) { |
|
118 | + if ($fleet_group) { |
|
119 | 119 | //Also it must be mission type 2 |
120 | 120 | $target_mission = MT_AKS; |
121 | 121 | |
122 | 122 | //The co-ords must be the same as where the acs fleet is going. |
123 | 123 | $target = "g{$galaxy}s{$system}p{$planet}t{$planet_type}"; |
124 | - if($_POST['acs_target_mr'] == $target) { |
|
124 | + if ($_POST['acs_target_mr'] == $target) { |
|
125 | 125 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) |
126 | 126 | $aks = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", true); |
127 | 127 | if (!$aks) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | } |
139 | 139 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. |
140 | - if(!$fleet_group && $target_mission == MT_AKS) { |
|
140 | + if (!$fleet_group && $target_mission == MT_AKS) { |
|
141 | 141 | $target_mission = MT_ATTACK; |
142 | 142 | } |
143 | 143 | |
@@ -147,22 +147,21 @@ discard block |
||
147 | 147 | $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded); |
148 | 148 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); |
149 | 149 | |
150 | - if($cant_attack !== ATTACK_ALLOWED) { |
|
150 | + if ($cant_attack !== ATTACK_ALLOWED) { |
|
151 | 151 | messageBox("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); |
152 | 152 | } |
153 | 153 | |
154 | 154 | $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); |
155 | 155 | if (!in_array($speed_percent, $speed_possible)) { |
156 | - messageBox ("<span class='error'><b>". $lang['fl_cheat_speed'] ."</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
156 | + messageBox("<span class='error'><b>" . $lang['fl_cheat_speed'] . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $fleet['start_time'] = $duration + SN_TIME_NOW; |
160 | 160 | |
161 | - $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : |
|
162 | - ($target_mission == MT_HOLD ? 12 : 0); |
|
163 | - if($max_duration) { |
|
161 | + $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); |
|
162 | + if ($max_duration) { |
|
164 | 163 | $StayDuration = sys_get_param_id('missiontime'); |
165 | - if($StayDuration > $max_duration || $StayDuration < 1) { |
|
164 | + if ($StayDuration > $max_duration || $StayDuration < 1) { |
|
166 | 165 | $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); |
167 | 166 | die(); |
168 | 167 | } |
@@ -172,11 +171,11 @@ discard block |
||
172 | 171 | $StayDuration = 0; |
173 | 172 | $StayTime = 0; |
174 | 173 | } |
175 | - $fleet['end_time'] = $StayDuration + (2 * $duration) + SN_TIME_NOW; |
|
174 | + $fleet['end_time'] = $StayDuration + (2 * $duration) + SN_TIME_NOW; |
|
176 | 175 | |
177 | - if($aks && $target_mission == MT_AKS) { |
|
178 | - if ($fleet['start_time']>$aks['ankunft']) { |
|
179 | - messageBox ($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME,$fleet['start_time']) . " AKS arrival: " .date(FMT_DATE_TIME,$aks['ankunft']), $lang['fl_error']); |
|
176 | + if ($aks && $target_mission == MT_AKS) { |
|
177 | + if ($fleet['start_time'] > $aks['ankunft']) { |
|
178 | + messageBox($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $fleet['start_time']) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']); |
|
180 | 179 | } |
181 | 180 | $fleet['start_time'] = $aks['ankunft']; |
182 | 181 | $fleet['end_time'] = $aks['ankunft'] + $duration; |
@@ -186,21 +185,21 @@ discard block |
||
186 | 185 | $FleetShipCount = 0; |
187 | 186 | $db_changeset = array(); |
188 | 187 | foreach ($fleetarray as $Ship => $Count) { |
189 | - $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
|
188 | + $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
|
190 | 189 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($Ship, -$Count, $user, $planetrow['id']); |
191 | 190 | } |
192 | 191 | $fleet_array = sys_unit_arr2str($fleetarray); |
193 | - $FleetShipCount += array_sum($fleetarray); |
|
194 | - $FleetStorage -= $consumption; |
|
192 | + $FleetShipCount += array_sum($fleetarray); |
|
193 | + $FleetStorage -= $consumption; |
|
195 | 194 | |
196 | - if ( $StorageNeeded > $FleetStorage) { |
|
197 | - messageBox ("<span class='error'><b>". $lang['fl_nostoragespa'] . HelperString::numberFloorAndFormat($StorageNeeded - $FleetStorage) ."</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
195 | + if ($StorageNeeded > $FleetStorage) { |
|
196 | + messageBox("<span class='error'><b>" . $lang['fl_nostoragespa'] . HelperString::numberFloorAndFormat($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
198 | 197 | } |
199 | 198 | if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
200 | - messageBox ("<font color=\"red\"><b>". $lang['fl_no_deuterium'] . HelperString::numberFloorAndFormat($TransDeuterium + $consumption - $planetrow['deuterium']) ."</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
199 | + messageBox("<font color=\"red\"><b>" . $lang['fl_no_deuterium'] . HelperString::numberFloorAndFormat($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
201 | 200 | } |
202 | 201 | if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
203 | - messageBox ("<font color=\"red\"><b>". $lang['fl_no_resources'] ."</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
202 | + messageBox("<font color=\"red\"><b>" . $lang['fl_no_resources'] . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
|
204 | 203 | } |
205 | 204 | |
206 | 205 | $fleet_set = array( |
@@ -242,7 +241,7 @@ discard block |
||
242 | 241 | // )); |
243 | 242 | // } |
244 | 243 | |
245 | - if(is_array($captain)) { |
|
244 | + if (is_array($captain)) { |
|
246 | 245 | DBStaticUnit::db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$fleet_id}"); |
247 | 246 | } |
248 | 247 | |
@@ -255,7 +254,7 @@ discard block |
||
255 | 254 | 'START_LEFT' => floor($fleet['end_time'] + 1 - SN_TIME_NOW), |
256 | 255 | ); |
257 | 256 | |
258 | - if(!empty($TargetPlanet)) { |
|
257 | + if (!empty($TargetPlanet)) { |
|
259 | 258 | $template_route += array( |
260 | 259 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
261 | 260 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -268,8 +267,8 @@ discard block |
||
268 | 267 | $template->assign_block_vars('fleets', $template_route); |
269 | 268 | |
270 | 269 | $sn_groups_fleet = sn_get_groups('fleet'); |
271 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
272 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
270 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
271 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
273 | 272 | // $ship_base_data = get_ship_data($ship_id, $user); |
274 | 273 | $template->assign_block_vars('fleets.ships', array( |
275 | 274 | 'ID' => $ship_id, |
@@ -47,7 +47,7 @@ discard block |
||
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 |
||
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 = classSupernova::$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 |
||
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 |
||
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 |
||
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); |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | 'builder_xp' => HelperString::numberFloorAndFormat($user_data['xpminier']), |
140 | 140 | 'builder_lvl' => HelperString::numberFloorAndFormat($user_data['lvl_minier']), |
141 | 141 | 'builder_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'])), |
142 | - 'builder_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
142 | + 'builder_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
143 | 143 | 'raid_xp' => HelperString::numberFloorAndFormat($user_data['xpraid']), |
144 | 144 | 'raid_lvl' => HelperString::numberFloorAndFormat($user_data['lvl_raid']), |
145 | - 'raid_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
145 | + 'raid_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
146 | 146 | 'raids' => HelperString::numberFloorAndFormat($user_data['raids']), |
147 | 147 | 'raidswin' => HelperString::numberFloorAndFormat($user_data['raidswin']), |
148 | 148 | 'raidsloose' => HelperString::numberFloorAndFormat($user_data['raidsloose']), |
149 | 149 | 'tech_xp' => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_xp']), |
150 | 150 | 'tech_lvl' => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_level']), |
151 | 151 | 'tech_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
152 | - 'tech_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
152 | + 'tech_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
153 | 153 | |
154 | 154 | 'explore_xp' => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_xp']), |
155 | 155 | 'explore_lvl' => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_level']), |
156 | 156 | 'explore_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
157 | - 'explore_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
158 | - |
|
159 | - 'build_points' => HelperString::numberFloorAndFormat( $StatRecord['build_points'] ), |
|
160 | - 'tech_points' => HelperString::numberFloorAndFormat( $StatRecord['tech_points'] ), |
|
161 | - 'fleet_points' => HelperString::numberFloorAndFormat( $StatRecord['fleet_points'] ), |
|
162 | - 'defs_points' => HelperString::numberFloorAndFormat( $StatRecord['defs_points'] ), |
|
163 | - 'res_points' => HelperString::numberFloorAndFormat( $StatRecord['res_points'] ), |
|
164 | - 'total_points' => HelperString::numberFloorAndFormat( $StatRecord['total_points'] ), |
|
157 | + 'explore_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
158 | + |
|
159 | + 'build_points' => HelperString::numberFloorAndFormat($StatRecord['build_points']), |
|
160 | + 'tech_points' => HelperString::numberFloorAndFormat($StatRecord['tech_points']), |
|
161 | + 'fleet_points' => HelperString::numberFloorAndFormat($StatRecord['fleet_points']), |
|
162 | + 'defs_points' => HelperString::numberFloorAndFormat($StatRecord['defs_points']), |
|
163 | + 'res_points' => HelperString::numberFloorAndFormat($StatRecord['res_points']), |
|
164 | + 'total_points' => HelperString::numberFloorAndFormat($StatRecord['total_points']), |
|
165 | 165 | 'user_rank' => $StatRecord['total_rank'], |
166 | 166 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
167 | 167 |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | global $who, $lang; |
12 | 12 | |
13 | 13 | // $sn_group_stat_common = sn_get_groups('STAT_COMMON'); |
14 | - foreach($array as $key => $value) { |
|
15 | - if($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { |
|
14 | + foreach ($array as $key => $value) { |
|
15 | + if ($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { |
|
16 | 16 | continue; |
17 | 17 | } |
18 | 18 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $subject_list = array( |
45 | 45 | 1 => array('header' => $lang['stat_player']), |
46 | 46 | ); |
47 | -if(!$source) { |
|
47 | +if (!$source) { |
|
48 | 48 | $subject_list[2] = array('header' => $lang['stat_allys']); |
49 | 49 | } |
50 | 50 | stat_tpl_assign($template, $who, 'subject', $subject_list, $sn_group_stat_common); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $page_count = floor($record_count / 100); |
113 | 113 | $pages = array(); |
114 | -for($i = 0; $i <= $page_count; $i++) { |
|
114 | +for ($i = 0; $i <= $page_count; $i++) { |
|
115 | 115 | $first_element = $i * 100 + 1; |
116 | 116 | $last_element = $first_element + 99; |
117 | 117 | $pages[$first_element] = array( |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | 'POINTS' => HelperString::numberFloorAndFormat($row['points']), |
131 | 131 | ); |
132 | 132 | |
133 | - if($who == 1) { |
|
133 | + if ($who == 1) { |
|
134 | 134 | $row_stat['ALLY_NAME'] = $row['ally_name']; |
135 | 135 | $row_stat['ALLY_ID'] = $row['ally_id']; |
136 | 136 | empty($row['username']) ? $row['username'] = $row['name'] : false; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | public function unset_by_prefix($prefix_unset = '') { |
152 | 152 | static $array_clear; |
153 | - !$array_clear ? $array_clear = function (&$v, $k, $p) { |
|
153 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
154 | 154 | strpos($k, $p) === 0 ? $v = null : false; |
155 | 155 | } : false; |
156 | 156 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | if ($this->$name[0] === null) { |
206 | 206 | for ($i = count($name) - 1; $i > 0; $i--) { |
207 | 207 | $cName = "{$name[$i]}_COUNT"; |
208 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
208 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
209 | 209 | if ($this->$cName1 == null || $i == 1) { |
210 | 210 | $this->$cName++; |
211 | 211 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $count = count($name); |
252 | 252 | for ($i = 1; $i < $count; $i++) { |
253 | 253 | $cName = "{$name[$i]}_COUNT"; |
254 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
254 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
255 | 255 | |
256 | 256 | if ($i == 1 || $this->$cName1 === null) { |
257 | 257 | $this->$cName--; |