Complex classes like Spotter often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Spotter, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | class Spotter{ |
||
| 8 | public $db; |
||
| 9 | |||
| 10 | public function __construct($dbc = null) { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Get SQL query part for filter used |
||
| 17 | * @param Array $filter the filter |
||
| 18 | * @return Array the SQL part |
||
| 19 | */ |
||
| 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
||
| 21 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
||
| 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
||
| 23 | if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
||
| 24 | $filter_query_join = ''; |
||
| 25 | $filter_query_where = ''; |
||
| 26 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
||
| 27 | if ($filter['airlines'][0] != '') { |
||
| 28 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
||
| 33 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id "; |
||
| 34 | } |
||
| 35 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
||
| 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
||
| 37 | } |
||
| 38 | if (isset($filter['source']) && !empty($filter['source'])) { |
||
| 39 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
||
| 40 | } |
||
| 41 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
||
| 42 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
||
| 43 | } |
||
| 44 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
||
| 45 | if ($filter_query_where == '') { |
||
| 46 | $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
||
| 47 | } else { |
||
| 48 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
||
| 52 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
||
| 53 | $filter_query = $filter_query_join.$filter_query_where; |
||
| 54 | return $filter_query; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Executes the SQL statements to get the spotter information |
||
| 59 | * |
||
| 60 | * @param String $query the SQL query |
||
| 61 | * @param Array $params parameter of the query |
||
| 62 | * @param String $limitQuery the limit query |
||
| 63 | * @return Array the spotter information |
||
| 64 | * |
||
| 65 | */ |
||
| 66 | public function getDataFromDB($query, $params = array(), $limitQuery = '') |
||
| 67 | { |
||
| 68 | global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM; |
||
| 69 | $Image = new Image($this->db); |
||
| 70 | $Schedule = new Schedule($this->db); |
||
| 71 | $ACARS = new ACARS($this->db); |
||
| 72 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
||
| 73 | if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
||
| 74 | if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
||
| 75 | if (!isset($globalVAM)) $globalVAM = FALSE; |
||
| 76 | date_default_timezone_set('UTC'); |
||
| 77 | |||
| 78 | if (!is_string($query)) |
||
| 79 | { |
||
| 80 | return false; |
||
| 81 | } |
||
| 82 | |||
| 83 | if ($limitQuery != "") |
||
| 84 | { |
||
| 85 | if (!is_string($limitQuery)) |
||
| 86 | { |
||
| 87 | return false; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | |||
| 92 | try { |
||
| 93 | $sth = $this->db->prepare($query.$limitQuery); |
||
| 94 | $sth->execute($params); |
||
| 95 | } catch (PDOException $e) { |
||
| 96 | printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
||
| 97 | exit(); |
||
| 98 | } |
||
| 99 | |||
| 100 | // $num_rows = count($sth->fetchAll()); |
||
| 101 | $num_rows = 0; |
||
| 102 | |||
| 103 | $spotter_array = array(); |
||
| 104 | |||
| 105 | |||
| 106 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 107 | { |
||
| 108 | $num_rows++; |
||
| 109 | $temp_array = array(); |
||
| 110 | if (isset($row['spotter_live_id'])) { |
||
| 111 | //$temp_array['spotter_id'] = $row['spotter_live_id']; |
||
| 112 | $temp_array['spotter_id'] = $this->getSpotterIDBasedOnFlightAwareID($row['flightaware_id']); |
||
| 113 | } elseif (isset($row['spotter_archive_id'])) { |
||
| 114 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
||
| 115 | } elseif (isset($row['spotter_archive_output_id'])) { |
||
| 116 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
||
| 117 | } elseif (isset($row['spotter_id'])) { |
||
| 118 | $temp_array['spotter_id'] = $row['spotter_id']; |
||
| 119 | } else { |
||
| 120 | $temp_array['spotter_id'] = ''; |
||
| 121 | } |
||
| 122 | if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
||
| 123 | if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
||
| 124 | $temp_array['ident'] = $row['ident']; |
||
| 125 | if (isset($row['registration']) && $row['registration'] != '') { |
||
| 126 | $temp_array['registration'] = $row['registration']; |
||
| 127 | } elseif (isset($temp_array['modes'])) { |
||
| 128 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
||
| 129 | } else $temp_array['registration'] = ''; |
||
| 130 | if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
||
| 131 | |||
| 132 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
||
| 133 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
||
| 134 | if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
||
| 135 | if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
||
| 136 | if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
||
| 137 | /* |
||
| 138 | if (Connection->tableExists('countries')) { |
||
| 139 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
||
| 140 | if (is_array($country_info) && isset($country_info['name']) && isset($country_info['iso2'])) { |
||
| 141 | $temp_array['country'] = $country_info['name']; |
||
| 142 | $temp_array['country_iso2'] = $country_info['iso2']; |
||
| 143 | } |
||
| 144 | } |
||
| 145 | */ |
||
| 146 | if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
||
| 147 | if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
||
| 148 | if (isset($row['route_stop'])) { |
||
| 149 | $temp_array['route_stop'] = $row['route_stop']; |
||
| 150 | if ($row['route_stop'] != '') { |
||
| 151 | $allroute = explode(' ',$row['route_stop']); |
||
| 152 | |||
| 153 | foreach ($allroute as $route) { |
||
| 154 | $route_airport_array = $this->getAllAirportInfo($route); |
||
| 155 | if (isset($route_airport_array[0]['name'])) { |
||
| 156 | $route_stop_details = array(); |
||
| 157 | $route_stop_details['airport_name'] = $route_airport_array[0]['name']; |
||
| 158 | $route_stop_details['airport_city'] = $route_airport_array[0]['city']; |
||
| 159 | $route_stop_details['airport_country'] = $route_airport_array[0]['country']; |
||
| 160 | $route_stop_details['airport_icao'] = $route_airport_array[0]['icao']; |
||
| 161 | $temp_array['route_stop_details'][] = $route_stop_details; |
||
| 162 | } |
||
| 163 | } |
||
| 164 | } |
||
| 165 | } |
||
| 166 | if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
||
| 167 | if (isset($row['heading'])) { |
||
| 168 | $temp_array['heading'] = $row['heading']; |
||
| 169 | $heading_direction = $this->parseDirection($row['heading']); |
||
| 170 | if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
||
| 171 | } |
||
| 172 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
||
| 173 | $temp_array['image'] = ""; |
||
| 174 | $temp_array['image_thumbnail'] = ""; |
||
| 175 | $temp_array['image_source'] = ""; |
||
| 176 | $temp_array['image_copyright'] = ""; |
||
| 177 | |||
| 178 | if (isset($row['highlight'])) { |
||
| 179 | $temp_array['highlight'] = $row['highlight']; |
||
| 180 | } else $temp_array['highlight'] = ''; |
||
| 181 | |||
| 182 | if (isset($row['date'])) { |
||
| 183 | $dateArray = $this->parseDateString($row['date']); |
||
| 184 | if ($dateArray['seconds'] < 10) |
||
| 185 | { |
||
| 186 | $temp_array['date'] = "a few seconds ago"; |
||
| 187 | } elseif ($dateArray['seconds'] >= 5 && $dateArray['seconds'] < 30) |
||
| 188 | { |
||
| 189 | $temp_array['date'] = "half a minute ago"; |
||
| 190 | } elseif ($dateArray['seconds'] >= 30 && $dateArray['seconds'] < 60) |
||
| 191 | { |
||
| 192 | $temp_array['date'] = "about a minute ago"; |
||
| 193 | } elseif ($dateArray['minutes'] < 5) |
||
| 194 | { |
||
| 195 | $temp_array['date'] = "a few minutes ago"; |
||
| 196 | } elseif ($dateArray['minutes'] >= 5 && $dateArray['minutes'] < 60) |
||
| 197 | { |
||
| 198 | $temp_array['date'] = "about ".$dateArray['minutes']." minutes ago"; |
||
| 199 | } elseif ($dateArray['hours'] < 2) |
||
| 200 | { |
||
| 201 | $temp_array['date'] = "about an hour ago"; |
||
| 202 | } elseif ($dateArray['hours'] >= 2 && $dateArray['hours'] < 24) |
||
| 203 | { |
||
| 204 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
||
| 205 | } else { |
||
| 206 | $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
||
| 207 | } |
||
| 208 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
||
| 209 | $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
||
| 210 | $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
||
| 211 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
||
| 212 | } |
||
| 213 | |||
| 214 | if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') { |
||
| 215 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 216 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 217 | if (isset($row['aircraft_shadow'])) { |
||
| 218 | $temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
||
| 219 | } |
||
| 220 | } elseif (isset($row['aircraft_icao'])) { |
||
| 221 | $aircraft_array = $this->getAllAircraftInfo($row['aircraft_icao']); |
||
| 222 | if (count($aircraft_array) > 0) { |
||
| 223 | $temp_array['aircraft_name'] = $aircraft_array[0]['type']; |
||
| 224 | $temp_array['aircraft_manufacturer'] = $aircraft_array[0]['manufacturer']; |
||
| 225 | |||
| 226 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
||
| 227 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
||
| 228 | } else $temp_array['aircraft_shadow'] = 'default.png'; |
||
| 229 | } else { |
||
| 230 | $temp_array['aircraft_shadow'] = 'default.png'; |
||
| 231 | $temp_array['aircraft_name'] = 'N/A'; |
||
| 232 | $temp_array['aircraft_manufacturer'] = 'N/A'; |
||
| 233 | } |
||
| 234 | } |
||
| 235 | $fromsource = NULL; |
||
| 236 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
||
| 237 | elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
||
| 238 | elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
||
| 239 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
||
| 240 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
||
| 241 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
||
| 242 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
||
| 243 | if (is_numeric(substr($row['ident'], 2, 1))) { |
||
| 244 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource); |
||
| 245 | } elseif (is_numeric(substr($row['ident'], 3, 1))) { |
||
| 246 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
||
| 247 | } else { |
||
| 248 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 249 | } |
||
| 250 | } else { |
||
| 251 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 252 | } |
||
| 253 | if (count($airline_array) > 0) { |
||
| 254 | $temp_array['airline_icao'] = $airline_array[0]['icao']; |
||
| 255 | $temp_array['airline_iata'] = $airline_array[0]['iata']; |
||
| 256 | $temp_array['airline_name'] = $airline_array[0]['name']; |
||
| 257 | $temp_array['airline_country'] = $airline_array[0]['country']; |
||
| 258 | $temp_array['airline_callsign'] = $airline_array[0]['callsign']; |
||
| 259 | $temp_array['airline_type'] = $airline_array[0]['type']; |
||
| 260 | } |
||
| 261 | } else { |
||
| 262 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 263 | if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
||
| 264 | else $temp_array['airline_iata'] = ''; |
||
| 265 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 266 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 267 | if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
||
| 268 | else $temp_array['airline_callsign'] = 'N/A'; |
||
| 269 | $temp_array['airline_type'] = $row['airline_type']; |
||
| 270 | } |
||
| 271 | if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
||
| 272 | $acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3)); |
||
| 273 | //$acars_array = ACARS->getLiveAcarsData('BA40YL'); |
||
| 274 | if (count($acars_array) > 0) { |
||
| 275 | $temp_array['acars'] = $acars_array; |
||
| 276 | //print_r($acars_array); |
||
| 277 | } |
||
| 278 | } |
||
| 279 | if (isset($row['owner_name']) && $row['owner_name'] != '' && $row['owner_name'] != NULL) { |
||
| 280 | $temp_array['aircraft_owner'] = $row['owner_name']; |
||
| 281 | } |
||
| 282 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
||
| 283 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
||
| 284 | if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
||
| 285 | $temp_array['aircraft_base'] = $owner_info['base']; |
||
| 286 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
||
| 287 | } |
||
| 288 | |||
| 289 | if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
||
| 290 | { |
||
| 291 | if ($globalIVAO) { |
||
| 292 | if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
||
| 293 | else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
||
| 294 | } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
||
| 295 | if (count($image_array) > 0) { |
||
| 296 | $temp_array['image'] = $image_array[0]['image']; |
||
| 297 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 298 | $temp_array['image_source'] = $image_array[0]['image_source']; |
||
| 299 | $temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
||
| 300 | if ($temp_array['image_source_website'] == '' && $temp_array['image_source'] == 'planespotters') { |
||
| 301 | $planespotter_url_array = explode("_", $temp_array['image']); |
||
| 302 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
||
| 303 | $temp_array['image_source_website'] = 'http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
||
| 304 | } |
||
| 305 | $temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
||
| 306 | } |
||
| 307 | } |
||
| 308 | |||
| 309 | |||
| 310 | if (isset($row['departure_airport_time']) && $row['departure_airport_time'] != '') { |
||
| 311 | $temp_array['departure_airport_time'] = $row['departure_airport_time']; |
||
| 312 | } |
||
| 313 | if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') { |
||
| 314 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
||
| 315 | } |
||
| 316 | if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
||
| 317 | $schedule_array = $Schedule->getSchedule($temp_array['ident']); |
||
| 318 | //print_r($schedule_array); |
||
| 319 | if (count($schedule_array) > 0) { |
||
| 320 | if ($schedule_array['departure_airport_icao'] != '') { |
||
| 321 | $row['departure_airport_icao'] = $schedule_array['departure_airport_icao']; |
||
| 322 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
||
| 323 | } |
||
| 324 | if ($schedule_array['arrival_airport_icao'] != '') { |
||
| 325 | $row['arrival_airport_icao'] = $schedule_array['arrival_airport_icao']; |
||
| 326 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
||
| 327 | } |
||
| 328 | |||
| 329 | $temp_array['departure_airport_time'] = $schedule_array['departure_airport_time']; |
||
| 330 | $temp_array['arrival_airport_time'] = $schedule_array['arrival_airport_time']; |
||
| 331 | } |
||
| 332 | } else { |
||
| 333 | if (isset($row['real_departure_airport_time']) && $row['real_departure_airport_time'] != '') { |
||
| 334 | $temp_array['departure_airport_time'] = $row['real_departure_airport_time']; |
||
| 335 | } |
||
| 336 | if (isset($row['real_arrival_airport_time']) && $row['real_arrival_airport_time'] != '') { |
||
| 337 | $temp_array['real_arrival_airport_time'] = $row['real_arrival_airport_time']; |
||
| 338 | } |
||
| 339 | } |
||
| 340 | |||
| 341 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
||
| 342 | if ($row['departure_airport_icao'] != '') { |
||
| 343 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
||
| 344 | if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 345 | /* |
||
| 346 | } elseif ($row['departure_airport_name'] != '') { |
||
| 347 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
||
| 348 | $temp_array['departure_airport_city'] = $row['departure_airport_city']; |
||
| 349 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 350 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
||
| 351 | */ |
||
| 352 | } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 353 | if (isset($departure_airport_array[0]['name'])) { |
||
| 354 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
||
| 355 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
||
| 356 | $temp_array['departure_airport_country'] = $departure_airport_array[0]['country']; |
||
| 357 | $temp_array['departure_airport_iata'] = $departure_airport_array[0]['iata']; |
||
| 358 | $temp_array['departure_airport_icao'] = $departure_airport_array[0]['icao']; |
||
| 359 | $temp_array['departure_airport_latitude'] = $departure_airport_array[0]['latitude']; |
||
| 360 | $temp_array['departure_airport_longitude'] = $departure_airport_array[0]['longitude']; |
||
| 361 | $temp_array['departure_airport_altitude'] = $departure_airport_array[0]['altitude']; |
||
| 362 | } |
||
| 363 | |||
| 364 | /* |
||
| 365 | if (isset($row['departure_airport_time'])) { |
||
| 366 | $temp_array['departure_airport_time'] = $row['departure_airport_time']; |
||
| 367 | } |
||
| 368 | */ |
||
| 369 | |||
| 370 | if ($row['arrival_airport_icao'] != '') { |
||
| 371 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
||
| 372 | if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 373 | } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 374 | if (isset($arrival_airport_array[0]['name'])) { |
||
| 375 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
||
| 376 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
||
| 377 | $temp_array['arrival_airport_country'] = $arrival_airport_array[0]['country']; |
||
| 378 | $temp_array['arrival_airport_iata'] = $arrival_airport_array[0]['iata']; |
||
| 379 | $temp_array['arrival_airport_icao'] = $arrival_airport_array[0]['icao']; |
||
| 380 | $temp_array['arrival_airport_latitude'] = $arrival_airport_array[0]['latitude']; |
||
| 381 | $temp_array['arrival_airport_longitude'] = $arrival_airport_array[0]['longitude']; |
||
| 382 | $temp_array['arrival_airport_altitude'] = $arrival_airport_array[0]['altitude']; |
||
| 383 | } |
||
| 384 | /* |
||
| 385 | if (isset($row['arrival_airport_time'])) { |
||
| 386 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
||
| 387 | } |
||
| 388 | */ |
||
| 389 | if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 390 | if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 391 | if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
||
| 392 | if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
||
| 393 | if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
||
| 394 | if (isset($row['squawk'])) { |
||
| 395 | $temp_array['squawk'] = $row['squawk']; |
||
| 396 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
||
| 397 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
||
| 398 | if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 399 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
||
| 400 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
||
| 401 | if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 402 | } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 403 | } |
||
| 404 | |||
| 405 | $temp_array['query_number_rows'] = $num_rows; |
||
| 406 | |||
| 407 | $spotter_array[] = $temp_array; |
||
| 408 | } |
||
| 409 | if ($num_rows == 0) return array(); |
||
| 410 | $spotter_array[0]['query_number_rows'] = $num_rows; |
||
| 411 | return $spotter_array; |
||
| 412 | } |
||
| 413 | |||
| 414 | |||
| 415 | /** |
||
| 416 | * Gets all the spotter information |
||
| 417 | * |
||
| 418 | * @return Array the spotter information |
||
| 419 | * |
||
| 420 | */ |
||
| 421 | public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filter = array()) |
||
| 422 | { |
||
| 423 | global $globalTimezone, $globalDBdriver; |
||
| 424 | require_once(dirname(__FILE__).'/class.Translation.php'); |
||
| 425 | $Translation = new Translation(); |
||
| 426 | |||
| 427 | date_default_timezone_set('UTC'); |
||
| 428 | |||
| 429 | $query_values = array(); |
||
| 430 | $additional_query = ''; |
||
| 431 | $filter_query = $this->getFilter($filter,true,true); |
||
| 432 | if ($q != "") |
||
| 433 | { |
||
| 434 | if (!is_string($q)) |
||
| 435 | { |
||
| 436 | return false; |
||
| 437 | } else { |
||
| 438 | $q_array = explode(" ", $q); |
||
| 439 | foreach ($q_array as $q_item){ |
||
| 440 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
||
| 441 | $additional_query .= " AND ("; |
||
| 442 | if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
||
| 443 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
||
| 444 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
||
| 445 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
||
| 446 | $additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
||
| 447 | $additional_query .= "(spotter_output.airline_name like '%".$q_item."%') OR "; |
||
| 448 | $additional_query .= "(spotter_output.airline_country like '%".$q_item."%') OR "; |
||
| 449 | $additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
||
| 450 | $additional_query .= "(spotter_output.departure_airport_name like '%".$q_item."%') OR "; |
||
| 451 | $additional_query .= "(spotter_output.departure_airport_city like '%".$q_item."%') OR "; |
||
| 452 | $additional_query .= "(spotter_output.departure_airport_country like '%".$q_item."%') OR "; |
||
| 453 | $additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
||
| 454 | $additional_query .= "(spotter_output.arrival_airport_name like '%".$q_item."%') OR "; |
||
| 455 | $additional_query .= "(spotter_output.arrival_airport_city like '%".$q_item."%') OR "; |
||
| 456 | $additional_query .= "(spotter_output.arrival_airport_country like '%".$q_item."%') OR "; |
||
| 457 | $additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
||
| 458 | $additional_query .= "(spotter_output.owner_name like '%".$q_item."%') OR "; |
||
| 459 | $additional_query .= "(spotter_output.pilot_id like '%".$q_item."%') OR "; |
||
| 460 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
||
| 461 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
||
| 462 | $translate = $Translation->ident2icao($q_item); |
||
| 463 | if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
||
| 464 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
||
| 465 | $additional_query .= ")"; |
||
| 466 | } |
||
| 467 | } |
||
| 468 | } |
||
| 469 | |||
| 470 | if ($registration != "") |
||
| 471 | { |
||
| 472 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 473 | if (!is_string($registration)) |
||
| 474 | { |
||
| 475 | return false; |
||
| 476 | } else { |
||
| 477 | $additional_query .= " AND spotter_output.registration = :registration"; |
||
| 478 | $query_values = array_merge($query_values,array(':registration' => $registration)); |
||
| 479 | } |
||
| 480 | } |
||
| 481 | |||
| 482 | if ($aircraft_icao != "") |
||
| 483 | { |
||
| 484 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 485 | if (!is_string($aircraft_icao)) |
||
| 486 | { |
||
| 487 | return false; |
||
| 488 | } else { |
||
| 489 | $additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao"; |
||
| 490 | $query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao)); |
||
| 491 | } |
||
| 492 | } |
||
| 493 | |||
| 494 | if ($aircraft_manufacturer != "") |
||
| 495 | { |
||
| 496 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 497 | if (!is_string($aircraft_manufacturer)) |
||
| 498 | { |
||
| 499 | return false; |
||
| 500 | } else { |
||
| 501 | $additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer"; |
||
| 502 | $query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 503 | } |
||
| 504 | } |
||
| 505 | |||
| 506 | if ($highlights == "true") |
||
| 507 | { |
||
| 508 | if (!is_string($highlights)) |
||
| 509 | { |
||
| 510 | return false; |
||
| 511 | } else { |
||
| 512 | $additional_query .= " AND (spotter_output.highlight <> '')"; |
||
| 513 | } |
||
| 514 | } |
||
| 515 | |||
| 516 | if ($airline_icao != "") |
||
| 517 | { |
||
| 518 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 519 | if (!is_string($airline_icao)) |
||
| 520 | { |
||
| 521 | return false; |
||
| 522 | } else { |
||
| 523 | $additional_query .= " AND spotter_output.airline_icao = :airline_icao"; |
||
| 524 | $query_values = array_merge($query_values,array(':airline_icao' => $airline_icao)); |
||
| 525 | } |
||
| 526 | } |
||
| 527 | |||
| 528 | if ($airline_country != "") |
||
| 529 | { |
||
| 530 | $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
||
| 531 | if (!is_string($airline_country)) |
||
| 532 | { |
||
| 533 | return false; |
||
| 534 | } else { |
||
| 535 | $additional_query .= " AND spotter_output.airline_country = :airline_country"; |
||
| 536 | $query_values = array_merge($query_values,array(':airline_country' => $airline_country)); |
||
| 537 | } |
||
| 538 | } |
||
| 539 | |||
| 540 | if ($airline_type != "") |
||
| 541 | { |
||
| 542 | if (!is_string($airline_type)) |
||
| 543 | { |
||
| 544 | return false; |
||
| 545 | } else { |
||
| 546 | if ($airline_type == "passenger") |
||
| 547 | { |
||
| 548 | $additional_query .= " AND (spotter_output.airline_type = 'passenger')"; |
||
| 549 | } |
||
| 550 | if ($airline_type == "cargo") |
||
| 551 | { |
||
| 552 | $additional_query .= " AND (spotter_output.airline_type = 'cargo')"; |
||
| 553 | } |
||
| 554 | if ($airline_type == "military") |
||
| 555 | { |
||
| 556 | $additional_query .= " AND (spotter_output.airline_type = 'military')"; |
||
| 557 | } |
||
| 558 | } |
||
| 559 | } |
||
| 560 | |||
| 561 | if ($airport != "") |
||
| 562 | { |
||
| 563 | $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
||
| 564 | if (!is_string($airport)) |
||
| 565 | { |
||
| 566 | return false; |
||
| 567 | } else { |
||
| 568 | $additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)"; |
||
| 569 | $query_values = array_merge($query_values,array(':airport' => $airport)); |
||
| 570 | } |
||
| 571 | } |
||
| 572 | |||
| 573 | if ($airport_country != "") |
||
| 574 | { |
||
| 575 | $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
||
| 576 | if (!is_string($airport_country)) |
||
| 577 | { |
||
| 578 | return false; |
||
| 579 | } else { |
||
| 580 | $additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)"; |
||
| 581 | $query_values = array_merge($query_values,array(':airport_country' => $airport_country)); |
||
| 582 | } |
||
| 583 | } |
||
| 584 | |||
| 585 | if ($callsign != "") |
||
| 586 | { |
||
| 587 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
||
| 588 | if (!is_string($callsign)) |
||
| 589 | { |
||
| 590 | return false; |
||
| 591 | } else { |
||
| 592 | $translate = $Translation->ident2icao($callsign); |
||
| 593 | if ($translate != $callsign) { |
||
| 594 | $additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)"; |
||
| 595 | $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
||
| 596 | } else { |
||
| 597 | $additional_query .= " AND spotter_output.ident = :callsign"; |
||
| 598 | $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
||
| 599 | } |
||
| 600 | } |
||
| 601 | } |
||
| 602 | |||
| 603 | if ($owner != "") |
||
| 604 | { |
||
| 605 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 606 | if (!is_string($owner)) |
||
| 607 | { |
||
| 608 | return false; |
||
| 609 | } else { |
||
| 610 | $additional_query .= " AND spotter_output.owner_name = :owner"; |
||
| 611 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 612 | } |
||
| 613 | } |
||
| 614 | |||
| 615 | if ($pilot_name != "") |
||
| 616 | { |
||
| 617 | $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
||
| 618 | if (!is_string($pilot_name)) |
||
| 619 | { |
||
| 620 | return false; |
||
| 621 | } else { |
||
| 622 | $additional_query .= " AND spotter_output.pilot_name = :pilot_name"; |
||
| 623 | $query_values = array_merge($query_values,array(':pilot_name' => $pilot_name)); |
||
| 624 | } |
||
| 625 | } |
||
| 626 | |||
| 627 | if ($pilot_id != "") |
||
| 628 | { |
||
| 629 | $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
||
| 630 | if (!is_string($pilot_id)) |
||
| 631 | { |
||
| 632 | return false; |
||
| 633 | } else { |
||
| 634 | $additional_query .= " AND spotter_output.pilot_id = :pilot_id"; |
||
| 635 | $query_values = array_merge($query_values,array(':pilot_id' => $pilot_id)); |
||
| 636 | } |
||
| 637 | } |
||
| 638 | |||
| 639 | if ($departure_airport_route != "") |
||
| 640 | { |
||
| 641 | $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
||
| 642 | if (!is_string($departure_airport_route)) |
||
| 643 | { |
||
| 644 | return false; |
||
| 645 | } else { |
||
| 646 | $additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route"; |
||
| 647 | $query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route)); |
||
| 648 | } |
||
| 649 | } |
||
| 650 | |||
| 651 | if ($arrival_airport_route != "") |
||
| 652 | { |
||
| 653 | $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
||
| 654 | if (!is_string($arrival_airport_route)) |
||
| 655 | { |
||
| 656 | return false; |
||
| 657 | } else { |
||
| 658 | $additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route"; |
||
| 659 | $query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route)); |
||
| 660 | } |
||
| 661 | } |
||
| 662 | |||
| 663 | if ($altitude != "") |
||
| 664 | { |
||
| 665 | $altitude_array = explode(",", $altitude); |
||
| 666 | $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 667 | $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 668 | |||
| 669 | if ($altitude_array[1] != "") |
||
| 670 | { |
||
| 671 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
||
| 672 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
||
| 673 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
||
| 674 | } else { |
||
| 675 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
||
| 676 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
||
| 677 | } |
||
| 678 | } |
||
| 679 | |||
| 680 | if ($date_posted != "") |
||
| 681 | { |
||
| 682 | $date_array = explode(",", $date_posted); |
||
| 683 | $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
||
| 684 | $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
||
| 685 | |||
| 686 | if ($globalTimezone != '') { |
||
| 687 | date_default_timezone_set($globalTimezone); |
||
| 688 | $datetime = new DateTime(); |
||
| 689 | $offset = $datetime->format('P'); |
||
| 690 | } else $offset = '+00:00'; |
||
| 691 | |||
| 692 | if ($date_array[1] != "") |
||
| 693 | { |
||
| 694 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
||
| 695 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
||
| 696 | if ($globalDBdriver == 'mysql') { |
||
| 697 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
||
| 698 | } else { |
||
| 699 | $additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) <= '".$date_array[1]."' "; |
||
| 700 | } |
||
| 701 | } else { |
||
| 702 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
||
| 703 | if ($globalDBdriver == 'mysql') { |
||
| 704 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
||
| 705 | } else { |
||
| 706 | $additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' "; |
||
| 707 | } |
||
| 708 | } |
||
| 709 | } |
||
| 710 | |||
| 711 | if ($limit != "") |
||
| 712 | { |
||
| 713 | $limit_array = explode(",", $limit); |
||
| 714 | |||
| 715 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 716 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 717 | |||
| 718 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 719 | { |
||
| 720 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 721 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 722 | } else $limit_query = ""; |
||
| 723 | } else $limit_query = ""; |
||
| 724 | |||
| 725 | |||
| 726 | if ($sort != "") |
||
| 727 | { |
||
| 728 | $search_orderby_array = $this->getOrderBy(); |
||
| 729 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 730 | } else { |
||
| 731 | if ($origLat != "" && $origLon != "" && $dist != "") { |
||
| 732 | $orderby_query = " ORDER BY distance ASC"; |
||
| 733 | } else { |
||
| 734 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 735 | } |
||
| 736 | } |
||
| 737 | |||
| 738 | if ($includegeodata == "true") |
||
| 739 | { |
||
| 740 | $additional_query .= " AND spotter_output.waypoints <> ''"; |
||
| 741 | } |
||
| 742 | |||
| 743 | |||
| 744 | if ($origLat != "" && $origLon != "" && $dist != "") { |
||
| 745 | $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
||
| 746 | |||
| 747 | if ($globalDBdriver == 'mysql') { |
||
| 748 | $query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance |
||
| 749 | FROM spotter_output, spotter_archive".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
||
| 750 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
||
| 751 | } else { |
||
| 752 | $query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
||
| 753 | FROM spotter_output, spotter_archive".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
||
| 754 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
||
| 755 | } |
||
| 756 | } else { |
||
| 757 | $query = "SELECT spotter_output.* FROM spotter_output ".$filter_query." spotter_output.ident <> '' |
||
| 758 | ".$additional_query." |
||
| 759 | ".$orderby_query; |
||
| 760 | } |
||
| 761 | $spotter_array = $this->getDataFromDB($query, $query_values,$limit_query); |
||
| 762 | return $spotter_array; |
||
| 763 | } |
||
| 764 | |||
| 765 | |||
| 766 | /** |
||
| 767 | * Gets all the spotter information based on the latest data entry |
||
| 768 | * |
||
| 769 | * @return Array the spotter information |
||
| 770 | * |
||
| 771 | */ |
||
| 772 | public function getLatestSpotterData($limit = '', $sort = '', $filter = array()) |
||
| 773 | { |
||
| 774 | global $global_query; |
||
| 775 | |||
| 776 | date_default_timezone_set('UTC'); |
||
| 777 | |||
| 778 | $filter_query = $this->getFilter($filter); |
||
| 779 | |||
| 780 | if ($limit != "") |
||
| 781 | { |
||
| 782 | $limit_array = explode(",", $limit); |
||
| 783 | |||
| 784 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 785 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 786 | |||
| 787 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 788 | { |
||
| 789 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 790 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 791 | } else $limit_query = ""; |
||
| 792 | } else $limit_query = ""; |
||
| 793 | |||
| 794 | if ($sort != "") |
||
| 795 | { |
||
| 796 | $search_orderby_array = $this->getOrderBy(); |
||
| 797 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 798 | } else { |
||
| 799 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 800 | } |
||
| 801 | |||
| 802 | $query = $global_query.$filter_query." ".$orderby_query; |
||
| 803 | |||
| 804 | $spotter_array = $this->getDataFromDB($query, array(),$limit_query); |
||
| 805 | |||
| 806 | return $spotter_array; |
||
| 807 | } |
||
| 808 | |||
| 809 | |||
| 810 | /** |
||
| 811 | * Gets all the spotter information based on a user's latitude and longitude |
||
| 812 | * |
||
| 813 | * @return Array the spotter information |
||
| 814 | * |
||
| 815 | */ |
||
| 816 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
||
| 817 | { |
||
| 818 | date_default_timezone_set('UTC'); |
||
| 819 | $limit_query = ''; |
||
| 820 | if ($lat != "") |
||
| 821 | { |
||
| 822 | if (!is_numeric($lat)) |
||
| 823 | { |
||
| 824 | return false; |
||
| 825 | } |
||
| 826 | } |
||
| 827 | |||
| 828 | if ($lng != "") |
||
| 829 | { |
||
| 830 | if (!is_numeric($lng)) |
||
| 831 | { |
||
| 832 | return false; |
||
| 833 | } |
||
| 834 | } |
||
| 835 | |||
| 836 | if ($radius != "") |
||
| 837 | { |
||
| 838 | if (!is_numeric($radius)) |
||
| 839 | { |
||
| 840 | return false; |
||
| 841 | } |
||
| 842 | } |
||
| 843 | $additional_query = ''; |
||
| 844 | if ($interval != "") |
||
| 845 | { |
||
| 846 | if (!is_string($interval)) |
||
| 847 | { |
||
| 848 | return false; |
||
| 849 | } else { |
||
| 850 | if ($interval == "30m"){ |
||
| 851 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date '; |
||
| 852 | } else if ($interval == "1h"){ |
||
| 853 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date '; |
||
| 854 | } else if ($interval == "3h"){ |
||
| 855 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date '; |
||
| 856 | } else if ($interval == "6h"){ |
||
| 857 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date '; |
||
| 858 | } else if ($interval == "12h"){ |
||
| 859 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date '; |
||
| 860 | } else if ($interval == "24h"){ |
||
| 861 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date '; |
||
| 862 | } else if ($interval == "7d"){ |
||
| 863 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date '; |
||
| 864 | } else if ($interval == "30d"){ |
||
| 865 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date '; |
||
| 866 | } |
||
| 867 | } |
||
| 868 | } |
||
| 869 | |||
| 870 | $query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output |
||
| 871 | WHERE spotter_output.latitude <> '' |
||
| 872 | AND spotter_output.longitude <> '' |
||
| 873 | ".$additional_query." |
||
| 874 | HAVING distance < :radius |
||
| 875 | ORDER BY distance"; |
||
| 876 | |||
| 877 | $spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query); |
||
| 878 | |||
| 879 | return $spotter_array; |
||
| 880 | } |
||
| 881 | |||
| 882 | |||
| 883 | /** |
||
| 884 | * Gets all the spotter information sorted by the newest aircraft type |
||
| 885 | * |
||
| 886 | * @return Array the spotter information |
||
| 887 | * |
||
| 888 | */ |
||
| 889 | public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array()) |
||
| 890 | { |
||
| 891 | global $global_query; |
||
| 892 | |||
| 893 | date_default_timezone_set('UTC'); |
||
| 894 | |||
| 895 | $filter_query = $this->getFilter($filter,true,true); |
||
| 896 | |||
| 897 | $limit_query = ''; |
||
| 898 | if ($limit != "") |
||
| 899 | { |
||
| 900 | $limit_array = explode(",", $limit); |
||
| 901 | |||
| 902 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 903 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 904 | |||
| 905 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 906 | { |
||
| 907 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 908 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 909 | } |
||
| 910 | } |
||
| 911 | |||
| 912 | if ($sort != "") |
||
| 913 | { |
||
| 914 | $search_orderby_array = $this->getOrderBy(); |
||
| 915 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 916 | } else { |
||
| 917 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 918 | } |
||
| 919 | |||
| 920 | $query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
||
| 921 | |||
| 922 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 923 | |||
| 924 | return $spotter_array; |
||
| 925 | } |
||
| 926 | |||
| 927 | |||
| 928 | /** |
||
| 929 | * Gets all the spotter information sorted by the newest aircraft registration |
||
| 930 | * |
||
| 931 | * @return Array the spotter information |
||
| 932 | * |
||
| 933 | */ |
||
| 934 | public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array()) |
||
| 935 | { |
||
| 936 | global $global_query; |
||
| 937 | |||
| 938 | date_default_timezone_set('UTC'); |
||
| 939 | $filter_query = $this->getFilter($filter,true,true); |
||
| 940 | |||
| 941 | $limit_query = ''; |
||
| 942 | if ($limit != "") |
||
| 943 | { |
||
| 944 | $limit_array = explode(",", $limit); |
||
| 945 | |||
| 946 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 947 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 948 | |||
| 949 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 950 | { |
||
| 951 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 952 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 953 | } |
||
| 954 | } |
||
| 955 | |||
| 956 | if ($sort != "") |
||
| 957 | { |
||
| 958 | $search_orderby_array = $this->getOrderBy(); |
||
| 959 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 960 | } else { |
||
| 961 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 962 | } |
||
| 963 | |||
| 964 | $query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
||
| 965 | |||
| 966 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 967 | |||
| 968 | return $spotter_array; |
||
| 969 | } |
||
| 970 | |||
| 971 | |||
| 972 | /** |
||
| 973 | * Gets all the spotter information sorted by the newest airline |
||
| 974 | * |
||
| 975 | * @return Array the spotter information |
||
| 976 | * |
||
| 977 | */ |
||
| 978 | public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array()) |
||
| 979 | { |
||
| 980 | global $global_query; |
||
| 981 | |||
| 982 | date_default_timezone_set('UTC'); |
||
| 983 | $filter_query = $this->getFilter($filter,true,true); |
||
| 984 | |||
| 985 | $limit_query = ''; |
||
| 986 | if ($limit != "") |
||
| 987 | { |
||
| 988 | $limit_array = explode(",", $limit); |
||
| 989 | |||
| 990 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 991 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 992 | |||
| 993 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 994 | { |
||
| 995 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 996 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 997 | } |
||
| 998 | } |
||
| 999 | |||
| 1000 | if ($sort != "") |
||
| 1001 | { |
||
| 1002 | $search_orderby_array = $this->getOrderBy(); |
||
| 1003 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1004 | } else { |
||
| 1005 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1006 | } |
||
| 1007 | |||
| 1008 | $query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
||
| 1009 | |||
| 1010 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1011 | |||
| 1012 | return $spotter_array; |
||
| 1013 | } |
||
| 1014 | |||
| 1015 | |||
| 1016 | /** |
||
| 1017 | * Gets all the spotter information sorted by the newest departure airport |
||
| 1018 | * |
||
| 1019 | * @return Array the spotter information |
||
| 1020 | * |
||
| 1021 | */ |
||
| 1022 | public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array()) |
||
| 1023 | { |
||
| 1024 | global $global_query; |
||
| 1025 | |||
| 1026 | date_default_timezone_set('UTC'); |
||
| 1027 | |||
| 1028 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1029 | |||
| 1030 | $limit_query = ''; |
||
| 1031 | |||
| 1032 | if ($limit != "") |
||
| 1033 | { |
||
| 1034 | $limit_array = explode(",", $limit); |
||
| 1035 | |||
| 1036 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1037 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1038 | |||
| 1039 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1040 | { |
||
| 1041 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1042 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1043 | } |
||
| 1044 | } |
||
| 1045 | |||
| 1046 | if ($sort != "") |
||
| 1047 | { |
||
| 1048 | $search_orderby_array = $this->getOrderBy(); |
||
| 1049 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1050 | } else { |
||
| 1051 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1052 | } |
||
| 1053 | |||
| 1054 | $query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
||
| 1055 | |||
| 1056 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1057 | |||
| 1058 | return $spotter_array; |
||
| 1059 | } |
||
| 1060 | |||
| 1061 | |||
| 1062 | /** |
||
| 1063 | * Gets all the spotter information sorted by the newest arrival airport |
||
| 1064 | * |
||
| 1065 | * @return Array the spotter information |
||
| 1066 | * |
||
| 1067 | */ |
||
| 1068 | public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array()) |
||
| 1069 | { |
||
| 1070 | global $global_query; |
||
| 1071 | |||
| 1072 | date_default_timezone_set('UTC'); |
||
| 1073 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1074 | $limit_query = ''; |
||
| 1075 | if ($limit != "") |
||
| 1076 | { |
||
| 1077 | $limit_array = explode(",", $limit); |
||
| 1078 | |||
| 1079 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1080 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1081 | |||
| 1082 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1083 | { |
||
| 1084 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1085 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1086 | } |
||
| 1087 | } |
||
| 1088 | |||
| 1089 | if ($sort != "") |
||
| 1090 | { |
||
| 1091 | $search_orderby_array = $this->getOrderBy(); |
||
| 1092 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1093 | } else { |
||
| 1094 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1095 | } |
||
| 1096 | |||
| 1097 | $query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
||
| 1098 | |||
| 1099 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1100 | |||
| 1101 | return $spotter_array; |
||
| 1102 | } |
||
| 1103 | |||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Gets all the spotter information based on the spotter id |
||
| 1107 | * |
||
| 1108 | * @return Array the spotter information |
||
| 1109 | * |
||
| 1110 | */ |
||
| 1111 | public function getSpotterDataByID($id = '') |
||
| 1112 | { |
||
| 1113 | global $global_query; |
||
| 1114 | |||
| 1115 | date_default_timezone_set('UTC'); |
||
| 1116 | if ($id == '') return array(); |
||
| 1117 | $additional_query = "spotter_output.spotter_id = :id"; |
||
| 1118 | $query_values = array(':id' => $id); |
||
| 1119 | |||
| 1120 | //$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." "; |
||
| 1121 | $query = $global_query." WHERE ".$additional_query." "; |
||
| 1122 | |||
| 1123 | $spotter_array = $this->getDataFromDB($query,$query_values); |
||
| 1124 | |||
| 1125 | return $spotter_array; |
||
| 1126 | } |
||
| 1127 | |||
| 1128 | |||
| 1129 | |||
| 1130 | |||
| 1131 | /** |
||
| 1132 | * Gets all the spotter information based on the callsign |
||
| 1133 | * |
||
| 1134 | * @return Array the spotter information |
||
| 1135 | * |
||
| 1136 | */ |
||
| 1137 | public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
||
| 1138 | { |
||
| 1139 | global $global_query; |
||
| 1140 | |||
| 1141 | date_default_timezone_set('UTC'); |
||
| 1142 | |||
| 1143 | $query_values = array(); |
||
| 1144 | $limit_query = ''; |
||
| 1145 | $additional_query = ''; |
||
| 1146 | if ($ident != "") |
||
| 1147 | { |
||
| 1148 | if (!is_string($ident)) |
||
| 1149 | { |
||
| 1150 | return false; |
||
| 1151 | } else { |
||
| 1152 | $additional_query = " AND (spotter_output.ident = :ident)"; |
||
| 1153 | $query_values = array(':ident' => $ident); |
||
| 1154 | } |
||
| 1155 | } |
||
| 1156 | |||
| 1157 | if ($limit != "") |
||
| 1158 | { |
||
| 1159 | $limit_array = explode(",", $limit); |
||
| 1160 | |||
| 1161 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1162 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1163 | |||
| 1164 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1165 | { |
||
| 1166 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1167 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1168 | } |
||
| 1169 | } |
||
| 1170 | |||
| 1171 | if ($sort != "") |
||
| 1172 | { |
||
| 1173 | $search_orderby_array = $this->getOrderBy(); |
||
| 1174 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1175 | } else { |
||
| 1176 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1177 | } |
||
| 1178 | |||
| 1179 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1180 | |||
| 1181 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1182 | |||
| 1183 | return $spotter_array; |
||
| 1184 | } |
||
| 1185 | |||
| 1186 | |||
| 1187 | |||
| 1188 | /** |
||
| 1189 | * Gets all the spotter information based on the aircraft type |
||
| 1190 | * |
||
| 1191 | * @return Array the spotter information |
||
| 1192 | * |
||
| 1193 | */ |
||
| 1194 | public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array()) |
||
| 1195 | { |
||
| 1196 | global $global_query; |
||
| 1197 | |||
| 1198 | date_default_timezone_set('UTC'); |
||
| 1199 | |||
| 1200 | $query_values = array(); |
||
| 1201 | $limit_query = ''; |
||
| 1202 | $additional_query = ''; |
||
| 1203 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1204 | |||
| 1205 | if ($aircraft_type != "") |
||
| 1206 | { |
||
| 1207 | if (!is_string($aircraft_type)) |
||
| 1208 | { |
||
| 1209 | return false; |
||
| 1210 | } else { |
||
| 1211 | $additional_query = " AND (spotter_output.aircraft_icao = :aircraft_type)"; |
||
| 1212 | $query_values = array(':aircraft_type' => $aircraft_type); |
||
| 1213 | } |
||
| 1214 | } |
||
| 1215 | |||
| 1216 | if ($limit != "") |
||
| 1217 | { |
||
| 1218 | $limit_array = explode(",", $limit); |
||
| 1219 | |||
| 1220 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1221 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1222 | |||
| 1223 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1224 | { |
||
| 1225 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1226 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1227 | } |
||
| 1228 | } |
||
| 1229 | |||
| 1230 | if ($sort != "") |
||
| 1231 | { |
||
| 1232 | $search_orderby_array = $this->getOrderBy(); |
||
| 1233 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1234 | } else { |
||
| 1235 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1236 | } |
||
| 1237 | |||
| 1238 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1239 | |||
| 1240 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1241 | |||
| 1242 | return $spotter_array; |
||
| 1243 | } |
||
| 1244 | |||
| 1245 | |||
| 1246 | /** |
||
| 1247 | * Gets all the spotter information based on the aircraft registration |
||
| 1248 | * |
||
| 1249 | * @return Array the spotter information |
||
| 1250 | * |
||
| 1251 | */ |
||
| 1252 | public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array()) |
||
| 1253 | { |
||
| 1254 | global $global_query; |
||
| 1255 | |||
| 1256 | date_default_timezone_set('UTC'); |
||
| 1257 | |||
| 1258 | $query_values = array(); |
||
| 1259 | $limit_query = ''; |
||
| 1260 | $additional_query = ''; |
||
| 1261 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1262 | |||
| 1263 | if ($registration != "") |
||
| 1264 | { |
||
| 1265 | if (!is_string($registration)) |
||
| 1266 | { |
||
| 1267 | return false; |
||
| 1268 | } else { |
||
| 1269 | $additional_query = " AND (spotter_output.registration = :registration)"; |
||
| 1270 | $query_values = array(':registration' => $registration); |
||
| 1271 | } |
||
| 1272 | } |
||
| 1273 | |||
| 1274 | if ($limit != "") |
||
| 1275 | { |
||
| 1276 | $limit_array = explode(",", $limit); |
||
| 1277 | |||
| 1278 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1279 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1280 | |||
| 1281 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1282 | { |
||
| 1283 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1284 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1285 | } |
||
| 1286 | } |
||
| 1287 | |||
| 1288 | if ($sort != "") |
||
| 1289 | { |
||
| 1290 | $search_orderby_array = $this->getOrderBy(); |
||
| 1291 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1292 | } else { |
||
| 1293 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1294 | } |
||
| 1295 | |||
| 1296 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1297 | |||
| 1298 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1299 | |||
| 1300 | return $spotter_array; |
||
| 1301 | } |
||
| 1302 | |||
| 1303 | |||
| 1304 | |||
| 1305 | |||
| 1306 | /** |
||
| 1307 | * Gets all the spotter information based on the airline |
||
| 1308 | * |
||
| 1309 | * @return Array the spotter information |
||
| 1310 | * |
||
| 1311 | */ |
||
| 1312 | public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '') |
||
| 1313 | { |
||
| 1314 | global $global_query; |
||
| 1315 | |||
| 1316 | date_default_timezone_set('UTC'); |
||
| 1317 | |||
| 1318 | $query_values = array(); |
||
| 1319 | $limit_query = ''; |
||
| 1320 | $additional_query = ''; |
||
| 1321 | |||
| 1322 | if ($airline != "") |
||
| 1323 | { |
||
| 1324 | if (!is_string($airline)) |
||
| 1325 | { |
||
| 1326 | return false; |
||
| 1327 | } else { |
||
| 1328 | $additional_query = " AND (spotter_output.airline_icao = :airline)"; |
||
| 1329 | $query_values = array(':airline' => $airline); |
||
| 1330 | } |
||
| 1331 | } |
||
| 1332 | |||
| 1333 | if ($limit != "") |
||
| 1334 | { |
||
| 1335 | $limit_array = explode(",", $limit); |
||
| 1336 | |||
| 1337 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1338 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1339 | |||
| 1340 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1341 | { |
||
| 1342 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1343 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1344 | } |
||
| 1345 | } |
||
| 1346 | |||
| 1347 | if ($sort != "") |
||
| 1348 | { |
||
| 1349 | $search_orderby_array = $this->getOrderBy(); |
||
| 1350 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1351 | } else { |
||
| 1352 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1353 | } |
||
| 1354 | |||
| 1355 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1356 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1357 | |||
| 1358 | return $spotter_array; |
||
| 1359 | } |
||
| 1360 | |||
| 1361 | |||
| 1362 | /** |
||
| 1363 | * Gets all the spotter information based on the airport |
||
| 1364 | * |
||
| 1365 | * @return Array the spotter information |
||
| 1366 | * |
||
| 1367 | */ |
||
| 1368 | public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '') |
||
| 1369 | { |
||
| 1370 | global $global_query; |
||
| 1371 | |||
| 1372 | date_default_timezone_set('UTC'); |
||
| 1373 | $query_values = array(); |
||
| 1374 | $limit_query = ''; |
||
| 1375 | $additional_query = ''; |
||
| 1376 | |||
| 1377 | if ($airport != "") |
||
| 1378 | { |
||
| 1379 | if (!is_string($airport)) |
||
| 1380 | { |
||
| 1381 | return false; |
||
| 1382 | } else { |
||
| 1383 | $additional_query .= " AND ((spotter_output.departure_airport_icao = :airport) OR (spotter_output.arrival_airport_icao = :airport))"; |
||
| 1384 | $query_values = array(':airport' => $airport); |
||
| 1385 | } |
||
| 1386 | } |
||
| 1387 | |||
| 1388 | if ($limit != "") |
||
| 1389 | { |
||
| 1390 | $limit_array = explode(",", $limit); |
||
| 1391 | |||
| 1392 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1393 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1394 | |||
| 1395 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1396 | { |
||
| 1397 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1398 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1399 | } |
||
| 1400 | } |
||
| 1401 | |||
| 1402 | if ($sort != "") |
||
| 1403 | { |
||
| 1404 | $search_orderby_array = $this->getOrderBy(); |
||
| 1405 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1406 | } else { |
||
| 1407 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1408 | } |
||
| 1409 | |||
| 1410 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." AND ((spotter_output.departure_airport_icao <> 'NA') AND (spotter_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
||
| 1411 | |||
| 1412 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1413 | |||
| 1414 | return $spotter_array; |
||
| 1415 | } |
||
| 1416 | |||
| 1417 | |||
| 1418 | |||
| 1419 | /** |
||
| 1420 | * Gets all the spotter information based on the date |
||
| 1421 | * |
||
| 1422 | * @return Array the spotter information |
||
| 1423 | * |
||
| 1424 | */ |
||
| 1425 | public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
||
| 1426 | { |
||
| 1427 | global $global_query, $globalTimezone, $globalDBdriver; |
||
| 1428 | |||
| 1429 | $query_values = array(); |
||
| 1430 | $limit_query = ''; |
||
| 1431 | $additional_query = ''; |
||
| 1432 | |||
| 1433 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1434 | |||
| 1435 | if ($date != "") |
||
| 1436 | { |
||
| 1437 | if ($globalTimezone != '') { |
||
| 1438 | date_default_timezone_set($globalTimezone); |
||
| 1439 | $datetime = new DateTime($date); |
||
| 1440 | $offset = $datetime->format('P'); |
||
| 1441 | } else { |
||
| 1442 | date_default_timezone_set('UTC'); |
||
| 1443 | $datetime = new DateTime($date); |
||
| 1444 | $offset = '+00:00'; |
||
| 1445 | } |
||
| 1446 | if ($globalDBdriver == 'mysql') { |
||
| 1447 | $additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date "; |
||
| 1448 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset); |
||
| 1449 | } elseif ($globalDBdriver == 'pgsql') { |
||
| 1450 | $additional_query = " AND to_char(spotter_output.date AT TIME ZONE :timezone,'YYYY-mm-dd') = :date "; |
||
| 1451 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':timezone' => $globalTimezone); |
||
| 1452 | } |
||
| 1453 | } |
||
| 1454 | |||
| 1455 | if ($limit != "") |
||
| 1456 | { |
||
| 1457 | $limit_array = explode(",", $limit); |
||
| 1458 | |||
| 1459 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1460 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1461 | |||
| 1462 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1463 | { |
||
| 1464 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1465 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1466 | } |
||
| 1467 | } |
||
| 1468 | |||
| 1469 | if ($sort != "") |
||
| 1470 | { |
||
| 1471 | $search_orderby_array = $this->getOrderBy(); |
||
| 1472 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1473 | } else { |
||
| 1474 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1475 | } |
||
| 1476 | |||
| 1477 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query.$orderby_query; |
||
| 1478 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1479 | return $spotter_array; |
||
| 1480 | } |
||
| 1481 | |||
| 1482 | |||
| 1483 | |||
| 1484 | /** |
||
| 1485 | * Gets all the spotter information based on the country name |
||
| 1486 | * |
||
| 1487 | * @return Array the spotter information |
||
| 1488 | * |
||
| 1489 | */ |
||
| 1490 | public function getSpotterDataByCountry($country = '', $limit = '', $sort = '') |
||
| 1539 | |||
| 1540 | |||
| 1541 | /** |
||
| 1542 | * Gets all the spotter information based on the manufacturer name |
||
| 1543 | * |
||
| 1544 | * @return Array the spotter information |
||
| 1545 | * |
||
| 1546 | */ |
||
| 1547 | public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '') |
||
| 1596 | |||
| 1597 | |||
| 1598 | |||
| 1599 | |||
| 1600 | /** |
||
| 1601 | * Gets a list of all aircraft that take a route |
||
| 1602 | * |
||
| 1603 | * @param String $departure_airport_icao ICAO code of departure airport |
||
| 1604 | * @param String $arrival_airport_icao ICAO code of arrival airport |
||
| 1605 | * @return Array the spotter information |
||
| 1606 | * |
||
| 1607 | */ |
||
| 1608 | public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '') |
||
| 1669 | |||
| 1670 | |||
| 1671 | |||
| 1672 | /** |
||
| 1673 | * Gets all the spotter information based on the special column in the table |
||
| 1674 | * |
||
| 1675 | * @return Array the spotter information |
||
| 1676 | * |
||
| 1677 | */ |
||
| 1678 | public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array()) |
||
| 1714 | |||
| 1715 | /** |
||
| 1716 | * Gets all the highlight based on a aircraft registration |
||
| 1717 | * |
||
| 1718 | * @return String the highlight text |
||
| 1719 | * |
||
| 1720 | */ |
||
| 1721 | public function getHighlightByRegistration($registration,$filter = array()) |
||
| 1722 | { |
||
| 1723 | global $global_query; |
||
| 1724 | |||
| 1725 | date_default_timezone_set('UTC'); |
||
| 1726 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1727 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 1728 | |||
| 1729 | $query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; |
||
| 1730 | $sth = $this->db->prepare($query); |
||
| 1731 | $sth->execute(array(':registration' => $registration)); |
||
| 1732 | |||
| 1733 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1734 | { |
||
| 1735 | $highlight = $row['highlight']; |
||
| 1736 | } |
||
| 1737 | if (isset($highlight)) return $highlight; |
||
| 1738 | } |
||
| 1739 | |||
| 1740 | |||
| 1741 | /** |
||
| 1742 | * Gets the squawk usage from squawk code |
||
| 1743 | * |
||
| 1744 | * @param String $squawk squawk code |
||
| 1745 | * @param String $country country |
||
| 1746 | * @return String usage |
||
| 1747 | * |
||
| 1748 | */ |
||
| 1749 | public function getSquawkUsage($squawk = '',$country = 'FR') |
||
| 1750 | { |
||
| 1751 | |||
| 1752 | $squawk = filter_var($squawk,FILTER_SANITIZE_STRING); |
||
| 1753 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 1754 | |||
| 1755 | $query = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1"; |
||
| 1756 | $query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country); |
||
| 1757 | |||
| 1758 | $sth = $this->db->prepare($query); |
||
| 1759 | $sth->execute($query_values); |
||
| 1760 | |||
| 1761 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 1762 | $sth->closeCursor(); |
||
| 1763 | if (count($row) > 0) { |
||
| 1764 | return $row['usage']; |
||
| 1765 | } else return ''; |
||
| 1766 | } |
||
| 1767 | |||
| 1768 | /** |
||
| 1769 | * Gets the airport icao from the iata |
||
| 1770 | * |
||
| 1771 | * @param String $airport_iata the iata code of the airport |
||
| 1772 | * @return String airport iata |
||
| 1773 | * |
||
| 1774 | */ |
||
| 1775 | public function getAirportIcao($airport_iata = '') |
||
| 1776 | { |
||
| 1777 | |||
| 1778 | $airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING); |
||
| 1779 | |||
| 1780 | $query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; |
||
| 1781 | $query_values = array(':airport' => $airport_iata); |
||
| 1782 | |||
| 1783 | $sth = $this->db->prepare($query); |
||
| 1784 | $sth->execute($query_values); |
||
| 1785 | |||
| 1786 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 1787 | $sth->closeCursor(); |
||
| 1788 | if (count($row) > 0) { |
||
| 1789 | return $row['icao']; |
||
| 1790 | } else return ''; |
||
| 1791 | } |
||
| 1792 | |||
| 1793 | /** |
||
| 1794 | * Gets the airport distance |
||
| 1795 | * |
||
| 1796 | * @param String $airport_icao the icao code of the airport |
||
| 1797 | * @param Float $latitude the latitude |
||
| 1798 | * @param Float $longitude the longitude |
||
| 1799 | * @return Float distance to the airport |
||
| 1800 | * |
||
| 1801 | */ |
||
| 1802 | public function getAirportDistance($airport_icao,$latitude,$longitude) |
||
| 1803 | { |
||
| 1804 | |||
| 1805 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 1806 | |||
| 1807 | $query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; |
||
| 1808 | $query_values = array(':airport' => $airport_icao); |
||
| 1809 | $sth = $this->db->prepare($query); |
||
| 1810 | $sth->execute($query_values); |
||
| 1811 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 1812 | $sth->closeCursor(); |
||
| 1813 | if (count($row) > 0) { |
||
| 1814 | $airport_latitude = $row['latitude']; |
||
| 1815 | $airport_longitude = $row['longitude']; |
||
| 1816 | $Common = new Common(); |
||
| 1817 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
||
| 1818 | } else return ''; |
||
| 1819 | } |
||
| 1820 | |||
| 1821 | /** |
||
| 1822 | * Gets the airport info based on the icao |
||
| 1823 | * |
||
| 1824 | * @param String $airport the icao code of the airport |
||
| 1825 | * @return Array airport information |
||
| 1826 | * |
||
| 1827 | */ |
||
| 1828 | public function getAllAirportInfo($airport = '') |
||
| 1829 | { |
||
| 1830 | |||
| 1831 | $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
||
| 1832 | |||
| 1833 | $query_values = array(); |
||
| 1834 | if ($airport == 'NA') { |
||
| 1835 | return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => '')); |
||
| 1836 | } elseif ($airport == '') { |
||
| 1837 | $query = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport"; |
||
| 1838 | } else { |
||
| 1839 | $query = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport WHERE airport.icao = :airport LIMIT 1"; |
||
| 1840 | $query_values = array(':airport' => $airport); |
||
| 1841 | } |
||
| 1842 | |||
| 1843 | $sth = $this->db->prepare($query); |
||
| 1844 | $sth->execute($query_values); |
||
| 1845 | /* |
||
| 1846 | $airport_array = array(); |
||
| 1847 | $temp_array = array(); |
||
| 1848 | |||
| 1849 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1850 | { |
||
| 1851 | $temp_array['name'] = $row['name']; |
||
| 1852 | $temp_array['city'] = $row['city']; |
||
| 1853 | $temp_array['country'] = $row['country']; |
||
| 1854 | $temp_array['iata'] = $row['iata']; |
||
| 1855 | $temp_array['icao'] = $row['icao']; |
||
| 1856 | $temp_array['latitude'] = $row['latitude']; |
||
| 1857 | $temp_array['longitude'] = $row['longitude']; |
||
| 1858 | $temp_array['altitude'] = $row['altitude']; |
||
| 1859 | $temp_array['home_link'] = $row['home_link']; |
||
| 1860 | $temp_array['wikipedia_link'] = $row['wikipedia_link']; |
||
| 1861 | $temp_array['image'] = $row['image']; |
||
| 1862 | $temp_array['image_thumb'] = $row['image_thumb']; |
||
| 1863 | |||
| 1864 | $airport_array[] = $temp_array; |
||
| 1865 | } |
||
| 1866 | |||
| 1867 | return $airport_array; |
||
| 1868 | */ |
||
| 1869 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 1870 | } |
||
| 1871 | |||
| 1872 | /** |
||
| 1873 | * Gets the airport info based on the country |
||
| 1874 | * |
||
| 1875 | * @param Array $countries Airports countries |
||
| 1876 | * @return Array airport information |
||
| 1877 | * |
||
| 1878 | */ |
||
| 1879 | public function getAllAirportInfobyCountry($countries) |
||
| 1880 | { |
||
| 1881 | $lst_countries = ''; |
||
| 1882 | foreach ($countries as $country) { |
||
| 1883 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 1884 | if ($lst_countries == '') { |
||
| 1885 | $lst_countries = "'".$country."'"; |
||
| 1886 | } else { |
||
| 1887 | $lst_countries .= ",'".$country."'"; |
||
| 1888 | } |
||
| 1889 | } |
||
| 1890 | $query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; |
||
| 1891 | |||
| 1892 | $sth = $this->db->prepare($query); |
||
| 1893 | $sth->execute(); |
||
| 1894 | |||
| 1895 | $airport_array = array(); |
||
| 1896 | $temp_array = array(); |
||
| 1897 | |||
| 1898 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1899 | { |
||
| 1900 | $temp_array['name'] = $row['name']; |
||
| 1901 | $temp_array['city'] = $row['city']; |
||
| 1902 | $temp_array['country'] = $row['country']; |
||
| 1903 | $temp_array['iata'] = $row['iata']; |
||
| 1904 | $temp_array['icao'] = $row['icao']; |
||
| 1905 | $temp_array['latitude'] = $row['latitude']; |
||
| 1906 | $temp_array['longitude'] = $row['longitude']; |
||
| 1907 | $temp_array['altitude'] = $row['altitude']; |
||
| 1908 | |||
| 1909 | $airport_array[] = $temp_array; |
||
| 1910 | } |
||
| 1911 | |||
| 1912 | return $airport_array; |
||
| 1913 | } |
||
| 1914 | |||
| 1915 | /** |
||
| 1916 | * Gets airports info based on the coord |
||
| 1917 | * |
||
| 1918 | * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max |
||
| 1919 | * @return Array airport information |
||
| 1920 | * |
||
| 1921 | */ |
||
| 1922 | public function getAllAirportInfobyCoord($coord) |
||
| 1923 | { |
||
| 1924 | global $globalDBdriver; |
||
| 1925 | if (is_array($coord)) { |
||
| 1926 | $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1927 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1928 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1929 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1930 | } else return array(); |
||
| 1931 | if ($globalDBdriver == 'mysql') { |
||
| 1932 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
||
| 1933 | } else { |
||
| 1934 | $query = "SELECT airport.* FROM airport WHERE CAST(airport.latitude AS FLOAT) BETWEEN ".$minlat." AND ".$maxlat." AND CAST(airport.longitude AS FLOAT) BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
||
| 1935 | } |
||
| 1936 | $sth = $this->db->prepare($query); |
||
| 1937 | $sth->execute(); |
||
| 1938 | |||
| 1939 | $airport_array = array(); |
||
| 1940 | |||
| 1941 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1942 | { |
||
| 1943 | $temp_array = $row; |
||
| 1944 | |||
| 1945 | $airport_array[] = $temp_array; |
||
| 1946 | } |
||
| 1947 | |||
| 1948 | return $airport_array; |
||
| 1949 | } |
||
| 1950 | |||
| 1951 | /** |
||
| 1952 | * Gets waypoints info based on the coord |
||
| 1953 | * |
||
| 1954 | * @param Array $coord waypoints coord |
||
| 1955 | * @return Array airport information |
||
| 1956 | * |
||
| 1957 | */ |
||
| 1958 | public function getAllWaypointsInfobyCoord($coord) |
||
| 1959 | { |
||
| 1960 | if (is_array($coord)) { |
||
| 1961 | $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1962 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1963 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1964 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1965 | } else return array(); |
||
| 1966 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
||
| 1967 | $query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
||
| 1968 | //$query = "SELECT waypoints.* FROM waypoints"; |
||
| 1969 | //$query = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end"; |
||
| 1970 | //$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
||
| 1971 | //$query = "SELECT z.name_begin as name_begin, z.name_end as name_end, z.latitude_begin as latitude_begin, z.longitude_begin as longitude_begin, z.latitude_end as latitude_end, z.longitude_end as longitude_end, z.segment_name as segment_name, w.name_end as name_end_seg2, w.latitude_end as latitude_end_seg2, w.longitude_end as longitude_end_seg2, w.segment_name as segment_name_seg2 FROM waypoints z INNER JOIN waypoints w ON z.name_end = w.name_begin WHERE z.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND z.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
||
| 1972 | //echo $query; |
||
| 1973 | |||
| 1974 | $sth = $this->db->prepare($query); |
||
| 1975 | $sth->execute(); |
||
| 1976 | |||
| 1977 | $waypoints_array = array(); |
||
| 1978 | |||
| 1979 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1980 | { |
||
| 1981 | $temp_array = $row; |
||
| 1982 | |||
| 1983 | $waypoints_array[] = $temp_array; |
||
| 1984 | } |
||
| 1985 | |||
| 1986 | return $waypoints_array; |
||
| 1987 | } |
||
| 1988 | |||
| 1989 | |||
| 1990 | /** |
||
| 1991 | * Gets the airline info based on the icao code or iata code |
||
| 1992 | * |
||
| 1993 | * @param String $airline_icao the iata code of the airport |
||
| 1994 | * @return Array airport information |
||
| 1995 | * |
||
| 1996 | */ |
||
| 1997 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
||
| 1998 | { |
||
| 1999 | global $globalUseRealAirlines; |
||
| 2000 | if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
||
| 2001 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
||
| 2002 | if ($airline_icao == 'NA') { |
||
| 2003 | $airline_array = array(); |
||
| 2004 | $airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); |
||
| 2005 | return $airline_array; |
||
| 2006 | } else { |
||
| 2007 | if (strlen($airline_icao) == 2) { |
||
| 2008 | if ($fromsource === NULL) { |
||
| 2009 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.iata = :airline_icao AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
||
| 2010 | } else { |
||
| 2011 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.iata = :airline_icao AND airlines.active = 'Y' AND airlines.forsource = :fromsource LIMIT 1"; |
||
| 2012 | } |
||
| 2013 | } else { |
||
| 2014 | if ($fromsource === NULL) { |
||
| 2015 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.icao = :airline_icao AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
||
| 2016 | } else { |
||
| 2017 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.icao = :airline_icao AND airlines.active = 'Y' AND airlines.forsource = :fromsource LIMIT 1"; |
||
| 2018 | } |
||
| 2019 | } |
||
| 2020 | |||
| 2021 | $sth = $this->db->prepare($query); |
||
| 2022 | if ($fromsource === NULL) { |
||
| 2023 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 2024 | } else { |
||
| 2025 | $sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource)); |
||
| 2026 | } |
||
| 2027 | /* |
||
| 2028 | $airline_array = array(); |
||
| 2029 | $temp_array = array(); |
||
| 2030 | |||
| 2031 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2032 | { |
||
| 2033 | $temp_array['name'] = $row['name']; |
||
| 2034 | $temp_array['iata'] = $row['iata']; |
||
| 2035 | $temp_array['icao'] = $row['icao']; |
||
| 2036 | $temp_array['callsign'] = $row['callsign']; |
||
| 2037 | $temp_array['country'] = $row['country']; |
||
| 2038 | $temp_array['type'] = $row['type']; |
||
| 2039 | $airline_array[] = $temp_array; |
||
| 2040 | } |
||
| 2041 | return $airline_array; |
||
| 2042 | */ |
||
| 2043 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2044 | if (empty($result) && $fromsource !== NULL) { |
||
| 2045 | $query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; |
||
| 2046 | $sth = $this->db->prepare($query); |
||
| 2047 | $sth->execute(array(':fromsource' => $fromsource)); |
||
| 2048 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2049 | $sth->closeCursor(); |
||
| 2050 | if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); |
||
| 2051 | } |
||
| 2052 | return $result; |
||
| 2053 | } |
||
| 2054 | } |
||
| 2055 | |||
| 2056 | |||
| 2057 | |||
| 2058 | /** |
||
| 2059 | * Gets the aircraft info based on the aircraft type |
||
| 2060 | * |
||
| 2061 | * @param String $aircraft_type the aircraft type |
||
| 2062 | * @return Array aircraft information |
||
| 2063 | * |
||
| 2064 | */ |
||
| 2065 | public function getAllAircraftInfo($aircraft_type) |
||
| 2066 | { |
||
| 2067 | $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
||
| 2068 | |||
| 2069 | if ($aircraft_type == 'NA') { |
||
| 2070 | return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); |
||
| 2071 | } |
||
| 2072 | $query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type"; |
||
| 2073 | |||
| 2074 | $sth = $this->db->prepare($query); |
||
| 2075 | $sth->execute(array(':aircraft_type' => $aircraft_type)); |
||
| 2076 | /* |
||
| 2077 | $aircraft_array = array(); |
||
| 2078 | $temp_array = array(); |
||
| 2079 | |||
| 2080 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2081 | { |
||
| 2082 | $temp_array = array(); |
||
| 2083 | $temp_array['icao'] = $row['icao']; |
||
| 2084 | $temp_array['type'] = $row['type']; |
||
| 2085 | $temp_array['manufacturer'] = $row['manufacturer']; |
||
| 2086 | $temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
||
| 2087 | |||
| 2088 | $aircraft_array[] = $temp_array; |
||
| 2089 | } |
||
| 2090 | return $aircraft_array; |
||
| 2091 | */ |
||
| 2092 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2093 | } |
||
| 2094 | |||
| 2095 | /** |
||
| 2096 | * Gets the aircraft icao based on the aircraft name/type |
||
| 2097 | * |
||
| 2098 | * @param String $aircraft_type the aircraft type |
||
| 2099 | * @return String aircraft information |
||
| 2100 | * |
||
| 2101 | */ |
||
| 2102 | public function getAircraftIcao($aircraft_type) |
||
| 2103 | { |
||
| 2104 | $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
||
| 2105 | $all_aircraft = array('737-300' => 'B733', |
||
| 2106 | '777-200' => 'B772', |
||
| 2107 | '777-200ER' => 'B772', |
||
| 2108 | '777-300ER' => 'B77W', |
||
| 2109 | 'c172p' => 'C172', |
||
| 2110 | 'aerostar' => 'AEST', |
||
| 2111 | 'A320-211' => 'A320', |
||
| 2112 | '747-8i' => 'B748', |
||
| 2113 | 'A380' => 'A388'); |
||
| 2114 | if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
||
| 2115 | |||
| 2116 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
||
| 2117 | $aircraft_type = strtoupper($aircraft_type); |
||
| 2118 | $sth = $this->db->prepare($query); |
||
| 2119 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
||
| 2120 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2121 | if (isset($result[0]['icao'])) return $result[0]['icao']; |
||
| 2122 | else return ''; |
||
| 2123 | } |
||
| 2124 | |||
| 2125 | /** |
||
| 2126 | * Gets the aircraft info based on the aircraft ident |
||
| 2127 | * |
||
| 2128 | * @param String $aircraft_modes the aircraft ident (hex) |
||
| 2129 | * @return String aircraft type |
||
| 2130 | * |
||
| 2131 | */ |
||
| 2132 | public function getAllAircraftType($aircraft_modes) |
||
| 2133 | { |
||
| 2134 | $aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
||
| 2135 | |||
| 2136 | $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1"; |
||
| 2137 | |||
| 2138 | $sth = $this->db->prepare($query); |
||
| 2139 | $sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
||
| 2140 | |||
| 2141 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2142 | $sth->closeCursor(); |
||
| 2143 | if (isset($row['icaotypecode'])) { |
||
| 2144 | return $row['icaotypecode']; |
||
| 2145 | } else return ''; |
||
| 2146 | } |
||
| 2147 | |||
| 2148 | /** |
||
| 2149 | * Gets correct aircraft operator corde |
||
| 2150 | * |
||
| 2151 | * @param String $operator the aircraft operator code (callsign) |
||
| 2152 | * @return String aircraft operator code |
||
| 2153 | * |
||
| 2154 | */ |
||
| 2155 | public function getOperator($operator) |
||
| 2156 | { |
||
| 2157 | $operator = filter_var($operator,FILTER_SANITIZE_STRING); |
||
| 2158 | $query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; |
||
| 2159 | |||
| 2160 | $sth = $this->db->prepare($query); |
||
| 2161 | $sth->execute(array(':operator' => $operator)); |
||
| 2162 | |||
| 2163 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2164 | $sth->closeCursor(); |
||
| 2165 | if (isset($row['operator_correct'])) { |
||
| 2166 | return $row['operator_correct']; |
||
| 2167 | } else return $operator; |
||
| 2168 | } |
||
| 2169 | |||
| 2170 | /** |
||
| 2171 | * Gets the aircraft route based on the aircraft callsign |
||
| 2172 | * |
||
| 2173 | * @param String $callsign the aircraft callsign |
||
| 2174 | * @return Array aircraft type |
||
| 2175 | * |
||
| 2176 | */ |
||
| 2177 | public function getRouteInfo($callsign) |
||
| 2178 | { |
||
| 2179 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
||
| 2180 | if ($callsign == '') return array(); |
||
| 2181 | $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
||
| 2182 | |||
| 2183 | $sth = $this->db->prepare($query); |
||
| 2184 | $sth->execute(array(':callsign' => $callsign)); |
||
| 2185 | |||
| 2186 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2187 | $sth->closeCursor(); |
||
| 2188 | if (count($row) > 0) { |
||
| 2189 | return $row; |
||
| 2190 | } else return array(); |
||
| 2191 | } |
||
| 2192 | |||
| 2193 | /** |
||
| 2194 | * Gets the aircraft info based on the aircraft registration |
||
| 2195 | * |
||
| 2196 | * @param String $registration the aircraft registration |
||
| 2197 | * @return Array aircraft information |
||
| 2198 | * |
||
| 2199 | */ |
||
| 2200 | public function getAircraftInfoByRegistration($registration) |
||
| 2201 | { |
||
| 2202 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2203 | |||
| 2204 | $query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration"; |
||
| 2205 | |||
| 2206 | $sth = $this->db->prepare($query); |
||
| 2207 | $sth->execute(array(':registration' => $registration)); |
||
| 2208 | |||
| 2209 | $aircraft_array = array(); |
||
| 2210 | $temp_array = array(); |
||
| 2211 | |||
| 2212 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2213 | { |
||
| 2214 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 2215 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 2216 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2217 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2218 | |||
| 2219 | $aircraft_array[] = $temp_array; |
||
| 2220 | } |
||
| 2221 | |||
| 2222 | return $aircraft_array; |
||
| 2223 | } |
||
| 2224 | |||
| 2225 | /** |
||
| 2226 | * Gets the aircraft owner & base based on the aircraft registration |
||
| 2227 | * |
||
| 2228 | * @param String $registration the aircraft registration |
||
| 2229 | * @return Array aircraft information |
||
| 2230 | * |
||
| 2231 | */ |
||
| 2232 | public function getAircraftOwnerByRegistration($registration) |
||
| 2233 | { |
||
| 2234 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2235 | $Connection = new Connection($this->db); |
||
| 2236 | if ($Connection->tableExists('aircraft_owner')) { |
||
| 2237 | $query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1"; |
||
| 2238 | $sth = $this->db->prepare($query); |
||
| 2239 | $sth->execute(array(':registration' => $registration)); |
||
| 2240 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2241 | $sth->closeCursor(); |
||
| 2242 | return $result; |
||
| 2243 | } else return array(); |
||
| 2244 | } |
||
| 2245 | |||
| 2246 | |||
| 2247 | /** |
||
| 2248 | * Gets all flights (but with only little info) |
||
| 2249 | * |
||
| 2250 | * @return Array basic flight information |
||
| 2251 | * |
||
| 2252 | */ |
||
| 2253 | public function getAllFlightsforSitemap() |
||
| 2254 | { |
||
| 2255 | //$query = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT "; |
||
| 2256 | $query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; |
||
| 2257 | |||
| 2258 | $sth = $this->db->prepare($query); |
||
| 2259 | $sth->execute(); |
||
| 2260 | /* |
||
| 2261 | $flight_array = array(); |
||
| 2262 | $temp_array = array(); |
||
| 2263 | |||
| 2264 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2265 | { |
||
| 2266 | $temp_array['spotter_id'] = $row['spotter_id']; |
||
| 2267 | // $temp_array['ident'] = $row['ident']; |
||
| 2268 | // $temp_array['airline_name'] = $row['airline_name']; |
||
| 2269 | // $temp_array['aircraft_type'] = $row['aircraft_icao']; |
||
| 2270 | // $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2271 | //$temp_array['image'] = $row['image']; |
||
| 2272 | |||
| 2273 | $flight_array[] = $temp_array; |
||
| 2274 | } |
||
| 2275 | |||
| 2276 | return $flight_array; |
||
| 2277 | */ |
||
| 2278 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2279 | } |
||
| 2280 | |||
| 2281 | /** |
||
| 2282 | * Gets a list of all aircraft manufacturers |
||
| 2283 | * |
||
| 2284 | * @return Array list of aircraft types |
||
| 2285 | * |
||
| 2286 | */ |
||
| 2287 | public function getAllManufacturers() |
||
| 2288 | { |
||
| 2289 | /* |
||
| 2290 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer AS aircraft_manufacturer |
||
| 2291 | FROM spotter_output |
||
| 2292 | WHERE spotter_output.aircraft_manufacturer <> '' |
||
| 2293 | ORDER BY spotter_output.aircraft_manufacturer ASC"; |
||
| 2294 | */ |
||
| 2295 | |||
| 2296 | $query = "SELECT DISTINCT manufacturer AS aircraft_manufacturer FROM aircraft WHERE manufacturer <> '' ORDER BY manufacturer ASC"; |
||
| 2297 | $sth = $this->db->prepare($query); |
||
| 2298 | $sth->execute(); |
||
| 2299 | |||
| 2300 | $manufacturer_array = array(); |
||
| 2301 | $temp_array = array(); |
||
| 2302 | |||
| 2303 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2304 | { |
||
| 2305 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2306 | |||
| 2307 | $manufacturer_array[] = $temp_array; |
||
| 2308 | } |
||
| 2309 | |||
| 2310 | return $manufacturer_array; |
||
| 2311 | } |
||
| 2312 | |||
| 2313 | |||
| 2314 | /** |
||
| 2315 | * Gets a list of all aircraft types |
||
| 2316 | * |
||
| 2317 | * @return Array list of aircraft types |
||
| 2318 | * |
||
| 2319 | */ |
||
| 2320 | public function getAllAircraftTypes($filters = array()) |
||
| 2321 | { |
||
| 2322 | /* |
||
| 2323 | $query = "SELECT DISTINCT spotter_output.aircraft_icao AS aircraft_icao, spotter_output.aircraft_name AS aircraft_name |
||
| 2324 | FROM spotter_output |
||
| 2325 | WHERE spotter_output.aircraft_icao <> '' |
||
| 2326 | ORDER BY spotter_output.aircraft_name ASC"; |
||
| 2327 | |||
| 2328 | */ |
||
| 2329 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2330 | $query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft".$filter_query." icao <> '' ORDER BY aircraft_manufacturer ASC"; |
||
| 2331 | |||
| 2332 | $sth = $this->db->prepare($query); |
||
| 2333 | $sth->execute(); |
||
| 2334 | |||
| 2335 | $aircraft_array = array(); |
||
| 2336 | $temp_array = array(); |
||
| 2337 | |||
| 2338 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2339 | { |
||
| 2340 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 2341 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2342 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2343 | |||
| 2344 | $aircraft_array[] = $temp_array; |
||
| 2345 | } |
||
| 2346 | |||
| 2347 | return $aircraft_array; |
||
| 2348 | } |
||
| 2349 | |||
| 2350 | |||
| 2351 | /** |
||
| 2352 | * Gets a list of all aircraft registrations |
||
| 2353 | * |
||
| 2354 | * @return Array list of aircraft registrations |
||
| 2355 | * |
||
| 2356 | */ |
||
| 2357 | public function getAllAircraftRegistrations($filters = array()) |
||
| 2358 | { |
||
| 2359 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2360 | $query = "SELECT DISTINCT spotter_output.registration |
||
| 2361 | FROM spotter_output".$filter_query." spotter_output.registration <> '' |
||
| 2362 | ORDER BY spotter_output.registration ASC"; |
||
| 2363 | |||
| 2364 | $sth = $this->db->prepare($query); |
||
| 2365 | $sth->execute(); |
||
| 2366 | |||
| 2367 | $aircraft_array = array(); |
||
| 2368 | $temp_array = array(); |
||
| 2369 | |||
| 2370 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2371 | { |
||
| 2372 | $temp_array['registration'] = $row['registration']; |
||
| 2373 | |||
| 2374 | $aircraft_array[] = $temp_array; |
||
| 2375 | } |
||
| 2376 | |||
| 2377 | return $aircraft_array; |
||
| 2378 | } |
||
| 2379 | |||
| 2380 | /** |
||
| 2381 | * Gets all source name |
||
| 2382 | * |
||
| 2383 | * @param String type format of source |
||
| 2384 | * @return Array list of source name |
||
| 2385 | * |
||
| 2386 | */ |
||
| 2387 | public function getAllSourceName($type = '',$filters = array()) |
||
| 2388 | { |
||
| 2389 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2390 | $query_values = array(); |
||
| 2391 | $query = "SELECT DISTINCT spotter_output.source_name |
||
| 2392 | FROM spotter_output".$filter_query." spotter_output.source_name <> ''"; |
||
| 2393 | if ($type != '') { |
||
| 2394 | $query_values = array(':type' => $type); |
||
| 2395 | $query .= " AND format_source = :type"; |
||
| 2396 | } |
||
| 2397 | $query .= " ORDER BY spotter_output.source_name ASC"; |
||
| 2398 | |||
| 2399 | $sth = $this->db->prepare($query); |
||
| 2400 | if (!empty($query_values)) $sth->execute($query_values); |
||
| 2401 | else $sth->execute(); |
||
| 2402 | |||
| 2403 | $source_array = array(); |
||
| 2404 | $temp_array = array(); |
||
| 2405 | |||
| 2406 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2407 | { |
||
| 2408 | $temp_array['source_name'] = $row['source_name']; |
||
| 2409 | $source_array[] = $temp_array; |
||
| 2410 | } |
||
| 2411 | return $source_array; |
||
| 2412 | } |
||
| 2413 | |||
| 2414 | |||
| 2415 | |||
| 2416 | /** |
||
| 2417 | * Gets a list of all airline names |
||
| 2418 | * |
||
| 2419 | * @return Array list of airline names |
||
| 2420 | * |
||
| 2421 | */ |
||
| 2422 | public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array()) |
||
| 2423 | { |
||
| 2424 | global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
||
| 2425 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2426 | $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
||
| 2427 | if ($airline_type == '' || $airline_type == 'all') { |
||
| 2428 | /* |
||
| 2429 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
||
| 2430 | FROM spotter_output |
||
| 2431 | WHERE spotter_output.airline_icao <> '' |
||
| 2432 | ORDER BY spotter_output.airline_name ASC"; |
||
| 2433 | */ |
||
| 2434 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
||
| 2435 | elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
||
| 2436 | elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
||
| 2437 | if ($forsource === NULL) { |
||
| 2438 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC"; |
||
| 2439 | $query_data = array(); |
||
| 2440 | } else { |
||
| 2441 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource = :forsource ORDER BY name ASC"; |
||
| 2442 | $query_data = array(':forsource' => $forsource); |
||
| 2443 | } |
||
| 2444 | } else { |
||
| 2445 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
||
| 2446 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
||
| 2447 | AND spotter_output.airline_type = :airline_type |
||
| 2448 | ORDER BY spotter_output.airline_icao ASC"; |
||
| 2449 | $query_data = array(':airline_type' => $airline_type); |
||
| 2450 | } |
||
| 2451 | |||
| 2452 | $sth = $this->db->prepare($query); |
||
| 2453 | $sth->execute($query_data); |
||
| 2454 | |||
| 2455 | $airline_array = array(); |
||
| 2456 | $temp_array = array(); |
||
| 2457 | |||
| 2458 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2459 | { |
||
| 2460 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 2461 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 2462 | $temp_array['airline_type'] = $row['airline_type']; |
||
| 2463 | |||
| 2464 | $airline_array[] = $temp_array; |
||
| 2465 | } |
||
| 2466 | return $airline_array; |
||
| 2467 | } |
||
| 2468 | |||
| 2469 | |||
| 2470 | /** |
||
| 2471 | * Gets a list of all airline countries |
||
| 2472 | * |
||
| 2473 | * @return Array list of airline countries |
||
| 2474 | * |
||
| 2475 | */ |
||
| 2476 | public function getAllAirlineCountries($filters = array()) |
||
| 2477 | { |
||
| 2478 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2479 | $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
||
| 2480 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
||
| 2481 | ORDER BY spotter_output.airline_country ASC"; |
||
| 2482 | |||
| 2483 | //$query = "SELECT DISTINCT country AS airline_country FROM airlines WHERE country <> '' AND active = 'Y' ORDER BY country ASC"; |
||
| 2484 | $sth = $this->db->prepare($query); |
||
| 2485 | $sth->execute(); |
||
| 2486 | |||
| 2487 | $airline_array = array(); |
||
| 2488 | $temp_array = array(); |
||
| 2489 | |||
| 2490 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2491 | { |
||
| 2492 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 2493 | |||
| 2494 | $airline_array[] = $temp_array; |
||
| 2495 | } |
||
| 2496 | |||
| 2497 | return $airline_array; |
||
| 2498 | } |
||
| 2499 | |||
| 2500 | |||
| 2501 | |||
| 2502 | /** |
||
| 2503 | * Gets a list of all departure & arrival names |
||
| 2504 | * |
||
| 2505 | * @return Array list of airport names |
||
| 2506 | * |
||
| 2507 | */ |
||
| 2508 | public function getAllAirportNames($filters = array()) |
||
| 2509 | { |
||
| 2510 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2511 | $airport_array = array(); |
||
| 2512 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country |
||
| 2513 | FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' |
||
| 2514 | ORDER BY spotter_output.departure_airport_city ASC"; |
||
| 2515 | |||
| 2516 | //$query = "SELECT DISTINCT icao AS airport_icao, name AS airport_name, city AS airport_city, country AS airport_country FROM airport ORDER BY city ASC"; |
||
| 2517 | $sth = $this->db->prepare($query); |
||
| 2518 | $sth->execute(); |
||
| 2519 | |||
| 2520 | $temp_array = array(); |
||
| 2521 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2522 | { |
||
| 2523 | $temp_array['airport_icao'] = $row['airport_icao']; |
||
| 2524 | $temp_array['airport_name'] = $row['airport_name']; |
||
| 2525 | $temp_array['airport_city'] = $row['airport_city']; |
||
| 2526 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2527 | |||
| 2528 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
||
| 2529 | } |
||
| 2530 | |||
| 2531 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country |
||
| 2532 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' |
||
| 2533 | ORDER BY spotter_output.arrival_airport_city ASC"; |
||
| 2534 | |||
| 2535 | $sth = $this->db->prepare($query); |
||
| 2536 | $sth->execute(); |
||
| 2537 | |||
| 2538 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2539 | { |
||
| 2540 | // if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao']) |
||
| 2541 | // { |
||
| 2542 | $temp_array['airport_icao'] = $row['airport_icao']; |
||
| 2543 | $temp_array['airport_name'] = $row['airport_name']; |
||
| 2544 | $temp_array['airport_city'] = $row['airport_city']; |
||
| 2545 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2546 | |||
| 2547 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
||
| 2548 | // } |
||
| 2549 | } |
||
| 2550 | |||
| 2551 | return $airport_array; |
||
| 2552 | } |
||
| 2553 | |||
| 2554 | |||
| 2555 | /** |
||
| 2556 | * Gets a list of all departure & arrival airport countries |
||
| 2557 | * |
||
| 2558 | * @return Array list of airport countries |
||
| 2559 | * |
||
| 2560 | */ |
||
| 2561 | public function getAllAirportCountries($filters = array()) |
||
| 2562 | { |
||
| 2563 | $airport_array = array(); |
||
| 2564 | |||
| 2565 | /* |
||
| 2566 | $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
||
| 2567 | FROM spotter_output |
||
| 2568 | WHERE spotter_output.departure_airport_country <> '' |
||
| 2569 | ORDER BY spotter_output.departure_airport_country ASC"; |
||
| 2570 | */ |
||
| 2571 | $query = "SELECT DISTINCT country AS airport_country FROM airport ORDER BY country ASC"; |
||
| 2572 | |||
| 2573 | $sth = $this->db->prepare($query); |
||
| 2574 | $sth->execute(); |
||
| 2575 | |||
| 2576 | $temp_array = array(); |
||
| 2577 | |||
| 2578 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2579 | { |
||
| 2580 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2581 | |||
| 2582 | $airport_array[$row['airport_country']] = $temp_array; |
||
| 2583 | } |
||
| 2584 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2585 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
||
| 2586 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
||
| 2587 | ORDER BY spotter_output.arrival_airport_country ASC"; |
||
| 2588 | |||
| 2589 | $sth = $this->db->prepare($query); |
||
| 2590 | $sth->execute(); |
||
| 2591 | |||
| 2592 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2593 | { |
||
| 2594 | if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country']) |
||
| 2595 | { |
||
| 2596 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2597 | $airport_array[$row['airport_country']] = $temp_array; |
||
| 2598 | } |
||
| 2599 | } |
||
| 2600 | |||
| 2601 | return $airport_array; |
||
| 2602 | } |
||
| 2603 | |||
| 2604 | |||
| 2605 | |||
| 2606 | |||
| 2607 | /** |
||
| 2608 | * Gets a list of all countries (airline, departure airport & arrival airport) |
||
| 2609 | * |
||
| 2610 | * @return Array list of countries |
||
| 2611 | * |
||
| 2612 | */ |
||
| 2613 | public function getAllCountries($filters = array()) |
||
| 2614 | { |
||
| 2615 | $Connection= new Connection($this->db); |
||
| 2616 | if ($Connection->tableExists('countries')) { |
||
| 2617 | $query = "SELECT countries.name AS airport_country |
||
| 2618 | FROM countries |
||
| 2619 | ORDER BY countries.name ASC"; |
||
| 2620 | $sth = $this->db->prepare($query); |
||
| 2621 | $sth->execute(); |
||
| 2622 | |||
| 2623 | $temp_array = array(); |
||
| 2624 | $country_array = array(); |
||
| 2625 | |||
| 2626 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2627 | { |
||
| 2628 | $temp_array['country'] = $row['airport_country']; |
||
| 2629 | $country_array[$row['airport_country']] = $temp_array; |
||
| 2630 | } |
||
| 2631 | } else { |
||
| 2632 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2633 | $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
||
| 2634 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' |
||
| 2635 | ORDER BY spotter_output.departure_airport_country ASC"; |
||
| 2636 | |||
| 2637 | $sth = $this->db->prepare($query); |
||
| 2638 | $sth->execute(); |
||
| 2639 | |||
| 2640 | $temp_array = array(); |
||
| 2641 | $country_array = array(); |
||
| 2642 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2643 | { |
||
| 2644 | $temp_array['country'] = $row['airport_country']; |
||
| 2645 | $country_array[$row['airport_country']] = $temp_array; |
||
| 2646 | } |
||
| 2647 | |||
| 2648 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
||
| 2649 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
||
| 2650 | ORDER BY spotter_output.arrival_airport_country ASC"; |
||
| 2651 | |||
| 2652 | $sth = $this->db->prepare($query); |
||
| 2653 | $sth->execute(); |
||
| 2654 | |||
| 2655 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2656 | { |
||
| 2657 | if ($country_array[$row['airport_country']]['country'] != $row['airport_country']) |
||
| 2658 | { |
||
| 2659 | $temp_array['country'] = $row['airport_country']; |
||
| 2660 | |||
| 2661 | $country_array[$row['country']] = $temp_array; |
||
| 2662 | } |
||
| 2663 | } |
||
| 2664 | |||
| 2665 | $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
||
| 2666 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
||
| 2667 | ORDER BY spotter_output.airline_country ASC"; |
||
| 2668 | |||
| 2669 | $sth = $this->db->prepare($query); |
||
| 2670 | $sth->execute(); |
||
| 2671 | |||
| 2672 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2673 | { |
||
| 2674 | if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country']) |
||
| 2675 | { |
||
| 2676 | $temp_array['country'] = $row['airline_country']; |
||
| 2677 | |||
| 2678 | $country_array[$row['country']] = $temp_array; |
||
| 2679 | } |
||
| 2680 | } |
||
| 2681 | } |
||
| 2682 | return $country_array; |
||
| 2683 | } |
||
| 2684 | |||
| 2685 | |||
| 2686 | |||
| 2687 | |||
| 2688 | /** |
||
| 2689 | * Gets a list of all idents/callsigns |
||
| 2690 | * |
||
| 2691 | * @return Array list of ident/callsign names |
||
| 2692 | * |
||
| 2693 | */ |
||
| 2694 | public function getAllIdents($filters = array()) |
||
| 2695 | { |
||
| 2696 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2697 | $query = "SELECT DISTINCT spotter_output.ident |
||
| 2698 | FROM spotter_output".$filter_query." spotter_output.ident <> '' |
||
| 2699 | ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0"; |
||
| 2700 | |||
| 2701 | $sth = $this->db->prepare($query); |
||
| 2702 | $sth->execute(); |
||
| 2703 | |||
| 2704 | $ident_array = array(); |
||
| 2705 | $temp_array = array(); |
||
| 2706 | |||
| 2707 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2708 | { |
||
| 2709 | $temp_array['ident'] = $row['ident']; |
||
| 2710 | $ident_array[] = $temp_array; |
||
| 2711 | } |
||
| 2712 | |||
| 2713 | return $ident_array; |
||
| 2714 | } |
||
| 2715 | |||
| 2716 | /** |
||
| 2717 | * Get a list of flights from airport since 7 days |
||
| 2718 | * @return Array number, icao, name and city of airports |
||
| 2719 | */ |
||
| 2720 | |||
| 2721 | public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) { |
||
| 2722 | global $globalTimezone, $globalDBdriver; |
||
| 2723 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2724 | if ($globalTimezone != '') { |
||
| 2725 | date_default_timezone_set($globalTimezone); |
||
| 2726 | $datetime = new DateTime(); |
||
| 2727 | $offset = $datetime->format('P'); |
||
| 2728 | } else $offset = '+00:00'; |
||
| 2729 | if ($airport_icao == '') { |
||
| 2730 | if ($globalDBdriver == 'mysql') { |
||
| 2731 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2732 | } else { |
||
| 2733 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2734 | } |
||
| 2735 | $sth = $this->db->prepare($query); |
||
| 2736 | $sth->execute(array(':offset' => $offset)); |
||
| 2737 | } else { |
||
| 2738 | if ($globalDBdriver == 'mysql') { |
||
| 2739 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2740 | } else { |
||
| 2741 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2742 | } |
||
| 2743 | $sth = $this->db->prepare($query); |
||
| 2744 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2745 | } |
||
| 2746 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2747 | } |
||
| 2748 | |||
| 2749 | /** |
||
| 2750 | * Get a list of flights from airport since 7 days |
||
| 2751 | * @return Array number, icao, name and city of airports |
||
| 2752 | */ |
||
| 2753 | |||
| 2754 | public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') { |
||
| 2755 | global $globalTimezone, $globalDBdriver; |
||
| 2756 | if ($globalTimezone != '') { |
||
| 2757 | date_default_timezone_set($globalTimezone); |
||
| 2758 | $datetime = new DateTime(); |
||
| 2759 | $offset = $datetime->format('P'); |
||
| 2760 | } else $offset = '+00:00'; |
||
| 2761 | if ($airport_icao == '') { |
||
| 2762 | if ($globalDBdriver == 'mysql') { |
||
| 2763 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2764 | } else { |
||
| 2765 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2766 | } |
||
| 2767 | $sth = $this->db->prepare($query); |
||
| 2768 | $sth->execute(array(':offset' => $offset)); |
||
| 2769 | } else { |
||
| 2770 | if ($globalDBdriver == 'mysql') { |
||
| 2771 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2772 | } else { |
||
| 2773 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2774 | } |
||
| 2775 | $sth = $this->db->prepare($query); |
||
| 2776 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2777 | } |
||
| 2778 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2779 | } |
||
| 2780 | |||
| 2781 | /** |
||
| 2782 | * Get a list of flights from detected airport since 7 days |
||
| 2783 | * @return Array number, icao, name and city of airports |
||
| 2784 | */ |
||
| 2785 | |||
| 2786 | public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) { |
||
| 2787 | global $globalTimezone, $globalDBdriver; |
||
| 2788 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2789 | if ($globalTimezone != '') { |
||
| 2790 | date_default_timezone_set($globalTimezone); |
||
| 2791 | $datetime = new DateTime(); |
||
| 2792 | $offset = $datetime->format('P'); |
||
| 2793 | } else $offset = '+00:00'; |
||
| 2794 | if ($airport_icao == '') { |
||
| 2795 | if ($globalDBdriver == 'mysql') { |
||
| 2796 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2797 | FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao <> 'NA' |
||
| 2798 | GROUP BY real_departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2799 | } else { |
||
| 2800 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2801 | FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao <> 'NA' |
||
| 2802 | GROUP BY real_departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2803 | } |
||
| 2804 | $sth = $this->db->prepare($query); |
||
| 2805 | $sth->execute(array(':offset' => $offset)); |
||
| 2806 | } else { |
||
| 2807 | if ($globalDBdriver == 'mysql') { |
||
| 2808 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2809 | FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao = :airport_icao |
||
| 2810 | GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2811 | } else { |
||
| 2812 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2813 | FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2814 | } |
||
| 2815 | $sth = $this->db->prepare($query); |
||
| 2816 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2817 | } |
||
| 2818 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2819 | } |
||
| 2820 | |||
| 2821 | /** |
||
| 2822 | * Get a list of flights from detected airport since 7 days |
||
| 2823 | * @return Array number, icao, name and city of airports |
||
| 2824 | */ |
||
| 2825 | |||
| 2826 | public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') { |
||
| 2827 | global $globalTimezone, $globalDBdriver; |
||
| 2828 | if ($globalTimezone != '') { |
||
| 2829 | date_default_timezone_set($globalTimezone); |
||
| 2830 | $datetime = new DateTime(); |
||
| 2831 | $offset = $datetime->format('P'); |
||
| 2832 | } else $offset = '+00:00'; |
||
| 2833 | if ($airport_icao == '') { |
||
| 2834 | if ($globalDBdriver == 'mysql') { |
||
| 2835 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2836 | FROM `spotter_output`, airport |
||
| 2837 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao <> 'NA' |
||
| 2838 | GROUP BY spotter_output.airline_icao, real_departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2839 | } else { |
||
| 2840 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2841 | FROM spotter_output, airport |
||
| 2842 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao <> 'NA' |
||
| 2843 | GROUP BY spotter_output.airline_icao, real_departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2844 | } |
||
| 2845 | $sth = $this->db->prepare($query); |
||
| 2846 | $sth->execute(array(':offset' => $offset)); |
||
| 2847 | } else { |
||
| 2848 | if ($globalDBdriver == 'mysql') { |
||
| 2849 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2850 | FROM `spotter_output`, airport |
||
| 2851 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao = :airport_icao |
||
| 2852 | GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2853 | } else { |
||
| 2854 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2855 | FROM spotter_output, airport |
||
| 2856 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao = :airport_icao GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; |
||
| 2857 | } |
||
| 2858 | $sth = $this->db->prepare($query); |
||
| 2859 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2860 | } |
||
| 2861 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2862 | } |
||
| 2863 | |||
| 2864 | |||
| 2865 | /** |
||
| 2866 | * Get a list of flights to airport since 7 days |
||
| 2867 | * @return Array number, icao, name and city of airports |
||
| 2868 | */ |
||
| 2869 | |||
| 2870 | public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) { |
||
| 2871 | global $globalTimezone, $globalDBdriver; |
||
| 2872 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2873 | if ($globalTimezone != '') { |
||
| 2874 | date_default_timezone_set($globalTimezone); |
||
| 2875 | $datetime = new DateTime(); |
||
| 2876 | $offset = $datetime->format('P'); |
||
| 2877 | } else $offset = '+00:00'; |
||
| 2878 | if ($airport_icao == '') { |
||
| 2879 | if ($globalDBdriver == 'mysql') { |
||
| 2880 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2881 | } else { |
||
| 2882 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2883 | } |
||
| 2884 | $sth = $this->db->prepare($query); |
||
| 2885 | $sth->execute(array(':offset' => $offset)); |
||
| 2886 | } else { |
||
| 2887 | if ($globalDBdriver == 'mysql') { |
||
| 2888 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2889 | } else { |
||
| 2890 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2891 | } |
||
| 2892 | $sth = $this->db->prepare($query); |
||
| 2893 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2894 | } |
||
| 2895 | |||
| 2896 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2897 | } |
||
| 2898 | |||
| 2899 | |||
| 2900 | /** |
||
| 2901 | * Get a list of flights detected to airport since 7 days |
||
| 2902 | * @return Array number, icao, name and city of airports |
||
| 2903 | */ |
||
| 2904 | |||
| 2905 | public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) { |
||
| 2906 | global $globalTimezone, $globalDBdriver; |
||
| 2907 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2908 | if ($globalTimezone != '') { |
||
| 2909 | date_default_timezone_set($globalTimezone); |
||
| 2910 | $datetime = new DateTime(); |
||
| 2911 | $offset = $datetime->format('P'); |
||
| 2912 | } else $offset = '+00:00'; |
||
| 2913 | if ($airport_icao == '') { |
||
| 2914 | if ($globalDBdriver == 'mysql') { |
||
| 2915 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2916 | FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' |
||
| 2917 | GROUP BY real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 2918 | } else { |
||
| 2919 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2920 | FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' |
||
| 2921 | GROUP BY real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 2922 | } |
||
| 2923 | $sth = $this->db->prepare($query); |
||
| 2924 | $sth->execute(array(':offset' => $offset)); |
||
| 2925 | } else { |
||
| 2926 | if ($globalDBdriver == 'mysql') { |
||
| 2927 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2928 | FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao |
||
| 2929 | GROUP BY real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 2930 | } else { |
||
| 2931 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2932 | FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao |
||
| 2933 | GROUP BY real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 2934 | } |
||
| 2935 | $sth = $this->db->prepare($query); |
||
| 2936 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2937 | } |
||
| 2938 | |||
| 2939 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2940 | } |
||
| 2941 | |||
| 2942 | |||
| 2943 | /** |
||
| 2944 | * Get a list of flights to airport since 7 days |
||
| 2945 | * @return Array number, icao, name and city of airports |
||
| 2946 | */ |
||
| 2947 | |||
| 2948 | public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') { |
||
| 2949 | global $globalTimezone, $globalDBdriver; |
||
| 2950 | if ($globalTimezone != '') { |
||
| 2951 | date_default_timezone_set($globalTimezone); |
||
| 2952 | $datetime = new DateTime(); |
||
| 2953 | $offset = $datetime->format('P'); |
||
| 2954 | } else $offset = '+00:00'; |
||
| 2955 | if ($airport_icao == '') { |
||
| 2956 | if ($globalDBdriver == 'mysql') { |
||
| 2957 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2958 | } else { |
||
| 2959 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2960 | } |
||
| 2961 | $sth = $this->db->prepare($query); |
||
| 2962 | $sth->execute(array(':offset' => $offset)); |
||
| 2963 | } else { |
||
| 2964 | if ($globalDBdriver == 'mysql') { |
||
| 2965 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2966 | } else { |
||
| 2967 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2968 | } |
||
| 2969 | $sth = $this->db->prepare($query); |
||
| 2970 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2971 | } |
||
| 2972 | |||
| 2973 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2974 | } |
||
| 2975 | |||
| 2976 | |||
| 2977 | /** |
||
| 2978 | * Get a list of flights detected to airport since 7 days |
||
| 2979 | * @return Array number, icao, name and city of airports |
||
| 2980 | */ |
||
| 2981 | |||
| 2982 | public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') { |
||
| 2983 | global $globalTimezone, $globalDBdriver; |
||
| 2984 | if ($globalTimezone != '') { |
||
| 2985 | date_default_timezone_set($globalTimezone); |
||
| 2986 | $datetime = new DateTime(); |
||
| 2987 | $offset = $datetime->format('P'); |
||
| 2988 | } else $offset = '+00:00'; |
||
| 2989 | if ($airport_icao == '') { |
||
| 2990 | if ($globalDBdriver == 'mysql') { |
||
| 2991 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2992 | FROM `spotter_output`, airport |
||
| 2993 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' |
||
| 2994 | GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 2995 | } else { |
||
| 2996 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 2997 | FROM spotter_output, airport |
||
| 2998 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' |
||
| 2999 | GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 3000 | } |
||
| 3001 | $sth = $this->db->prepare($query); |
||
| 3002 | $sth->execute(array(':offset' => $offset)); |
||
| 3003 | } else { |
||
| 3004 | if ($globalDBdriver == 'mysql') { |
||
| 3005 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 3006 | FROM `spotter_output`, airport |
||
| 3007 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao |
||
| 3008 | GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 3009 | } else { |
||
| 3010 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 3011 | FROM spotter_output, airport |
||
| 3012 | WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao |
||
| 3013 | GROUP BY spotter_output.airline_icao,real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; |
||
| 3014 | } |
||
| 3015 | $sth = $this->db->prepare($query); |
||
| 3016 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3017 | } |
||
| 3018 | |||
| 3019 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3020 | } |
||
| 3021 | |||
| 3022 | |||
| 3023 | /** |
||
| 3024 | * Gets a list of all dates |
||
| 3025 | * |
||
| 3026 | * @return Array list of date names |
||
| 3027 | * |
||
| 3028 | */ |
||
| 3029 | public function getAllDates() |
||
| 3030 | { |
||
| 3031 | global $globalTimezone, $globalDBdriver; |
||
| 3032 | if ($globalTimezone != '') { |
||
| 3033 | date_default_timezone_set($globalTimezone); |
||
| 3034 | $datetime = new DateTime(); |
||
| 3035 | $offset = $datetime->format('P'); |
||
| 3036 | } else $offset = '+00:00'; |
||
| 3037 | |||
| 3038 | if ($globalDBdriver == 'mysql') { |
||
| 3039 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
||
| 3040 | FROM spotter_output |
||
| 3041 | WHERE spotter_output.date <> '' |
||
| 3042 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
||
| 3043 | } else { |
||
| 3044 | $query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 3045 | FROM spotter_output |
||
| 3046 | WHERE spotter_output.date <> '' |
||
| 3047 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
||
| 3048 | } |
||
| 3049 | |||
| 3050 | $sth = $this->db->prepare($query); |
||
| 3051 | $sth->execute(array(':offset' => $offset)); |
||
| 3052 | |||
| 3053 | $date_array = array(); |
||
| 3054 | $temp_array = array(); |
||
| 3055 | |||
| 3056 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3057 | { |
||
| 3058 | $temp_array['date'] = $row['date']; |
||
| 3059 | |||
| 3060 | $date_array[] = $temp_array; |
||
| 3061 | } |
||
| 3062 | |||
| 3063 | return $date_array; |
||
| 3064 | } |
||
| 3065 | |||
| 3066 | |||
| 3067 | |||
| 3068 | /** |
||
| 3069 | * Gets all route combinations |
||
| 3070 | * |
||
| 3071 | * @return Array the route list |
||
| 3072 | * |
||
| 3073 | */ |
||
| 3074 | public function getAllRoutes() |
||
| 3075 | { |
||
| 3076 | $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao |
||
| 3077 | FROM spotter_output |
||
| 3078 | WHERE spotter_output.ident <> '' |
||
| 3079 | GROUP BY route |
||
| 3080 | ORDER BY route ASC"; |
||
| 3081 | |||
| 3082 | $sth = $this->db->prepare($query); |
||
| 3083 | $sth->execute(); |
||
| 3084 | |||
| 3085 | $routes_array = array(); |
||
| 3086 | $temp_array = array(); |
||
| 3087 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3088 | { |
||
| 3089 | $temp_array['route'] = $row['route']; |
||
| 3090 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 3091 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 3092 | |||
| 3093 | $routes_array[] = $temp_array; |
||
| 3094 | } |
||
| 3095 | return $routes_array; |
||
| 3096 | } |
||
| 3097 | |||
| 3098 | /** |
||
| 3099 | * Update ident spotter data |
||
| 3100 | * |
||
| 3101 | * @param String $flightaware_id the ID from flightaware |
||
| 3102 | * @param String $ident the flight ident |
||
| 3103 | * @return String success or false |
||
| 3104 | * |
||
| 3105 | */ |
||
| 3106 | public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL) |
||
| 3107 | { |
||
| 3108 | if (!is_numeric(substr($ident, 0, 3))) |
||
| 3109 | { |
||
| 3110 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
| 3111 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
||
| 3112 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
| 3113 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
||
| 3114 | } else { |
||
| 3115 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3116 | } |
||
| 3117 | if (count($airline_array) == 0) { |
||
| 3118 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3119 | } |
||
| 3120 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
||
| 3121 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3122 | } |
||
| 3123 | } else { |
||
| 3124 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3125 | } |
||
| 3126 | $airline_name = $airline_array[0]['name']; |
||
| 3127 | $airline_icao = $airline_array[0]['icao']; |
||
| 3128 | $airline_country = $airline_array[0]['country']; |
||
| 3129 | $airline_type = $airline_array[0]['type']; |
||
| 3130 | |||
| 3131 | |||
| 3132 | $query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id'; |
||
| 3133 | $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type); |
||
| 3134 | |||
| 3135 | try { |
||
| 3136 | $sth = $this->db->prepare($query); |
||
| 3137 | $sth->execute($query_values); |
||
| 3138 | } catch (PDOException $e) { |
||
| 3139 | return "error : ".$e->getMessage(); |
||
| 3140 | } |
||
| 3141 | |||
| 3142 | return "success"; |
||
| 3143 | |||
| 3144 | } |
||
| 3145 | /** |
||
| 3146 | * Update latest spotter data |
||
| 3147 | * |
||
| 3148 | * @param String $flightaware_id the ID from flightaware |
||
| 3149 | * @param String $ident the flight ident |
||
| 3150 | * @param String $arrival_airport_icao the arrival airport |
||
| 3151 | * @return String success or false |
||
| 3152 | * |
||
| 3153 | */ |
||
| 3154 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
||
| 3155 | { |
||
| 3156 | if ($groundspeed == '') $groundspeed = NULL; |
||
| 3157 | $query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
||
| 3158 | $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
||
| 3159 | |||
| 3160 | try { |
||
| 3161 | $sth = $this->db->prepare($query); |
||
| 3162 | $sth->execute($query_values); |
||
| 3163 | } catch (PDOException $e) { |
||
| 3164 | return "error : ".$e->getMessage(); |
||
| 3165 | } |
||
| 3166 | |||
| 3167 | return "success"; |
||
| 3168 | |||
| 3169 | } |
||
| 3170 | |||
| 3171 | /** |
||
| 3172 | * Adds a new spotter data |
||
| 3173 | * |
||
| 3174 | * @param String $flightaware_id the ID from flightaware |
||
| 3175 | * @param String $ident the flight ident |
||
| 3176 | * @param String $aircraft_icao the aircraft type |
||
| 3177 | * @param String $departure_airport_icao the departure airport |
||
| 3178 | * @param String $arrival_airport_icao the arrival airport |
||
| 3179 | * @param String $latitude latitude of flight |
||
| 3180 | * @param String $longitude latitude of flight |
||
| 3181 | * @param String $waypoints waypoints of flight |
||
| 3182 | * @param String $altitude altitude of flight |
||
| 3183 | * @param String $heading heading of flight |
||
| 3184 | * @param String $groundspeed speed of flight |
||
| 3185 | * @param String $date date of flight |
||
| 3186 | * @param String $departure_airport_time departure time of flight |
||
| 3187 | * @param String $arrival_airport_time arrival time of flight |
||
| 3188 | * @param String $squawk squawk code of flight |
||
| 3189 | * @param String $route_stop route stop of flight |
||
| 3190 | * @param String $highlight highlight or not |
||
| 3191 | * @param String $ModeS ModesS code of flight |
||
| 3192 | * @param String $registration registration code of flight |
||
| 3193 | * @param String $pilot_id pilot id of flight (for virtual airlines) |
||
| 3194 | * @param String $pilot_name pilot name of flight (for virtual airlines) |
||
| 3195 | * @param String $verticalrate vertival rate of flight |
||
| 3196 | * @return String success or false |
||
| 3197 | */ |
||
| 3198 | public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '') |
||
| 3199 | { |
||
| 3200 | global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM; |
||
| 3201 | |||
| 3202 | //if (isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
||
| 3203 | $Image = new Image($this->db); |
||
| 3204 | $Common = new Common(); |
||
| 3205 | |||
| 3206 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
||
| 3207 | if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
||
| 3208 | if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
||
| 3209 | if (!isset($globalVAM)) $globalVAM = FALSE; |
||
| 3210 | date_default_timezone_set('UTC'); |
||
| 3211 | |||
| 3212 | //getting the registration |
||
| 3213 | if ($flightaware_id != "" && $registration == '') |
||
| 3214 | { |
||
| 3215 | if (!is_string($flightaware_id)) |
||
| 3216 | { |
||
| 3217 | return false; |
||
| 3218 | } else { |
||
| 3219 | if ($ModeS != '') { |
||
| 3220 | $timeelapsed = microtime(true); |
||
| 3221 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
||
| 3222 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3223 | } else { |
||
| 3224 | $myhex = explode('-',$flightaware_id); |
||
| 3225 | if (count($myhex) > 0) { |
||
| 3226 | $timeelapsed = microtime(true); |
||
| 3227 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
||
| 3228 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3229 | } |
||
| 3230 | } |
||
| 3231 | } |
||
| 3232 | } |
||
| 3233 | $fromsource = NULL; |
||
| 3234 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
||
| 3235 | elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
||
| 3236 | elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
||
| 3237 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
||
| 3238 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
||
| 3239 | //getting the airline information |
||
| 3240 | if ($ident != "") |
||
| 3241 | { |
||
| 3242 | if (!is_string($ident)) |
||
| 3243 | { |
||
| 3244 | return false; |
||
| 3245 | } else { |
||
| 3246 | if (!is_numeric(substr($ident, 0, 3))) |
||
| 3247 | { |
||
| 3248 | $timeelapsed = microtime(true); |
||
| 3249 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
| 3250 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
||
| 3251 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
| 3252 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
||
| 3253 | } else { |
||
| 3254 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3255 | } |
||
| 3256 | if (count($airline_array) == 0) { |
||
| 3257 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3258 | } |
||
| 3259 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
||
| 3260 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3261 | } |
||
| 3262 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3263 | |||
| 3264 | } else { |
||
| 3265 | $timeelapsed = microtime(true); |
||
| 3266 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3267 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3268 | } |
||
| 3269 | } |
||
| 3270 | } else $airline_array = array(); |
||
| 3271 | |||
| 3272 | //getting the aircraft information |
||
| 3273 | $aircraft_array = array(); |
||
| 3274 | if ($aircraft_icao != "") |
||
| 3275 | { |
||
| 3276 | if (!is_string($aircraft_icao)) |
||
| 3277 | { |
||
| 3278 | return false; |
||
| 3279 | } else { |
||
| 3280 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
||
| 3281 | { |
||
| 3282 | $timeelapsed = microtime(true); |
||
| 3283 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
||
| 3284 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3285 | } else { |
||
| 3286 | $timeelapsed = microtime(true); |
||
| 3287 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
||
| 3288 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3289 | } |
||
| 3290 | } |
||
| 3291 | } else { |
||
| 3292 | if ($ModeS != '') { |
||
| 3293 | $timeelapsed = microtime(true); |
||
| 3294 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
||
| 3295 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3296 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
||
| 3297 | { |
||
| 3298 | $timeelapsed = microtime(true); |
||
| 3299 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
||
| 3300 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3301 | } else { |
||
| 3302 | $timeelapsed = microtime(true); |
||
| 3303 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
||
| 3304 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3305 | } |
||
| 3306 | } |
||
| 3307 | } |
||
| 3308 | |||
| 3309 | //getting the departure airport information |
||
| 3310 | $departure_airport_array = array(); |
||
| 3311 | if ($departure_airport_icao != "") |
||
| 3312 | { |
||
| 3313 | if (!is_string($departure_airport_icao)) |
||
| 3314 | { |
||
| 3315 | return false; |
||
| 3316 | } else { |
||
| 3317 | $timeelapsed = microtime(true); |
||
| 3318 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
||
| 3319 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3320 | } |
||
| 3321 | } |
||
| 3322 | |||
| 3323 | //getting the arrival airport information |
||
| 3324 | $arrival_airport_array = array(); |
||
| 3325 | if ($arrival_airport_icao != "") |
||
| 3326 | { |
||
| 3327 | if (!is_string($arrival_airport_icao)) |
||
| 3328 | { |
||
| 3329 | return false; |
||
| 3330 | } else { |
||
| 3331 | $timeelapsed = microtime(true); |
||
| 3332 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
||
| 3333 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3334 | } |
||
| 3335 | } |
||
| 3336 | |||
| 3337 | |||
| 3338 | if ($latitude != "") |
||
| 3339 | { |
||
| 3340 | if (!is_numeric($latitude)) |
||
| 3341 | { |
||
| 3342 | return false; |
||
| 3343 | } |
||
| 3344 | } |
||
| 3345 | |||
| 3346 | if ($longitude != "") |
||
| 3347 | { |
||
| 3348 | if (!is_numeric($longitude)) |
||
| 3349 | { |
||
| 3350 | return false; |
||
| 3351 | } |
||
| 3352 | } |
||
| 3353 | |||
| 3354 | if ($waypoints != "") |
||
| 3355 | { |
||
| 3356 | if (!is_string($waypoints)) |
||
| 3357 | { |
||
| 3358 | return false; |
||
| 3359 | } |
||
| 3360 | } |
||
| 3361 | |||
| 3362 | if ($altitude != "") |
||
| 3363 | { |
||
| 3364 | if (!is_numeric($altitude)) |
||
| 3365 | { |
||
| 3366 | return false; |
||
| 3367 | } |
||
| 3368 | } else $altitude = 0; |
||
| 3369 | |||
| 3370 | if ($heading != "") |
||
| 3371 | { |
||
| 3372 | if (!is_numeric($heading)) |
||
| 3373 | { |
||
| 3374 | return false; |
||
| 3375 | } |
||
| 3376 | } |
||
| 3377 | |||
| 3378 | if ($groundspeed != "") |
||
| 3379 | { |
||
| 3380 | if (!is_numeric($groundspeed)) |
||
| 3381 | { |
||
| 3382 | return false; |
||
| 3383 | } |
||
| 3384 | } |
||
| 3385 | |||
| 3386 | |||
| 3387 | if ($date == "") |
||
| 3388 | { |
||
| 3389 | $date = date("Y-m-d H:i:s", time()); |
||
| 3390 | } |
||
| 3391 | |||
| 3392 | //getting the aircraft image |
||
| 3393 | if (($registration != "" || $registration != 'NA') && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM) |
||
| 3394 | { |
||
| 3395 | $timeelapsed = microtime(true); |
||
| 3396 | $image_array = $Image->getSpotterImage($registration); |
||
| 3397 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3398 | if (!isset($image_array[0]['registration'])) |
||
| 3399 | { |
||
| 3400 | //echo "Add image !!!! \n"; |
||
| 3401 | $Image->addSpotterImage($registration); |
||
| 3402 | } |
||
| 3403 | $timeelapsed = microtime(true); |
||
| 3404 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
||
| 3405 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3406 | if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
||
| 3407 | } |
||
| 3408 | |||
| 3409 | if ($globalIVAO && $aircraft_icao != '') |
||
| 3410 | { |
||
| 3411 | if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
||
| 3412 | else $airline_icao = ''; |
||
| 3413 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
||
| 3414 | if (!isset($image_array[0]['registration'])) |
||
| 3415 | { |
||
| 3416 | //echo "Add image !!!! \n"; |
||
| 3417 | $Image->addSpotterImage('',$aircraft_icao,$airline_icao); |
||
| 3418 | } |
||
| 3419 | } |
||
| 3420 | |||
| 3421 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
||
| 3422 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 3423 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 3424 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3425 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 3426 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 3427 | $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3428 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3429 | $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
||
| 3430 | $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3431 | $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
||
| 3432 | $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3433 | $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
||
| 3434 | $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
||
| 3435 | $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
||
| 3436 | $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
||
| 3437 | $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
||
| 3438 | $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
||
| 3439 | $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
||
| 3440 | |||
| 3441 | if (count($airline_array) == 0) |
||
| 3442 | { |
||
| 3443 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 3444 | } |
||
| 3445 | if (count($aircraft_array) == 0) |
||
| 3446 | { |
||
| 3447 | $aircraft_array = $this->getAllAircraftInfo('NA'); |
||
| 3448 | } |
||
| 3449 | if (count($departure_airport_array) == 0) |
||
| 3450 | { |
||
| 3451 | $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 3452 | } |
||
| 3453 | if (count($arrival_airport_array) == 0) |
||
| 3454 | { |
||
| 3455 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 3456 | } |
||
| 3457 | if ($registration == '') $registration = 'NA'; |
||
| 3458 | if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
||
| 3459 | if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
||
| 3460 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
||
| 3461 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
||
| 3462 | if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
||
| 3463 | $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
||
| 3464 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
||
| 3465 | |||
| 3466 | $airline_name = $airline_array[0]['name']; |
||
| 3467 | $airline_icao = $airline_array[0]['icao']; |
||
| 3468 | $airline_country = $airline_array[0]['country']; |
||
| 3469 | $airline_type = $airline_array[0]['type']; |
||
| 3470 | if ($airline_type == '') { |
||
| 3471 | $timeelapsed = microtime(true); |
||
| 3472 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
||
| 3473 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3474 | } |
||
| 3475 | if ($airline_type == null) $airline_type = ''; |
||
| 3476 | $aircraft_type = $aircraft_array[0]['type']; |
||
| 3477 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
||
| 3478 | $departure_airport_name = $departure_airport_array[0]['name']; |
||
| 3479 | $departure_airport_city = $departure_airport_array[0]['city']; |
||
| 3480 | $departure_airport_country = $departure_airport_array[0]['country']; |
||
| 3481 | $arrival_airport_name = $arrival_airport_array[0]['name']; |
||
| 3482 | $arrival_airport_city = $arrival_airport_array[0]['city']; |
||
| 3483 | $arrival_airport_country = $arrival_airport_array[0]['country']; |
||
| 3484 | $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name); |
||
| 3485 | |||
| 3486 | try { |
||
| 3487 | |||
| 3488 | $sth = $this->db->prepare($query); |
||
| 3489 | $sth->execute($query_values); |
||
| 3490 | $this->db = null; |
||
| 3491 | } catch (PDOException $e) { |
||
| 3492 | return "error : ".$e->getMessage(); |
||
| 3493 | } |
||
| 3494 | |||
| 3495 | return "success"; |
||
| 3496 | |||
| 3497 | } |
||
| 3498 | |||
| 3499 | |||
| 3500 | /** |
||
| 3501 | * Gets the aircraft ident within the last hour |
||
| 3502 | * |
||
| 3503 | * @return String the ident |
||
| 3504 | * |
||
| 3505 | */ |
||
| 3506 | public function getIdentFromLastHour($ident) |
||
| 3507 | { |
||
| 3508 | global $globalDBdriver, $globalTimezone; |
||
| 3509 | if ($globalDBdriver == 'mysql') { |
||
| 3510 | $query = "SELECT spotter_output.ident FROM spotter_output |
||
| 3511 | WHERE spotter_output.ident = :ident |
||
| 3512 | AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
||
| 3513 | AND spotter_output.date < UTC_TIMESTAMP()"; |
||
| 3514 | $query_data = array(':ident' => $ident); |
||
| 3515 | } else { |
||
| 3516 | $query = "SELECT spotter_output.ident FROM spotter_output |
||
| 3517 | WHERE spotter_output.ident = :ident |
||
| 3518 | AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
||
| 3519 | AND spotter_output.date < now() AT TIME ZONE 'UTC'"; |
||
| 3520 | $query_data = array(':ident' => $ident); |
||
| 3521 | } |
||
| 3522 | |||
| 3523 | $sth = $this->db->prepare($query); |
||
| 3524 | $sth->execute($query_data); |
||
| 3525 | $ident_result=''; |
||
| 3526 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3527 | { |
||
| 3528 | $ident_result = $row['ident']; |
||
| 3529 | } |
||
| 3530 | |||
| 3531 | return $ident_result; |
||
| 3532 | } |
||
| 3533 | |||
| 3534 | |||
| 3535 | /** |
||
| 3536 | * Gets the aircraft data from the last 20 seconds |
||
| 3537 | * |
||
| 3538 | * @return Array the spotter data |
||
| 3539 | * |
||
| 3540 | */ |
||
| 3541 | public function getRealTimeData($q = '') |
||
| 3542 | { |
||
| 3543 | global $globalDBdriver; |
||
| 3544 | $additional_query = ''; |
||
| 3545 | if ($q != "") |
||
| 3546 | { |
||
| 3547 | if (!is_string($q)) |
||
| 3548 | { |
||
| 3549 | return false; |
||
| 3550 | } else { |
||
| 3551 | $q_array = explode(" ", $q); |
||
| 3552 | foreach ($q_array as $q_item){ |
||
| 3553 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
||
| 3554 | $additional_query .= " AND ("; |
||
| 3555 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
||
| 3556 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
||
| 3557 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
||
| 3558 | $additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
||
| 3559 | $additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
||
| 3560 | $additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
||
| 3561 | $additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
||
| 3562 | $additional_query .= "(spotter_output.ident like '%".$q_item."%')"; |
||
| 3563 | $additional_query .= ")"; |
||
| 3564 | } |
||
| 3565 | } |
||
| 3566 | } |
||
| 3567 | if ($globalDBdriver == 'mysql') { |
||
| 3568 | $query = "SELECT spotter_output.* FROM spotter_output |
||
| 3569 | WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
||
| 3570 | AND spotter_output.date < UTC_TIMESTAMP()"; |
||
| 3571 | } else { |
||
| 3572 | $query = "SELECT spotter_output.* FROM spotter_output |
||
| 3573 | WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
||
| 3574 | AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
||
| 3575 | } |
||
| 3576 | $spotter_array = $this->getDataFromDB($query, array()); |
||
| 3577 | |||
| 3578 | return $spotter_array; |
||
| 3579 | } |
||
| 3580 | |||
| 3581 | |||
| 3582 | |||
| 3583 | /** |
||
| 3584 | * Gets all airlines that have flown over |
||
| 3585 | * |
||
| 3586 | * @return Array the airline list |
||
| 3587 | * |
||
| 3588 | */ |
||
| 3589 | public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3590 | { |
||
| 3591 | global $globalDBdriver; |
||
| 3592 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3593 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3594 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' "; |
||
| 3595 | if ($olderthanmonths > 0) { |
||
| 3596 | if ($globalDBdriver == 'mysql') { |
||
| 3597 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3598 | } else { |
||
| 3599 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3600 | } |
||
| 3601 | } |
||
| 3602 | if ($sincedate != '') { |
||
| 3603 | if ($globalDBdriver == 'mysql') { |
||
| 3604 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3605 | } else { |
||
| 3606 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3607 | } |
||
| 3608 | } |
||
| 3609 | $query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
||
| 3610 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3611 | |||
| 3612 | $sth = $this->db->prepare($query); |
||
| 3613 | $sth->execute(); |
||
| 3614 | |||
| 3615 | $airline_array = array(); |
||
| 3616 | $temp_array = array(); |
||
| 3617 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3618 | { |
||
| 3619 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3620 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3621 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3622 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3623 | $airline_array[] = $temp_array; |
||
| 3624 | } |
||
| 3625 | return $airline_array; |
||
| 3626 | } |
||
| 3627 | |||
| 3628 | /** |
||
| 3629 | * Gets all pilots that have flown over |
||
| 3630 | * |
||
| 3631 | * @return Array the pilots list |
||
| 3632 | * |
||
| 3633 | */ |
||
| 3634 | public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3635 | { |
||
| 3636 | global $globalDBdriver; |
||
| 3637 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3638 | $query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count |
||
| 3639 | FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' "; |
||
| 3640 | if ($olderthanmonths > 0) { |
||
| 3641 | if ($globalDBdriver == 'mysql') { |
||
| 3642 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3643 | } else { |
||
| 3644 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3645 | } |
||
| 3646 | } |
||
| 3647 | if ($sincedate != '') { |
||
| 3648 | if ($globalDBdriver == 'mysql') { |
||
| 3649 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3650 | } else { |
||
| 3651 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3652 | } |
||
| 3653 | } |
||
| 3654 | $query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
||
| 3655 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3656 | |||
| 3657 | |||
| 3658 | $sth = $this->db->prepare($query); |
||
| 3659 | $sth->execute(); |
||
| 3660 | |||
| 3661 | $airline_array = array(); |
||
| 3662 | $temp_array = array(); |
||
| 3663 | |||
| 3664 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3665 | { |
||
| 3666 | $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 3667 | $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 3668 | $temp_array['pilot_count'] = $row['pilot_count']; |
||
| 3669 | $airline_array[] = $temp_array; |
||
| 3670 | } |
||
| 3671 | return $airline_array; |
||
| 3672 | } |
||
| 3673 | |||
| 3674 | /** |
||
| 3675 | * Gets all pilots that have flown over |
||
| 3676 | * |
||
| 3677 | * @return Array the pilots list |
||
| 3678 | * |
||
| 3679 | */ |
||
| 3680 | public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
||
| 3681 | { |
||
| 3682 | global $globalDBdriver; |
||
| 3683 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count |
||
| 3684 | FROM spotter_output WHERE spotter_output.pilot_id <> '' "; |
||
| 3685 | if ($olderthanmonths > 0) { |
||
| 3686 | if ($globalDBdriver == 'mysql') { |
||
| 3687 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3688 | } else { |
||
| 3689 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3690 | } |
||
| 3691 | } |
||
| 3692 | if ($sincedate != '') { |
||
| 3693 | if ($globalDBdriver == 'mysql') { |
||
| 3694 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3695 | } else { |
||
| 3696 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3697 | } |
||
| 3698 | } |
||
| 3699 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
||
| 3700 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3701 | |||
| 3702 | |||
| 3703 | $sth = $this->db->prepare($query); |
||
| 3704 | $sth->execute(); |
||
| 3705 | |||
| 3706 | $airline_array = array(); |
||
| 3707 | $temp_array = array(); |
||
| 3708 | |||
| 3709 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3710 | { |
||
| 3711 | $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 3712 | $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 3713 | $temp_array['pilot_count'] = $row['pilot_count']; |
||
| 3714 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3715 | $airline_array[] = $temp_array; |
||
| 3716 | } |
||
| 3717 | return $airline_array; |
||
| 3718 | } |
||
| 3719 | |||
| 3720 | /** |
||
| 3721 | * Gets all owner that have flown over |
||
| 3722 | * |
||
| 3723 | * @return Array the pilots list |
||
| 3724 | * |
||
| 3725 | */ |
||
| 3726 | public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3727 | { |
||
| 3728 | global $globalDBdriver; |
||
| 3729 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3730 | $query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
||
| 3731 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
||
| 3732 | if ($olderthanmonths > 0) { |
||
| 3733 | if ($globalDBdriver == 'mysql') { |
||
| 3734 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3735 | } else { |
||
| 3736 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3737 | } |
||
| 3738 | } |
||
| 3739 | if ($sincedate != '') { |
||
| 3740 | if ($globalDBdriver == 'mysql') { |
||
| 3741 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3742 | } else { |
||
| 3743 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3744 | } |
||
| 3745 | } |
||
| 3746 | $query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
||
| 3747 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3748 | |||
| 3749 | |||
| 3750 | $sth = $this->db->prepare($query); |
||
| 3751 | $sth->execute(); |
||
| 3752 | |||
| 3753 | $airline_array = array(); |
||
| 3754 | $temp_array = array(); |
||
| 3755 | |||
| 3756 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3757 | { |
||
| 3758 | $temp_array['owner_name'] = $row['owner_name']; |
||
| 3759 | $temp_array['owner_count'] = $row['owner_count']; |
||
| 3760 | $airline_array[] = $temp_array; |
||
| 3761 | } |
||
| 3762 | return $airline_array; |
||
| 3763 | } |
||
| 3764 | |||
| 3765 | /** |
||
| 3766 | * Gets all owner that have flown over |
||
| 3767 | * |
||
| 3768 | * @return Array the pilots list |
||
| 3769 | * |
||
| 3770 | */ |
||
| 3771 | public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3772 | { |
||
| 3773 | global $globalDBdriver; |
||
| 3774 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3775 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
||
| 3776 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
||
| 3777 | if ($olderthanmonths > 0) { |
||
| 3778 | if ($globalDBdriver == 'mysql') { |
||
| 3779 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3780 | } else { |
||
| 3781 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3782 | } |
||
| 3783 | } |
||
| 3784 | if ($sincedate != '') { |
||
| 3785 | if ($globalDBdriver == 'mysql') { |
||
| 3786 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3787 | } else { |
||
| 3788 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3789 | } |
||
| 3790 | } |
||
| 3791 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
||
| 3792 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3793 | |||
| 3794 | |||
| 3795 | $sth = $this->db->prepare($query); |
||
| 3796 | $sth->execute(); |
||
| 3797 | |||
| 3798 | $airline_array = array(); |
||
| 3799 | $temp_array = array(); |
||
| 3800 | |||
| 3801 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3802 | { |
||
| 3803 | $temp_array['owner_name'] = $row['owner_name']; |
||
| 3804 | $temp_array['owner_count'] = $row['owner_count']; |
||
| 3805 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3806 | $airline_array[] = $temp_array; |
||
| 3807 | } |
||
| 3808 | return $airline_array; |
||
| 3809 | } |
||
| 3810 | |||
| 3811 | /** |
||
| 3812 | * Gets all airlines that have flown over by aircraft |
||
| 3813 | * |
||
| 3814 | * @return Array the airline list |
||
| 3815 | * |
||
| 3816 | */ |
||
| 3817 | public function countAllAirlinesByAircraft($aircraft_icao,$filters = array()) |
||
| 3818 | { |
||
| 3819 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3820 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3821 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3822 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 3823 | GROUP BY spotter_output.airline_name |
||
| 3824 | ORDER BY airline_count DESC"; |
||
| 3825 | |||
| 3826 | |||
| 3827 | $sth = $this->db->prepare($query); |
||
| 3828 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 3829 | |||
| 3830 | $airline_array = array(); |
||
| 3831 | $temp_array = array(); |
||
| 3832 | |||
| 3833 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3834 | { |
||
| 3835 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3836 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3837 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3838 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3839 | |||
| 3840 | $airline_array[] = $temp_array; |
||
| 3841 | } |
||
| 3842 | |||
| 3843 | return $airline_array; |
||
| 3844 | } |
||
| 3845 | |||
| 3846 | |||
| 3847 | /** |
||
| 3848 | * Gets all airline countries that have flown over by aircraft |
||
| 3849 | * |
||
| 3850 | * @return Array the airline country list |
||
| 3851 | * |
||
| 3852 | */ |
||
| 3853 | public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 3854 | { |
||
| 3855 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3856 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3857 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 3858 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 3859 | GROUP BY spotter_output.airline_country |
||
| 3860 | ORDER BY airline_country_count DESC |
||
| 3861 | LIMIT 10 OFFSET 0"; |
||
| 3862 | |||
| 3863 | |||
| 3864 | $sth = $this->db->prepare($query); |
||
| 3865 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 3866 | |||
| 3867 | $airline_country_array = array(); |
||
| 3868 | $temp_array = array(); |
||
| 3869 | |||
| 3870 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3871 | { |
||
| 3872 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 3873 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3874 | |||
| 3875 | $airline_country_array[] = $temp_array; |
||
| 3876 | } |
||
| 3877 | return $airline_country_array; |
||
| 3878 | } |
||
| 3879 | |||
| 3880 | |||
| 3881 | |||
| 3882 | |||
| 3883 | /** |
||
| 3884 | * Gets all airlines that have flown over by airport |
||
| 3885 | * |
||
| 3886 | * @return Array the airline list |
||
| 3887 | * |
||
| 3888 | */ |
||
| 3889 | public function countAllAirlinesByAirport($airport_icao,$filters = array()) |
||
| 3890 | { |
||
| 3891 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 3892 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3893 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3894 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
||
| 3895 | GROUP BY spotter_output.airline_name |
||
| 3896 | ORDER BY airline_count DESC"; |
||
| 3897 | |||
| 3898 | |||
| 3899 | $sth = $this->db->prepare($query); |
||
| 3900 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 3901 | |||
| 3902 | $airline_array = array(); |
||
| 3903 | $temp_array = array(); |
||
| 3904 | |||
| 3905 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3906 | { |
||
| 3907 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3908 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3909 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3910 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3911 | |||
| 3912 | $airline_array[] = $temp_array; |
||
| 3913 | } |
||
| 3914 | return $airline_array; |
||
| 3915 | } |
||
| 3916 | |||
| 3917 | |||
| 3918 | /** |
||
| 3919 | * Gets all airline countries that have flown over by airport icao |
||
| 3920 | * |
||
| 3921 | * @return Array the airline country list |
||
| 3922 | * |
||
| 3923 | */ |
||
| 3924 | public function countAllAirlineCountriesByAirport($airport_icao,$filters = array()) |
||
| 3925 | { |
||
| 3926 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 3927 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3928 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 3929 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
||
| 3930 | GROUP BY spotter_output.airline_country |
||
| 3931 | ORDER BY airline_country_count DESC |
||
| 3932 | LIMIT 10 OFFSET 0"; |
||
| 3933 | |||
| 3934 | |||
| 3935 | $sth = $this->db->prepare($query); |
||
| 3936 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 3937 | |||
| 3938 | $airline_country_array = array(); |
||
| 3939 | $temp_array = array(); |
||
| 3940 | |||
| 3941 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3942 | { |
||
| 3943 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 3944 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3945 | |||
| 3946 | $airline_country_array[] = $temp_array; |
||
| 3947 | } |
||
| 3948 | return $airline_country_array; |
||
| 3949 | } |
||
| 3950 | |||
| 3951 | |||
| 3952 | /** |
||
| 3953 | * Gets all airlines that have flown over by aircraft manufacturer |
||
| 3954 | * |
||
| 3955 | * @return Array the airline list |
||
| 3956 | * |
||
| 3957 | */ |
||
| 3958 | public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 3959 | { |
||
| 3960 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 3961 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3962 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3963 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 3964 | GROUP BY spotter_output.airline_name |
||
| 3965 | ORDER BY airline_count DESC"; |
||
| 3966 | |||
| 3967 | $sth = $this->db->prepare($query); |
||
| 3968 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 3969 | |||
| 3970 | $airline_array = array(); |
||
| 3971 | $temp_array = array(); |
||
| 3972 | |||
| 3973 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3974 | { |
||
| 3975 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3976 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3977 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3978 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3979 | |||
| 3980 | $airline_array[] = $temp_array; |
||
| 3981 | } |
||
| 3982 | return $airline_array; |
||
| 3983 | } |
||
| 3984 | |||
| 3985 | |||
| 3986 | |||
| 3987 | /** |
||
| 3988 | * Gets all airline countries that have flown over by aircraft manufacturer |
||
| 3989 | * |
||
| 3990 | * @return Array the airline country list |
||
| 3991 | * |
||
| 3992 | */ |
||
| 3993 | public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 3994 | { |
||
| 3995 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 3996 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3997 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 3998 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 3999 | GROUP BY spotter_output.airline_country |
||
| 4000 | ORDER BY airline_country_count DESC |
||
| 4001 | LIMIT 10 OFFSET 0"; |
||
| 4002 | |||
| 4003 | |||
| 4004 | $sth = $this->db->prepare($query); |
||
| 4005 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 4006 | |||
| 4007 | $airline_country_array = array(); |
||
| 4008 | $temp_array = array(); |
||
| 4009 | |||
| 4010 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4011 | { |
||
| 4012 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4013 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4014 | $airline_country_array[] = $temp_array; |
||
| 4015 | } |
||
| 4016 | return $airline_country_array; |
||
| 4017 | } |
||
| 4018 | |||
| 4019 | |||
| 4020 | /** |
||
| 4021 | * Gets all airlines that have flown over by date |
||
| 4022 | * |
||
| 4023 | * @return Array the airline list |
||
| 4024 | * |
||
| 4025 | */ |
||
| 4026 | public function countAllAirlinesByDate($date,$filters = array()) |
||
| 4027 | { |
||
| 4028 | global $globalTimezone, $globalDBdriver; |
||
| 4029 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4030 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4031 | if ($globalTimezone != '') { |
||
| 4032 | date_default_timezone_set($globalTimezone); |
||
| 4033 | $datetime = new DateTime($date); |
||
| 4034 | $offset = $datetime->format('P'); |
||
| 4035 | } else $offset = '+00:00'; |
||
| 4036 | |||
| 4037 | if ($globalDBdriver == 'mysql') { |
||
| 4038 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4039 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4040 | GROUP BY spotter_output.airline_name |
||
| 4041 | ORDER BY airline_count DESC"; |
||
| 4042 | } else { |
||
| 4043 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4044 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4045 | GROUP BY spotter_output.airline_name |
||
| 4046 | ORDER BY airline_count DESC"; |
||
| 4047 | } |
||
| 4048 | |||
| 4049 | $sth = $this->db->prepare($query); |
||
| 4050 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4051 | |||
| 4052 | $airline_array = array(); |
||
| 4053 | $temp_array = array(); |
||
| 4054 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4055 | { |
||
| 4056 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4057 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4058 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4059 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4060 | |||
| 4061 | $airline_array[] = $temp_array; |
||
| 4062 | } |
||
| 4063 | |||
| 4064 | return $airline_array; |
||
| 4065 | } |
||
| 4066 | |||
| 4067 | |||
| 4068 | /** |
||
| 4069 | * Gets all airline countries that have flown over by date |
||
| 4070 | * |
||
| 4071 | * @return Array the airline country list |
||
| 4072 | * |
||
| 4073 | */ |
||
| 4074 | public function countAllAirlineCountriesByDate($date,$filters = array()) |
||
| 4075 | { |
||
| 4076 | global $globalTimezone, $globalDBdriver; |
||
| 4077 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4078 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4079 | if ($globalTimezone != '') { |
||
| 4080 | date_default_timezone_set($globalTimezone); |
||
| 4081 | $datetime = new DateTime($date); |
||
| 4082 | $offset = $datetime->format('P'); |
||
| 4083 | } else $offset = '+00:00'; |
||
| 4084 | |||
| 4085 | if ($globalDBdriver == 'mysql') { |
||
| 4086 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4087 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4088 | GROUP BY spotter_output.airline_country |
||
| 4089 | ORDER BY airline_country_count DESC |
||
| 4090 | LIMIT 10 OFFSET 0"; |
||
| 4091 | } else { |
||
| 4092 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4093 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4094 | GROUP BY spotter_output.airline_country |
||
| 4095 | ORDER BY airline_country_count DESC |
||
| 4096 | LIMIT 10 OFFSET 0"; |
||
| 4097 | } |
||
| 4098 | |||
| 4099 | $sth = $this->db->prepare($query); |
||
| 4100 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4101 | |||
| 4102 | $airline_country_array = array(); |
||
| 4103 | $temp_array = array(); |
||
| 4104 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4105 | { |
||
| 4106 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4107 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4108 | |||
| 4109 | $airline_country_array[] = $temp_array; |
||
| 4110 | } |
||
| 4111 | return $airline_country_array; |
||
| 4112 | } |
||
| 4113 | |||
| 4114 | |||
| 4115 | /** |
||
| 4116 | * Gets all airlines that have flown over by ident/callsign |
||
| 4117 | * |
||
| 4118 | * @return Array the airline list |
||
| 4119 | * |
||
| 4120 | */ |
||
| 4121 | public function countAllAirlinesByIdent($ident,$filters = array()) |
||
| 4122 | { |
||
| 4123 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 4124 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4125 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4126 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
||
| 4127 | GROUP BY spotter_output.airline_name |
||
| 4128 | ORDER BY airline_count DESC"; |
||
| 4129 | |||
| 4130 | |||
| 4131 | $sth = $this->db->prepare($query); |
||
| 4132 | $sth->execute(array(':ident' => $ident)); |
||
| 4133 | |||
| 4134 | $airline_array = array(); |
||
| 4135 | $temp_array = array(); |
||
| 4136 | |||
| 4137 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4138 | { |
||
| 4139 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4140 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4141 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4142 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4143 | |||
| 4144 | $airline_array[] = $temp_array; |
||
| 4145 | } |
||
| 4146 | return $airline_array; |
||
| 4147 | } |
||
| 4148 | |||
| 4149 | /** |
||
| 4150 | * Gets all airlines that have flown over by route |
||
| 4151 | * |
||
| 4152 | * @return Array the airline list |
||
| 4153 | * |
||
| 4154 | */ |
||
| 4155 | public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 4156 | { |
||
| 4157 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4158 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4159 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4160 | |||
| 4161 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4162 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 4163 | GROUP BY spotter_output.airline_name |
||
| 4164 | ORDER BY airline_count DESC"; |
||
| 4165 | |||
| 4166 | |||
| 4167 | $sth = $this->db->prepare($query); |
||
| 4168 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 4169 | |||
| 4170 | $airline_array = array(); |
||
| 4171 | $temp_array = array(); |
||
| 4172 | |||
| 4173 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4174 | { |
||
| 4175 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4176 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4177 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4178 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4179 | |||
| 4180 | $airline_array[] = $temp_array; |
||
| 4181 | } |
||
| 4182 | return $airline_array; |
||
| 4183 | } |
||
| 4184 | |||
| 4185 | /** |
||
| 4186 | * Gets all airline countries that have flown over by route |
||
| 4187 | * |
||
| 4188 | * @return Array the airline country list |
||
| 4189 | * |
||
| 4190 | */ |
||
| 4191 | public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array()) |
||
| 4192 | { |
||
| 4193 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4194 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4195 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4196 | |||
| 4197 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4198 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 4199 | GROUP BY spotter_output.airline_country |
||
| 4200 | ORDER BY airline_country_count DESC |
||
| 4201 | LIMIT 10 OFFSET 0"; |
||
| 4202 | |||
| 4203 | |||
| 4204 | $sth = $this->db->prepare($query); |
||
| 4205 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 4206 | |||
| 4207 | $airline_country_array = array(); |
||
| 4208 | $temp_array = array(); |
||
| 4209 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4210 | { |
||
| 4211 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4212 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4213 | |||
| 4214 | $airline_country_array[] = $temp_array; |
||
| 4215 | } |
||
| 4216 | |||
| 4217 | return $airline_country_array; |
||
| 4218 | } |
||
| 4219 | |||
| 4220 | |||
| 4221 | /** |
||
| 4222 | * Gets all airlines that have flown over by country |
||
| 4223 | * |
||
| 4224 | * @return Array the airline list |
||
| 4225 | * |
||
| 4226 | */ |
||
| 4227 | public function countAllAirlinesByCountry($country,$filters = array()) |
||
| 4228 | { |
||
| 4229 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 4230 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4231 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4232 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 4233 | GROUP BY spotter_output.airline_name |
||
| 4234 | ORDER BY airline_count DESC"; |
||
| 4235 | |||
| 4236 | |||
| 4237 | $sth = $this->db->prepare($query); |
||
| 4238 | $sth->execute(array(':country' => $country)); |
||
| 4239 | |||
| 4240 | $airline_array = array(); |
||
| 4241 | $temp_array = array(); |
||
| 4242 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4243 | { |
||
| 4244 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4245 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4246 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4247 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4248 | |||
| 4249 | $airline_array[] = $temp_array; |
||
| 4250 | } |
||
| 4251 | return $airline_array; |
||
| 4252 | } |
||
| 4253 | |||
| 4254 | |||
| 4255 | /** |
||
| 4256 | * Gets all airline countries that have flown over by country |
||
| 4257 | * |
||
| 4258 | * @return Array the airline country list |
||
| 4259 | * |
||
| 4260 | */ |
||
| 4261 | public function countAllAirlineCountriesByCountry($country,$filters = array()) |
||
| 4262 | { |
||
| 4263 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4264 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 4265 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4266 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 4267 | GROUP BY spotter_output.airline_country |
||
| 4268 | ORDER BY airline_country_count DESC |
||
| 4269 | LIMIT 10 OFFSET 0"; |
||
| 4270 | |||
| 4271 | |||
| 4272 | $sth = $this->db->prepare($query); |
||
| 4273 | $sth->execute(array(':country' => $country)); |
||
| 4274 | |||
| 4275 | $airline_country_array = array(); |
||
| 4276 | $temp_array = array(); |
||
| 4277 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4278 | { |
||
| 4279 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4280 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4281 | |||
| 4282 | $airline_country_array[] = $temp_array; |
||
| 4283 | } |
||
| 4284 | return $airline_country_array; |
||
| 4285 | } |
||
| 4286 | |||
| 4287 | |||
| 4288 | /** |
||
| 4289 | * Gets all airlines countries |
||
| 4290 | * |
||
| 4291 | * @return Array the airline country list |
||
| 4292 | * |
||
| 4293 | */ |
||
| 4294 | public function countAllAirlineCountries($limit = true, $filters = array()) |
||
| 4295 | { |
||
| 4296 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4297 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4298 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' |
||
| 4299 | GROUP BY spotter_output.airline_country |
||
| 4300 | ORDER BY airline_country_count DESC"; |
||
| 4301 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4302 | |||
| 4303 | $sth = $this->db->prepare($query); |
||
| 4304 | $sth->execute(); |
||
| 4305 | |||
| 4306 | $airline_array = array(); |
||
| 4307 | $temp_array = array(); |
||
| 4308 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4309 | { |
||
| 4310 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4311 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4312 | |||
| 4313 | $airline_array[] = $temp_array; |
||
| 4314 | } |
||
| 4315 | return $airline_array; |
||
| 4316 | } |
||
| 4317 | |||
| 4318 | /** |
||
| 4319 | * Gets all number of flight over countries |
||
| 4320 | * |
||
| 4321 | * @return Array the airline country list |
||
| 4322 | * |
||
| 4323 | */ |
||
| 4324 | public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
||
| 4325 | { |
||
| 4326 | global $globalDBdriver; |
||
| 4327 | //$filter_query = $this->getFilter($filters,true,true); |
||
| 4328 | $Connection= new Connection($this->db); |
||
| 4329 | if (!$Connection->tableExists('countries')) return array(); |
||
| 4330 | /* |
||
| 4331 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
||
| 4332 | FROM countries c, spotter_output s |
||
| 4333 | WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; |
||
| 4334 | */ |
||
| 4335 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
||
| 4336 | FROM countries c, spotter_live s |
||
| 4337 | WHERE c.iso2 = s.over_country "; |
||
| 4338 | if ($olderthanmonths > 0) { |
||
| 4339 | if ($globalDBdriver == 'mysql') { |
||
| 4340 | $query .= 'AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 4341 | } else { |
||
| 4342 | $query .= "AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 4343 | } |
||
| 4344 | } |
||
| 4345 | if ($sincedate != '') { |
||
| 4346 | if ($globalDBdriver == 'mysql') { |
||
| 4347 | $query .= "AND spotter_live.date > '".$sincedate."' "; |
||
| 4348 | } else { |
||
| 4349 | $query .= "AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4350 | } |
||
| 4351 | } |
||
| 4352 | |||
| 4353 | $query .= "GROUP BY c.name ORDER BY nb DESC"; |
||
| 4354 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4355 | |||
| 4356 | |||
| 4357 | $sth = $this->db->prepare($query); |
||
| 4358 | $sth->execute(); |
||
| 4359 | |||
| 4360 | $flight_array = array(); |
||
| 4361 | $temp_array = array(); |
||
| 4362 | |||
| 4363 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4364 | { |
||
| 4365 | $temp_array['flight_count'] = $row['nb']; |
||
| 4366 | $temp_array['flight_country'] = $row['name']; |
||
| 4367 | $temp_array['flight_country_iso3'] = $row['iso3']; |
||
| 4368 | $temp_array['flight_country_iso2'] = $row['iso2']; |
||
| 4369 | $flight_array[] = $temp_array; |
||
| 4370 | } |
||
| 4371 | return $flight_array; |
||
| 4372 | } |
||
| 4373 | |||
| 4374 | |||
| 4375 | /** |
||
| 4376 | * Gets all aircraft types that have flown over |
||
| 4377 | * |
||
| 4378 | * @return Array the aircraft list |
||
| 4379 | * |
||
| 4380 | */ |
||
| 4381 | public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 4421 | |||
| 4422 | /** |
||
| 4423 | * Gets all aircraft types that have flown over by airline |
||
| 4424 | * |
||
| 4425 | * @return Array the aircraft list |
||
| 4426 | * |
||
| 4427 | */ |
||
| 4428 | public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 4429 | { |
||
| 4430 | global $globalDBdriver; |
||
| 4431 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4432 | $query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
||
| 4433 | FROM spotter_output".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' "; |
||
| 4434 | if ($olderthanmonths > 0) { |
||
| 4435 | if ($globalDBdriver == 'mysql') { |
||
| 4436 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 4437 | } else { |
||
| 4438 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 4439 | } |
||
| 4440 | } |
||
| 4441 | if ($sincedate != '') { |
||
| 4442 | if ($globalDBdriver == 'mysql') { |
||
| 4443 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 4444 | } else { |
||
| 4445 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4446 | } |
||
| 4447 | } |
||
| 4448 | |||
| 4449 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
||
| 4450 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4451 | |||
| 4452 | $sth = $this->db->prepare($query); |
||
| 4453 | $sth->execute(); |
||
| 4454 | |||
| 4455 | $aircraft_array = array(); |
||
| 4456 | $temp_array = array(); |
||
| 4457 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4458 | { |
||
| 4459 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4460 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4461 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4462 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 4463 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4464 | $aircraft_array[] = $temp_array; |
||
| 4465 | } |
||
| 4466 | return $aircraft_array; |
||
| 4467 | } |
||
| 4468 | |||
| 4469 | |||
| 4470 | /** |
||
| 4471 | * Gets all aircraft registration that have flown over by aircaft icao |
||
| 4472 | * |
||
| 4473 | * @return Array the aircraft list |
||
| 4474 | * |
||
| 4475 | */ |
||
| 4476 | public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array()) |
||
| 4477 | { |
||
| 4478 | $Image = new Image($this->db); |
||
| 4479 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4480 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 4481 | |||
| 4482 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
||
| 4483 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 4484 | GROUP BY spotter_output.registration |
||
| 4485 | ORDER BY registration_count DESC"; |
||
| 4486 | |||
| 4487 | $sth = $this->db->prepare($query); |
||
| 4488 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 4489 | |||
| 4490 | $aircraft_array = array(); |
||
| 4491 | $temp_array = array(); |
||
| 4492 | |||
| 4493 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4494 | { |
||
| 4495 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4496 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4497 | $temp_array['registration'] = $row['registration']; |
||
| 4498 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4499 | $temp_array['image_thumbnail'] = ""; |
||
| 4500 | if($row['registration'] != "") |
||
| 4501 | { |
||
| 4511 | |||
| 4512 | |||
| 4513 | /** |
||
| 4514 | * Gets all aircraft types that have flown over by airline icao |
||
| 4515 | * |
||
| 4516 | * @return Array the aircraft list |
||
| 4517 | * |
||
| 4518 | */ |
||
| 4519 | public function countAllAircraftTypesByAirline($airline_icao,$filters = array()) |
||
| 4544 | |||
| 4545 | |||
| 4546 | /** |
||
| 4547 | * Gets all aircraft registration that have flown over by airline icao |
||
| 4548 | * |
||
| 4549 | * @return Array the aircraft list |
||
| 4550 | * |
||
| 4551 | */ |
||
| 4552 | public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array()) |
||
| 4586 | |||
| 4587 | |||
| 4588 | /** |
||
| 4589 | * Gets all aircraft manufacturer that have flown over by airline icao |
||
| 4590 | * |
||
| 4591 | * @return Array the aircraft list |
||
| 4592 | * |
||
| 4593 | */ |
||
| 4594 | public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array()) |
||
| 4618 | |||
| 4619 | |||
| 4620 | /** |
||
| 4621 | * Gets all aircraft types that have flown over by airline icao |
||
| 4622 | * |
||
| 4623 | * @return Array the aircraft list |
||
| 4624 | * |
||
| 4625 | */ |
||
| 4626 | public function countAllAircraftTypesByAirport($airport_icao,$filters = array()) |
||
| 4651 | |||
| 4652 | |||
| 4653 | /** |
||
| 4654 | * Gets all aircraft registration that have flown over by airport icao |
||
| 4655 | * |
||
| 4656 | * @return Array the aircraft list |
||
| 4657 | * |
||
| 4658 | */ |
||
| 4659 | public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array()) |
||
| 4693 | |||
| 4694 | |||
| 4695 | /** |
||
| 4696 | * Gets all aircraft manufacturer that have flown over by airport icao |
||
| 4697 | * |
||
| 4698 | * @return Array the aircraft list |
||
| 4699 | * |
||
| 4700 | */ |
||
| 4701 | public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array()) |
||
| 4724 | |||
| 4725 | /** |
||
| 4726 | * Gets all aircraft types that have flown over by aircraft manufacturer |
||
| 4727 | * |
||
| 4728 | * @return Array the aircraft list |
||
| 4729 | * |
||
| 4730 | */ |
||
| 4731 | public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 4754 | |||
| 4755 | |||
| 4756 | /** |
||
| 4757 | * Gets all aircraft registration that have flown over by aircaft manufacturer |
||
| 4758 | * |
||
| 4759 | * @return Array the aircraft list |
||
| 4760 | * |
||
| 4761 | */ |
||
| 4762 | public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array()) |
||
| 4795 | |||
| 4796 | /** |
||
| 4797 | * Gets all aircraft types that have flown over by date |
||
| 4798 | * |
||
| 4799 | * @return Array the aircraft list |
||
| 4800 | * |
||
| 4801 | */ |
||
| 4802 | public function countAllAircraftTypesByDate($date,$filters = array()) |
||
| 4840 | |||
| 4841 | |||
| 4842 | /** |
||
| 4843 | * Gets all aircraft registration that have flown over by date |
||
| 4844 | * |
||
| 4845 | * @return Array the aircraft list |
||
| 4846 | * |
||
| 4847 | */ |
||
| 4848 | public function countAllAircraftRegistrationByDate($date,$filters = array()) |
||
| 4895 | |||
| 4896 | |||
| 4897 | /** |
||
| 4898 | * Gets all aircraft manufacturer that have flown over by date |
||
| 4899 | * |
||
| 4900 | * @return Array the aircraft manufacturer list |
||
| 4901 | * |
||
| 4902 | */ |
||
| 4903 | public function countAllAircraftManufacturerByDate($date,$filters = array()) |
||
| 4941 | |||
| 4942 | |||
| 4943 | /** |
||
| 4944 | * Gets all aircraft types that have flown over by ident/callsign |
||
| 4945 | * |
||
| 4946 | * @return Array the aircraft list |
||
| 4947 | * |
||
| 4948 | */ |
||
| 4949 | public function countAllAircraftTypesByIdent($ident,$filters = array()) |
||
| 4974 | |||
| 4975 | |||
| 4976 | /** |
||
| 4977 | * Gets all aircraft registration that have flown over by ident/callsign |
||
| 4978 | * |
||
| 4979 | * @return Array the aircraft list |
||
| 4980 | * |
||
| 4981 | */ |
||
| 4982 | public function countAllAircraftRegistrationByIdent($ident,$filters = array()) |
||
| 5018 | |||
| 5019 | |||
| 5020 | /** |
||
| 5021 | * Gets all aircraft manufacturer that have flown over by ident/callsign |
||
| 5022 | * |
||
| 5023 | * @return Array the aircraft manufacturer list |
||
| 5024 | * |
||
| 5025 | */ |
||
| 5026 | public function countAllAircraftManufacturerByIdent($ident,$filters = array()) |
||
| 5048 | |||
| 5049 | |||
| 5050 | /** |
||
| 5051 | * Gets all aircraft types that have flown over by route |
||
| 5052 | * |
||
| 5053 | * @return Array the aircraft list |
||
| 5054 | * |
||
| 5055 | */ |
||
| 5056 | public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 5082 | |||
| 5083 | /** |
||
| 5084 | * Gets all aircraft registration that have flown over by route |
||
| 5085 | * |
||
| 5086 | * @return Array the aircraft list |
||
| 5087 | * |
||
| 5088 | */ |
||
| 5089 | public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 5127 | |||
| 5128 | |||
| 5129 | /** |
||
| 5130 | * Gets all aircraft manufacturer that have flown over by route |
||
| 5131 | * |
||
| 5132 | * @return Array the aircraft manufacturer list |
||
| 5133 | * |
||
| 5134 | */ |
||
| 5135 | public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 5163 | |||
| 5164 | |||
| 5165 | |||
| 5166 | |||
| 5167 | /** |
||
| 5168 | * Gets all aircraft types that have flown over by country |
||
| 5169 | * |
||
| 5170 | * @return Array the aircraft list |
||
| 5171 | * |
||
| 5172 | */ |
||
| 5173 | public function countAllAircraftTypesByCountry($country,$filters = array()) |
||
| 5200 | |||
| 5201 | |||
| 5202 | /** |
||
| 5203 | * Gets all aircraft registration that have flown over by country |
||
| 5204 | * |
||
| 5205 | * @return Array the aircraft list |
||
| 5206 | * |
||
| 5207 | */ |
||
| 5208 | public function countAllAircraftRegistrationByCountry($country,$filters = array()) |
||
| 5244 | |||
| 5245 | |||
| 5246 | /** |
||
| 5247 | * Gets all aircraft manufacturer that have flown over by country |
||
| 5248 | * |
||
| 5249 | * @return Array the aircraft manufacturer list |
||
| 5250 | * |
||
| 5251 | */ |
||
| 5252 | public function countAllAircraftManufacturerByCountry($country,$filters = array()) |
||
| 5278 | |||
| 5279 | |||
| 5280 | |||
| 5281 | /** |
||
| 5282 | * Gets all aircraft manufacturers that have flown over |
||
| 5283 | * |
||
| 5284 | * @return Array the aircraft list |
||
| 5285 | * |
||
| 5286 | */ |
||
| 5287 | public function countAllAircraftManufacturers($filters = array()) |
||
| 5313 | |||
| 5314 | |||
| 5315 | |||
| 5316 | /** |
||
| 5317 | * Gets all aircraft registrations that have flown over |
||
| 5318 | * |
||
| 5319 | * @return Array the aircraft list |
||
| 5320 | * |
||
| 5321 | */ |
||
| 5322 | public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 5374 | |||
| 5375 | |||
| 5376 | /** |
||
| 5377 | * Gets all aircraft registrations that have flown over |
||
| 5378 | * |
||
| 5379 | * @return Array the aircraft list |
||
| 5380 | * |
||
| 5381 | */ |
||
| 5382 | public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 5435 | |||
| 5436 | |||
| 5437 | /** |
||
| 5438 | * Gets all departure airports of the airplanes that have flown over |
||
| 5439 | * |
||
| 5440 | * @return Array the airport list |
||
| 5441 | * |
||
| 5442 | */ |
||
| 5443 | public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5488 | |||
| 5489 | /** |
||
| 5490 | * Gets all departure airports of the airplanes that have flown over |
||
| 5491 | * |
||
| 5492 | * @return Array the airport list |
||
| 5493 | * |
||
| 5494 | */ |
||
| 5495 | public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5541 | |||
| 5542 | /** |
||
| 5543 | * Gets all detected departure airports of the airplanes that have flown over |
||
| 5544 | * |
||
| 5545 | * @return Array the airport list |
||
| 5546 | * |
||
| 5547 | */ |
||
| 5548 | public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5592 | |||
| 5593 | /** |
||
| 5594 | * Gets all detected departure airports of the airplanes that have flown over |
||
| 5595 | * |
||
| 5596 | * @return Array the airport list |
||
| 5597 | * |
||
| 5598 | */ |
||
| 5599 | public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5645 | |||
| 5646 | /** |
||
| 5647 | * Gets all departure airports of the airplanes that have flown over based on an airline icao |
||
| 5648 | * |
||
| 5649 | * @return Array the airport list |
||
| 5650 | * |
||
| 5651 | */ |
||
| 5652 | public function countAllDepartureAirportsByAirline($airline_icao,$filters = array()) |
||
| 5681 | |||
| 5682 | |||
| 5683 | |||
| 5684 | /** |
||
| 5685 | * Gets all departure airports by country of the airplanes that have flown over based on an airline icao |
||
| 5686 | * |
||
| 5687 | * @return Array the airport list |
||
| 5688 | * |
||
| 5689 | */ |
||
| 5690 | public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array()) |
||
| 5716 | |||
| 5717 | |||
| 5718 | |||
| 5719 | /** |
||
| 5720 | * Gets all departure airports of the airplanes that have flown over based on an aircraft icao |
||
| 5721 | * |
||
| 5722 | * @return Array the airport list |
||
| 5723 | * |
||
| 5724 | */ |
||
| 5725 | public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array()) |
||
| 5754 | |||
| 5755 | |||
| 5756 | /** |
||
| 5757 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 5758 | * |
||
| 5759 | * @return Array the airport list |
||
| 5760 | * |
||
| 5761 | */ |
||
| 5762 | public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 5788 | |||
| 5789 | |||
| 5790 | /** |
||
| 5791 | * Gets all departure airports of the airplanes that have flown over based on an aircraft registration |
||
| 5792 | * |
||
| 5793 | * @return Array the airport list |
||
| 5794 | * |
||
| 5795 | */ |
||
| 5796 | public function countAllDepartureAirportsByRegistration($registration,$filters = array()) |
||
| 5825 | |||
| 5826 | |||
| 5827 | /** |
||
| 5828 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration |
||
| 5829 | * |
||
| 5830 | * @return Array the airport list |
||
| 5831 | * |
||
| 5832 | */ |
||
| 5833 | public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array()) |
||
| 5859 | |||
| 5860 | |||
| 5861 | /** |
||
| 5862 | * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao |
||
| 5863 | * |
||
| 5864 | * @return Array the airport list |
||
| 5865 | * |
||
| 5866 | */ |
||
| 5867 | public function countAllDepartureAirportsByAirport($airport_icao,$filters = array()) |
||
| 5896 | |||
| 5897 | |||
| 5898 | /** |
||
| 5899 | * Gets all departure airports by country of the airplanes that have flown over based on an airport icao |
||
| 5900 | * |
||
| 5901 | * @return Array the airport list |
||
| 5902 | * |
||
| 5903 | */ |
||
| 5904 | public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array()) |
||
| 5930 | |||
| 5931 | |||
| 5932 | |||
| 5933 | /** |
||
| 5934 | * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer |
||
| 5935 | * |
||
| 5936 | * @return Array the airport list |
||
| 5937 | * |
||
| 5938 | */ |
||
| 5939 | public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 5968 | |||
| 5969 | |||
| 5970 | /** |
||
| 5971 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer |
||
| 5972 | * |
||
| 5973 | * @return Array the airport list |
||
| 5974 | * |
||
| 5975 | */ |
||
| 5976 | public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 6002 | |||
| 6003 | |||
| 6004 | /** |
||
| 6005 | * Gets all departure airports of the airplanes that have flown over based on a date |
||
| 6006 | * |
||
| 6007 | * @return Array the airport list |
||
| 6008 | * |
||
| 6009 | */ |
||
| 6010 | public function countAllDepartureAirportsByDate($date,$filters = array()) |
||
| 6051 | |||
| 6052 | |||
| 6053 | |||
| 6054 | /** |
||
| 6055 | * Gets all departure airports by country of the airplanes that have flown over based on a date |
||
| 6056 | * |
||
| 6057 | * @return Array the airport list |
||
| 6058 | * |
||
| 6059 | */ |
||
| 6060 | public function countAllDepartureAirportCountriesByDate($date,$filters = array()) |
||
| 6098 | |||
| 6099 | |||
| 6100 | |||
| 6101 | /** |
||
| 6102 | * Gets all departure airports of the airplanes that have flown over based on a ident/callsign |
||
| 6103 | * |
||
| 6104 | * @return Array the airport list |
||
| 6105 | * |
||
| 6106 | */ |
||
| 6107 | public function countAllDepartureAirportsByIdent($ident,$filters = array()) |
||
| 6136 | |||
| 6137 | |||
| 6138 | |||
| 6139 | /** |
||
| 6140 | * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident |
||
| 6141 | * |
||
| 6142 | * @return Array the airport list |
||
| 6143 | * |
||
| 6144 | */ |
||
| 6145 | public function countAllDepartureAirportCountriesByIdent($ident,$filters = array()) |
||
| 6171 | |||
| 6172 | |||
| 6173 | |||
| 6174 | /** |
||
| 6175 | * Gets all departure airports of the airplanes that have flown over based on a country |
||
| 6176 | * |
||
| 6177 | * @return Array the airport list |
||
| 6178 | * |
||
| 6179 | */ |
||
| 6180 | public function countAllDepartureAirportsByCountry($country,$filters = array()) |
||
| 6210 | |||
| 6211 | |||
| 6212 | /** |
||
| 6213 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 6214 | * |
||
| 6215 | * @return Array the airport list |
||
| 6216 | * |
||
| 6217 | */ |
||
| 6218 | public function countAllDepartureAirportCountriesByCountry($country,$filters = array()) |
||
| 6244 | |||
| 6245 | |||
| 6246 | /** |
||
| 6247 | * Gets all arrival airports of the airplanes that have flown over |
||
| 6248 | * |
||
| 6249 | * @return Array the airport list |
||
| 6250 | * |
||
| 6251 | */ |
||
| 6252 | public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
||
| 6307 | |||
| 6308 | /** |
||
| 6309 | * Gets all arrival airports of the airplanes that have flown over |
||
| 6310 | * |
||
| 6311 | * @return Array the airport list |
||
| 6312 | * |
||
| 6313 | */ |
||
| 6314 | public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
||
| 6370 | |||
| 6371 | |||
| 6372 | /** |
||
| 6373 | * Gets all detected arrival airports of the airplanes that have flown over |
||
| 6374 | * |
||
| 6375 | * @return Array the airport list |
||
| 6376 | * |
||
| 6377 | */ |
||
| 6378 | public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
||
| 6432 | |||
| 6433 | /** |
||
| 6434 | * Gets all detected arrival airports of the airplanes that have flown over |
||
| 6435 | * |
||
| 6436 | * @return Array the airport list |
||
| 6437 | * |
||
| 6438 | */ |
||
| 6439 | public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
||
| 6495 | |||
| 6496 | /** |
||
| 6497 | * Gets all arrival airports of the airplanes that have flown over based on an airline icao |
||
| 6498 | * |
||
| 6499 | * @return Array the airport list |
||
| 6500 | * |
||
| 6501 | */ |
||
| 6502 | public function countAllArrivalAirportsByAirline($airline_icao, $filters = array()) |
||
| 6530 | |||
| 6531 | |||
| 6532 | /** |
||
| 6533 | * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao |
||
| 6534 | * |
||
| 6535 | * @return Array the airport list |
||
| 6536 | * |
||
| 6537 | */ |
||
| 6538 | public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array()) |
||
| 6565 | |||
| 6566 | |||
| 6567 | /** |
||
| 6568 | * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao |
||
| 6569 | * |
||
| 6570 | * @return Array the airport list |
||
| 6571 | * |
||
| 6572 | */ |
||
| 6573 | public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array()) |
||
| 6602 | |||
| 6603 | |||
| 6604 | |||
| 6605 | /** |
||
| 6606 | * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 6607 | * |
||
| 6608 | * @return Array the airport list |
||
| 6609 | * |
||
| 6610 | */ |
||
| 6611 | public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 6637 | |||
| 6638 | |||
| 6639 | /** |
||
| 6640 | * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration |
||
| 6641 | * |
||
| 6642 | * @return Array the airport list |
||
| 6643 | * |
||
| 6644 | */ |
||
| 6645 | public function countAllArrivalAirportsByRegistration($registration,$filters = array()) |
||
| 6675 | |||
| 6676 | |||
| 6677 | /** |
||
| 6678 | * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration |
||
| 6679 | * |
||
| 6680 | * @return Array the airport list |
||
| 6681 | * |
||
| 6682 | */ |
||
| 6683 | public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array()) |
||
| 6709 | |||
| 6710 | |||
| 6711 | |||
| 6712 | /** |
||
| 6713 | * Gets all arrival airports of the airplanes that have flown over based on an departure airport |
||
| 6714 | * |
||
| 6715 | * @return Array the airport list |
||
| 6716 | * |
||
| 6717 | */ |
||
| 6718 | public function countAllArrivalAirportsByAirport($airport_icao,$filters = array()) |
||
| 6747 | |||
| 6748 | |||
| 6749 | /** |
||
| 6750 | * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao |
||
| 6751 | * |
||
| 6752 | * @return Array the airport list |
||
| 6753 | * |
||
| 6754 | */ |
||
| 6755 | public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array()) |
||
| 6781 | |||
| 6782 | |||
| 6783 | /** |
||
| 6784 | * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer |
||
| 6785 | * |
||
| 6786 | * @return Array the airport list |
||
| 6787 | * |
||
| 6788 | */ |
||
| 6789 | public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 6818 | |||
| 6819 | |||
| 6820 | |||
| 6821 | /** |
||
| 6822 | * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer |
||
| 6823 | * |
||
| 6824 | * @return Array the airport list |
||
| 6825 | * |
||
| 6826 | */ |
||
| 6827 | public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 6853 | |||
| 6854 | |||
| 6855 | |||
| 6856 | /** |
||
| 6857 | * Gets all arrival airports of the airplanes that have flown over based on a date |
||
| 6858 | * |
||
| 6859 | * @return Array the airport list |
||
| 6860 | * |
||
| 6861 | */ |
||
| 6862 | public function countAllArrivalAirportsByDate($date,$filters = array()) |
||
| 6903 | |||
| 6904 | |||
| 6905 | |||
| 6906 | /** |
||
| 6907 | * Gets all arrival airports by country of the airplanes that have flown over based on a date |
||
| 6908 | * |
||
| 6909 | * @return Array the airport list |
||
| 6910 | * |
||
| 6911 | */ |
||
| 6912 | public function countAllArrivalAirportCountriesByDate($date, $filters = array()) |
||
| 6950 | |||
| 6951 | |||
| 6952 | |||
| 6953 | /** |
||
| 6954 | * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign |
||
| 6955 | * |
||
| 6956 | * @return Array the airport list |
||
| 6957 | * |
||
| 6958 | */ |
||
| 6959 | public function countAllArrivalAirportsByIdent($ident,$filters = array()) |
||
| 6988 | |||
| 6989 | |||
| 6990 | /** |
||
| 6991 | * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident |
||
| 6992 | * |
||
| 6993 | * @return Array the airport list |
||
| 6994 | * |
||
| 6995 | */ |
||
| 6996 | public function countAllArrivalAirportCountriesByIdent($ident, $filters = array()) |
||
| 7022 | |||
| 7023 | |||
| 7024 | |||
| 7025 | /** |
||
| 7026 | * Gets all arrival airports of the airplanes that have flown over based on a country |
||
| 7027 | * |
||
| 7028 | * @return Array the airport list |
||
| 7029 | * |
||
| 7030 | */ |
||
| 7031 | public function countAllArrivalAirportsByCountry($country,$filters = array()) |
||
| 7060 | |||
| 7061 | |||
| 7062 | /** |
||
| 7063 | * Gets all arrival airports by country of the airplanes that have flown over based on a country |
||
| 7064 | * |
||
| 7065 | * @return Array the airport list |
||
| 7066 | * |
||
| 7067 | */ |
||
| 7068 | public function countAllArrivalAirportCountriesByCountry($country,$filters = array()) |
||
| 7094 | |||
| 7095 | |||
| 7096 | |||
| 7097 | /** |
||
| 7098 | * Counts all airport departure countries |
||
| 7099 | * |
||
| 7100 | * @return Array the airport departure list |
||
| 7101 | * |
||
| 7102 | */ |
||
| 7103 | public function countAllDepartureCountries($filters = array()) |
||
| 7129 | |||
| 7130 | |||
| 7131 | /** |
||
| 7132 | * Counts all airport arrival countries |
||
| 7133 | * |
||
| 7134 | * @return Array the airport arrival list |
||
| 7135 | * |
||
| 7136 | */ |
||
| 7137 | public function countAllArrivalCountries($limit = true,$filters = array()) |
||
| 7163 | |||
| 7164 | |||
| 7165 | |||
| 7166 | |||
| 7167 | |||
| 7168 | /** |
||
| 7169 | * Gets all route combinations |
||
| 7170 | * |
||
| 7171 | * @return Array the route list |
||
| 7172 | * |
||
| 7173 | */ |
||
| 7174 | public function countAllRoutes($filters = array()) |
||
| 7207 | |||
| 7208 | |||
| 7209 | |||
| 7210 | |||
| 7211 | /** |
||
| 7212 | * Gets all route combinations based on an aircraft |
||
| 7213 | * |
||
| 7214 | * @return Array the route list |
||
| 7215 | * |
||
| 7216 | */ |
||
| 7217 | public function countAllRoutesByAircraft($aircraft_icao,$filters = array()) |
||
| 7249 | |||
| 7250 | |||
| 7251 | /** |
||
| 7252 | * Gets all route combinations based on an aircraft registration |
||
| 7253 | * |
||
| 7254 | * @return Array the route list |
||
| 7255 | * |
||
| 7256 | */ |
||
| 7257 | public function countAllRoutesByRegistration($registration, $filters = array()) |
||
| 7290 | |||
| 7291 | |||
| 7292 | |||
| 7293 | /** |
||
| 7294 | * Gets all route combinations based on an airline |
||
| 7295 | * |
||
| 7296 | * @return Array the route list |
||
| 7297 | * |
||
| 7298 | */ |
||
| 7299 | public function countAllRoutesByAirline($airline_icao, $filters = array()) |
||
| 7332 | |||
| 7333 | |||
| 7334 | |||
| 7335 | /** |
||
| 7336 | * Gets all route combinations based on an airport |
||
| 7337 | * |
||
| 7338 | * @return Array the route list |
||
| 7339 | * |
||
| 7340 | */ |
||
| 7341 | public function countAllRoutesByAirport($airport_icao, $filters = array()) |
||
| 7373 | |||
| 7374 | |||
| 7375 | |||
| 7376 | /** |
||
| 7377 | * Gets all route combinations based on an country |
||
| 7378 | * |
||
| 7379 | * @return Array the route list |
||
| 7380 | * |
||
| 7381 | */ |
||
| 7382 | public function countAllRoutesByCountry($country, $filters = array()) |
||
| 7414 | |||
| 7415 | |||
| 7416 | /** |
||
| 7417 | * Gets all route combinations based on an date |
||
| 7418 | * |
||
| 7419 | * @return Array the route list |
||
| 7420 | * |
||
| 7421 | */ |
||
| 7422 | public function countAllRoutesByDate($date, $filters = array()) |
||
| 7468 | |||
| 7469 | |||
| 7470 | /** |
||
| 7471 | * Gets all route combinations based on an ident/callsign |
||
| 7472 | * |
||
| 7473 | * @return Array the route list |
||
| 7474 | * |
||
| 7475 | */ |
||
| 7476 | public function countAllRoutesByIdent($ident, $filters = array()) |
||
| 7509 | |||
| 7510 | |||
| 7511 | /** |
||
| 7512 | * Gets all route combinations based on an manufacturer |
||
| 7513 | * |
||
| 7514 | * @return Array the route list |
||
| 7515 | * |
||
| 7516 | */ |
||
| 7517 | public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array()) |
||
| 7550 | |||
| 7551 | |||
| 7552 | |||
| 7553 | /** |
||
| 7554 | * Gets all route combinations with waypoints |
||
| 7555 | * |
||
| 7556 | * @return Array the route list |
||
| 7557 | * |
||
| 7558 | */ |
||
| 7559 | public function countAllRoutesWithWaypoints($filters = array()) |
||
| 7593 | |||
| 7594 | /** |
||
| 7595 | * Gets all callsigns that have flown over |
||
| 7596 | * |
||
| 7597 | * @return Array the callsign list |
||
| 7598 | * |
||
| 7599 | */ |
||
| 7600 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 7635 | |||
| 7636 | /** |
||
| 7637 | * Gets all callsigns that have flown over |
||
| 7638 | * |
||
| 7639 | * @return Array the callsign list |
||
| 7640 | * |
||
| 7641 | */ |
||
| 7642 | public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
||
| 7677 | |||
| 7678 | |||
| 7679 | |||
| 7680 | |||
| 7681 | /** |
||
| 7682 | * Counts all dates |
||
| 7683 | * |
||
| 7684 | * @return Array the date list |
||
| 7685 | * |
||
| 7686 | */ |
||
| 7687 | public function countAllDates($filters = array()) |
||
| 7729 | |||
| 7730 | /** |
||
| 7731 | * Counts all dates |
||
| 7732 | * |
||
| 7733 | * @return Array the date list |
||
| 7734 | * |
||
| 7735 | */ |
||
| 7736 | public function countAllDatesByAirlines($filters = array()) |
||
| 7778 | |||
| 7779 | /** |
||
| 7780 | * Counts all dates during the last 7 days |
||
| 7781 | * |
||
| 7782 | * @return Array the date list |
||
| 7783 | * |
||
| 7784 | */ |
||
| 7785 | public function countAllDatesLast7Days($filters = array()) |
||
| 7824 | |||
| 7825 | /** |
||
| 7826 | * Counts all dates during the last month |
||
| 7827 | * |
||
| 7828 | * @return Array the date list |
||
| 7829 | * |
||
| 7830 | */ |
||
| 7831 | public function countAllDatesLastMonth($filters = array()) |
||
| 7870 | |||
| 7871 | |||
| 7872 | /** |
||
| 7873 | * Counts all dates during the last month |
||
| 7874 | * |
||
| 7875 | * @return Array the date list |
||
| 7876 | * |
||
| 7877 | */ |
||
| 7878 | public function countAllDatesLastMonthByAirlines($filters = array()) |
||
| 7919 | |||
| 7920 | |||
| 7921 | /** |
||
| 7922 | * Counts all month |
||
| 7923 | * |
||
| 7924 | * @return Array the month list |
||
| 7925 | * |
||
| 7926 | */ |
||
| 7927 | public function countAllMonths($filters = array()) |
||
| 7966 | |||
| 7967 | /** |
||
| 7968 | * Counts all month |
||
| 7969 | * |
||
| 7970 | * @return Array the month list |
||
| 7971 | * |
||
| 7972 | */ |
||
| 7973 | public function countAllMonthsByAirlines($filters = array()) |
||
| 8015 | |||
| 8016 | /** |
||
| 8017 | * Counts all military month |
||
| 8018 | * |
||
| 8019 | * @return Array the month list |
||
| 8020 | * |
||
| 8021 | */ |
||
| 8022 | public function countAllMilitaryMonths($filters = array()) |
||
| 8060 | |||
| 8061 | /** |
||
| 8062 | * Counts all month owners |
||
| 8063 | * |
||
| 8064 | * @return Array the month list |
||
| 8065 | * |
||
| 8066 | */ |
||
| 8067 | public function countAllMonthsOwners($filters = array()) |
||
| 8106 | |||
| 8107 | /** |
||
| 8108 | * Counts all month owners |
||
| 8109 | * |
||
| 8110 | * @return Array the month list |
||
| 8111 | * |
||
| 8112 | */ |
||
| 8113 | public function countAllMonthsOwnersByAirlines($filters = array()) |
||
| 8153 | |||
| 8154 | /** |
||
| 8155 | * Counts all month pilot |
||
| 8156 | * |
||
| 8157 | * @return Array the month list |
||
| 8158 | * |
||
| 8159 | */ |
||
| 8160 | public function countAllMonthsPilots($filters = array()) |
||
| 8199 | |||
| 8200 | /** |
||
| 8201 | * Counts all month pilot |
||
| 8202 | * |
||
| 8203 | * @return Array the month list |
||
| 8204 | * |
||
| 8205 | */ |
||
| 8206 | public function countAllMonthsPilotsByAirlines($filters = array()) |
||
| 8246 | |||
| 8247 | /** |
||
| 8248 | * Counts all month airline |
||
| 8249 | * |
||
| 8250 | * @return Array the month list |
||
| 8251 | * |
||
| 8252 | */ |
||
| 8253 | public function countAllMonthsAirlines($filters = array()) |
||
| 8292 | |||
| 8293 | /** |
||
| 8294 | * Counts all month aircraft |
||
| 8295 | * |
||
| 8296 | * @return Array the month list |
||
| 8297 | * |
||
| 8298 | */ |
||
| 8299 | public function countAllMonthsAircrafts($filters = array()) |
||
| 8338 | |||
| 8339 | |||
| 8340 | /** |
||
| 8341 | * Counts all month aircraft |
||
| 8342 | * |
||
| 8343 | * @return Array the month list |
||
| 8344 | * |
||
| 8345 | */ |
||
| 8346 | public function countAllMonthsAircraftsByAirlines($filters = array()) |
||
| 8386 | |||
| 8387 | /** |
||
| 8388 | * Counts all month real arrival |
||
| 8389 | * |
||
| 8390 | * @return Array the month list |
||
| 8391 | * |
||
| 8392 | */ |
||
| 8393 | public function countAllMonthsRealArrivals($filters = array()) |
||
| 8432 | |||
| 8433 | |||
| 8434 | /** |
||
| 8435 | * Counts all month real arrival |
||
| 8436 | * |
||
| 8437 | * @return Array the month list |
||
| 8438 | * |
||
| 8439 | */ |
||
| 8440 | public function countAllMonthsRealArrivalsByAirlines($filters = array()) |
||
| 8480 | |||
| 8481 | |||
| 8482 | /** |
||
| 8483 | * Counts all dates during the last year |
||
| 8484 | * |
||
| 8485 | * @return Array the date list |
||
| 8486 | * |
||
| 8487 | */ |
||
| 8488 | public function countAllMonthsLastYear($filters) |
||
| 8528 | |||
| 8529 | |||
| 8530 | |||
| 8531 | /** |
||
| 8532 | * Counts all hours |
||
| 8533 | * |
||
| 8534 | * @return Array the hour list |
||
| 8535 | * |
||
| 8536 | */ |
||
| 8537 | public function countAllHours($orderby,$filters = array()) |
||
| 8595 | |||
| 8596 | /** |
||
| 8597 | * Counts all hours |
||
| 8598 | * |
||
| 8599 | * @return Array the hour list |
||
| 8600 | * |
||
| 8601 | */ |
||
| 8602 | public function countAllHoursByAirlines($orderby, $filters = array()) |
||
| 8660 | |||
| 8661 | |||
| 8662 | |||
| 8663 | /** |
||
| 8664 | * Counts all hours by airline |
||
| 8665 | * |
||
| 8666 | * @return Array the hour list |
||
| 8667 | * |
||
| 8668 | */ |
||
| 8669 | public function countAllHoursByAirline($airline_icao, $filters = array()) |
||
| 8709 | |||
| 8710 | |||
| 8711 | |||
| 8712 | |||
| 8713 | /** |
||
| 8714 | * Counts all hours by aircraft |
||
| 8715 | * |
||
| 8716 | * @return Array the hour list |
||
| 8717 | * |
||
| 8718 | */ |
||
| 8719 | public function countAllHoursByAircraft($aircraft_icao, $filters = array()) |
||
| 8758 | |||
| 8759 | |||
| 8760 | /** |
||
| 8761 | * Counts all hours by aircraft registration |
||
| 8762 | * |
||
| 8763 | * @return Array the hour list |
||
| 8764 | * |
||
| 8765 | */ |
||
| 8766 | public function countAllHoursByRegistration($registration, $filters = array()) |
||
| 8805 | |||
| 8806 | |||
| 8807 | /** |
||
| 8808 | * Counts all hours by airport |
||
| 8809 | * |
||
| 8810 | * @return Array the hour list |
||
| 8811 | * |
||
| 8812 | */ |
||
| 8813 | public function countAllHoursByAirport($airport_icao, $filters = array()) |
||
| 8852 | |||
| 8853 | |||
| 8854 | |||
| 8855 | /** |
||
| 8856 | * Counts all hours by manufacturer |
||
| 8857 | * |
||
| 8858 | * @return Array the hour list |
||
| 8859 | * |
||
| 8860 | */ |
||
| 8861 | public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array()) |
||
| 8900 | |||
| 8901 | |||
| 8902 | |||
| 8903 | /** |
||
| 8904 | * Counts all hours by date |
||
| 8905 | * |
||
| 8906 | * @return Array the hour list |
||
| 8907 | * |
||
| 8908 | */ |
||
| 8909 | public function countAllHoursByDate($date, $filters = array()) |
||
| 8948 | |||
| 8949 | |||
| 8950 | |||
| 8951 | /** |
||
| 8952 | * Counts all hours by a ident/callsign |
||
| 8953 | * |
||
| 8954 | * @return Array the hour list |
||
| 8955 | * |
||
| 8956 | */ |
||
| 8957 | public function countAllHoursByIdent($ident, $filters = array()) |
||
| 8997 | |||
| 8998 | |||
| 8999 | |||
| 9000 | /** |
||
| 9001 | * Counts all hours by route |
||
| 9002 | * |
||
| 9003 | * @return Array the hour list |
||
| 9004 | * |
||
| 9005 | */ |
||
| 9006 | public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array()) |
||
| 9046 | |||
| 9047 | |||
| 9048 | /** |
||
| 9049 | * Counts all hours by country |
||
| 9050 | * |
||
| 9051 | * @return Array the hour list |
||
| 9052 | * |
||
| 9053 | */ |
||
| 9054 | public function countAllHoursByCountry($country, $filters = array()) |
||
| 9093 | |||
| 9094 | |||
| 9095 | |||
| 9096 | |||
| 9097 | /** |
||
| 9098 | * Counts all aircraft that have flown over |
||
| 9099 | * |
||
| 9100 | * @return Integer the number of aircrafts |
||
| 9101 | * |
||
| 9102 | */ |
||
| 9103 | public function countOverallAircrafts($filters = array()) |
||
| 9112 | |||
| 9113 | /** |
||
| 9114 | * Counts all flight that really arrival |
||
| 9115 | * |
||
| 9116 | * @return Integer the number of aircrafts |
||
| 9117 | * |
||
| 9118 | */ |
||
| 9119 | public function countOverallArrival($filters = array()) |
||
| 9129 | |||
| 9130 | /** |
||
| 9131 | * Counts all pilots that have flown over |
||
| 9132 | * |
||
| 9133 | * @return Integer the number of pilots |
||
| 9134 | * |
||
| 9135 | */ |
||
| 9136 | public function countOverallPilots($filters = array()) |
||
| 9145 | |||
| 9146 | /** |
||
| 9147 | * Counts all owners that have flown over |
||
| 9148 | * |
||
| 9149 | * @return Integer the number of owners |
||
| 9150 | * |
||
| 9151 | */ |
||
| 9152 | public function countOverallOwners($filters = array()) |
||
| 9161 | |||
| 9162 | |||
| 9163 | /** |
||
| 9164 | * Counts all flights that have flown over |
||
| 9165 | * |
||
| 9166 | * @return Integer the number of flights |
||
| 9167 | * |
||
| 9168 | */ |
||
| 9169 | public function countOverallFlights($filters = array()) |
||
| 9179 | |||
| 9180 | /** |
||
| 9181 | * Counts all military flights that have flown over |
||
| 9182 | * |
||
| 9183 | * @return Integer the number of flights |
||
| 9184 | * |
||
| 9185 | */ |
||
| 9186 | public function countOverallMilitaryFlights($filters = array()) |
||
| 9196 | |||
| 9197 | |||
| 9198 | |||
| 9199 | /** |
||
| 9200 | * Counts all airlines that have flown over |
||
| 9201 | * |
||
| 9202 | * @return Integer the number of airlines |
||
| 9203 | * |
||
| 9204 | */ |
||
| 9205 | public function countOverallAirlines($filters = array()) |
||
| 9215 | |||
| 9216 | |||
| 9217 | /** |
||
| 9218 | * Counts all hours of today |
||
| 9219 | * |
||
| 9220 | * @return Array the hour list |
||
| 9221 | * |
||
| 9222 | */ |
||
| 9223 | public function countAllHoursFromToday($filters = array()) |
||
| 9260 | |||
| 9261 | /** |
||
| 9262 | * Gets all the spotter information based on calculated upcoming flights |
||
| 9263 | * |
||
| 9264 | * @return Array the spotter information |
||
| 9265 | * |
||
| 9266 | */ |
||
| 9267 | public function getUpcomingFlights($limit = '', $sort = '', $filters = array()) |
||
| 9339 | |||
| 9340 | |||
| 9341 | /** |
||
| 9342 | * Gets the Barrie Spotter ID based on the FlightAware ID |
||
| 9343 | * |
||
| 9344 | * @return Integer the Barrie Spotter ID |
||
| 9345 | q * |
||
| 9346 | */ |
||
| 9347 | public function getSpotterIDBasedOnFlightAwareID($flightaware_id) |
||
| 9364 | |||
| 9365 | |||
| 9366 | /** |
||
| 9367 | * Parses a date string |
||
| 9368 | * |
||
| 9369 | * @param String $dateString the date string |
||
| 9370 | * @param String $timezone the timezone of a user |
||
| 9371 | * @return Array the time information |
||
| 9372 | * |
||
| 9373 | */ |
||
| 9374 | public function parseDateString($dateString, $timezone = '') |
||
| 9404 | |||
| 9405 | |||
| 9406 | |||
| 9407 | |||
| 9408 | /** |
||
| 9409 | * Parses the direction degrees to working |
||
| 9410 | * |
||
| 9411 | * @param Float $direction the direction in degrees |
||
| 9412 | * @return Array the direction information |
||
| 9413 | * |
||
| 9414 | */ |
||
| 9415 | public function parseDirection($direction = 0) |
||
| 9490 | |||
| 9491 | |||
| 9492 | /** |
||
| 9493 | * Gets the aircraft registration |
||
| 9494 | * |
||
| 9495 | * @param String $flightaware_id the flight aware id |
||
| 9496 | * @return String the aircraft registration |
||
| 9497 | * |
||
| 9498 | */ |
||
| 9499 | |||
| 9500 | public function getAircraftRegistration($flightaware_id) |
||
| 9524 | |||
| 9525 | |||
| 9526 | /** |
||
| 9527 | * Gets the aircraft registration from ModeS |
||
| 9528 | * |
||
| 9529 | * @param String $aircraft_modes the flight ModeS in hex |
||
| 9530 | * @return String the aircraft registration |
||
| 9531 | * |
||
| 9532 | */ |
||
| 9533 | public function getAircraftRegistrationBymodeS($aircraft_modes) |
||
| 9550 | |||
| 9551 | /** |
||
| 9552 | * Gets the aircraft type from ModeS |
||
| 9553 | * |
||
| 9554 | * @param String $aircraft_modes the flight ModeS in hex |
||
| 9555 | * @return String the aircraft type |
||
| 9556 | * |
||
| 9557 | */ |
||
| 9558 | public function getAircraftTypeBymodeS($aircraft_modes) |
||
| 9575 | |||
| 9576 | /** |
||
| 9577 | * Gets Countrie from latitude/longitude |
||
| 9578 | * |
||
| 9579 | * @param Float $latitude latitute of the flight |
||
| 9580 | * @param Float $longitude longitute of the flight |
||
| 9581 | * @return String the countrie |
||
| 9582 | */ |
||
| 9583 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
||
| 9617 | |||
| 9618 | /** |
||
| 9619 | * converts the registration code using the country prefix |
||
| 9620 | * |
||
| 9621 | * @param String $registration the aircraft registration |
||
| 9622 | * @return String the aircraft registration |
||
| 9623 | * |
||
| 9624 | */ |
||
| 9625 | public function convertAircraftRegistration($registration) |
||
| 9674 | |||
| 9675 | /** |
||
| 9676 | * Country from the registration code |
||
| 9677 | * |
||
| 9678 | * @param String $registration the aircraft registration |
||
| 9679 | * @return String the country |
||
| 9680 | * |
||
| 9681 | */ |
||
| 9682 | public function countryFromAircraftRegistration($registration) |
||
| 9735 | |||
| 9736 | /** |
||
| 9737 | * Set a new highlight value for a flight |
||
| 9738 | * |
||
| 9739 | * @param String $flightaware_id flightaware_id from spotter_output table |
||
| 9740 | * @param String $highlight New highlight value |
||
| 9741 | */ |
||
| 9742 | public function setHighlightFlight($flightaware_id,$highlight) { |
||
| 9748 | |||
| 9749 | /** |
||
| 9750 | * Gets the short url from bit.ly |
||
| 9751 | * |
||
| 9752 | * @param String $url the full url |
||
| 9753 | * @return String the bit.ly url |
||
| 9754 | * |
||
| 9755 | */ |
||
| 9756 | public function getBitlyURL($url) |
||
| 9779 | |||
| 9780 | |||
| 9781 | public function getOrderBy() |
||
| 9788 | |||
| 9789 | /* |
||
| 9790 | public function importFromFlightAware() |
||
| 9791 | { |
||
| 9792 | global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore; |
||
| 9793 | $Spotter = new Spotter($this->db); |
||
| 9794 | $SpotterLive = new SpotterLive($this->db); |
||
| 9795 | $options = array( |
||
| 9796 | 'trace' => true, |
||
| 9797 | 'exceptions' => 0, |
||
| 9798 | 'login' => $globalFlightAwareUsername, |
||
| 9799 | 'password' => $globalFlightAwarePassword, |
||
| 9800 | ); |
||
| 9801 | $client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); |
||
| 9802 | $params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0'); |
||
| 9803 | $result = $client->SearchBirdseyeInFlight($params); |
||
| 9804 | $dataFound = false; |
||
| 9805 | $ignoreImport = false; |
||
| 9806 | if (isset($result->SearchBirdseyeInFlightResult)) |
||
| 9807 | { |
||
| 9808 | if (is_array($result->SearchBirdseyeInFlightResult->aircraft)) |
||
| 9809 | { |
||
| 9810 | foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft) |
||
| 9811 | { |
||
| 9812 | if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L ')) |
||
| 9813 | { |
||
| 9814 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 9815 | { |
||
| 9816 | if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
||
| 9817 | { |
||
| 9818 | $ignoreImport = true; |
||
| 9819 | } |
||
| 9820 | } |
||
| 9821 | if ($ignoreImport == false) |
||
| 9822 | { |
||
| 9823 | $flightaware_id = $aircraft->faFlightID; |
||
| 9824 | $ident = $aircraft->ident; |
||
| 9825 | $aircraft_type = $aircraft->type; |
||
| 9826 | $departure_airport = $aircraft->origin; |
||
| 9827 | $arrival_airport = $aircraft->destination; |
||
| 9828 | $latitude = $aircraft->latitude; |
||
| 9829 | $longitude = $aircraft->longitude; |
||
| 9830 | $waypoints = $aircraft->waypoints; |
||
| 9831 | $altitude = $aircraft->altitude; |
||
| 9832 | $heading = $aircraft->heading; |
||
| 9833 | $groundspeed = $aircraft->groundspeed; |
||
| 9834 | $dataFound = true; |
||
| 9835 | //gets the callsign from the last hour |
||
| 9836 | $last_hour_ident = $this->getIdentFromLastHour($ident); |
||
| 9837 | //change the departure/arrival airport to NA if its not available |
||
| 9838 | if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
||
| 9839 | if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
||
| 9840 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
||
| 9841 | if($last_hour_ident == "") |
||
| 9842 | { |
||
| 9843 | //adds the spotter data for the archive |
||
| 9844 | $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9845 | } |
||
| 9846 | |||
| 9847 | //adds the spotter LIVE data |
||
| 9848 | $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9849 | } |
||
| 9850 | } |
||
| 9851 | $ignoreImport = false; |
||
| 9852 | } |
||
| 9853 | } else { |
||
| 9854 | if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L ')) |
||
| 9855 | { |
||
| 9856 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 9857 | { |
||
| 9858 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 9859 | { |
||
| 9860 | if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
||
| 9861 | { |
||
| 9862 | $ignoreImport = true; |
||
| 9863 | } |
||
| 9864 | } |
||
| 9865 | if ($ignoreImport == false) |
||
| 9866 | { |
||
| 9867 | $flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID; |
||
| 9868 | $ident = $result->SearchBirdseyeInFlightResult->aircraft->ident; |
||
| 9869 | $aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type; |
||
| 9870 | $departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin; |
||
| 9871 | $arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination; |
||
| 9872 | $latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude; |
||
| 9873 | $longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude; |
||
| 9874 | $waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints; |
||
| 9875 | $altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude; |
||
| 9876 | $heading = $result->SearchBirdseyeInFlightResult->aircraft->heading; |
||
| 9877 | $groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed; |
||
| 9878 | $dataFound = true; |
||
| 9879 | //gets the callsign from the last hour |
||
| 9880 | $last_hour_ident = $this->getIdentFromLastHour($ident); |
||
| 9881 | //change the departure/arrival airport to NA if its not available |
||
| 9882 | if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
||
| 9883 | if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
||
| 9884 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
||
| 9885 | if($last_hour_ident == "") |
||
| 9886 | { |
||
| 9887 | //adds the spotter data for the archive |
||
| 9888 | $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9889 | } |
||
| 9890 | //adds the spotter LIVE data |
||
| 9891 | $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9892 | } |
||
| 9893 | $ignoreImport = false; |
||
| 9894 | } |
||
| 9895 | } |
||
| 9896 | } |
||
| 9897 | } |
||
| 9898 | } |
||
| 9899 | */ |
||
| 9900 | |||
| 9901 | // Update flights data when new data in DB |
||
| 9902 | public function updateFieldsFromOtherTables() |
||
| 9988 | |||
| 9989 | // Update arrival airports for data already in DB |
||
| 9990 | public function updateArrivalAirports() |
||
| 10031 | |||
| 10032 | public function closestAirports($origLat,$origLon,$dist = 10) { |
||
| 10053 | } |
||
| 10054 | /* |
||
| 10066 | ?> |