@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function flt_fleet_speed($user, $fleet) |
|
4 | -{ |
|
3 | +function flt_fleet_speed($user, $fleet) { |
|
5 | 4 | if (!is_array($fleet)) |
6 | 5 | { |
7 | 6 | $fleet = array($fleet => 1); |
@@ -29,16 +28,13 @@ discard block |
||
29 | 28 | if($from['galaxy'] != $to['galaxy']) |
30 | 29 | { |
31 | 30 | $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance; |
32 | - } |
|
33 | - elseif($from['system'] != $to['system']) |
|
31 | + } elseif($from['system'] != $to['system']) |
|
34 | 32 | { |
35 | 33 | $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700; |
36 | - } |
|
37 | - elseif($from['planet'] != $to['planet']) |
|
34 | + } elseif($from['planet'] != $to['planet']) |
|
38 | 35 | { |
39 | 36 | $distance = abs($from['planet'] - $to['planet']) * 5 + 1000; |
40 | - } |
|
41 | - else |
|
37 | + } else |
|
42 | 38 | { |
43 | 39 | $distance = 5; |
44 | 40 | } |
@@ -55,8 +51,7 @@ discard block |
||
55 | 51 | * |
56 | 52 | * @return array |
57 | 53 | */ |
58 | -function flt_travel_data($user_row, $from, $to, $fleet_array, $speed_percent = 10) |
|
59 | -{ |
|
54 | +function flt_travel_data($user_row, $from, $to, $fleet_array, $speed_percent = 10) { |
|
60 | 55 | $distance = flt_travel_distance($from, $to); |
61 | 56 | |
62 | 57 | $consumption = 0; |
@@ -120,8 +115,7 @@ discard block |
||
120 | 115 | ); |
121 | 116 | } |
122 | 117 | |
123 | -function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) |
|
124 | -{ |
|
118 | +function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { |
|
125 | 119 | global $config; |
126 | 120 | |
127 | 121 | $config_bashing_attacks = $config->fleet_bashing_attacks; |
@@ -531,8 +525,7 @@ discard block |
||
531 | 525 | $fleet_ship_count += $amount; |
532 | 526 | $fleet_string .= "{$unit_id},{$amount};"; |
533 | 527 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$amount, $user, $from['id']); |
534 | - } |
|
535 | - elseif(in_array($unit_id, sn_get_groups('resources_loot'))) |
|
528 | + } elseif(in_array($unit_id, sn_get_groups('resources_loot'))) |
|
536 | 529 | { |
537 | 530 | $planet_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
538 | 531 | } |
@@ -624,8 +617,7 @@ discard block |
||
624 | 617 | //ini_set('error_reporting', E_ALL ^ E_NOTICE); |
625 | 618 | } |
626 | 619 | |
627 | -function flt_calculate_ship_to_transport_sort($a, $b) |
|
628 | -{ |
|
620 | +function flt_calculate_ship_to_transport_sort($a, $b) { |
|
629 | 621 | return $a['transport_effectivness'] == $b['transport_effectivness'] ? 0 : ($a['transport_effectivness'] > $b['transport_effectivness'] ? -1 : 1); |
630 | 622 | } |
631 | 623 | |
@@ -634,8 +626,7 @@ discard block |
||
634 | 626 | // $resource_amount - how much amount of resources need to be transported |
635 | 627 | // $from - transport from |
636 | 628 | // $to - transport to |
637 | -function flt_calculate_fleet_to_transport($ship_list, $resource_amount, $from, $to) |
|
638 | -{ |
|
629 | +function flt_calculate_fleet_to_transport($ship_list, $resource_amount, $from, $to) { |
|
639 | 630 | global $user; |
640 | 631 | |
641 | 632 | $ship_data = array(); |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | } |
9 | 9 | |
10 | 10 | $speeds = array(); |
11 | - if(!empty($fleet)) |
|
11 | + if (!empty($fleet)) |
|
12 | 12 | { |
13 | 13 | foreach ($fleet as $ship_id => $amount) |
14 | 14 | { |
15 | - if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
15 | + if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
16 | 16 | { |
17 | 17 | $single_ship_data = get_ship_data($ship_id, $user); |
18 | 18 | $speeds[] = $single_ship_data['speed']; |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | function flt_travel_distance($from, $to) { |
27 | 27 | global $config; |
28 | 28 | |
29 | - if($from['galaxy'] != $to['galaxy']) |
|
29 | + if ($from['galaxy'] != $to['galaxy']) |
|
30 | 30 | { |
31 | 31 | $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance; |
32 | 32 | } |
33 | - elseif($from['system'] != $to['system']) |
|
33 | + elseif ($from['system'] != $to['system']) |
|
34 | 34 | { |
35 | 35 | $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700; |
36 | 36 | } |
37 | - elseif($from['planet'] != $to['planet']) |
|
37 | + elseif ($from['planet'] != $to['planet']) |
|
38 | 38 | { |
39 | 39 | $distance = abs($from['planet'] - $to['planet']) * 5 + 1000; |
40 | 40 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
67 | 67 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
68 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) |
|
68 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) |
|
69 | 69 | { |
70 | 70 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
71 | 71 | $real_speed = $speed_percent * sqrt($fleet_speed); |
72 | 72 | |
73 | 73 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
74 | 74 | |
75 | - foreach($fleet_array as $ship_id => $ship_count) |
|
75 | + foreach ($fleet_array as $ship_id => $ship_count) |
|
76 | 76 | { |
77 | 77 | if (!$ship_id || !$ship_count) |
78 | 78 | { |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | |
127 | 127 | $config_bashing_attacks = $config->fleet_bashing_attacks; |
128 | 128 | $config_bashing_interval = $config->fleet_bashing_interval; |
129 | - if(!$config_bashing_attacks) { |
|
129 | + if (!$config_bashing_attacks) { |
|
130 | 130 | // Bashing allowed - protection disabled |
131 | 131 | return ATTACK_ALLOWED; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $bashing_result = ATTACK_BASHING; |
135 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
135 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
136 | 136 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
137 | - if(!empty($relations)) { |
|
137 | + if (!empty($relations)) { |
|
138 | 138 | $relations = $relations[$enemy['ally_id']]; |
139 | - switch($relations['alliance_diplomacy_relation']) { |
|
139 | + switch ($relations['alliance_diplomacy_relation']) { |
|
140 | 140 | case ALLY_DIPLOMACY_WAR: |
141 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
141 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
142 | 142 | $bashing_result = ATTACK_BASHING_WAR_DELAY; |
143 | 143 | } else { |
144 | 144 | return ATTACK_ALLOWED; |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | // } |
176 | 176 | // } |
177 | 177 | $bashing_fleet_list = fleet_list_bashing($user['id'], $planet_dst); |
178 | - foreach($bashing_fleet_list as $fleet_row) { |
|
178 | + foreach ($bashing_fleet_list as $fleet_row) { |
|
179 | 179 | // Checking for ACS - each ACS count only once |
180 | - if($fleet_row['fleet_group']) { |
|
180 | + if ($fleet_row['fleet_group']) { |
|
181 | 181 | $bashing_list["{$user['id']}_{$fleet_row['fleet_group']}"] = $fleet_row['fleet_start_time']; |
182 | 182 | } else { |
183 | 183 | $bashing_list[] = $fleet_row['fleet_start_time']; |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
188 | - if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
188 | + if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
189 | 189 | return ATTACK_ALLOWED; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $query = doquery("SELECT bashing_time FROM {{bashing}} WHERE bashing_user_id = {$user['id']} AND bashing_planet_id = {$planet_dst['id']} AND bashing_time >= {$time_limit};"); |
193 | - while($bashing_row = db_fetch($query)) { |
|
193 | + while ($bashing_row = db_fetch($query)) { |
|
194 | 194 | $bashing_list[] = $bashing_row['bashing_time']; |
195 | 195 | } |
196 | 196 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | $last_attack = 0; |
200 | 200 | $wave = 0; |
201 | 201 | $attack = 1; |
202 | - foreach($bashing_list as &$bash_time) { |
|
202 | + foreach ($bashing_list as &$bash_time) { |
|
203 | 203 | $attack++; |
204 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
204 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
205 | 205 | $attack = 1; |
206 | 206 | $wave++; |
207 | 207 | } |
@@ -212,21 +212,21 @@ discard block |
||
212 | 212 | return ($wave > $config->fleet_bashing_waves ? $bashing_result : ATTACK_ALLOWED); |
213 | 213 | } |
214 | 214 | |
215 | -function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false){$result = null; return sn_function_call('flt_can_attack', array($planet_src, $planet_dst, $fleet, $mission, $options, &$result));} |
|
215 | +function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false) {$result = null; return sn_function_call('flt_can_attack', array($planet_src, $planet_dst, $fleet, $mission, $options, &$result)); } |
|
216 | 216 | function sn_flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false, &$result) { |
217 | 217 | //TODO: try..catch |
218 | 218 | global $config, $user; |
219 | 219 | |
220 | - if($user['vacation']) { |
|
220 | + if ($user['vacation']) { |
|
221 | 221 | return $result = ATTACK_OWN_VACATION; |
222 | 222 | } |
223 | 223 | |
224 | - if(empty($fleet) || !is_array($fleet)) { |
|
224 | + if (empty($fleet) || !is_array($fleet)) { |
|
225 | 225 | return $result = ATTACK_NO_FLEET; |
226 | 226 | } |
227 | 227 | |
228 | 228 | $sn_groups_mission = sn_get_groups('missions'); |
229 | - if(!isset($sn_groups_mission[$mission])) { |
|
229 | + if (!isset($sn_groups_mission[$mission])) { |
|
230 | 230 | return $result = ATTACK_MISSION_ABSENT; |
231 | 231 | } |
232 | 232 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -245,32 +245,32 @@ discard block |
||
245 | 245 | $resources = 0; |
246 | 246 | $ship_ids = sn_get_groups('fleet'); |
247 | 247 | $resource_ids = sn_get_groups('resources_loot'); |
248 | - foreach($fleet as $ship_id => $ship_count) { |
|
248 | + foreach ($fleet as $ship_id => $ship_count) { |
|
249 | 249 | $is_ship = in_array($ship_id, $ship_ids); |
250 | 250 | $is_resource = in_array($ship_id, $resource_ids); |
251 | - if(!$is_ship && !$is_resource) { |
|
251 | + if (!$is_ship && !$is_resource) { |
|
252 | 252 | // TODO Спецобработчик для Капитана и модулей |
253 | 253 | // return ATTACK_WRONG_UNIT; |
254 | 254 | } |
255 | 255 | |
256 | - if($ship_count < 0) { |
|
256 | + if ($ship_count < 0) { |
|
257 | 257 | return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG; |
258 | 258 | } |
259 | 259 | |
260 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
260 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
261 | 261 | // TODO ATTACK_NO_MISSILE |
262 | 262 | return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES; |
263 | 263 | } |
264 | 264 | |
265 | - if($is_ship) { |
|
265 | + if ($is_ship) { |
|
266 | 266 | $single_ship_data = get_ship_data($ship_id, $user); |
267 | - if($single_ship_data[P_SPEED] <= 0) { |
|
267 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
268 | 268 | return $result = ATTACK_ZERO_SPEED; |
269 | 269 | } |
270 | 270 | $ships += $ship_count; |
271 | 271 | $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; |
272 | 272 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
273 | - } elseif($is_resource) { |
|
273 | + } elseif ($is_resource) { |
|
274 | 274 | $resources += $ship_count; |
275 | 275 | } |
276 | 276 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | } |
282 | 282 | */ |
283 | 283 | |
284 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
284 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
285 | 285 | return $result = ATTACK_RESOURCE_FORBIDDEN; |
286 | 286 | } |
287 | 287 | |
@@ -293,35 +293,35 @@ discard block |
||
293 | 293 | */ |
294 | 294 | |
295 | 295 | $speed = $options['fleet_speed_percent']; |
296 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
296 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
297 | 297 | return $result = ATTACK_WRONG_SPEED; |
298 | 298 | } |
299 | 299 | |
300 | 300 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
301 | 301 | |
302 | 302 | |
303 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
303 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
304 | 304 | return $result = ATTACK_NO_FUEL; |
305 | 305 | } |
306 | 306 | |
307 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
307 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
308 | 308 | return $result = ATTACK_TOO_FAR; |
309 | 309 | } |
310 | 310 | |
311 | - if($travel_data['hold'] < $resources) { |
|
311 | + if ($travel_data['hold'] < $resources) { |
|
312 | 312 | return $result = ATTACK_OVERLOADED; |
313 | 313 | } |
314 | 314 | |
315 | 315 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
316 | 316 | |
317 | 317 | $fleet_group = $options['fleet_group']; |
318 | - if($fleet_group) { |
|
319 | - if($mission != MT_AKS) { |
|
318 | + if ($fleet_group) { |
|
319 | + if ($mission != MT_AKS) { |
|
320 | 320 | return $result = ATTACK_WRONG_MISSION; |
321 | 321 | }; |
322 | 322 | |
323 | 323 | $acs = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", '', true); |
324 | - if(!$acs['id']) { |
|
324 | + if (!$acs['id']) { |
|
325 | 325 | return $result = ATTACK_NO_ACS; |
326 | 326 | } |
327 | 327 | |
@@ -329,70 +329,70 @@ discard block |
||
329 | 329 | return $result = ATTACK_ACS_WRONG_TARGET; |
330 | 330 | } |
331 | 331 | |
332 | - if ($fleet_start_time>$acs['ankunft']) { |
|
332 | + if ($fleet_start_time > $acs['ankunft']) { |
|
333 | 333 | return $result = ATTACK_ACS_TOO_LATE; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | $flying_fleets = $options['flying_fleets']; |
338 | - if(!$flying_fleets) { |
|
338 | + if (!$flying_fleets) { |
|
339 | 339 | // $flying_fleets = doquery("SELECT COUNT(fleet_id) AS `flying_fleets` FROM {{fleets}} WHERE `fleet_owner` = '{$user['id']}';", '', true); |
340 | 340 | // $flying_fleets = $flying_fleets['flying_fleets']; |
341 | 341 | $flying_fleets = fleet_count_flying($user['id']); |
342 | 342 | } |
343 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
343 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
344 | 344 | return $result = ATTACK_NO_SLOTS; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
348 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
348 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
349 | 349 | return $result = ATTACK_SPIES_LONLY; |
350 | 350 | } |
351 | 351 | |
352 | 352 | // Checking for no planet |
353 | - if(!$planet_dst['id_owner']) { |
|
354 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
353 | + if (!$planet_dst['id_owner']) { |
|
354 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
355 | 355 | return $result = ATTACK_NO_COLONIZER; |
356 | 356 | } |
357 | 357 | |
358 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
358 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
359 | 359 | return $result = ATTACK_ALLOWED; |
360 | 360 | } |
361 | 361 | return $result = ATTACK_NO_TARGET; |
362 | 362 | } |
363 | 363 | |
364 | - if($mission == MT_RECYCLE) { |
|
365 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
364 | + if ($mission == MT_RECYCLE) { |
|
365 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
366 | 366 | return $result = ATTACK_NO_DEBRIS; |
367 | 367 | } |
368 | - if($recyclers <= 0) { |
|
368 | + if ($recyclers <= 0) { |
|
369 | 369 | return $result = ATTACK_NO_RECYCLERS; |
370 | 370 | } |
371 | 371 | return $result = ATTACK_ALLOWED; |
372 | 372 | } |
373 | 373 | |
374 | 374 | // Got planet. Checking if it is ours |
375 | - if($planet_dst['id_owner'] == $user['id']) { |
|
376 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
375 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
376 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
377 | 377 | return $result = ATTACK_ALLOWED; |
378 | 378 | } |
379 | 379 | return $planet_src['id'] == $planet_dst['id'] ? ATTACK_SAME : ATTACK_OWN; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
383 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
383 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
384 | 384 | return $result = ATTACK_WRONG_MISSION; |
385 | 385 | } |
386 | 386 | |
387 | 387 | $enemy = db_user_by_id($planet_dst['id_owner']); |
388 | 388 | // We cannot attack or send resource to users in VACATION mode |
389 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
389 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
390 | 390 | return $result = ATTACK_VACATION; |
391 | 391 | } |
392 | 392 | |
393 | 393 | // Multi IP protection |
394 | 394 | // TODO: Here we need a procedure to check proxies |
395 | - if(sys_is_multiaccount($user, $enemy)) { |
|
395 | + if (sys_is_multiaccount($user, $enemy)) { |
|
396 | 396 | return $result = ATTACK_SAME_IP; |
397 | 397 | } |
398 | 398 | |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | $enemy_points = $enemy['total_points']; |
401 | 401 | |
402 | 402 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
403 | - if($mission == MT_TRANSPORT) { |
|
404 | - if($user_points >= $enemy_points || $config->allow_buffing) { |
|
403 | + if ($mission == MT_TRANSPORT) { |
|
404 | + if ($user_points >= $enemy_points || $config->allow_buffing) { |
|
405 | 405 | return $result = ATTACK_ALLOWED; |
406 | 406 | } else { |
407 | 407 | return $result = ATTACK_BUFFING; |
@@ -411,65 +411,65 @@ discard block |
||
411 | 411 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
412 | 412 | |
413 | 413 | // Is it admin with planet protection? |
414 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
414 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
415 | 415 | return $result = ATTACK_ADMIN; |
416 | 416 | } |
417 | 417 | |
418 | 418 | // Okay. Now skipping protection checks for inactive longer then 1 week |
419 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60*60*24*7)) { |
|
420 | - if( |
|
419 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
420 | + if ( |
|
421 | 421 | (classSupernova::$gc->general->playerIsNoobByPoints($enemy_points) && !classSupernova::$gc->general->playerIsNoobByPoints($user_points)) |
422 | 422 | || |
423 | 423 | (classSupernova::$gc->general->playerIs1stStrongerThen2nd($user_points, $enemy_points)) |
424 | 424 | ) { |
425 | - if($mission != MT_HOLD) { |
|
425 | + if ($mission != MT_HOLD) { |
|
426 | 426 | return $result = ATTACK_NOOB; |
427 | 427 | } |
428 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
428 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
429 | 429 | return $result = ATTACK_NOOB; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Is it HOLD mission? If yes - there should be ally deposit |
435 | - if($mission == MT_HOLD) { |
|
436 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
435 | + if ($mission == MT_HOLD) { |
|
436 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
437 | 437 | return $result = ATTACK_ALLOWED; |
438 | 438 | } |
439 | 439 | return $result = ATTACK_NO_ALLY_DEPOSIT; |
440 | 440 | } |
441 | 441 | |
442 | - if($mission == MT_SPY) { |
|
442 | + if ($mission == MT_SPY) { |
|
443 | 443 | return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Is it MISSILE mission? |
447 | - if($mission == MT_MISSILE) { |
|
447 | + if ($mission == MT_MISSILE) { |
|
448 | 448 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
449 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
449 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
450 | 450 | return $result = ATTACK_NO_SILO; |
451 | 451 | } |
452 | 452 | |
453 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
453 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
454 | 454 | return $result = ATTACK_NO_MISSILE; |
455 | 455 | } |
456 | 456 | |
457 | 457 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
458 | 458 | $mip_range = flt_get_missile_range($user); |
459 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
459 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
460 | 460 | return $result = ATTACK_MISSILE_TOO_FAR; |
461 | 461 | } |
462 | 462 | |
463 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
463 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
464 | 464 | return $result = ATTACK_WRONG_STRUCTURE; |
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
468 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
469 | 469 | return $result = ATTACK_WRONG_MISSION; |
470 | 470 | } |
471 | 471 | |
472 | - if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
472 | + if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
473 | 473 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
474 | 474 | } |
475 | 475 | |
@@ -495,18 +495,18 @@ discard block |
||
495 | 495 | $from = $from['planet']; |
496 | 496 | |
497 | 497 | $can_attack = flt_can_attack($from, $to, $fleet, $mission, $options); |
498 | - if($can_attack != ATTACK_ALLOWED) { |
|
498 | + if ($can_attack != ATTACK_ALLOWED) { |
|
499 | 499 | $internal_transaction ? sn_db_transaction_rollback() : false; |
500 | 500 | return $can_attack; |
501 | 501 | } |
502 | 502 | |
503 | 503 | $fleet_group = isset($options['fleet_group']) ? floatval($options['fleet_group']) : 0; |
504 | 504 | |
505 | - $travel_data = flt_travel_data($user, $from, $to, $fleet, $options['fleet_speed_percent']); |
|
505 | + $travel_data = flt_travel_data($user, $from, $to, $fleet, $options['fleet_speed_percent']); |
|
506 | 506 | |
507 | 507 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
508 | 508 | |
509 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
509 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
510 | 510 | $stay_duration = $options['stay_time'] * 3600; |
511 | 511 | $stay_time = $fleet_start_time + $stay_duration; |
512 | 512 | } else { |
@@ -519,20 +519,20 @@ discard block |
||
519 | 519 | $fleet_string = ''; |
520 | 520 | $db_changeset = array(); |
521 | 521 | $planet_fields = array(); |
522 | - foreach($fleet as $unit_id => $amount) |
|
522 | + foreach ($fleet as $unit_id => $amount) |
|
523 | 523 | { |
524 | - if(!$amount || !$unit_id) |
|
524 | + if (!$amount || !$unit_id) |
|
525 | 525 | { |
526 | 526 | continue; |
527 | 527 | } |
528 | 528 | |
529 | - if(in_array($unit_id, sn_get_groups('fleet'))) |
|
529 | + if (in_array($unit_id, sn_get_groups('fleet'))) |
|
530 | 530 | { |
531 | 531 | $fleet_ship_count += $amount; |
532 | 532 | $fleet_string .= "{$unit_id},{$amount};"; |
533 | 533 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$amount, $user, $from['id']); |
534 | 534 | } |
535 | - elseif(in_array($unit_id, sn_get_groups('resources_loot'))) |
|
535 | + elseif (in_array($unit_id, sn_get_groups('resources_loot'))) |
|
536 | 536 | { |
537 | 537 | $planet_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
538 | 538 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | |
641 | 641 | $ship_data = array(); |
642 | 642 | $fleet_array = array(); |
643 | - foreach($ship_list as $transport_id => $cork) |
|
643 | + foreach ($ship_list as $transport_id => $cork) |
|
644 | 644 | { |
645 | 645 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
646 | 646 | } |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | $fleet_hold = 0; |
650 | 650 | $fleet_capacity = 0; |
651 | 651 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
652 | - foreach($ship_data as $transport_id => &$ship_info) |
|
652 | + foreach ($ship_data as $transport_id => &$ship_info) |
|
653 | 653 | { |
654 | 654 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
655 | - if($ship_loaded) |
|
655 | + if ($ship_loaded) |
|
656 | 656 | { |
657 | 657 | $fleet_array[$transport_id] = $ship_loaded; |
658 | 658 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
@@ -14,39 +14,39 @@ discard block |
||
14 | 14 | |
15 | 15 | lng_include('fleet'); |
16 | 16 | |
17 | -if($TargetPlanet = sys_get_param_id('jmpto')) |
|
17 | +if ($TargetPlanet = sys_get_param_id('jmpto')) |
|
18 | 18 | { |
19 | 19 | sn_db_transaction_start(); |
20 | 20 | db_user_by_id($user['id'], true, 'id'); |
21 | 21 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
22 | - if(!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
22 | + if (!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
23 | 23 | { |
24 | 24 | $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`'); |
25 | - if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
25 | + if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
26 | 26 | { |
27 | - $NextDestTime = uni_get_time_to_jump ( $TargetGate ); |
|
28 | - if(!$NextDestTime) |
|
27 | + $NextDestTime = uni_get_time_to_jump($TargetGate); |
|
28 | + if (!$NextDestTime) |
|
29 | 29 | { |
30 | 30 | // $SubQueryOri = ""; |
31 | 31 | // $SubQueryDes = ""; |
32 | 32 | $ship_list = sys_get_param('ships'); |
33 | 33 | $db_changeset = array(); |
34 | - foreach($ship_list as $ship_id => $ship_count) |
|
34 | + foreach ($ship_list as $ship_id => $ship_count) |
|
35 | 35 | { |
36 | - if(!in_array($ship_id, sn_get_groups('fleet'))) |
|
36 | + if (!in_array($ship_id, sn_get_groups('fleet'))) |
|
37 | 37 | { |
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | 41 | $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id))); |
42 | - if($ship_count) |
|
42 | + if ($ship_count) |
|
43 | 43 | { |
44 | 44 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($ship_id, -$ship_count, $user, $planetrow['id']); |
45 | 45 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($ship_id, $ship_count, $user, $TargetGate['id']); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | // Dit monsieur, y avait quelque chose a envoyer ??? |
49 | - if(!empty($db_changeset)) |
|
49 | + if (!empty($db_changeset)) |
|
50 | 50 | { |
51 | 51 | DBStaticPlanet::db_planet_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
52 | 52 | DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'"); |
56 | 56 | |
57 | 57 | $planetrow['last_jump_time'] = SN_TIME_NOW; |
58 | - $RetMessage = $lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow)); |
|
58 | + $RetMessage = $lang['gate_jump_done'] . " - " . pretty_time(uni_get_time_to_jump($planetrow)); |
|
59 | 59 | } else { |
60 | 60 | $RetMessage = $lang['gate_wait_data']; |
61 | 61 | } |
62 | 62 | } else { |
63 | - $RetMessage = $lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime); |
|
63 | + $RetMessage = $lang['gate_wait_dest'] . " - " . pretty_time($NextDestTime); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $RetMessage = $lang['gate_no_dest_g']; |
67 | 67 | } |
68 | 68 | } else { |
69 | - $RetMessage = $lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime); |
|
69 | + $RetMessage = $lang['gate_wait_star'] . " - " . pretty_time($NextJumpTime); |
|
70 | 70 | } |
71 | 71 | sn_db_transaction_commit(); |
72 | 72 | messageBox($RetMessage, $lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10); |
73 | 73 | } else { |
74 | 74 | $template = gettemplate('jumpgate', true); |
75 | - if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
75 | + if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
76 | 76 | { |
77 | 77 | $Combo = ''; |
78 | 78 | $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']); |
79 | 79 | // while($CurMoon = db_fetch($MoonList)) |
80 | - foreach($MoonList as $CurMoon) |
|
80 | + foreach ($MoonList as $CurMoon) |
|
81 | 81 | { |
82 | - if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
82 | + if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
83 | 83 | { |
84 | 84 | $NextJumpTime = uni_get_time_to_jump($CurMoon); |
85 | 85 | $template->assign_block_vars('moon', array( |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - foreach(sn_get_groups('fleet') as $Ship) |
|
96 | + foreach (sn_get_groups('fleet') as $Ship) |
|
97 | 97 | { |
98 | - if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
98 | + if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
99 | 99 | { |
100 | 100 | continue; |
101 | 101 | } |
@@ -115,8 +115,7 @@ |
||
115 | 115 | )); |
116 | 116 | |
117 | 117 | display($template, $lang['tech'][STRUC_MOON_GATE]); |
118 | - } |
|
119 | - else |
|
118 | + } else |
|
120 | 119 | { |
121 | 120 | messageBox($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10); |
122 | 121 | } |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(!empty($_POST['return']) && is_array($_POST['return'])) { |
|
6 | - foreach($_POST['return'] as $fleet_id) { |
|
7 | - if($fleet_id = idval($fleet_id)) { |
|
5 | +if (!empty($_POST['return']) && is_array($_POST['return'])) { |
|
6 | + foreach ($_POST['return'] as $fleet_id) { |
|
7 | + if ($fleet_id = idval($fleet_id)) { |
|
8 | 8 | sn_db_transaction_start(); |
9 | 9 | $FleetRow = db_fleet_get($fleet_id); |
10 | 10 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | lng_include('overview'); |
24 | 24 | lng_include('fleet'); |
25 | 25 | |
26 | -if(!$planetrow) { |
|
26 | +if (!$planetrow) { |
|
27 | 27 | messageBox($lang['fl_noplanetrow'], $lang['fl_error']); |
28 | 28 | } |
29 | 29 | |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | |
32 | 32 | $i = 0; |
33 | 33 | $fleet_list = fleet_list_by_owner_id($user['id']); |
34 | -foreach($fleet_list as $fleet_id => $fleet_row) { |
|
34 | +foreach ($fleet_list as $fleet_id => $fleet_row) { |
|
35 | 35 | $i++; |
36 | 36 | $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user); |
37 | 37 | |
38 | 38 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
39 | 39 | |
40 | - foreach($fleet_data['ships'] as $ship_data) { |
|
40 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
41 | 41 | $template->assign_block_vars('fleets.ships', $ship_data); |
42 | 42 | } |
43 | 43 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | -if(!$user_admin) { |
|
7 | +if (!$user_admin) { |
|
8 | 8 | messageBox($lang['Denied_access'], $lang['ally_admin']); |
9 | 9 | } |
10 | 10 | |
11 | 11 | $template = gettemplate('ali_admin', $template); |
12 | 12 | |
13 | 13 | $text_list = array( |
14 | - 1 => array ('db_field' => 'ally_description', 'text_type' => 'Public_text_of_alliance'), |
|
15 | - 2 => array ('db_field' => 'ally_text', 'text_type' => 'Internal_text'), |
|
16 | - 3 => array ('db_field' => 'ally_request', 'text_type' => 'Show_of_request_text'), |
|
14 | + 1 => array('db_field' => 'ally_description', 'text_type' => 'Public_text_of_alliance'), |
|
15 | + 2 => array('db_field' => 'ally_text', 'text_type' => 'Internal_text'), |
|
16 | + 3 => array('db_field' => 'ally_request', 'text_type' => 'Show_of_request_text'), |
|
17 | 17 | ); |
18 | 18 | |
19 | 19 | $allyTextID = sys_get_param_int('t', 1); |
20 | -$allyTextID = ($allyTextID<1 || $allyTextID>3) ? 1 : $allyTextID; |
|
20 | +$allyTextID = ($allyTextID < 1 || $allyTextID > 3) ? 1 : $allyTextID; |
|
21 | 21 | |
22 | -if(sys_get_param_str('isSaveOptions')) { |
|
22 | +if (sys_get_param_str('isSaveOptions')) { |
|
23 | 23 | require_once('includes/includes/sys_avatar.php'); |
24 | 24 | |
25 | 25 | $new_image = $ally['ally_image']; |
@@ -31,32 +31,32 @@ discard block |
||
31 | 31 | // $template->assign_block_vars('result', $avatar_upload_result); |
32 | 32 | |
33 | 33 | $ally_changeset = array(); |
34 | - if(($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) { |
|
34 | + if (($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) { |
|
35 | 35 | $new_tag_unsafe = $new_tag; |
36 | 36 | $new_tag = db_escape($new_tag); |
37 | 37 | $isTaggedAllyExists = DBStaticAlly::db_ally_get_by_tag($new_tag); |
38 | - if(!empty($isTaggedAllyExists)) { |
|
38 | + if (!empty($isTaggedAllyExists)) { |
|
39 | 39 | messageBox(sprintf($lang['ally_message_tag_exists'], $new_tag_unsafe), '', 'alliance.php?mode=admin&edit=ally'); |
40 | 40 | } |
41 | 41 | $ally_changeset[] = "`ally_tag`='{$new_tag}'"; |
42 | 42 | db_user_set_by_id($ally['ally_user_id'], "`username`='[{$new_tag}]'"); |
43 | 43 | } |
44 | 44 | |
45 | - if(($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) { |
|
45 | + if (($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) { |
|
46 | 46 | $new_name_unsafe = $new_name; |
47 | 47 | $new_name = db_escape($new_name); |
48 | 48 | $isTaggedAllyExists = DBStaticAlly::db_ally_get_by_name($new_name); |
49 | - if(!empty($isTaggedAllyExists)) { |
|
49 | + if (!empty($isTaggedAllyExists)) { |
|
50 | 50 | messageBox(sprintf($lang['ally_message_name_exists'], $new_name_unsafe), '', 'alliance.php?mode=admin&edit=ally'); |
51 | 51 | } |
52 | 52 | $ally_changeset[] = "`ally_name`='{$new_name}'"; |
53 | 53 | } |
54 | 54 | |
55 | - if(($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) { |
|
55 | + if (($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) { |
|
56 | 56 | $new_owner_rank = db_escape($new_owner_rank); |
57 | 57 | $ally_changeset[] = "`ally_owner_range` = '{$new_owner_rank}'"; |
58 | 58 | } |
59 | - if(($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) { |
|
59 | + if (($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) { |
|
60 | 60 | $new_web = db_escape($new_web); |
61 | 61 | $ally_changeset[] = "`ally_web` = '{$new_web}'"; |
62 | 62 | } |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | // if(($new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow'])) && $new_request != $ally['ally_request_notallow']) { |
66 | 66 | // $ally_changeset[] = "`ally_request_notallow` = '{$new_request}'"; |
67 | 67 | // } |
68 | - if($new_image != $ally['ally_image']) { |
|
68 | + if ($new_image != $ally['ally_image']) { |
|
69 | 69 | $new_image = intval($new_image); |
70 | 70 | $ally_changeset[] = "`ally_image` = '{$new_image}'"; |
71 | 71 | } |
72 | 72 | |
73 | - if(!empty($ally_changeset)) { |
|
73 | + if (!empty($ally_changeset)) { |
|
74 | 74 | doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;"); |
75 | 75 | sys_redirect('alliance.php?mode=admin&edit=ally'); |
76 | 76 | } |
77 | 77 | } |
78 | -elseif(sys_get_param_str('isSaveText')) |
|
78 | +elseif (sys_get_param_str('isSaveText')) |
|
79 | 79 | { |
80 | 80 | $text = sys_get_param_str_both('text'); |
81 | 81 | doquery("UPDATE {{alliance}} SET `{$text_list[$allyTextID]['db_field']}`='{$text['safe']}' WHERE `id`='{$ally['id']}';"); |
82 | 82 | $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe']; |
83 | 83 | } |
84 | -elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) |
|
84 | +elseif (sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) |
|
85 | 85 | { |
86 | - if(!$isAllyOwner) |
|
86 | + if (!$isAllyOwner) |
|
87 | 87 | { |
88 | 88 | messageBox($lang['Denied_access'], $lang['ally_admin']); |
89 | 89 | } |
90 | 90 | |
91 | 91 | $newLeader = db_user_by_id($idNewLeader, false, `ally_id`); |
92 | - if($newLeader['ally_id'] == $user['ally_id']) |
|
92 | + if ($newLeader['ally_id'] == $user['ally_id']) |
|
93 | 93 | { |
94 | 94 | sn_db_transaction_start(); |
95 | 95 | db_user_set_by_id($user['id'], "`ally_rank_id`='0'"); |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | sys_redirect('alliance.php'); |
100 | 100 | } |
101 | 101 | } |
102 | -elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) |
|
102 | +elseif (sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) |
|
103 | 103 | { |
104 | - if(!$isAllyOwner) |
|
104 | + if (!$isAllyOwner) |
|
105 | 105 | { |
106 | 106 | messageBox($lang['Denied_access'], $lang['ally_admin']); |
107 | 107 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'ally_name' => htmlspecialchars($ally['ally_name']), |
125 | 125 | 'ally_tag' => htmlspecialchars($ally['ally_tag']), |
126 | 126 | 'ally_web' => htmlspecialchars($ally['ally_web']), |
127 | - 'ally_request_notallow_0' => (( $ally['ally_request_notallow']) ? ' SELECTED' : ''), |
|
127 | + 'ally_request_notallow_0' => (($ally['ally_request_notallow']) ? ' SELECTED' : ''), |
|
128 | 128 | 'ally_request_notallow_1' => ((!$ally['ally_request_notallow']) ? ' SELECTED' : ''), |
129 | 129 | 'ally_owner_range' => htmlspecialchars($ally['ally_owner_range']), |
130 | 130 | 'hideNotOwner' => $ally['ally_owner'] != $user['id'] ? 'display: hide;' : '', |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | $userAllyAdmins = db_user_list("`ally_id`= {$ally['id']}", false, '`id`, `username`'); |
135 | 135 | unset($tmp); |
136 | - foreach($userAllyAdmins as $userAllyAdmin) |
|
136 | + foreach ($userAllyAdmins as $userAllyAdmin) |
|
137 | 137 | { |
138 | 138 | $tmp .= "<option value={$userAllyAdmin['id']}>{$userAllyAdmin['username']}</option>"; |
139 | 139 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | $template->assign_var('adminMembers', $tmp); |
142 | 142 | } |
143 | 143 | |
144 | -foreach($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) |
|
144 | +foreach ($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) |
|
145 | 145 | { |
146 | - if(!$sn_ali_admin_action_locale['title']) |
|
146 | + if (!$sn_ali_admin_action_locale['title']) |
|
147 | 147 | { |
148 | 148 | continue; |
149 | 149 | } |
@@ -74,14 +74,12 @@ discard block |
||
74 | 74 | doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;"); |
75 | 75 | sys_redirect('alliance.php?mode=admin&edit=ally'); |
76 | 76 | } |
77 | -} |
|
78 | -elseif(sys_get_param_str('isSaveText')) |
|
77 | +} elseif(sys_get_param_str('isSaveText')) |
|
79 | 78 | { |
80 | 79 | $text = sys_get_param_str_both('text'); |
81 | 80 | doquery("UPDATE {{alliance}} SET `{$text_list[$allyTextID]['db_field']}`='{$text['safe']}' WHERE `id`='{$ally['id']}';"); |
82 | 81 | $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe']; |
83 | -} |
|
84 | -elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) |
|
82 | +} elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) |
|
85 | 83 | { |
86 | 84 | if(!$isAllyOwner) |
87 | 85 | { |
@@ -98,8 +96,7 @@ discard block |
||
98 | 96 | sn_db_transaction_commit(); |
99 | 97 | sys_redirect('alliance.php'); |
100 | 98 | } |
101 | -} |
|
102 | -elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) |
|
99 | +} elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) |
|
103 | 100 | { |
104 | 101 | if(!$isAllyOwner) |
105 | 102 | { |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
4 | 4 | { |
5 | 5 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
6 | 6 | } |
7 | 7 | |
8 | 8 | $template = gettemplate('ali_info', true); |
9 | 9 | |
10 | -if($mode == 'exit') |
|
10 | +if ($mode == 'exit') |
|
11 | 11 | { |
12 | 12 | if ($ally['ally_owner'] == $user['id']) |
13 | 13 | { |
@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']); |
25 | 25 | } |
26 | 26 | } |
27 | -elseif($mode == 'ainfo') |
|
27 | +elseif ($mode == 'ainfo') |
|
28 | 28 | { |
29 | 29 | $tag = sys_get_param_str('tag'); |
30 | 30 | $id_ally = sys_get_param_id('a'); |
31 | - if($tag) |
|
31 | + if ($tag) |
|
32 | 32 | { |
33 | 33 | $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true); |
34 | 34 | } |
35 | - elseif($id_ally) |
|
35 | + elseif ($id_ally) |
|
36 | 36 | { |
37 | 37 | $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true); |
38 | 38 | } |
39 | 39 | |
40 | - if(!$ally) |
|
40 | + if (!$ally) |
|
41 | 41 | { |
42 | 42 | messageBox($lang['ali_sys_notFound'], $lang['Ally_info_1']); |
43 | 43 | } |
44 | 44 | |
45 | - if(!$ally['ally_description']) |
|
45 | + if (!$ally['ally_description']) |
|
46 | 46 | { |
47 | 47 | $ally['ally_description'] = $lang['Ally_nodescription']; |
48 | 48 | } |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | 'EXTERNAL' => true, |
52 | 52 | 'USER_ALLY_ID' => $user['ally_id'], |
53 | 53 | )); |
54 | - $page_header = $lang['sys_alliance']; |
|
54 | + $page_header = $lang['sys_alliance']; |
|
55 | 55 | } |
56 | 56 | else |
57 | 57 | { |
58 | 58 | $page_header = $lang['your_alliance']; |
59 | 59 | |
60 | - if($ally['ally_owner'] == $user['id']) |
|
60 | + if ($ally['ally_owner'] == $user['id']) |
|
61 | 61 | { |
62 | 62 | $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder']; |
63 | 63 | } |
64 | - elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) |
|
64 | + elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) |
|
65 | 65 | { |
66 | 66 | $range = $ranks[$user['ally_rank_id']]['name']; |
67 | 67 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | )); |
106 | 106 | |
107 | 107 | $relations = ali_relations($ally['id']); |
108 | -foreach($relations as $relation) |
|
108 | +foreach ($relations as $relation) |
|
109 | 109 | { |
110 | - if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) |
|
110 | + if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) |
|
111 | 111 | { |
112 | 112 | $template->assign_block_vars('relation', array( |
113 | 113 | 'NAME' => $relation['alliance_diplomacy_contr_ally_name'], |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | -function ali_render(){$func_args = func_get_args();return sn_function_call(__FUNCTION__, $func_args);} |
|
120 | +function ali_render() {$func_args = func_get_args(); return sn_function_call(__FUNCTION__, $func_args); } |
|
121 | 121 | ali_render(); |
122 | 122 | |
123 | 123 | display($template, "{$lang['alliance']} [{$ally['ally_name']}]"); |
@@ -23,16 +23,14 @@ discard block |
||
23 | 23 | $lang['Go_out_welldone'] = str_replace("%s", $ally_name, $lang['Go_out_welldone']); |
24 | 24 | messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']); |
25 | 25 | } |
26 | -} |
|
27 | -elseif($mode == 'ainfo') |
|
26 | +} elseif($mode == 'ainfo') |
|
28 | 27 | { |
29 | 28 | $tag = sys_get_param_str('tag'); |
30 | 29 | $id_ally = sys_get_param_id('a'); |
31 | 30 | if($tag) |
32 | 31 | { |
33 | 32 | $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true); |
34 | - } |
|
35 | - elseif($id_ally) |
|
33 | + } elseif($id_ally) |
|
36 | 34 | { |
37 | 35 | $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true); |
38 | 36 | } |
@@ -52,20 +50,17 @@ discard block |
||
52 | 50 | 'USER_ALLY_ID' => $user['ally_id'], |
53 | 51 | )); |
54 | 52 | $page_header = $lang['sys_alliance']; |
55 | -} |
|
56 | -else |
|
53 | +} else |
|
57 | 54 | { |
58 | 55 | $page_header = $lang['your_alliance']; |
59 | 56 | |
60 | 57 | if($ally['ally_owner'] == $user['id']) |
61 | 58 | { |
62 | 59 | $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder']; |
63 | - } |
|
64 | - elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) |
|
60 | + } elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) |
|
65 | 61 | { |
66 | 62 | $range = $ranks[$user['ally_rank_id']]['name']; |
67 | - } |
|
68 | - else |
|
63 | + } else |
|
69 | 64 | { |
70 | 65 | $range = $lang['member']; |
71 | 66 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use \DBAL\DbQuery; |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
6 | 6 | { |
7 | 7 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
8 | 8 | } |
@@ -16,28 +16,28 @@ discard block |
||
16 | 16 | |
17 | 17 | $ally_name_safe = db_escape($user['ally_name']); |
18 | 18 | |
19 | -if(sys_get_param_str('ali_dip_offer_make')) |
|
19 | +if (sys_get_param_str('ali_dip_offer_make')) |
|
20 | 20 | { |
21 | 21 | $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation'); |
22 | - if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) |
|
22 | + if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) |
|
23 | 23 | { |
24 | 24 | messageBox($lang['ali_dip_err_wrong_offer'], $page_title); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id'); |
28 | - if($alliance_negotiation_contr_ally_id == $user['ally_id']) |
|
28 | + if ($alliance_negotiation_contr_ally_id == $user['ally_id']) |
|
29 | 29 | { |
30 | 30 | messageBox($lang['ali_dip_err_same_ally'], $page_title); |
31 | 31 | } |
32 | 32 | |
33 | 33 | $contr_ally_row = doquery("SELECT `ally_name` FROM {{alliance}} WHERE `id` = {$alliance_negotiation_contr_ally_id} LIMIT 1;", '', true); |
34 | - if(!$contr_ally_row) |
|
34 | + if (!$contr_ally_row) |
|
35 | 35 | { |
36 | 36 | messageBox($lang['ali_dip_err_no_ally'], $page_title); |
37 | 37 | } |
38 | 38 | |
39 | 39 | $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id); |
40 | - if($alliance_negotiation_relation == $relation_current_id) |
|
40 | + if ($alliance_negotiation_relation == $relation_current_id) |
|
41 | 41 | { |
42 | 42 | messageBox(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title); |
43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation]; |
51 | 51 | $relation_current = $sn_diplomacy_relation_list[$relation_current_id]; |
52 | - if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) |
|
52 | + if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) |
|
53 | 53 | { |
54 | 54 | DbQuery::build() |
55 | 55 | ->setTable('alliance_negotiation') |
@@ -82,39 +82,39 @@ discard block |
||
82 | 82 | else |
83 | 83 | { |
84 | 84 | $offer_id = sys_get_param_id('offer_id'); |
85 | - if($offer_id) |
|
85 | + if ($offer_id) |
|
86 | 86 | { |
87 | 87 | $offer_answer = sys_get_param_str('answer'); |
88 | 88 | |
89 | 89 | $negotiation = doquery("SELECT * FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;", '', true); |
90 | - if(!$negotiation) |
|
90 | + if (!$negotiation) |
|
91 | 91 | { |
92 | 92 | messageBox($lang['ali_dip_err_offer_none'], $page_title); |
93 | 93 | } |
94 | - elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
94 | + elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
95 | 95 | { |
96 | 96 | // TODO: Add log of hack attempt |
97 | 97 | messageBox($lang['ali_dip_err_offer_alien'], $page_title); |
98 | 98 | } |
99 | - elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
99 | + elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
100 | 100 | { |
101 | - if($offer_answer == 'accept') |
|
101 | + if ($offer_answer == 'accept') |
|
102 | 102 | { |
103 | 103 | // TODO: Add log of hack attempt |
104 | 104 | messageBox($lang['ali_dip_err_offer_accept_own'], $page_title); |
105 | 105 | } |
106 | - elseif($offer_answer == 'deny') |
|
106 | + elseif ($offer_answer == 'deny') |
|
107 | 107 | { |
108 | 108 | doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;"); |
109 | 109 | } |
110 | 110 | } |
111 | 111 | else |
112 | 112 | { |
113 | - if($offer_answer == 'accept') |
|
113 | + if ($offer_answer == 'accept') |
|
114 | 114 | { |
115 | 115 | $accept_offer = true; |
116 | 116 | } |
117 | - elseif($offer_answer == 'deny') |
|
117 | + elseif ($offer_answer == 'deny') |
|
118 | 118 | { |
119 | 119 | DBStaticAlly::db_ally_negotiation_update_status_1($offer_id); |
120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | -if($accept_offer) |
|
125 | +if ($accept_offer) |
|
126 | 126 | { |
127 | 127 | sn_db_transaction_start(); |
128 | 128 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | sn_db_transaction_commit(); |
162 | 162 | } |
163 | 163 | |
164 | -foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) |
|
164 | +foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) |
|
165 | 165 | { |
166 | 166 | $template->assign_block_vars('relation', array( |
167 | 167 | 'ID' => $diplomacy_relation_id, |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | $query = doquery("SELECT id, ally_name, ally_tag FROM {{alliance}} WHERE `id` != {$user['ally_id']} ORDER BY ally_name;"); |
173 | -while($alliance = db_fetch($query)) |
|
173 | +while ($alliance = db_fetch($query)) |
|
174 | 174 | { |
175 | 175 | $template->assign_block_vars('alliance', array( |
176 | 176 | 'ID' => $alliance['id'], |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | WHERE |
190 | 190 | alliance_negotiation_ally_id = {$user['ally_id']} OR alliance_negotiation_contr_ally_id = {$user['ally_id']};" |
191 | 191 | ); |
192 | -while($offer = db_fetch($query)) |
|
192 | +while ($offer = db_fetch($query)) |
|
193 | 193 | { |
194 | 194 | $template->assign_block_vars('offer', array( |
195 | 195 | 'ID' => $offer['alliance_negotiation_id'], |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | ->doInsert(); |
67 | 67 | |
68 | 68 | $accept_offer = false; |
69 | - } |
|
70 | - else |
|
69 | + } else |
|
71 | 70 | { |
72 | 71 | $accept_offer = true; |
73 | 72 | $negotiation = array( |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | 'alliance_negotiation_relation' => $alliance_negotiation_relation, |
79 | 78 | ); |
80 | 79 | } |
81 | -} |
|
82 | -else |
|
80 | +} else |
|
83 | 81 | { |
84 | 82 | $offer_id = sys_get_param_id('offer_id'); |
85 | 83 | if($offer_id) |
@@ -90,31 +88,26 @@ discard block |
||
90 | 88 | if(!$negotiation) |
91 | 89 | { |
92 | 90 | messageBox($lang['ali_dip_err_offer_none'], $page_title); |
93 | - } |
|
94 | - elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
91 | + } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
95 | 92 | { |
96 | 93 | // TODO: Add log of hack attempt |
97 | 94 | messageBox($lang['ali_dip_err_offer_alien'], $page_title); |
98 | - } |
|
99 | - elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
95 | + } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
100 | 96 | { |
101 | 97 | if($offer_answer == 'accept') |
102 | 98 | { |
103 | 99 | // TODO: Add log of hack attempt |
104 | 100 | messageBox($lang['ali_dip_err_offer_accept_own'], $page_title); |
105 | - } |
|
106 | - elseif($offer_answer == 'deny') |
|
101 | + } elseif($offer_answer == 'deny') |
|
107 | 102 | { |
108 | 103 | doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;"); |
109 | 104 | } |
110 | - } |
|
111 | - else |
|
105 | + } else |
|
112 | 106 | { |
113 | 107 | if($offer_answer == 'accept') |
114 | 108 | { |
115 | 109 | $accept_offer = true; |
116 | - } |
|
117 | - elseif($offer_answer == 'deny') |
|
110 | + } elseif($offer_answer == 'deny') |
|
118 | 111 | { |
119 | 112 | DBStaticAlly::db_ally_negotiation_update_status_1($offer_id); |
120 | 113 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | // Pretty Safe |
3 | 3 | // TODO: Add ally_tag to usertable |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
6 | 6 | { |
7 | 7 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
8 | 8 | } |
@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | $ally_name_raw = sys_get_param_str_unsafe('name'); |
13 | 13 | $ally_name = db_escape($ally_name_raw); |
14 | 14 | |
15 | -if($ally_tag) |
|
15 | +if ($ally_tag) |
|
16 | 16 | { |
17 | - if(!$ally_name_raw || !$ally_tag_raw) |
|
17 | + if (!$ally_name_raw || !$ally_tag_raw) |
|
18 | 18 | { |
19 | 19 | messageBox($lang['have_not_name'], $lang['make_alliance']); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $query = doquery("SELECT ally_tag FROM {{alliance}} WHERE `ally_tag` = '{$ally_tag}' or `ally_name` = '{$ally_name}' LIMIT 1;", true); |
23 | - if($query) |
|
23 | + if ($query) |
|
24 | 24 | { |
25 | 25 | messageBox(str_replace('%s', $query['ally_tag'] == $ally_tag_raw ? $ally_tag_raw : $ally_name_raw, $lang['always_exist']), $lang['make_alliance']); |
26 | 26 | } |
@@ -4,18 +4,18 @@ discard block |
||
4 | 4 | // @version 1.0 |
5 | 5 | // @copyright 2008 by Chlorel for XNova |
6 | 6 | |
7 | -if(SN_IN_FLEET !== true) { |
|
7 | +if (SN_IN_FLEET !== true) { |
|
8 | 8 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
9 | 9 | } |
10 | 10 | |
11 | 11 | $template = gettemplate('fleet1', true); |
12 | 12 | |
13 | 13 | $ships = sys_get_param('ships', array()); |
14 | -if(!is_array($ships)) { |
|
14 | +if (!is_array($ships)) { |
|
15 | 15 | $ships = array(); |
16 | 16 | } |
17 | 17 | |
18 | -foreach(array(PT_PLANET, PT_DEBRIS, PT_MOON) as $possible_planet_type_id) { |
|
18 | +foreach (array(PT_PLANET, PT_DEBRIS, PT_MOON) as $possible_planet_type_id) { |
|
19 | 19 | $template->assign_block_vars('possible_planet_type_id', array( |
20 | 20 | 'ID' => $possible_planet_type_id, |
21 | 21 | 'NAME' => $lang['sys_planet_type_sh'][$possible_planet_type_id], |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 'START_NAME' => $planetrow['name'], |
29 | 29 | ); |
30 | 30 | |
31 | -if(!empty($TargetPlanet)) { |
|
31 | +if (!empty($TargetPlanet)) { |
|
32 | 32 | $template_route += array( |
33 | 33 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
34 | 34 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $template->assign_block_vars('fleets', $template_route); |
40 | 40 | |
41 | 41 | $sn_groups_fleet = sn_get_groups('fleet'); |
42 | -foreach($ships as $ship_id => $ship_count) { |
|
43 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
42 | +foreach ($ships as $ship_id => $ship_count) { |
|
43 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
44 | 44 | $ship_info = get_unit_param($ship_id); |
45 | - if($ship_count > mrc_get_level($user, $planetrow, $ship_id, false, true)) { |
|
45 | + if ($ship_count > mrc_get_level($user, $planetrow, $ship_id, false, true)) { |
|
46 | 46 | $page .= $lang['fl_noenought']; |
47 | 47 | } else { |
48 | 48 | $fleet['fleetarray'][$ship_id] = $ship_count; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -if(empty($fleet['fleetarray'])) { |
|
64 | +if (empty($fleet['fleetarray'])) { |
|
65 | 65 | messageBox($lang['fl_err_no_ships'], $lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
66 | 66 | } |
67 | 67 | |
68 | 68 | // Building list of shortcuts |
69 | 69 | $query = doquery("SELECT * FROM {{notes}} WHERE `owner` = {$user['id']} AND `galaxy` <> 0 AND `system` <> 0 AND `planet` <> 0 ORDER BY `priority` DESC, `galaxy`, `system`, `planet`, `planet_type`;"); |
70 | -while($shortcut = db_fetch($query)) { |
|
70 | +while ($shortcut = db_fetch($query)) { |
|
71 | 71 | $template->assign_block_vars('shortcut', array( |
72 | 72 | 'NAME' => $shortcut['title'], |
73 | 73 | 'GALAXY' => $shortcut['galaxy'], |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Building list of own planets & moons |
84 | -$colonies = DBStaticPlanet::db_planet_list_sorted ( $user ); |
|
85 | -if(count($colonies) > 1) { |
|
84 | +$colonies = DBStaticPlanet::db_planet_list_sorted($user); |
|
85 | +if (count($colonies) > 1) { |
|
86 | 86 | // while($row = db_fetch($colonies)) |
87 | - foreach($colonies as $row) { |
|
87 | + foreach ($colonies as $row) { |
|
88 | 88 | $template->assign_block_vars('colonies', array( |
89 | 89 | 'NAME' => $row['name'], |
90 | 90 | 'GALAXY' => $row['galaxy'], |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | //ACS Start |
100 | 100 | //Need to look for acs attacks. |
101 | 101 | $aks_madnessred = doquery('SELECT * FROM {{aks}};'); |
102 | -while($row = db_fetch($aks_madnessred)) { |
|
102 | +while ($row = db_fetch($aks_madnessred)) { |
|
103 | 103 | $members = explode(',', $row['eingeladen']); |
104 | - foreach($members as $a => $b) { |
|
104 | + foreach ($members as $a => $b) { |
|
105 | 105 | if ($b == $user['id']) { |
106 | 106 | $template->assign_block_vars('acss', array( |
107 | 107 | 'ID' => $row['id'], |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | // @version 1.0 |
6 | 6 | // @copyright 2008 by Chlorel for XNova |
7 | 7 | |
8 | -if($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
8 | +if ($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
9 | 9 | define('IN_AJAX', true); |
10 | - if(!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
10 | + if (!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
11 | 11 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT, $fleet_ship_sort); |
12 | 12 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE, sys_get_param_id('fleet_ship_sort_inverse', 0)); |
13 | 13 | classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT] = $fleet_ship_sort; |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | die(); |
17 | 17 | } |
18 | 18 | |
19 | -if(SN_IN_FLEET !== true) { |
|
19 | +if (SN_IN_FLEET !== true) { |
|
20 | 20 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
21 | 21 | } |
22 | 22 | |
23 | 23 | lng_include('overview'); |
24 | 24 | |
25 | -if(!$planetrow) { |
|
25 | +if (!$planetrow) { |
|
26 | 26 | messageBox($lang['fl_noplanetrow'], $lang['fl_error']); |
27 | 27 | } |
28 | 28 | |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | $record_index = 0; |
32 | 32 | $ship_list = array(); |
33 | -foreach(sn_get_groups('fleet') as $n => $unit_id) { |
|
33 | +foreach (sn_get_groups('fleet') as $n => $unit_id) { |
|
34 | 34 | $unit_level = mrc_get_level($user, $planetrow, $unit_id, false, true); |
35 | - if($unit_level > 0) { |
|
35 | + if ($unit_level > 0) { |
|
36 | 36 | $ship_data = get_ship_data($unit_id, $user); |
37 | 37 | $ship_list[$unit_id] = array( |
38 | 38 | '__INDEX' => $record_index++, |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | $fleet_ship_sort = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT]; |
54 | 54 | $fleet_ship_sort_inverse = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]; |
55 | -if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
56 | - switch($fleet_ship_sort) { |
|
55 | +if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
56 | + switch ($fleet_ship_sort) { |
|
57 | 57 | case PLAYER_OPTION_SORT_NAME: $fleet_ship_sort_field = 'NAME'; break; |
58 | 58 | case PLAYER_OPTION_SORT_SPEED: $fleet_ship_sort_field = 'SPEED'; break; |
59 | 59 | case PLAYER_OPTION_SORT_COUNT: $fleet_ship_sort_field = 'AMOUNT'; break; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | }); |
69 | 69 | } |
70 | 70 | |
71 | -foreach($ship_list as $ship_data) { |
|
71 | +foreach ($ship_list as $ship_data) { |
|
72 | 72 | $template->assign_block_vars('ships', $ship_data); |
73 | 73 | } |
74 | 74 | |
75 | -foreach($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
75 | +foreach ($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
76 | 76 | $template->assign_block_vars('ship_sort_list', array( |
77 | 77 | 'VALUE' => $sort_id, |
78 | 78 | 'TEXT' => $sort_text, |