supernova-ws /
SuperNova
| 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 | global $user, $planetrow, $lang; |
||||
| 26 | |||||
| 27 | use Fleet\DbFleetStatic; |
||||
| 28 | use Planet\DBStaticPlanet; |
||||
| 29 | |||||
| 30 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||||
| 31 | $template_result = is_array($template_result) ? $template_result : array(); |
||||
| 32 | |||||
| 33 | define('SN_IN_FLEET', true); |
||||
| 34 | |||||
| 35 | require_once('includes/includes/flt_functions.php'); |
||||
| 36 | |||||
| 37 | lng_include('fleet'); |
||||
| 38 | |||||
| 39 | //$fleet_page = ($fleet_page = sys_get_param_int('fleet_page')) ? $fleet_page : sys_get_param_int('mode'); |
||||
| 40 | $fleet_page = sys_get_param_int('fleet_page', sys_get_param_int('mode')); |
||||
| 41 | |||||
| 42 | $galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); |
||||
| 43 | $system = sys_get_param_int('system', $planetrow['system']); |
||||
| 44 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
||||
| 45 | |||||
| 46 | $target_mission = sys_get_param_int('target_mission'); |
||||
| 47 | if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
||||
| 48 | $planet_type = PT_PLANET; |
||||
| 49 | } elseif($target_mission == MT_RECYCLE) { |
||||
| 50 | $planet_type = PT_DEBRIS; |
||||
| 51 | } elseif($target_mission == MT_DESTROY) { |
||||
| 52 | $planet_type = PT_MOON; |
||||
| 53 | } else { |
||||
| 54 | $planet_type = sys_get_param_int('planet_type'); |
||||
| 55 | if (!$planet_type) { |
||||
| 56 | $planet_type = sys_get_param_int('planettype', $planetrow['planet_type']); |
||||
| 57 | } |
||||
| 58 | } |
||||
| 59 | |||||
| 60 | $options = array(); |
||||
| 61 | $options['fleets_max'] = GetMaxFleets($user); |
||||
| 62 | |||||
| 63 | $MaxFleets = GetMaxFleets($user); |
||||
| 64 | //$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", true); |
||||
| 65 | //$FlyingFleets = $FlyingFleets['Number']; |
||||
| 66 | $FlyingFleets = DbFleetStatic::fleet_count_flying($user['id']); |
||||
| 67 | if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
||||
| 68 | SnTemplate::messageBox($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5); |
||||
| 69 | } |
||||
| 70 | |||||
| 71 | $MaxExpeditions = get_player_max_expeditons($user); |
||||
| 72 | if($MaxExpeditions) { |
||||
| 73 | // $FlyingExpeditions = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true); |
||||
| 74 | // $FlyingExpeditions = $FlyingExpeditions['expedi']; |
||||
| 75 | $FlyingExpeditions = DbFleetStatic::fleet_count_flying($user['id'], MT_EXPLORE); |
||||
| 76 | } else { |
||||
| 77 | $FlyingExpeditions = 0; |
||||
| 78 | } |
||||
| 79 | |||||
| 80 | switch ($fleet_page) { |
||||
| 81 | case 3: |
||||
| 82 | |||||
| 83 | case 2: |
||||
| 84 | $fleet_group_mr = sys_get_param_id('fleet_group'); |
||||
| 85 | $fleetarray = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 86 | $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
||||
| 87 | |||||
| 88 | foreach($fleetarray as $ship_id => &$ship_amount) { |
||||
| 89 | if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
||||
| 90 | $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
||||
| 91 | die(); |
||||
| 92 | } |
||||
| 93 | $ship_amount = floatval($ship_amount); |
||||
| 94 | } |
||||
| 95 | |||||
| 96 | $UsedPlanet = false; |
||||
| 97 | $YourPlanet = false; |
||||
| 98 | $missiontype = array(); |
||||
| 99 | if ($planet > SN::$config->game_maxPlanet) { |
||||
| 100 | $target_mission = MT_EXPLORE; |
||||
| 101 | $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE]; |
||||
| 102 | } elseif ($galaxy && $system && $planet) { |
||||
| 103 | $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
||||
| 104 | |||||
| 105 | $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
||||
| 106 | |||||
| 107 | if ($TargetPlanet['id_owner']) { |
||||
| 108 | $UsedPlanet = true; |
||||
| 109 | if ($TargetPlanet['id_owner'] == $user['id']) { |
||||
| 110 | $YourPlanet = true; |
||||
| 111 | } |
||||
| 112 | } |
||||
| 113 | |||||
| 114 | if (!$UsedPlanet) { |
||||
| 115 | if ($fleetarray[SHIP_COLONIZER]) { |
||||
| 116 | $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE]; |
||||
| 117 | $target_mission = MT_COLONIZE; |
||||
| 118 | $planet_type = PT_PLANET; |
||||
| 119 | } else { |
||||
| 120 | SnTemplate::messageBox("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error']); |
||||
| 121 | } |
||||
| 122 | } else { |
||||
| 123 | $recyclers = 0; |
||||
| 124 | foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
||||
| 125 | $recyclers += $fleetarray[$recycler_id]; |
||||
| 126 | } |
||||
| 127 | if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
||||
| 128 | $target_mission = MT_RECYCLE; |
||||
| 129 | $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE]; |
||||
| 130 | } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) { |
||||
| 131 | if ($YourPlanet) { |
||||
| 132 | $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE]; |
||||
| 133 | $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT]; |
||||
| 134 | } else { |
||||
| 135 | // Not Your Planet |
||||
| 136 | if ($fleetarray[SHIP_SPY]) { |
||||
| 137 | // Only spy missions if any spy |
||||
| 138 | $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY]; |
||||
| 139 | } else { |
||||
| 140 | // If no spies... |
||||
| 141 | if ($fleet_group_mr) { |
||||
| 142 | $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS]; |
||||
| 143 | } else { |
||||
| 144 | $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK]; |
||||
| 145 | $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT]; |
||||
| 146 | |||||
| 147 | $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD]; |
||||
| 148 | |||||
| 149 | if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
||||
| 150 | $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY]; |
||||
| 151 | } |
||||
| 152 | } |
||||
| 153 | } |
||||
| 154 | } |
||||
| 155 | } |
||||
| 156 | } |
||||
| 157 | } |
||||
| 158 | |||||
| 159 | if (!$target_mission && is_array($missiontype)) { |
||||
| 160 | $target_mission = MT_ATTACK; |
||||
| 161 | } |
||||
| 162 | |||||
| 163 | // $sn_group_missions = sn_get_groups('missions'); |
||||
| 164 | // foreach($sn_group_missions as $mission_id => $cork) { |
||||
| 165 | // $missiontype[$mission_id] = $lang['type_mission'][$mission_id]; |
||||
| 166 | // } |
||||
| 167 | // |
||||
| 168 | // |
||||
| 169 | ksort($missiontype); |
||||
| 170 | |||||
| 171 | $speed_percent = sys_get_param_int('speed', 10); |
||||
| 172 | $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent); |
||||
| 173 | |||||
| 174 | // $fleet_speed = flt_fleet_speed($user, $fleetarray); |
||||
| 175 | $fleet_speed = $travel_data['fleet_speed']; |
||||
| 176 | $distance = $travel_data['distance']; |
||||
| 177 | $duration = $travel_data['duration']; |
||||
| 178 | $consumption = $travel_data['consumption']; |
||||
| 179 | // No Break |
||||
| 180 | |||||
| 181 | case 1: |
||||
| 182 | if ($galaxy && $system && $planet) { |
||||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||||
| 183 | $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
||||
| 184 | |||||
| 185 | $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
||||
| 186 | } |
||||
| 187 | |||||
| 188 | case 0: |
||||
| 189 | $template_result += array( |
||||
| 190 | 'thisgalaxy' => $planetrow['galaxy'], |
||||
| 191 | 'thissystem' => $planetrow['system'], |
||||
| 192 | 'thisplanet' => $planetrow['planet'], |
||||
| 193 | 'thisplanet_type' => $planetrow['planet_type'], |
||||
| 194 | ); |
||||
| 195 | // no break |
||||
| 196 | |||||
| 197 | } |
||||
| 198 | |||||
| 199 | $template_result += array( |
||||
| 200 | 'galaxy' => $galaxy, |
||||
| 201 | 'system' => $system, |
||||
| 202 | 'planet' => $planet, |
||||
| 203 | 'planet_type' => $planet_type, |
||||
| 204 | 'target_mission' => $target_mission ? $target_mission : 0, |
||||
| 205 | 'MISSION_NAME' => $target_mission ? $lang['type_mission'][$target_mission] : '', |
||||
| 206 | ); |
||||
| 207 | |||||
| 208 | $is_transport_missions = false; |
||||
| 209 | if($missiontype) { |
||||
| 210 | $sn_group_missions = sn_get_groups('missions'); |
||||
| 211 | foreach($missiontype as $mission_data_id => $mission_data) { |
||||
| 212 | $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']); |
||||
| 213 | } |
||||
| 214 | } |
||||
| 215 | |||||
| 216 | switch($fleet_page) { |
||||
| 217 | case 1: |
||||
| 218 | require('includes/includes/flt_page1.inc'); |
||||
| 219 | break; |
||||
| 220 | |||||
| 221 | case 2: |
||||
| 222 | require_once('includes/includes/flt_page2.inc'); |
||||
| 223 | sn_fleet_page2(); |
||||
| 224 | break; |
||||
| 225 | |||||
| 226 | case 3: |
||||
| 227 | require_once('includes/includes/flt_page3.inc'); |
||||
| 228 | sn_fleet_page3(); |
||||
| 229 | break; |
||||
| 230 | |||||
| 231 | case 4: |
||||
| 232 | require('includes/includes/flt_page4.inc'); |
||||
| 233 | break; |
||||
| 234 | |||||
| 235 | case 5: |
||||
| 236 | $template = SnTemplate::gettemplate('fleet5', true); |
||||
|
0 ignored issues
–
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 237 | $pageFleet5Gathering = new \Pages\Deprecated\PageFleet5Gathering(); |
||||
| 238 | $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template); |
||||
| 239 | // Building list of own planets & moons |
||||
| 240 | $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template); |
||||
| 241 | break; |
||||
| 242 | |||||
| 243 | default: |
||||
| 244 | define('SN_RENDER_NAVBAR_PLANET', true); |
||||
| 245 | |||||
| 246 | require('includes/includes/flt_page0.inc'); |
||||
| 247 | break; |
||||
| 248 | } |
||||
| 249 |