These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | fleet.php |
||
5 | Fleet manager |
||
6 | |||
7 | V3.3 copyright (c) 2009-2010 by Gorlum for http://supernova.ws |
||
8 | [~] Imploded fleet_back.php code |
||
9 | |||
10 | V3.2 copyright (c) 2009-2010 by Gorlum for http://supernova.ws |
||
11 | [~] separate independent chunks in INC-files |
||
12 | |||
13 | V3.1 copyright (c) 2009-2010 by Gorlum for http://supernova.ws |
||
14 | [~] Security checked & tested |
||
15 | |||
16 | V3.0 Updated by Gorlum Sep 2009 |
||
17 | [!] extracting templates from code |
||
18 | [~] some redundant code cleaning |
||
19 | |||
20 | V2.0 Updated by Chlorel. 16 Jan 2008 (String extraction, bug corrections, code uniformisation |
||
21 | |||
22 | V1.0 Created by Perberos. All rights reversed (C) 2006 |
||
23 | */ |
||
24 | |||
25 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
26 | $template_result = is_array($template_result) ? $template_result : array(); |
||
27 | |||
28 | define('SN_IN_FLEET', true); |
||
29 | |||
30 | require_once('includes/includes/flt_functions.php'); |
||
31 | |||
32 | lng_include('fleet'); |
||
33 | |||
34 | //$fleet_page = ($fleet_page = sys_get_param_int('fleet_page')) ? $fleet_page : sys_get_param_int('mode'); |
||
35 | $fleet_page = sys_get_param_int('fleet_page', sys_get_param_int('mode')); |
||
36 | |||
37 | $galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); |
||
38 | $system = sys_get_param_int('system', $planetrow['system']); |
||
39 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
||
40 | |||
41 | $target_mission = sys_get_param_int('target_mission'); |
||
42 | if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
||
43 | $planet_type = PT_PLANET; |
||
44 | } elseif($target_mission == MT_RECYCLE) { |
||
45 | $planet_type = PT_DEBRIS; |
||
46 | } elseif($target_mission == MT_DESTROY) { |
||
47 | $planet_type = PT_MOON; |
||
48 | } else { |
||
49 | $planet_type = sys_get_param_int('planet_type'); |
||
50 | if (!$planet_type) { |
||
51 | $planet_type = sys_get_param_int('planettype', $planetrow['planet_type']); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | $options = array(); |
||
56 | $options['fleets_max'] = GetMaxFleets($user); |
||
57 | |||
58 | $MaxFleets = GetMaxFleets($user); |
||
59 | $FlyingFleets = FleetList::fleet_count_flying($user['id']); |
||
60 | if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
||
61 | message(classLocale::$lang['fl_noslotfree'], classLocale::$lang['fl_error'], "fleet." . PHP_EX, 5); |
||
62 | } |
||
63 | |||
64 | $MaxExpeditions = get_player_max_expeditons($user); |
||
65 | if($MaxExpeditions) { |
||
66 | $FlyingExpeditions = FleetList::fleet_count_flying($user['id'], MT_EXPLORE); |
||
67 | } else { |
||
68 | $FlyingExpeditions = 0; |
||
69 | } |
||
70 | |||
71 | switch ($fleet_page) { |
||
72 | case 3: |
||
73 | |||
74 | case 2: |
||
75 | $fleet_group_mr = sys_get_param_id('fleet_group'); |
||
76 | $fleetarray = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet')))); |
||
77 | $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
||
78 | |||
79 | foreach($fleetarray as $ship_id => &$ship_amount) { |
||
80 | if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
||
81 | $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
||
82 | die(); |
||
83 | } |
||
84 | $ship_amount = floatval($ship_amount); |
||
85 | } |
||
86 | |||
87 | $UsedPlanet = false; |
||
88 | $YourPlanet = false; |
||
89 | $missiontype = array(); |
||
90 | if ($planet > $config->game_maxPlanet) { |
||
91 | $target_mission = MT_EXPLORE; |
||
92 | $missiontype[MT_EXPLORE] = classLocale::$lang['type_mission'][MT_EXPLORE]; |
||
93 | } elseif ($galaxy && $system && $planet) { |
||
94 | $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
||
95 | |||
96 | $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
||
97 | |||
98 | if ($TargetPlanet['id_owner']) { |
||
99 | $UsedPlanet = true; |
||
100 | if ($TargetPlanet['id_owner'] == $user['id']) { |
||
101 | $YourPlanet = true; |
||
102 | } |
||
103 | } |
||
104 | |||
105 | if (!$UsedPlanet) { |
||
106 | if ($fleetarray[SHIP_COLONIZER]) { |
||
107 | $missiontype[MT_COLONIZE] = classLocale::$lang['type_mission'][MT_COLONIZE]; |
||
108 | $target_mission = MT_COLONIZE; |
||
109 | $planet_type = PT_PLANET; |
||
110 | } else { |
||
111 | message ("<font color=\"red\"><b>". classLocale::$lang['fl_no_planet_type'] ."</b></font>", classLocale::$lang['fl_error']); |
||
112 | } |
||
113 | } else { |
||
114 | $recyclers = 0; |
||
115 | foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
||
116 | $recyclers += $fleetarray[$recycler_id]; |
||
117 | } |
||
118 | if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
||
119 | $target_mission = MT_RECYCLE; |
||
120 | $missiontype[MT_RECYCLE] = classLocale::$lang['type_mission'][MT_RECYCLE]; |
||
121 | } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) { |
||
122 | if ($YourPlanet) { |
||
123 | $missiontype[MT_RELOCATE] = classLocale::$lang['type_mission'][MT_RELOCATE]; |
||
124 | $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT]; |
||
125 | } else { |
||
126 | // Not Your Planet |
||
127 | if ($fleetarray[SHIP_SPY]) { |
||
128 | // Only spy missions if any spy |
||
129 | $missiontype[MT_SPY] = classLocale::$lang['type_mission'][MT_SPY]; |
||
130 | } else { |
||
131 | // If no spies... |
||
132 | if ($fleet_group_mr) { |
||
133 | $missiontype[MT_AKS] = classLocale::$lang['type_mission'][MT_AKS]; |
||
134 | } else { |
||
135 | $missiontype[MT_ATTACK] = classLocale::$lang['type_mission'][MT_ATTACK]; |
||
136 | $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT]; |
||
137 | |||
138 | $missiontype[MT_HOLD] = classLocale::$lang['type_mission'][MT_HOLD]; |
||
139 | |||
140 | if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
||
141 | $missiontype[MT_DESTROY] = classLocale::$lang['type_mission'][MT_DESTROY]; |
||
142 | } |
||
143 | } |
||
144 | } |
||
145 | } |
||
146 | } |
||
147 | } |
||
148 | } |
||
149 | |||
150 | if (!$target_mission && is_array($missiontype)) { |
||
151 | $target_mission = MT_ATTACK; |
||
152 | } |
||
153 | |||
154 | // $sn_group_missions = sn_get_groups('missions'); |
||
0 ignored issues
–
show
|
|||
155 | // foreach($sn_group_missions as $mission_id => $cork) { |
||
156 | // $missiontype[$mission_id] = $lang['type_mission'][$mission_id]; |
||
157 | // } |
||
158 | // |
||
159 | // |
||
160 | ksort($missiontype); |
||
161 | |||
162 | $speed_percent = sys_get_param_int('speed', 10); |
||
163 | $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent); |
||
164 | |||
165 | // $fleet_speed = flt_fleet_speed($user, $fleetarray); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
166 | $fleet_speed = $travel_data['fleet_speed']; |
||
167 | $distance = $travel_data['distance']; |
||
168 | $duration = $travel_data['duration']; |
||
169 | $consumption = $travel_data['consumption']; |
||
170 | // No Break |
||
171 | |||
172 | case 1: |
||
173 | if ($galaxy && $system && $planet) { |
||
174 | $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
||
175 | |||
176 | $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
||
177 | } |
||
178 | |||
179 | case 0: |
||
180 | $template_result += array( |
||
181 | 'thisgalaxy' => $planetrow['galaxy'], |
||
182 | 'thissystem' => $planetrow['system'], |
||
183 | 'thisplanet' => $planetrow['planet'], |
||
184 | 'thisplanet_type' => $planetrow['planet_type'], |
||
185 | ); |
||
186 | // no break |
||
187 | |||
188 | } |
||
189 | |||
190 | $template_result += array( |
||
191 | 'galaxy' => $galaxy, |
||
192 | 'system' => $system, |
||
193 | 'planet' => $planet, |
||
194 | 'planet_type' => $planet_type, |
||
195 | 'target_mission' => $target_mission ? $target_mission : 0, |
||
196 | 'MISSION_NAME' => $target_mission ? classLocale::$lang['type_mission'][$target_mission] : '', |
||
197 | ); |
||
198 | |||
199 | $is_transport_missions = false; |
||
200 | if($missiontype) { |
||
201 | $sn_group_missions = sn_get_groups('missions'); |
||
202 | foreach($missiontype as $mission_data_id => $mission_data) { |
||
203 | $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']); |
||
204 | } |
||
205 | } |
||
206 | |||
207 | switch($fleet_page) { |
||
208 | case 1: |
||
209 | require('includes/includes/flt_page1.inc'); |
||
210 | break; |
||
211 | |||
212 | case 2: |
||
213 | require_once('includes/includes/flt_page2.inc'); |
||
214 | sn_fleet_page2(); |
||
215 | break; |
||
216 | |||
217 | case 3: |
||
218 | require_once('includes/includes/flt_page3.inc'); |
||
219 | sn_fleet_page3($duration); |
||
220 | break; |
||
221 | |||
222 | case 4: |
||
223 | require('includes/includes/flt_page4.inc'); |
||
224 | break; |
||
225 | |||
226 | case 5: |
||
227 | require('includes/includes/flt_page5.inc'); |
||
228 | break; |
||
229 | |||
230 | default: |
||
231 | define('SN_RENDER_NAVBAR_PLANET', true); |
||
232 | |||
233 | require('includes/includes/flt_page0.inc'); |
||
234 | break; |
||
235 | } |
||
236 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.