@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | */ |
16 | 16 | // ---------------------------------------------------------------------------------------------------------------- |
17 | 17 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
18 | - foreach($unit_group as $unit_id) { |
|
19 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
18 | + foreach ($unit_group as $unit_id) { |
|
19 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
20 | 20 | $compress_data[$unit_id] = $unit_count; |
21 | 21 | } |
22 | 22 | } |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $classLocale = classLocale::$lang; |
27 | 27 | |
28 | 28 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
29 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
30 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
29 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
30 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
31 | 31 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
32 | 32 | } |
33 | 33 | |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | |
57 | 57 | $objFleet = $mission_data->fleet; |
58 | 58 | |
59 | - if(empty($target_user_row['id']) || empty($spying_user_row['id'])) { |
|
59 | + if (empty($target_user_row['id']) || empty($spying_user_row['id'])) { |
|
60 | 60 | $objFleet->markReturnedAndSave(); |
61 | 61 | |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | 65 | $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY); |
66 | - if($spy_probes > 0) { |
|
66 | + if ($spy_probes > 0) { |
|
67 | 67 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
68 | 68 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
69 | 69 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
88 | 88 | $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
89 | 89 | $spy_message .= "</tr>"; |
90 | - if($spy_diff >= 2) { |
|
90 | + if ($spy_diff >= 2) { |
|
91 | 91 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
92 | 92 | coe_compress_add_units(classSupernova::$gc->groupFleet, $target_planet_row, $combat_pack[0]); |
93 | 93 | } |
94 | - if($spy_diff >= 3) { |
|
94 | + if ($spy_diff >= 3) { |
|
95 | 95 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
96 | 96 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
97 | 97 | } |
98 | - if($spy_diff >= 5) { |
|
98 | + if ($spy_diff >= 5) { |
|
99 | 99 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
100 | 100 | } |
101 | 101 | |
102 | - if($spy_diff_empire >= 0) { |
|
102 | + if ($spy_diff_empire >= 0) { |
|
103 | 103 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
104 | 104 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
105 | 105 | } |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
109 | 109 | |
110 | 110 | $target_unit_list = 0; |
111 | - foreach(classSupernova::$gc->groupFleet as $unit_id) { |
|
111 | + foreach (classSupernova::$gc->groupFleet as $unit_id) { |
|
112 | 112 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
116 | 116 | |
117 | - if(mt_rand(0, 99) > $spy_detected) { |
|
117 | + if (mt_rand(0, 99) > $spy_detected) { |
|
118 | 118 | $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected); |
119 | 119 | $spy_detected = false; |
120 | 120 | } else { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
135 | 135 | $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
136 | 136 | |
137 | - if($spy_detected) { |
|
137 | + if ($spy_detected) { |
|
138 | 138 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
139 | 139 | |
140 | 140 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message); |
157 | 157 | } |
158 | 158 | |
159 | - if($spy_detected) { |
|
159 | + if ($spy_detected) { |
|
160 | 160 | $objFleet->dbDelete(); |
161 | 161 | } else { |
162 | 162 | $objFleet->markReturnedAndSave(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | // TODO - Currently $ship_data is one for all players |
24 | 24 | static $shipCostInMetalPerPiece, $rates; |
25 | 25 | |
26 | - if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
26 | + if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | $outcome_value = &$result['$outcome_value']; |
49 | 49 | $outcome_list = &$result['$outcome_list']; |
50 | 50 | |
51 | - if(!$shipCostInMetalPerPiece) { |
|
51 | + if (!$shipCostInMetalPerPiece) { |
|
52 | 52 | $rates = get_resource_exchange(); |
53 | 53 | |
54 | - foreach(classSupernova::$gc->groupFleet as $unit_id) { |
|
54 | + foreach (classSupernova::$gc->groupFleet as $unit_id) { |
|
55 | 55 | $unit_info = get_unit_param($unit_id); |
56 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
56 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | $shipCostInMetalPerPiece[$unit_id] = get_unit_cost_in($unit_info[P_COST], RES_METAL); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
74 | 74 | |
75 | 75 | $chance_max = 0; |
76 | - foreach($outcome_list as $key => &$value) { |
|
77 | - if(!$value['chance']) { |
|
76 | + foreach ($outcome_list as $key => &$value) { |
|
77 | + if (!$value['chance']) { |
|
78 | 78 | unset($outcome_list[$key]); |
79 | 79 | continue; |
80 | 80 | } |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | } |
83 | 83 | $outcome_value = mt_rand(0, $chance_max); |
84 | 84 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
85 | - foreach($outcome_list as $key => &$value) { |
|
86 | - if(!$value['chance']) { |
|
85 | + foreach ($outcome_list as $key => &$value) { |
|
86 | + if (!$value['chance']) { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | $mission_outcome = $key; |
90 | 90 | $outcome_description = $value; |
91 | - if($outcome_value <= $outcome_description['value']) { |
|
91 | + if ($outcome_value <= $outcome_description['value']) { |
|
92 | 92 | break; |
93 | 93 | } |
94 | 94 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // $outcome_mission_sub = -1; |
106 | 106 | |
107 | 107 | $fleet_found = array(); |
108 | - switch($mission_outcome) { |
|
108 | + switch ($mission_outcome) { |
|
109 | 109 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
110 | 110 | $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000); |
111 | 111 | break; |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | |
127 | 127 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
128 | 128 | $can_be_found = array(); |
129 | - foreach($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
130 | - if($shipMetalCost < $max_metal_cost) { |
|
129 | + foreach ($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
130 | + if ($shipMetalCost < $max_metal_cost) { |
|
131 | 131 | $can_be_found[$ship_id] = $shipMetalCost; |
132 | 132 | } |
133 | 133 | } |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | unset($can_be_found[SHIP_COLONIZER]); |
136 | 136 | unset($can_be_found[SHIP_SPY]); |
137 | 137 | |
138 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
138 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
139 | 139 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
140 | 140 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
141 | 141 | $found_ship_cost = reset($found_ship); |
142 | 142 | $found_ship_id = key($found_ship); |
143 | 143 | |
144 | - if($found_ship_cost > $found_in_metal) { |
|
144 | + if ($found_ship_cost > $found_in_metal) { |
|
145 | 145 | unset($can_be_found[$found_ship_id]); |
146 | 146 | } else { |
147 | 147 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - if(empty($fleet_found)) { |
|
153 | + if (empty($fleet_found)) { |
|
154 | 154 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
155 | 155 | } else { |
156 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
156 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
157 | 157 | $objFleet->shipAdjustCount($unit_id, $unit_amount); |
158 | 158 | } |
159 | 159 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $objFleet->resourcesAdjust($resources_found); |
179 | 179 | |
180 | - if(array_sum($resources_found) == 0) { |
|
180 | + if (array_sum($resources_found) == 0) { |
|
181 | 181 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
182 | 182 | } |
183 | 183 | break; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // Рассчитываем количество найденной ТМ |
189 | 189 | $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
190 | 190 | |
191 | - if(!$found_dark_matter) { |
|
191 | + if (!$found_dark_matter) { |
|
192 | 192 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
193 | 193 | } |
194 | 194 | break; |
@@ -202,40 +202,39 @@ discard block |
||
202 | 202 | |
203 | 203 | mission_expedition_result_adjust($result); |
204 | 204 | |
205 | - if($found_dark_matter) { |
|
205 | + if ($found_dark_matter) { |
|
206 | 206 | rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
207 | 207 | $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
208 | 208 | } |
209 | 209 | |
210 | - if(!empty($fleet_lost)) { |
|
210 | + if (!empty($fleet_lost)) { |
|
211 | 211 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet']; |
212 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
212 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
213 | 213 | $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if(!empty($fleet_found)) { |
|
217 | + if (!empty($fleet_found)) { |
|
218 | 218 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet']; |
219 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
219 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
220 | 220 | $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
224 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
225 | 225 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources']; |
226 | - foreach($resources_found as $resource_id => $resource_amount) { |
|
226 | + foreach ($resources_found as $resource_id => $resource_amount) { |
|
227 | 227 | $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n"; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - if(!$msg_text) { |
|
231 | + if (!$msg_text) { |
|
232 | 232 | $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
233 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
233 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
234 | 234 | $messages = &$messages[$outcome_mission_sub]; |
235 | 235 | } |
236 | 236 | |
237 | - $msg_text = is_string($messages) ? $messages : |
|
238 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
237 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
239 | 238 | } |
240 | 239 | |
241 | 240 | $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | function gettemplatename($u_dpath) { |
13 | 13 | static $template_names = array(); |
14 | 14 | |
15 | - if(!isset($template_names[$u_dpath])) { |
|
15 | + if (!isset($template_names[$u_dpath])) { |
|
16 | 16 | $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME; |
17 | 17 | } |
18 | 18 | |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | * @param $sn_menu_extra |
55 | 55 | */ |
56 | 56 | function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) { |
57 | - if(empty($sn_menu) || empty($sn_menu_extra)) { |
|
57 | + if (empty($sn_menu) || empty($sn_menu_extra)) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - foreach($sn_menu_extra as $menu_item_id => $menu_item) { |
|
62 | - if(empty($menu_item['LOCATION'])) { |
|
61 | + foreach ($sn_menu_extra as $menu_item_id => $menu_item) { |
|
62 | + if (empty($menu_item['LOCATION'])) { |
|
63 | 63 | $sn_menu[$menu_item_id] = $menu_item; |
64 | 64 | continue; |
65 | 65 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | unset($menu_item['LOCATION']); |
69 | 69 | |
70 | 70 | $is_positioned = $item_location[0]; |
71 | - if($is_positioned == '+' || $is_positioned == '-') { |
|
71 | + if ($is_positioned == '+' || $is_positioned == '-') { |
|
72 | 72 | $item_location = substr($item_location, 1); |
73 | 73 | } else { |
74 | 74 | $is_positioned = ''; |
75 | 75 | } |
76 | 76 | |
77 | - if($item_location) { |
|
77 | + if ($item_location) { |
|
78 | 78 | $menu_keys = array_keys($sn_menu); |
79 | 79 | $insert_position = array_search($item_location, $menu_keys); |
80 | - if($insert_position === false) { |
|
80 | + if ($insert_position === false) { |
|
81 | 81 | $insert_position = count($sn_menu) - 1; |
82 | 82 | $is_positioned = '+'; |
83 | 83 | $item_location = ''; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position); |
91 | 91 | $sn_menu[$menu_item_id] = $menu_item; |
92 | 92 | |
93 | - if(!$is_positioned && $item_location) { |
|
93 | + if (!$is_positioned && $item_location) { |
|
94 | 94 | unset($spliced[$item_location]); |
95 | 95 | } |
96 | 96 | $sn_menu = array_merge($sn_menu, $spliced); |
@@ -104,24 +104,24 @@ discard block |
||
104 | 104 | * @param template $template |
105 | 105 | */ |
106 | 106 | function tpl_menu_assign_to_template(&$sn_menu, &$template) { |
107 | - if(empty($sn_menu) || !is_array($sn_menu)) { |
|
107 | + if (empty($sn_menu) || !is_array($sn_menu)) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
111 | - foreach($sn_menu as $menu_item_id => $menu_item) { |
|
112 | - if(!$menu_item) { |
|
111 | + foreach ($sn_menu as $menu_item_id => $menu_item) { |
|
112 | + if (!$menu_item) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - if(is_string($menu_item_id)) { |
|
116 | + if (is_string($menu_item_id)) { |
|
117 | 117 | $menu_item['ID'] = $menu_item_id; |
118 | 118 | } |
119 | 119 | |
120 | - if($menu_item['TYPE'] == 'lang') { |
|
120 | + if ($menu_item['TYPE'] == 'lang') { |
|
121 | 121 | $lang_string = &classLocale::$lang; |
122 | - if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
123 | - for($i = 1; $i < count($matches); $i++) { |
|
124 | - if(defined($matches[$i])) { |
|
122 | + if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
123 | + for ($i = 1; $i < count($matches); $i++) { |
|
124 | + if (defined($matches[$i])) { |
|
125 | 125 | $matches[$i] = constant($matches[$i]); |
126 | 126 | } |
127 | 127 | $lang_string = &$lang_string[$matches[$i]]; |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | $menu_item['ALT'] = htmlentities($menu_item['ALT']); |
134 | 134 | $menu_item['TITLE'] = htmlentities($menu_item['TITLE']); |
135 | 135 | |
136 | - if(!empty($menu_item['ICON'])) { |
|
137 | - if(is_string($menu_item['ICON'])) { |
|
136 | + if (!empty($menu_item['ICON'])) { |
|
137 | + if (is_string($menu_item['ICON'])) { |
|
138 | 138 | $menu_item['ICON_PATH'] = $menu_item['ICON']; |
139 | 139 | } else { |
140 | 140 | $menu_item['ICON'] = $menu_item_id; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'MENU_START_HIDE' => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'), |
165 | 165 | )); |
166 | 166 | |
167 | - if(isset($template_result['MENU_CUSTOMIZE'])) { |
|
167 | + if (isset($template_result['MENU_CUSTOMIZE'])) { |
|
168 | 168 | $template->assign_vars(array( |
169 | 169 | 'PLAYER_OPTION_MENU_SHOW_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON], |
170 | 170 | 'PLAYER_OPTION_MENU_HIDE_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON], |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | )); |
179 | 179 | } |
180 | 180 | |
181 | - if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
181 | + if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
182 | 182 | tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra); |
183 | 183 | tpl_menu_assign_to_template($sn_menu_admin, $template); |
184 | 184 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
219 | 219 | $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true; |
220 | 220 | |
221 | - if(is_object($page)) { |
|
221 | + if (is_object($page)) { |
|
222 | 222 | isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false; |
223 | 223 | isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false; |
224 | 224 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false; |
227 | 227 | } |
228 | 228 | |
229 | - if(empty($user['id']) || !is_numeric($user['id'])) { |
|
229 | + if (empty($user['id']) || !is_numeric($user['id'])) { |
|
230 | 230 | $isDisplayMenu = false; |
231 | 231 | $isDisplayTopNav = false; |
232 | 232 | } |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0); |
239 | 239 | |
240 | 240 | $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE]; |
241 | - if(strpos($font_size, '%') !== false) { |
|
241 | + if (strpos($font_size, '%') !== false) { |
|
242 | 242 | // Размер шрифта в процентах |
243 | 243 | $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
244 | - } elseif(strpos($font_size, 'px') !== false) { |
|
244 | + } elseif (strpos($font_size, 'px') !== false) { |
|
245 | 245 | // Размер шрифта в пикселях |
246 | 246 | $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
247 | 247 | } else { |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | |
254 | 254 | $template = gettemplate('_global_header', true); |
255 | 255 | |
256 | - if(!empty(classSupernova::$sn_mvc['javascript'])) { |
|
257 | - foreach(classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
258 | - if(empty($page_name) || $page_name == $sn_page_name) { |
|
259 | - foreach($script_list as $filename => $content) { |
|
256 | + if (!empty(classSupernova::$sn_mvc['javascript'])) { |
|
257 | + foreach (classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
258 | + if (empty($page_name) || $page_name == $sn_page_name) { |
|
259 | + foreach ($script_list as $filename => $content) { |
|
260 | 260 | $template_result['.']['javascript'][] = array( |
261 | 261 | 'FILE' => $filename, |
262 | 262 | 'CONTENT' => $content, |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | classSupernova::$sn_mvc['css'][''] = array_merge($standard_css, classSupernova::$sn_mvc['css']['']); |
283 | 283 | |
284 | 284 | |
285 | - foreach(classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
286 | - if(empty($page_name) || $page_name == $sn_page_name) { |
|
287 | - foreach($script_list as $filename => $content) { |
|
285 | + foreach (classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
286 | + if (empty($page_name) || $page_name == $sn_page_name) { |
|
287 | + foreach ($script_list as $filename => $content) { |
|
288 | 288 | $template_result['.']['css'][] = array( |
289 | 289 | 'FILE' => $filename, |
290 | 290 | 'CONTENT' => $content, |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | $template->assign_recursive($template_result); |
332 | 332 | displayP(parsetemplate($template)); |
333 | 333 | |
334 | - if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
|
334 | + if (($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
|
335 | 335 | // $AdminPage = $AdminPage ? $user['authlevel'] : 0; |
336 | 336 | displayP(parsetemplate(tpl_render_menu())); |
337 | 337 | } |
338 | 338 | |
339 | - if($isDisplayTopNav && !$in_admin) { |
|
339 | + if ($isDisplayTopNav && !$in_admin) { |
|
340 | 340 | displayP(parsetemplate(tpl_render_topnav($user, $planetrow))); |
341 | 341 | } |
342 | 342 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | |
345 | 345 | !is_array($page) ? $page = array($page) : false; |
346 | 346 | $result_added = false; |
347 | - foreach($page as $page_item) { |
|
348 | - if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
347 | + foreach ($page as $page_item) { |
|
348 | + if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
349 | 349 | $page_item = gettemplate('_result_message', $page_item); |
350 | 350 | $temp = $page_item->files['_result_message']; |
351 | 351 | unset($page_item->files['_result_message']); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | )); |
369 | 369 | displayP(parsetemplate($template)); |
370 | 370 | |
371 | - $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false;; |
|
371 | + $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false; ; |
|
372 | 372 | |
373 | 373 | classSupernova::$db->db_disconnect(); |
374 | 374 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @param string $type |
407 | 407 | */ |
408 | 408 | function tpl_topnav_event_build(&$template, $FleetList, $type = 'fleet') { |
409 | - if(empty($FleetList)) { |
|
409 | + if (empty($FleetList)) { |
|
410 | 410 | return; |
411 | 411 | } |
412 | 412 | |
@@ -415,19 +415,19 @@ discard block |
||
415 | 415 | $fleet_event_count = 0; |
416 | 416 | $fleet_flying_sorter = array(); |
417 | 417 | $fleet_flying_events = array(); |
418 | - foreach($FleetList->_container as $objFleet) { |
|
418 | + foreach ($FleetList->_container as $objFleet) { |
|
419 | 419 | $will_return = true; |
420 | - if(!$objFleet->isReturning()) { |
|
420 | + if (!$objFleet->isReturning()) { |
|
421 | 421 | // cut fleets on Hold and Expedition |
422 | - if($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
|
422 | + if ($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
|
423 | 423 | $objFleet->mission_type == MT_RELOCATE ? $will_return = false : false; |
424 | 424 | tpl_topnav_event_build_helper($objFleet->time_arrive_to_target, EVENT_FLEET_ARRIVE, classLocale::$lang['sys_event_arrive'], $objFleet->target_coordinates_typed(), !$will_return, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
425 | 425 | } |
426 | - if($objFleet->time_mission_job_complete) { |
|
426 | + if ($objFleet->time_mission_job_complete) { |
|
427 | 427 | tpl_topnav_event_build_helper($objFleet->time_mission_job_complete, EVENT_FLEET_STAY, classLocale::$lang['sys_event_stay'], $objFleet->target_coordinates_typed(), false, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
428 | 428 | } |
429 | 429 | } |
430 | - if($will_return) { |
|
430 | + if ($will_return) { |
|
431 | 431 | tpl_topnav_event_build_helper($objFleet->time_return_to_source, EVENT_FLEET_RETURN, classLocale::$lang['sys_event_return'], $objFleet->launch_coordinates_typed(), true, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
432 | 432 | } |
433 | 433 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | asort($fleet_flying_sorter); |
436 | 436 | |
437 | 437 | $fleet_flying_count = $FleetList->count(); |
438 | - foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
438 | + foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
439 | 439 | $fleet_event = &$fleet_flying_events[$fleet_event_id]; |
440 | 440 | $template->assign_block_vars("flying_{$type}s", array( |
441 | 441 | 'TIME' => max(0, $fleet_time - SN_TIME_NOW), |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | global $template_result; |
465 | 465 | $classLocale = classLocale::$lang; |
466 | 466 | |
467 | - if(!is_array($user)) { |
|
467 | + if (!is_array($user)) { |
|
468 | 468 | return ''; |
469 | 469 | } |
470 | 470 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | |
486 | 486 | $ThisUsersPlanets = DBStaticPlanet::db_planet_list_sorted($user); |
487 | 487 | // while ($CurPlanet = db_fetch($ThisUsersPlanets)) |
488 | - foreach($ThisUsersPlanets as $CurPlanet) { |
|
489 | - if($CurPlanet['destruyed']) { |
|
488 | + foreach ($ThisUsersPlanets as $CurPlanet) { |
|
489 | + if ($CurPlanet['destruyed']) { |
|
490 | 490 | continue; |
491 | 491 | } |
492 | 492 | |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | */ |
511 | 511 | $fleet_flying_list = array(); |
512 | 512 | $fleet_flying_list[0] = FleetList::dbGetFleetListByOwnerId($user['id']); |
513 | - foreach($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
|
514 | - if(empty($fleet_flying_list[$objFleet->mission_type])) { |
|
513 | + foreach ($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
|
514 | + if (empty($fleet_flying_list[$objFleet->mission_type])) { |
|
515 | 515 | $fleet_flying_list[$objFleet->mission_type] = new FleetList(); |
516 | 516 | } |
517 | 517 | $fleet_flying_list[$objFleet->mission_type][$fleet_id] = $objFleet; |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]); |
524 | 524 | que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true); |
525 | 525 | |
526 | - if(!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
|
527 | - foreach(classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
|
526 | + if (!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
|
527 | + foreach (classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
|
528 | 528 | $template->assign_block_vars('navbar_prefix_button', array( |
529 | 529 | 'IMAGE' => $navbar_button_image, |
530 | 530 | 'URL_RELATIVE' => $navbar_button_url, |
@@ -538,13 +538,13 @@ discard block |
||
538 | 538 | $time_now_parsed = getdate(SN_TIME_NOW); |
539 | 539 | $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW); |
540 | 540 | |
541 | - if(classSupernova::$config->game_news_overview) { |
|
541 | + if (classSupernova::$config->game_news_overview) { |
|
542 | 542 | $user_last_read_safe = intval($user['news_lastread']); |
543 | 543 | nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", classSupernova::$config->game_news_overview); |
544 | 544 | } |
545 | 545 | |
546 | 546 | $notes_query = DBStaticNote::db_note_list_by_owner($user['id'], true); |
547 | - while($note_row = db_fetch($notes_query)) { |
|
547 | + while ($note_row = db_fetch($notes_query)) { |
|
548 | 548 | note_assign($template, $note_row); |
549 | 549 | } |
550 | 550 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | 'QUE_ID' => QUE_RESEARCH, |
559 | 559 | 'QUE_HTML' => 'topnav', |
560 | 560 | |
561 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
561 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
562 | 562 | |
563 | 563 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], classLocale::$lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
564 | 564 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | 'QUE_STRUCTURES' => QUE_STRUCTURES, |
636 | 636 | )); |
637 | 637 | |
638 | - if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
638 | + if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
639 | 639 | tpl_set_resource_info($template, $planetrow); |
640 | 640 | $template->assign_vars(array( |
641 | 641 | 'SN_RENDER_NAVBAR_PLANET' => true, |
@@ -650,12 +650,12 @@ discard block |
||
650 | 650 | * @param template|string $template |
651 | 651 | */ |
652 | 652 | function displayP($template) { |
653 | - if(is_object($template)) { |
|
654 | - if(empty($template->parsed)) { |
|
653 | + if (is_object($template)) { |
|
654 | + if (empty($template->parsed)) { |
|
655 | 655 | parsetemplate($template); |
656 | 656 | } |
657 | 657 | |
658 | - foreach($template->files as $section => $filename) { |
|
658 | + foreach ($template->files as $section => $filename) { |
|
659 | 659 | $template->display($section); |
660 | 660 | } |
661 | 661 | } else { |
@@ -670,11 +670,11 @@ discard block |
||
670 | 670 | * @return mixed |
671 | 671 | */ |
672 | 672 | function parsetemplate($template, $array = false) { |
673 | - if(is_object($template)) { |
|
673 | + if (is_object($template)) { |
|
674 | 674 | global $user; |
675 | 675 | |
676 | - if(!empty($array) && is_array($array)) { |
|
677 | - foreach($array as $key => $data) { |
|
676 | + if (!empty($array) && is_array($array)) { |
|
677 | + foreach ($array as $key => $data) { |
|
678 | 678 | $template->assign_var($key, $data); |
679 | 679 | } |
680 | 680 | } |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | $template_ex = '.tpl.html'; |
717 | 717 | |
718 | - if($template === false) { |
|
718 | + if ($template === false) { |
|
719 | 719 | return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex); |
720 | 720 | } |
721 | 721 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | !empty(classSupernova::$sn_mvc['i18n']['']) ? lng_load_i18n(classSupernova::$sn_mvc['i18n']['']) : false; |
736 | 736 | $sn_page_name ? lng_load_i18n(classSupernova::$sn_mvc['i18n'][$sn_page_name]) : false; |
737 | 737 | |
738 | - foreach($files as &$filename) { |
|
738 | + foreach ($files as &$filename) { |
|
739 | 739 | $filename = $filename . $template_ex; |
740 | 740 | } |
741 | 741 | |
@@ -760,13 +760,13 @@ discard block |
||
760 | 760 | 'LANG' => $language ? $language : '', |
761 | 761 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
762 | 762 | |
763 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
763 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
764 | 764 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
765 | 765 | )); |
766 | 766 | |
767 | - foreach(lng_get_list() as $lng_id => $lng_data) { |
|
768 | - if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
769 | - foreach($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
767 | + foreach (lng_get_list() as $lng_id => $lng_data) { |
|
768 | + if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
769 | + foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
770 | 770 | $lng_data1 = $lng_data; |
771 | 771 | $lng_data1 = array_merge($lng_data1, $lang_variant); |
772 | 772 | $template->assign_block_vars('language', $lng_data1); |
@@ -789,8 +789,8 @@ discard block |
||
789 | 789 | $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']]; |
790 | 790 | |
791 | 791 | $que_length = 0; |
792 | - if(!empty($que)) { |
|
793 | - foreach($que as $que_item) { |
|
792 | + if (!empty($que)) { |
|
793 | + foreach ($que as $que_item) { |
|
794 | 794 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
795 | 795 | } |
796 | 796 | $que_length = count($que); |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | * @param int $user_dark_matter |
806 | 806 | */ |
807 | 807 | function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) { |
808 | - foreach($density_price_chart as $density_price_index => &$density_price_data) { |
|
808 | + foreach ($density_price_chart as $density_price_index => &$density_price_data) { |
|
809 | 809 | $density_cost = $density_price_data; |
810 | 810 | $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false); |
811 | 811 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | function tpl_assign_select(&$template, $name, $values) { |
830 | 830 | !is_array($values) ? $values = array($values => $values) : false; |
831 | 831 | |
832 | - foreach($values as $key => $value) { |
|
832 | + foreach ($values as $key => $value) { |
|
833 | 833 | $template->assign_block_vars($name, array( |
834 | 834 | 'KEY' => htmlentities($key, ENT_COMPAT, 'UTF-8'), |
835 | 835 | 'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'), |
@@ -4,19 +4,19 @@ discard block |
||
4 | 4 | |
5 | 5 | $classLocale = classLocale::$lang; |
6 | 6 | |
7 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
7 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
8 | 8 | include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX); |
9 | 9 | } |
10 | 10 | |
11 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
11 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
12 | 12 | require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX); |
13 | 13 | sn_user_birthday_celebrate(); |
14 | 14 | } |
15 | 15 | |
16 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
16 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
17 | 17 | classSupernova::$config->db_saveItem('var_online_user_count', DBStaticUser::db_user_count(true)); |
18 | 18 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
19 | - if(classSupernova::$config->server_log_online) { |
|
19 | + if (classSupernova::$config->server_log_online) { |
|
20 | 20 | db_log_online_insert(); |
21 | 21 | } |
22 | 22 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
44 | 44 | //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die(); |
45 | 45 | |
46 | -if(!empty($user['id'])) { |
|
46 | +if (!empty($user['id'])) { |
|
47 | 47 | classSupernova::$user_options->user_change($user['id']); |
48 | 48 | } |
49 | 49 | |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | : false |
57 | 57 | ); |
58 | 58 | |
59 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
60 | - $prohibited_characters = array_map(function ($value) { |
|
59 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
60 | + $prohibited_characters = array_map(function($value) { |
|
61 | 61 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
62 | 62 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
63 | 63 | $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters); |
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
67 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
68 | 68 | pdump("Отключи отладку перед продакшном!"); |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ? define('INSTALL_MODE', GAME_DISABLE_INSTALL) |
79 | 79 | : false; |
80 | 80 | |
81 | -if( |
|
81 | +if ( |
|
82 | 82 | classSupernova::$config->game_disable == GAME_DISABLE_STAT |
83 | 83 | && |
84 | 84 | SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) > 600 |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | classSupernova::$debug->warning('Stat worked too long - watchdog unlocked', 'Stat WARNING'); |
92 | 92 | } |
93 | 93 | |
94 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
94 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
95 | 95 | $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse( |
96 | 96 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
97 | 97 | ? classSupernova::$config->game_disable_reason |
98 | 98 | : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
99 | 99 | ); |
100 | - if(defined('IN_API')) { |
|
100 | + if (defined('IN_API')) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | - if( |
|
104 | + if ( |
|
105 | 105 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
106 | 106 | && |
107 | 107 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | |
116 | 116 | // TODO ban |
117 | 117 | // TODO $skip_ban_check |
118 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
119 | - if(defined('IN_API')) { |
|
118 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
119 | + if (defined('IN_API')) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | // pdump($allow_anonymous, '$allow_anonymous'); |
135 | 135 | // pdump($sys_user_logged_in, '$sys_user_logged_in'); |
136 | 136 | |
137 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
137 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
138 | 138 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
139 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
139 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
140 | 140 | // pdump($sn_page_name); |
141 | 141 | // pdump(INITIAL_PAGE); |
142 | 142 | // die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}'); |
143 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
143 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
144 | 144 | // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
145 | 145 | sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
146 | 146 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | global $skip_fleet_update; |
163 | 163 | $skip_fleet_update = $skip_fleet_update || classSupernova::$options['fleet_update_skip'] || defined('IN_ADMIN'); |
164 | -if( |
|
164 | +if ( |
|
165 | 165 | !$skip_fleet_update |
166 | 166 | && !(defined('IN_AJAX') && IN_AJAX === true) |
167 | 167 | && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | flt_flying_fleet_handler($skip_fleet_update); |
171 | 171 | } |
172 | 172 | |
173 | -if(!defined('IN_AJAX')) { |
|
173 | +if (!defined('IN_AJAX')) { |
|
174 | 174 | pdump("Scheduled processes is disabled"); |
175 | 175 | } |
176 | 176 | // scheduler_process(); |
@@ -298,7 +298,7 @@ |
||
298 | 298 | |
299 | 299 | if (!empty($resourcesChange)) { |
300 | 300 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
301 | - if($planet_id) { |
|
301 | + if ($planet_id) { |
|
302 | 302 | // update planet |
303 | 303 | DBStaticPlanet::db_planet_update_resources($resourcesChange, $planet_id); |
304 | 304 | } else { |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update')); |
10 | 10 | $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update); |
11 | 11 | |
12 | - if(sys_get_param_int('admin_update')) { |
|
12 | + if (sys_get_param_int('admin_update')) { |
|
13 | 13 | define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1); |
14 | - if(USER_LEVEL > 0) { |
|
14 | + if (USER_LEVEL > 0) { |
|
15 | 15 | $is_admin_request = true; |
16 | 16 | $ts_scheduled_update = SN_TIME_NOW; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - if($ts_scheduled_update > $ts_var_stat_update) { |
|
20 | + if ($ts_scheduled_update > $ts_var_stat_update) { |
|
21 | 21 | lng_include('admin'); |
22 | 22 | sn_db_transaction_start(); |
23 | 23 | $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')); |
24 | - if(SN_TIME_NOW > $ts_var_stat_update_end) { |
|
24 | + if (SN_TIME_NOW > $ts_var_stat_update_end) { |
|
25 | 25 | $old_server_status = classSupernova::$config->db_loadItem('game_disable'); |
26 | 26 | classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT); |
27 | 27 | |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | classSupernova::$config->db_saveItem('var_stat_update_admin_forced', SN_TIME_SQL); |
57 | 57 | classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL); |
58 | 58 | |
59 | - if($old_server_status == GAME_DISABLE_STAT) { |
|
59 | + if ($old_server_status == GAME_DISABLE_STAT) { |
|
60 | 60 | $old_server_status = GAME_DISABLE_NONE; |
61 | 61 | } |
62 | 62 | classSupernova::$config->db_saveItem('game_disable', $old_server_status); |
63 | - } elseif($ts_scheduled_update > $ts_var_stat_update) { |
|
63 | + } elseif ($ts_scheduled_update > $ts_var_stat_update) { |
|
64 | 64 | $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW; |
65 | 65 | $msg = classSupernova::$config->db_loadItem('var_stat_update_msg'); |
66 | 66 | $msg = "{$msg} ETA {$timeout} seconds. Please wait..."; |
67 | 67 | } |
68 | 68 | sn_db_transaction_rollback(); |
69 | - } elseif($is_admin_request) { |
|
69 | + } elseif ($is_admin_request) { |
|
70 | 70 | $msg = 'Stat is up to date'; |
71 | 71 | } |
72 | 72 |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | use DBStatic\DBStaticFleetACS; |
5 | 5 | |
6 | 6 | function tpl_assign_fleet_compare($a, $b) { |
7 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
8 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
7 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
8 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
9 | 9 | return 0; |
10 | 10 | } |
11 | 11 | |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | * @param string $js_name |
22 | 22 | */ |
23 | 23 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
24 | - if(!$fleets) { |
|
24 | + if (!$fleets) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
28 | 28 | usort($fleets, 'tpl_assign_fleet_compare'); |
29 | 29 | |
30 | - foreach($fleets as $fleet_data) { |
|
30 | + foreach ($fleets as $fleet_data) { |
|
31 | 31 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
32 | 32 | |
33 | - if($fleet_data['ships']) { |
|
34 | - foreach($fleet_data['ships'] as $ship_data) { |
|
33 | + if ($fleet_data['ships']) { |
|
34 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
35 | 35 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
36 | 36 | } |
37 | 37 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
53 | 53 | ); |
54 | 54 | |
55 | - foreach($fleet as $ship_id => $ship_amount) { |
|
56 | - if(in_array($ship_id, classSupernova::$gc->groupFleet)) { |
|
55 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
56 | + if (in_array($ship_id, classSupernova::$gc->groupFleet)) { |
|
57 | 57 | $single_ship_data = get_ship_data($ship_id, $user_data); |
58 | 58 | $return['ships'][$ship_id] = array( |
59 | 59 | 'ID' => $ship_id, |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | |
93 | 93 | $result = array(); |
94 | 94 | |
95 | - if(!$user_data) { |
|
95 | + if (!$user_data) { |
|
96 | 96 | $user_data = $user; |
97 | 97 | } |
98 | 98 | |
99 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
99 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
100 | 100 | $aks = DBStaticFleetACS::db_acs_get_by_group_id($objFleet->group_id); |
101 | 101 | } |
102 | 102 | |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
138 | 138 | ); |
139 | 139 | |
140 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
140 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
141 | 141 | $result['START_NAME'] = $objFleet->fleet_start_name; |
142 | 142 | } |
143 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
143 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
144 | 144 | $result['END_NAME'] = $objFleet->fleet_end_name; |
145 | 145 | } |
146 | 146 | |
147 | - if(property_exists($objFleet, 'event_time')) { |
|
147 | + if (property_exists($objFleet, 'event_time')) { |
|
148 | 148 | $result['fleet'] = array_merge($result['fleet'], array( |
149 | 149 | 'OV_LABEL' => $objFleet->ov_label, |
150 | 150 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | $ship_id = 0; |
157 | 157 | $result['ships'] = array(); |
158 | - if($spy_level >= 6) { |
|
159 | - foreach($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
160 | - if($spy_level >= 10) { |
|
158 | + if ($spy_level >= 6) { |
|
159 | + foreach ($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
160 | + if ($spy_level >= 10) { |
|
161 | 161 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
162 | 162 | $result['ships'][$ship_sn_id] = array( |
163 | 163 | 'ID' => $ship_sn_id, |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | function tpl_parse_planet_que($que, $planet, $que_id) { |
191 | 191 | $hangar_que = array(); |
192 | 192 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
193 | - if(!empty($que_hangar)) { |
|
194 | - foreach($que_hangar as $que_item) { |
|
193 | + if (!empty($que_hangar)) { |
|
194 | + foreach ($que_hangar as $que_item) { |
|
195 | 195 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
196 | 196 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
197 | 197 | } |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
252 | 252 | ); |
253 | 253 | |
254 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
254 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
255 | 255 | $result['building_que'] = array(); |
256 | 256 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
257 | - foreach($building_que as $que_element) { |
|
257 | + foreach ($building_que as $que_element) { |
|
258 | 258 | $result['building_que'][] = que_tpl_parse_element($que_element); |
259 | 259 | } |
260 | 260 | } |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | static $snGroupFleet; |
274 | 274 | !$snGroupFleet ? $snGroupFleet = classSupernova::$gc->groupFleet : false; |
275 | 275 | |
276 | - if(empty($array_of_Fleet)) { |
|
276 | + if (empty($array_of_Fleet)) { |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | |
280 | 280 | $fleet_list = array(); |
281 | - foreach($array_of_Fleet as $fleet) { |
|
282 | - if($fleet->playerOwnerId == $user['id']) { |
|
283 | - if($fleet->mission_type == MT_MISSILE) { |
|
281 | + foreach ($array_of_Fleet as $fleet) { |
|
282 | + if ($fleet->playerOwnerId == $user['id']) { |
|
283 | + if ($fleet->mission_type == MT_MISSILE) { |
|
284 | 284 | continue; |
285 | 285 | } |
286 | 286 | $fleet_ownage = 'own'; |
287 | 287 | } else { |
288 | - switch($fleet->mission_type) { |
|
288 | + switch ($fleet->mission_type) { |
|
289 | 289 | case MT_ATTACK: |
290 | 290 | case MT_ACS: |
291 | 291 | case MT_DESTROY: |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | |
303 | 303 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
304 | 304 | |
305 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
306 | - foreach($fleet->shipsIterator() as $ship_id => $ship) { |
|
307 | - if(!empty($snGroupFleet[$ship_id])) { |
|
305 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
306 | + foreach ($fleet->shipsIterator() as $ship_id => $ship) { |
|
307 | + if (!empty($snGroupFleet[$ship_id])) { |
|
308 | 308 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship->count; |
309 | 309 | } |
310 | 310 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | return $fleet_list; |
322 | 322 | } |
323 | 323 | |
324 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
324 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
325 | 325 | $template->assign_vars(array( |
326 | 326 | 'RESOURCE_ROUNDING' => $round, |
327 | 327 |
@@ -83,8 +83,8 @@ |
||
83 | 83 | $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4; |
84 | 84 | } |
85 | 85 | |
86 | - $return['structures'] = $structures; // Structures left after attack |
|
87 | - $return['metal'] = floor($metal); // Metal scraps |
|
86 | + $return['structures'] = $structures; // Structures left after attack |
|
87 | + $return['metal'] = floor($metal); // Metal scraps |
|
88 | 88 | $return['crystal'] = floor($crystal); // Crystal scraps |
89 | 89 | |
90 | 90 | return $return; |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | $possible_cores = array(); |
13 | 13 | $probability = 0; |
14 | - foreach($density_list as $possible_core_id => $core_data) { |
|
15 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
14 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
15 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
16 | 16 | continue; |
17 | 17 | } |
18 | 18 | |
19 | - if( |
|
19 | + if ( |
|
20 | 20 | // Core type exists |
21 | 21 | in_array($possible_core_id, $position_data['core_types']) |
22 | 22 | // Limit core type with planet sector count |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | |
38 | 38 | $random = mt_rand(1, $probability); |
39 | 39 | $selected_core = null; |
40 | - foreach($possible_cores as $core_type => $core_info) { |
|
41 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
40 | + foreach ($possible_cores as $core_type => $core_info) { |
|
41 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
42 | 42 | $selected_core = $core_info; |
43 | 43 | break; |
44 | 44 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { |
62 | 62 | $Position = intval($Position); |
63 | 63 | |
64 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
64 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | $planet_generator = sn_get_groups('planet_generator'); |
72 | 72 | |
73 | - if($HomeWorld) { |
|
73 | + if ($HomeWorld) { |
|
74 | 74 | $position_data = $planet_generator[0]; |
75 | 75 | } else { |
76 | 76 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
77 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
77 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
78 | 78 | // Корректируем температуру для планеты-странника |
79 | 79 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
80 | 80 | } |
@@ -165,15 +165,15 @@ discard block |
||
165 | 165 | $moon_name = ''; |
166 | 166 | $moon_row = array(); |
167 | 167 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
168 | - if(!$moon['id']) { |
|
168 | + if (!$moon['id']) { |
|
169 | 169 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
170 | 170 | |
171 | - if($moon_planet['id']) { |
|
171 | + if ($moon_planet['id']) { |
|
172 | 172 | $base_storage_size = BASE_STORAGE_SIZE; |
173 | 173 | |
174 | - if(!$moon_chance) { |
|
174 | + if (!$moon_chance) { |
|
175 | 175 | $size = mt_rand(1100, 8999); |
176 | - } elseif($moon_chance <= 100) { |
|
176 | + } elseif ($moon_chance <= 100) { |
|
177 | 177 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
178 | 178 | } else { |
179 | 179 | $size = $moon_chance; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | $field_max = ceil($size / 1000); |
190 | 190 | |
191 | - if(isset($options['image']) && $options['image']) { |
|
191 | + if (isset($options['image']) && $options['image']) { |
|
192 | 192 | $moon_image = $options['image']; |
193 | 193 | } else { |
194 | 194 | $moon_image = 'mond'; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | 'deuterium_max' => $base_storage_size, |
222 | 222 | )); |
223 | 223 | |
224 | - if($update_debris) { |
|
224 | + if ($update_debris) { |
|
225 | 225 | $debris_spent = $moon_chance * 1000000; |
226 | 226 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
227 | 227 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | DBStaticPlanet::db_planet_update_adjust_by_id( |
230 | 230 | $moon_planet['id'], |
231 | 231 | array( |
232 | - 'debris_metal' => -$metal_spent, // `debris_metal` = GREATEST(0, `debris_metal` - {$metal_spent}) |
|
233 | - 'debris_crystal' => -$crystal_spent, // `debris_crystal` = GREATEST(0, `debris_crystal` - {$crystal_spent}) |
|
232 | + 'debris_metal' => -$metal_spent, // `debris_metal` = GREATEST(0, `debris_metal` - {$metal_spent}) |
|
233 | + 'debris_crystal' => -$crystal_spent, // `debris_crystal` = GREATEST(0, `debris_crystal` - {$crystal_spent}) |
|
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | } |
@@ -262,28 +262,28 @@ discard block |
||
262 | 262 | $planet_row['id'] = $user['current_planet']; |
263 | 263 | |
264 | 264 | // Пытаемся переключить на новую планету |
265 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
265 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
266 | 266 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
267 | 267 | } else { |
268 | 268 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
272 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
272 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
273 | 273 | { |
274 | 274 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
275 | 275 | // Если текущей планеты не существует - выставляем Столицу |
276 | - if(!isset($planet_row['id'])) { |
|
276 | + if (!isset($planet_row['id'])) { |
|
277 | 277 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
278 | 278 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
279 | - if(!isset($planet_row['id'])) { |
|
279 | + if (!isset($planet_row['id'])) { |
|
280 | 280 | classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
281 | 281 | } |
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Если производилось переключение планеты - делаем запись в юзере |
286 | - if($user['current_planet'] != $planet_row['id']) { |
|
286 | + if ($user['current_planet'] != $planet_row['id']) { |
|
287 | 287 | $user['current_planet'] = $planet_row['id']; |
288 | 288 | DBStaticUser::db_user_set_by_id( |
289 | 289 | $user['id'], |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
316 | - if(!$from['id']) { |
|
316 | + if (!$from['id']) { |
|
317 | 317 | $result = classLocale::$lang['sys_planet_expedition']; |
318 | 318 | } else { |
319 | 319 | $from_planet_id = $include_id ? ( |
@@ -363,30 +363,30 @@ discard block |
||
363 | 363 | $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]); |
364 | 364 | |
365 | 365 | return |
366 | - isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&& |
|
367 | - isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&& |
|
366 | + isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies && |
|
367 | + isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems && |
|
368 | 368 | isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets; |
369 | 369 | } |
370 | 370 | |
371 | 371 | function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) { |
372 | 372 | try { |
373 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
373 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
374 | 374 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
375 | 375 | } |
376 | 376 | |
377 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
377 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
378 | 378 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
379 | 379 | } |
380 | 380 | |
381 | 381 | // TODO: Replace quick-check with using gathered flying fleet data |
382 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
382 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
383 | 383 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
384 | 384 | } |
385 | 385 | |
386 | - if(is_array($new_coordinates)) { |
|
386 | + if (is_array($new_coordinates)) { |
|
387 | 387 | $new_coordinates['planet_type'] = PT_PLANET; |
388 | 388 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
389 | - if($incoming['id']) { |
|
389 | + if ($incoming['id']) { |
|
390 | 390 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
391 | 391 | } |
392 | 392 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | 'result' => ERR_NONE, |
396 | 396 | 'message' => '', |
397 | 397 | ); |
398 | - } catch(exception $e) { |
|
398 | + } catch (exception $e) { |
|
399 | 399 | $response = array( |
400 | 400 | 'result' => $e->getCode(), |
401 | 401 | 'message' => $e->getMessage(), |