@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return array |
241 | 241 | */ |
242 | 242 | public static function parseParamStrings($array, $delimiter = '=') { |
243 | - !is_array($array) ? $array = array((string)$array) : false; |
|
243 | + !is_array($array) ? $array = array((string) $array) : false; |
|
244 | 244 | |
245 | 245 | $result = array(); |
246 | 246 | foreach ($array as $param) { |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @return float|null |
263 | 263 | */ |
264 | 264 | public static function maxValueByField(&$array, $fieldName) { |
265 | - return array_reduce($array, function ($carry, $item) use ($fieldName) { |
|
266 | - if(is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
265 | + return array_reduce($array, function($carry, $item) use ($fieldName) { |
|
266 | + if (is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
267 | 267 | $carry = $item[$fieldName]; |
268 | 268 | } |
269 | 269 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | |
281 | 281 | return |
282 | 282 | array_reduce($array, |
283 | - function ($carry, $item) use (&$fieldName, $maxValue) { |
|
284 | - if(is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
283 | + function($carry, $item) use (&$fieldName, $maxValue) { |
|
284 | + if (is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
285 | 285 | $carry[] = $item; |
286 | 286 | } |
287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | public static function intersectByKeys(array &$array1, array &$array2) { |
295 | - return array_uintersect_assoc($array1, $array2, function ($a, $b) {return 0;}); |
|
295 | + return array_uintersect_assoc($array1, $array2, function($a, $b) {return 0; }); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | $prefix_length = strlen($this->db->db_prefix); |
54 | 54 | |
55 | - while($row = $this->db->db_fetch($query)) { |
|
56 | - foreach($row as $table_name) { |
|
55 | + while ($row = $this->db->db_fetch($query)) { |
|
56 | + foreach ($row as $table_name) { |
|
57 | 57 | $this->tablesAll[$table_name] = $table_name; |
58 | 58 | |
59 | - if(strpos($table_name, $this->db->db_prefix) === 0) { |
|
59 | + if (strpos($table_name, $this->db->db_prefix) === 0) { |
|
60 | 60 | $table_name_sn = substr($table_name, $prefix_length); |
61 | 61 | $this->tablesSn[$table_name_sn] = $table_name_sn; |
62 | 62 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return \string[] |
71 | 71 | */ |
72 | 72 | public function getAllTables() { |
73 | - if(!isset($this->tablesAll)) { |
|
73 | + if (!isset($this->tablesAll)) { |
|
74 | 74 | $this->loadTableNamesFromDb(); |
75 | 75 | } |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return string[] |
84 | 84 | */ |
85 | 85 | public function getSnTables() { |
86 | - if(!isset($this->tablesSn)) { |
|
86 | + if (!isset($this->tablesSn)) { |
|
87 | 87 | $this->loadTableNamesFromDb(); |
88 | 88 | } |
89 | 89 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return TableSchema |
108 | 108 | */ |
109 | 109 | public function getTableSchema($tableName) { |
110 | - if(empty($this->tableSchemas[$tableName])) { |
|
110 | + if (empty($this->tableSchemas[$tableName])) { |
|
111 | 111 | $this->tableSchemas[$tableName] = new TableSchema($tableName, $this); |
112 | 112 | } |
113 | 113 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | protected $_repository; |
31 | 31 | |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * @var ContainerPlus $_oldRepo |
34 | 34 | */ |
35 | 35 | protected $_oldRepo; |
@@ -86,7 +86,7 @@ |
||
86 | 86 | |
87 | 87 | public function get($entityClass, $id) { |
88 | 88 | $entityIndex = get_class($entityClass) . '\\' . $id; |
89 | - if(!isset($this->_repository[$entityIndex])) { |
|
89 | + if (!isset($this->_repository[$entityIndex])) { |
|
90 | 90 | |
91 | 91 | } |
92 | 92 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | class SnBootstrap { |
12 | 12 | |
13 | 13 | public static function install_benchmark() { |
14 | - register_shutdown_function(function () { |
|
14 | + register_shutdown_function(function() { |
|
15 | 15 | if (defined('IN_AJAX')) { |
16 | 16 | return; |
17 | 17 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | $config->pass()->game_disable = GAME_DISABLE_STAT; |
59 | 59 | |
60 | 60 | $statMinimalInterval = intval($config->pass()->stats_minimal_interval); |
61 | - $config->pass()->var_stat_update_end= date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
61 | + $config->pass()->var_stat_update_end = date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
62 | 62 | $config->pass()->var_stat_update_msg = 'Update started'; |
63 | 63 | sn_db_transaction_commit(); |
64 | 64 |
@@ -22,11 +22,11 @@ |
||
22 | 22 | |
23 | 23 | define('IN_AJAX', true); |
24 | 24 | |
25 | -if(($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
25 | +if (($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
26 | 26 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
27 | 27 | print(json_encode($result)); |
28 | 28 | } |
29 | 29 | |
30 | -if(!defined('IN_ADMIN')) { |
|
30 | +if (!defined('IN_ADMIN')) { |
|
31 | 31 | die(); |
32 | 32 | } |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -define('INSIDE' , true); |
|
11 | -define('INSTALL' , false); |
|
12 | -define('IN_ADMIN' , true); |
|
10 | +define('INSIDE', true); |
|
11 | +define('INSTALL', false); |
|
12 | +define('IN_ADMIN', true); |
|
13 | 13 | |
14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
15 | 15 | |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | function adm_lng_assign_string($lang_id, $locale_string_name, $value) { |
21 | 21 | global $locale_string_template, $languages_info, $languages, $domain; |
22 | 22 | |
23 | - if(is_array($value)) { |
|
24 | - foreach($value as $sub_key => $sub_value) { |
|
23 | + if (is_array($value)) { |
|
24 | + foreach ($value as $sub_key => $sub_value) { |
|
25 | 25 | adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value); |
26 | 26 | } |
27 | - } elseif($value) { |
|
28 | - if(!isset($locale_string_template[$locale_string_name])) { |
|
27 | + } elseif ($value) { |
|
28 | + if (!isset($locale_string_template[$locale_string_name])) { |
|
29 | 29 | $locale_string_template[$locale_string_name] = array(); |
30 | 30 | } |
31 | 31 | $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8'))); |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | global $domain, $lang_id; |
47 | 47 | |
48 | 48 | $return = "{$ident}'{$string_name}' => "; |
49 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
49 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
50 | 50 | $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"; |
51 | 51 | } else { |
52 | 52 | $return .= "array(\r\n"; |
53 | - foreach($string_value as $arr_name => $arr_data) { |
|
53 | + foreach ($string_value as $arr_name => $arr_data) { |
|
54 | 54 | $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . ' '); |
55 | 55 | } |
56 | 56 | $return .= "{$ident}),\r\n"; |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | |
104 | 104 | $string_name_new = false; |
105 | 105 | |
106 | - if(isset($honor_constants[$domain][$string_name_prefix])) { |
|
106 | + if (isset($honor_constants[$domain][$string_name_prefix])) { |
|
107 | 107 | $found_constants = array_keys($constants, $string_name); |
108 | - foreach($found_constants as $constant_name) { |
|
108 | + foreach ($found_constants as $constant_name) { |
|
109 | 109 | $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]); |
110 | - foreach($honor_prefix_list as $honor_prefix) { |
|
111 | - if(strpos($constant_name, $honor_prefix) === 0) { |
|
110 | + foreach ($honor_prefix_list as $honor_prefix) { |
|
111 | + if (strpos($constant_name, $honor_prefix) === 0) { |
|
112 | 112 | $string_name_new = $constant_name; |
113 | 113 | break; |
114 | 114 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | |
119 | 119 | $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'"; |
120 | 120 | fwrite($file_handler, "{$ident}{$string_name_new} => "); |
121 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
121 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
122 | 122 | fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"); |
123 | 123 | // fwrite($file_handler, "'" . addslashes($string_value[$lang_id]) . "',"); |
124 | 124 | } else { |
125 | 125 | $string_name_prefix = $string_name_prefix . "[{$string_name}]"; |
126 | 126 | fwrite($file_handler, "array(\r\n"); |
127 | - foreach($string_value as $arr_name => $arr_data) { |
|
127 | + foreach ($string_value as $arr_name => $arr_data) { |
|
128 | 128 | adm_lng_write_string($arr_name, $arr_data, $ident . ' ', $string_name_prefix); |
129 | 129 | } |
130 | 130 | fwrite($file_handler, "{$ident}),\r\n"); |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $languages_info = lng_get_list(); |
145 | 145 | $domain = sys_get_param_str('domain'); |
146 | 146 | |
147 | -if($domain) { |
|
147 | +if ($domain) { |
|
148 | 148 | $lang_new = sys_get_param('lang_new'); |
149 | - if(!empty($lang_new) && is_array($lang_new)) { |
|
149 | + if (!empty($lang_new) && is_array($lang_new)) { |
|
150 | 150 | $constants = get_defined_constants(true); |
151 | 151 | $constants = $constants['user']; |
152 | 152 | ksort($constants); |
153 | - foreach($languages_info as $lang_id => $land_data) { |
|
153 | + foreach ($languages_info as $lang_id => $land_data) { |
|
154 | 154 | $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w'); |
155 | 155 | fwrite($file_handler, "<?php\r\n\r\n/*\r\n############################################################################# |
156 | 156 | # Filename: {$domain}.mo.php |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | # Website: http://www.supernova.ws |
159 | 159 | # Description: Massive Multiplayer Online Browser Space Startegy Game\r\n#\r\n"); |
160 | 160 | |
161 | - foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
161 | + foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
162 | 162 | $lang_copyright = str_replace(array('©', '"', '<', '>'), array('©', '"', '<', '>'), $lang_copyright); |
163 | 163 | fwrite($file_handler, "# {$lang_copyright}\r\n"); |
164 | 164 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n |
167 | 167 | /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n |
168 | 168 | \$a_lang_array = array(\r\n"); |
169 | - foreach($lang_new as $string_name => $string_value) { |
|
169 | + foreach ($lang_new as $string_name => $string_value) { |
|
170 | 170 | adm_lng_write_string($string_name, $string_value); |
171 | 171 | } |
172 | 172 | fwrite($file_handler, ");\r\n"); |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | sys_redirect("admin_locale.php?domain={$domain}"); |
177 | 177 | } |
178 | 178 | |
179 | - foreach($languages_info as $lang_id => $lang_data) { |
|
179 | + foreach ($languages_info as $lang_id => $lang_data) { |
|
180 | 180 | $template->assign_block_vars('language', $lang_data); |
181 | 181 | $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php"; |
182 | 182 | $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : '')); |
183 | - foreach($languages[$lang_id] as $locale_string_name => $cork) { |
|
183 | + foreach ($languages[$lang_id] as $locale_string_name => $cork) { |
|
184 | 184 | adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - foreach($locale_string_template as $locale_string_name => $locale_string_list) { |
|
188 | + foreach ($locale_string_template as $locale_string_name => $locale_string_list) { |
|
189 | 189 | $template->assign_block_vars('string', array( |
190 | 190 | 'NAME' => $locale_string_name, |
191 | 191 | )); |
192 | 192 | |
193 | - foreach($languages_info as $lang_id => $cork2) { |
|
193 | + foreach ($languages_info as $lang_id => $cork2) { |
|
194 | 194 | $template->assign_block_vars('string.locale', array( |
195 | 195 | 'LANG' => $lang_id, |
196 | 196 | 'VALUE' => $locale_string_list["[{$lang_id}]"], |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | $dir = dir($path); |
207 | 207 | while (false !== ($lang_id = $dir->read())) { |
208 | 208 | $full_path = $path . $lang_id; |
209 | - if($lang_id[0] != "." && is_dir($full_path)) { |
|
209 | + if ($lang_id[0] != "." && is_dir($full_path)) { |
|
210 | 210 | $lang_file_list = dir($full_path); |
211 | 211 | while (false !== ($filename = $lang_file_list->read())) { |
212 | 212 | $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.'))); |
213 | - if(!$lang_domain) { |
|
213 | + if (!$lang_domain) { |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | 217 | $file_ext = strtolower(substr($filename, strpos($filename, '.'))); |
218 | - if($lang_domain != 'language') { |
|
219 | - if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
218 | + if ($lang_domain != 'language') { |
|
219 | + if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
220 | 220 | $language_domains[$lang_domain] = $lang_domain; |
221 | 221 | $languages[$lang_id][$lang_domain] = $lang_domain; |
222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | $dir->close(); |
228 | 228 | |
229 | - foreach($language_domains as $lang_domain) { |
|
229 | + foreach ($language_domains as $lang_domain) { |
|
230 | 230 | $template->assign_block_vars('domain', array( |
231 | 231 | 'NAME' => $lang_domain, |
232 | 232 | )); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
40 | 40 | |
41 | 41 | $target_mission = sys_get_param_int('target_mission'); |
42 | -if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
42 | +if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
43 | 43 | $planet_type = PT_PLANET; |
44 | -} elseif($target_mission == MT_RECYCLE) { |
|
44 | +} elseif ($target_mission == MT_RECYCLE) { |
|
45 | 45 | $planet_type = PT_DEBRIS; |
46 | -} elseif($target_mission == MT_DESTROY) { |
|
46 | +} elseif ($target_mission == MT_DESTROY) { |
|
47 | 47 | $planet_type = PT_MOON; |
48 | 48 | } else { |
49 | 49 | $planet_type = sys_get_param_int('planet_type'); |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | //$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", true); |
60 | 60 | //$FlyingFleets = $FlyingFleets['Number']; |
61 | 61 | $FlyingFleets = fleet_count_flying($user['id']); |
62 | -if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
|
62 | +if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
|
63 | 63 | messageBox($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5); |
64 | 64 | } |
65 | 65 | |
66 | 66 | $MaxExpeditions = get_player_max_expeditons($user); |
67 | -if($MaxExpeditions) { |
|
67 | +if ($MaxExpeditions) { |
|
68 | 68 | // $FlyingExpeditions = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true); |
69 | 69 | // $FlyingExpeditions = $FlyingExpeditions['expedi']; |
70 | - $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE); |
|
70 | + $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE); |
|
71 | 71 | } else { |
72 | 72 | $FlyingExpeditions = 0; |
73 | 73 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | $fleetarray = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true); |
81 | 81 | $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
82 | 82 | |
83 | - foreach($fleetarray as $ship_id => &$ship_amount) { |
|
84 | - if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
83 | + foreach ($fleetarray as $ship_id => &$ship_amount) { |
|
84 | + if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
85 | 85 | $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
86 | 86 | die(); |
87 | 87 | } |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | $target_mission = MT_COLONIZE; |
113 | 113 | $planet_type = PT_PLANET; |
114 | 114 | } else { |
115 | - messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']); |
|
115 | + messageBox("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error']); |
|
116 | 116 | } |
117 | 117 | } else { |
118 | 118 | $recyclers = 0; |
119 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
119 | + foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
120 | 120 | $recyclers += $fleetarray[$recycler_id]; |
121 | 121 | } |
122 | 122 | if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD]; |
143 | 143 | |
144 | - if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
144 | + if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
145 | 145 | $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY]; |
146 | 146 | } |
147 | 147 | } |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | ); |
202 | 202 | |
203 | 203 | $is_transport_missions = false; |
204 | -if($missiontype) { |
|
204 | +if ($missiontype) { |
|
205 | 205 | $sn_group_missions = sn_get_groups('missions'); |
206 | - foreach($missiontype as $mission_data_id => $mission_data) { |
|
206 | + foreach ($missiontype as $mission_data_id => $mission_data) { |
|
207 | 207 | $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']); |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | -switch($fleet_page) { |
|
211 | +switch ($fleet_page) { |
|
212 | 212 | case 1: |
213 | 213 | require('includes/includes/flt_page1.inc'); |
214 | 214 | break; |
@@ -77,121 +77,121 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | switch ($fleet_page) { |
80 | - case 3: |
|
80 | + case 3: |
|
81 | 81 | |
82 | - case 2: |
|
83 | - $fleet_group_mr = sys_get_param_id('fleet_group'); |
|
84 | - $fleetarray = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true); |
|
85 | - $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
|
82 | + case 2: |
|
83 | + $fleet_group_mr = sys_get_param_id('fleet_group'); |
|
84 | + $fleetarray = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true); |
|
85 | + $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
|
86 | 86 | |
87 | - foreach($fleetarray as $ship_id => &$ship_amount) { |
|
88 | - if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
89 | - $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
|
90 | - die(); |
|
91 | - } |
|
92 | - $ship_amount = floatval($ship_amount); |
|
93 | - } |
|
94 | - |
|
95 | - $UsedPlanet = false; |
|
96 | - $YourPlanet = false; |
|
97 | - $missiontype = array(); |
|
98 | - if ($planet > SN::$config->game_maxPlanet) { |
|
99 | - $target_mission = MT_EXPLORE; |
|
100 | - $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE]; |
|
101 | - } elseif ($galaxy && $system && $planet) { |
|
102 | - $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
103 | - |
|
104 | - $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
105 | - |
|
106 | - if ($TargetPlanet['id_owner']) { |
|
107 | - $UsedPlanet = true; |
|
108 | - if ($TargetPlanet['id_owner'] == $user['id']) { |
|
109 | - $YourPlanet = true; |
|
87 | + foreach($fleetarray as $ship_id => &$ship_amount) { |
|
88 | + if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
89 | + $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
|
90 | + die(); |
|
110 | 91 | } |
92 | + $ship_amount = floatval($ship_amount); |
|
111 | 93 | } |
112 | 94 | |
113 | - if (!$UsedPlanet) { |
|
114 | - if ($fleetarray[SHIP_COLONIZER]) { |
|
115 | - $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE]; |
|
116 | - $target_mission = MT_COLONIZE; |
|
117 | - $planet_type = PT_PLANET; |
|
118 | - } else { |
|
119 | - messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']); |
|
120 | - } |
|
121 | - } else { |
|
122 | - $recyclers = 0; |
|
123 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
124 | - $recyclers += $fleetarray[$recycler_id]; |
|
95 | + $UsedPlanet = false; |
|
96 | + $YourPlanet = false; |
|
97 | + $missiontype = array(); |
|
98 | + if ($planet > SN::$config->game_maxPlanet) { |
|
99 | + $target_mission = MT_EXPLORE; |
|
100 | + $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE]; |
|
101 | + } elseif ($galaxy && $system && $planet) { |
|
102 | + $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
103 | + |
|
104 | + $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
105 | + |
|
106 | + if ($TargetPlanet['id_owner']) { |
|
107 | + $UsedPlanet = true; |
|
108 | + if ($TargetPlanet['id_owner'] == $user['id']) { |
|
109 | + $YourPlanet = true; |
|
110 | + } |
|
125 | 111 | } |
126 | - if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
|
127 | - $target_mission = MT_RECYCLE; |
|
128 | - $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE]; |
|
129 | - } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) { |
|
130 | - if ($YourPlanet) { |
|
131 | - $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE]; |
|
132 | - $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT]; |
|
112 | + |
|
113 | + if (!$UsedPlanet) { |
|
114 | + if ($fleetarray[SHIP_COLONIZER]) { |
|
115 | + $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE]; |
|
116 | + $target_mission = MT_COLONIZE; |
|
117 | + $planet_type = PT_PLANET; |
|
133 | 118 | } else { |
134 | - // Not Your Planet |
|
135 | - if ($fleetarray[SHIP_SPY]) { |
|
136 | - // Only spy missions if any spy |
|
137 | - $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY]; |
|
119 | + messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']); |
|
120 | + } |
|
121 | + } else { |
|
122 | + $recyclers = 0; |
|
123 | + foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
124 | + $recyclers += $fleetarray[$recycler_id]; |
|
125 | + } |
|
126 | + if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
|
127 | + $target_mission = MT_RECYCLE; |
|
128 | + $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE]; |
|
129 | + } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) { |
|
130 | + if ($YourPlanet) { |
|
131 | + $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE]; |
|
132 | + $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT]; |
|
138 | 133 | } else { |
139 | - // If no spies... |
|
140 | - if ($fleet_group_mr) { |
|
141 | - $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS]; |
|
134 | + // Not Your Planet |
|
135 | + if ($fleetarray[SHIP_SPY]) { |
|
136 | + // Only spy missions if any spy |
|
137 | + $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY]; |
|
142 | 138 | } else { |
143 | - $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK]; |
|
144 | - $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT]; |
|
145 | - |
|
146 | - $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD]; |
|
147 | - |
|
148 | - if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
149 | - $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY]; |
|
139 | + // If no spies... |
|
140 | + if ($fleet_group_mr) { |
|
141 | + $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS]; |
|
142 | + } else { |
|
143 | + $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK]; |
|
144 | + $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT]; |
|
145 | + |
|
146 | + $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD]; |
|
147 | + |
|
148 | + if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
149 | + $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY]; |
|
150 | + } |
|
150 | 151 | } |
151 | 152 | } |
152 | 153 | } |
153 | 154 | } |
154 | 155 | } |
155 | 156 | } |
156 | - } |
|
157 | - |
|
158 | - if (!$target_mission && is_array($missiontype)) { |
|
159 | - $target_mission = MT_ATTACK; |
|
160 | - } |
|
161 | - |
|
162 | -// $sn_group_missions = sn_get_groups('missions'); |
|
163 | -// foreach($sn_group_missions as $mission_id => $cork) { |
|
164 | -// $missiontype[$mission_id] = $lang['type_mission'][$mission_id]; |
|
165 | -// } |
|
166 | -// |
|
167 | -// |
|
168 | - ksort($missiontype); |
|
169 | - |
|
170 | - $speed_percent = sys_get_param_int('speed', 10); |
|
171 | - $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent); |
|
172 | - |
|
173 | -// $fleet_speed = flt_fleet_speed($user, $fleetarray); |
|
174 | - $fleet_speed = $travel_data['fleet_speed']; |
|
175 | - $distance = $travel_data['distance']; |
|
176 | - $duration = $travel_data['duration']; |
|
177 | - $consumption = $travel_data['consumption']; |
|
178 | - // No Break |
|
179 | - |
|
180 | - case 1: |
|
181 | - if ($galaxy && $system && $planet) { |
|
182 | - $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
183 | - |
|
184 | - $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
185 | - } |
|
186 | - |
|
187 | - case 0: |
|
188 | - $template_result += array( |
|
189 | - 'thisgalaxy' => $planetrow['galaxy'], |
|
190 | - 'thissystem' => $planetrow['system'], |
|
191 | - 'thisplanet' => $planetrow['planet'], |
|
192 | - 'thisplanet_type' => $planetrow['planet_type'], |
|
193 | - ); |
|
194 | - // no break |
|
157 | + |
|
158 | + if (!$target_mission && is_array($missiontype)) { |
|
159 | + $target_mission = MT_ATTACK; |
|
160 | + } |
|
161 | + |
|
162 | + // $sn_group_missions = sn_get_groups('missions'); |
|
163 | + // foreach($sn_group_missions as $mission_id => $cork) { |
|
164 | + // $missiontype[$mission_id] = $lang['type_mission'][$mission_id]; |
|
165 | + // } |
|
166 | + // |
|
167 | + // |
|
168 | + ksort($missiontype); |
|
169 | + |
|
170 | + $speed_percent = sys_get_param_int('speed', 10); |
|
171 | + $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent); |
|
172 | + |
|
173 | + // $fleet_speed = flt_fleet_speed($user, $fleetarray); |
|
174 | + $fleet_speed = $travel_data['fleet_speed']; |
|
175 | + $distance = $travel_data['distance']; |
|
176 | + $duration = $travel_data['duration']; |
|
177 | + $consumption = $travel_data['consumption']; |
|
178 | + // No Break |
|
179 | + |
|
180 | + case 1: |
|
181 | + if ($galaxy && $system && $planet) { |
|
182 | + $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
183 | + |
|
184 | + $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
185 | + } |
|
186 | + |
|
187 | + case 0: |
|
188 | + $template_result += array( |
|
189 | + 'thisgalaxy' => $planetrow['galaxy'], |
|
190 | + 'thissystem' => $planetrow['system'], |
|
191 | + 'thisplanet' => $planetrow['planet'], |
|
192 | + 'thisplanet_type' => $planetrow['planet_type'], |
|
193 | + ); |
|
194 | + // no break |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -213,35 +213,35 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | switch($fleet_page) { |
216 | - case 1: |
|
217 | - require('includes/includes/flt_page1.inc'); |
|
218 | - break; |
|
219 | - |
|
220 | - case 2: |
|
221 | - require_once('includes/includes/flt_page2.inc'); |
|
222 | - sn_fleet_page2(); |
|
223 | - break; |
|
224 | - |
|
225 | - case 3: |
|
226 | - require_once('includes/includes/flt_page3.inc'); |
|
227 | - sn_fleet_page3(); |
|
228 | - break; |
|
229 | - |
|
230 | - case 4: |
|
231 | - require('includes/includes/flt_page4.inc'); |
|
232 | - break; |
|
233 | - |
|
234 | - case 5: |
|
235 | - $template = gettemplate('fleet5', true); |
|
236 | - $pageFleet5Gathering = new \Pages\Deprecated\PageFleet5Gathering(); |
|
237 | - $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template); |
|
238 | - // Building list of own planets & moons |
|
239 | - $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template); |
|
240 | - break; |
|
241 | - |
|
242 | - default: |
|
243 | - define('SN_RENDER_NAVBAR_PLANET', true); |
|
244 | - |
|
245 | - require('includes/includes/flt_page0.inc'); |
|
246 | - break; |
|
216 | + case 1: |
|
217 | + require('includes/includes/flt_page1.inc'); |
|
218 | + break; |
|
219 | + |
|
220 | + case 2: |
|
221 | + require_once('includes/includes/flt_page2.inc'); |
|
222 | + sn_fleet_page2(); |
|
223 | + break; |
|
224 | + |
|
225 | + case 3: |
|
226 | + require_once('includes/includes/flt_page3.inc'); |
|
227 | + sn_fleet_page3(); |
|
228 | + break; |
|
229 | + |
|
230 | + case 4: |
|
231 | + require('includes/includes/flt_page4.inc'); |
|
232 | + break; |
|
233 | + |
|
234 | + case 5: |
|
235 | + $template = gettemplate('fleet5', true); |
|
236 | + $pageFleet5Gathering = new \Pages\Deprecated\PageFleet5Gathering(); |
|
237 | + $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template); |
|
238 | + // Building list of own planets & moons |
|
239 | + $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template); |
|
240 | + break; |
|
241 | + |
|
242 | + default: |
|
243 | + define('SN_RENDER_NAVBAR_PLANET', true); |
|
244 | + |
|
245 | + require('includes/includes/flt_page0.inc'); |
|
246 | + break; |
|
247 | 247 | } |
@@ -75,11 +75,11 @@ |
||
75 | 75 | * @return float[] - [int resourceId] -> [float ratesNormalizedToResourceCost] |
76 | 76 | */ |
77 | 77 | public function getResourceExchangeIn($resourceId) { |
78 | - if(empty($this->resourceExchangeRates[$resourceId])) { |
|
78 | + if (empty($this->resourceExchangeRates[$resourceId])) { |
|
79 | 79 | $defaultRates = $this->getResourcesExchange(); |
80 | 80 | |
81 | 81 | $this->resourceExchangeRates[$resourceId] = []; |
82 | - foreach($defaultRates as $defaultResourceId => $defaultRate) { |
|
82 | + foreach ($defaultRates as $defaultResourceId => $defaultRate) { |
|
83 | 83 | $this->resourceExchangeRates[$resourceId][$defaultResourceId] = $defaultRate / $defaultRates[$resourceId]; |
84 | 84 | } |
85 | 85 | } |