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 $aircraft_correct_icaotype = array('CL64' => 'CL60', |
||
| 9 | 'F9LX' => 'F900', |
||
| 10 | 'K35T' => 'K35R', |
||
| 11 | 'F5EX' => 'FA50', |
||
| 12 | 'G102' => 'GLID', |
||
| 13 | 'LJ36' => 'LJ35', |
||
| 14 | 'G500' => 'EGRT', |
||
| 15 | 'A300' => 'A30B', |
||
| 16 | 'ROT' => 'B77W', |
||
| 17 | 'BPN' => 'B772', |
||
| 18 | '0011' => 'B77W', |
||
| 19 | 'F9DX' => 'F900', |
||
| 20 | 'B757' => 'B752', |
||
| 21 | '4/05' => 'A332', |
||
| 22 | 'F/A3' => 'A320', |
||
| 23 | 'F2EX' => 'F2TH', |
||
| 24 | 'EA55' => 'EA50', |
||
| 25 | 'B73B' => 'B737', |
||
| 26 | 'G450' => 'GLF4', |
||
| 27 | 'H25X' => 'H25B', |
||
| 28 | 'E175' => 'E75S', |
||
| 29 | 'B777' => 'B77W', |
||
| 30 | 'F2LX' => 'F2TH', |
||
| 31 | 'CL65' => 'CL60', |
||
| 32 | 'A380' => 'A388', |
||
| 33 | 'G550' => 'GLF5', |
||
| 34 | 'F9EX' => 'F900', |
||
| 35 | 'E195' => 'E190', |
||
| 36 | 'H750' => 'H25B', |
||
| 37 | 'B747' => 'B744', |
||
| 38 | 'B767' => 'B763', |
||
| 39 | 'PA39' => 'PA30', |
||
| 40 | 'H900' => 'H25B', |
||
| 41 | 'AN74' => 'AN72', |
||
| 42 | 'CL85' => 'CRJ2', |
||
| 43 | 'G400' => 'GLF4', |
||
| 44 | 'CL61' => 'CL60', |
||
| 45 | 'F2TS' => 'F2TH', |
||
| 46 | 'Z602' => 'CH60', |
||
| 47 | 'G100' => 'ASTR'); |
||
| 48 | |||
| 49 | |||
| 50 | public $db; |
||
| 51 | |||
| 52 | public function __construct($dbc = null) { |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Get SQL query part for filter used |
||
| 59 | * @param Array $filter the filter |
||
| 60 | * @return Array the SQL part |
||
| 61 | */ |
||
| 62 | public function getFilter($filter = array(),$where = false,$and = false) { |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Executes the SQL statements to get the spotter information |
||
| 170 | * |
||
| 171 | * @param String $query the SQL query |
||
| 172 | * @param Array $params parameter of the query |
||
| 173 | * @param String $limitQuery the limit query |
||
| 174 | * @return Array the spotter information |
||
| 175 | * |
||
| 176 | */ |
||
| 177 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
||
| 178 | { |
||
| 179 | global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM; |
||
| 180 | $Image = new Image($this->db); |
||
| 181 | $Schedule = new Schedule($this->db); |
||
| 182 | $ACARS = new ACARS($this->db); |
||
| 183 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
||
| 184 | if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
||
| 185 | if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
||
| 186 | if (!isset($globalVAM)) $globalVAM = FALSE; |
||
| 187 | date_default_timezone_set('UTC'); |
||
| 188 | |||
| 189 | if (!is_string($query)) |
||
| 190 | { |
||
| 191 | return false; |
||
| 192 | } |
||
| 193 | |||
| 194 | if ($limitQuery != "") |
||
| 195 | { |
||
| 196 | if (!is_string($limitQuery)) |
||
| 197 | { |
||
| 198 | return false; |
||
| 199 | } |
||
| 200 | } |
||
| 201 | |||
| 202 | |||
| 203 | try { |
||
| 204 | $sth = $this->db->prepare($query.$limitQuery); |
||
| 205 | $sth->execute($params); |
||
| 206 | } catch (PDOException $e) { |
||
| 207 | printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
||
| 208 | exit(); |
||
| 209 | } |
||
| 210 | |||
| 211 | // $num_rows = count($sth->fetchAll()); |
||
| 212 | $num_rows = 0; |
||
| 213 | |||
| 214 | $spotter_array = array(); |
||
| 215 | |||
| 216 | |||
| 217 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 218 | { |
||
| 219 | $num_rows++; |
||
| 220 | $temp_array = array(); |
||
| 221 | if (isset($row['spotter_live_id'])) { |
||
| 222 | //$temp_array['spotter_id'] = $row['spotter_live_id']; |
||
| 223 | $temp_array['spotter_id'] = $this->getSpotterIDBasedOnFlightAwareID($row['flightaware_id']); |
||
| 224 | } elseif (isset($row['spotter_archive_id'])) { |
||
| 225 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
||
| 226 | } elseif (isset($row['spotter_archive_output_id'])) { |
||
| 227 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
||
| 228 | } elseif (isset($row['spotter_id'])) { |
||
| 229 | $temp_array['spotter_id'] = $row['spotter_id']; |
||
| 230 | } else { |
||
| 231 | $temp_array['spotter_id'] = ''; |
||
| 232 | } |
||
| 233 | if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
||
| 234 | if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
||
| 235 | $temp_array['ident'] = $row['ident']; |
||
| 236 | if (isset($row['registration']) && $row['registration'] != '') { |
||
| 237 | $temp_array['registration'] = $row['registration']; |
||
| 238 | } elseif (isset($temp_array['modes'])) { |
||
| 239 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
||
| 240 | } else $temp_array['registration'] = ''; |
||
| 241 | if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
||
| 242 | |||
| 243 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
||
| 244 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
||
| 245 | if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
||
| 246 | if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
||
| 247 | if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
||
| 248 | /* |
||
| 249 | if (Connection->tableExists('countries')) { |
||
| 250 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
||
| 251 | if (is_array($country_info) && isset($country_info['name']) && isset($country_info['iso2'])) { |
||
| 252 | $temp_array['country'] = $country_info['name']; |
||
| 253 | $temp_array['country_iso2'] = $country_info['iso2']; |
||
| 254 | } |
||
| 255 | } |
||
| 256 | */ |
||
| 257 | if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
||
| 258 | if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
||
| 259 | if (isset($row['route_stop']) && $row['route_stop'] != '') { |
||
| 260 | $temp_array['route_stop'] = $row['route_stop']; |
||
| 261 | $allroute = explode(' ',$row['route_stop']); |
||
| 262 | foreach ($allroute as $route) { |
||
| 263 | $route_airport_array = $this->getAllAirportInfo($route); |
||
| 264 | if (isset($route_airport_array[0]['name'])) { |
||
| 265 | $route_stop_details = array(); |
||
| 266 | $route_stop_details['airport_name'] = $route_airport_array[0]['name']; |
||
| 267 | $route_stop_details['airport_city'] = $route_airport_array[0]['city']; |
||
| 268 | $route_stop_details['airport_country'] = $route_airport_array[0]['country']; |
||
| 269 | $route_stop_details['airport_icao'] = $route_airport_array[0]['icao']; |
||
| 270 | $temp_array['route_stop_details'][] = $route_stop_details; |
||
| 271 | } |
||
| 272 | } |
||
| 273 | } |
||
| 274 | if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
||
| 275 | if (isset($row['heading'])) { |
||
| 276 | $temp_array['heading'] = $row['heading']; |
||
| 277 | $heading_direction = $this->parseDirection($row['heading']); |
||
| 278 | if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
||
| 279 | } |
||
| 280 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
||
| 281 | $temp_array['image'] = ""; |
||
| 282 | $temp_array['image_thumbnail'] = ""; |
||
| 283 | $temp_array['image_source'] = ""; |
||
| 284 | $temp_array['image_copyright'] = ""; |
||
| 285 | |||
| 286 | if (isset($row['highlight'])) { |
||
| 287 | $temp_array['highlight'] = $row['highlight']; |
||
| 288 | } else $temp_array['highlight'] = ''; |
||
| 289 | |||
| 290 | if (isset($row['date'])) { |
||
| 291 | $dateArray = $this->parseDateString($row['date']); |
||
| 292 | if ($dateArray['seconds'] < 10) |
||
| 293 | { |
||
| 294 | $temp_array['date'] = "a few seconds ago"; |
||
| 295 | } elseif ($dateArray['seconds'] >= 5 && $dateArray['seconds'] < 30) |
||
| 296 | { |
||
| 297 | $temp_array['date'] = "half a minute ago"; |
||
| 298 | } elseif ($dateArray['seconds'] >= 30 && $dateArray['seconds'] < 60) |
||
| 299 | { |
||
| 300 | $temp_array['date'] = "about a minute ago"; |
||
| 301 | } elseif ($dateArray['minutes'] < 5) |
||
| 302 | { |
||
| 303 | $temp_array['date'] = "a few minutes ago"; |
||
| 304 | } elseif ($dateArray['minutes'] >= 5 && $dateArray['minutes'] < 60) |
||
| 305 | { |
||
| 306 | $temp_array['date'] = "about ".$dateArray['minutes']." minutes ago"; |
||
| 307 | } elseif ($dateArray['hours'] < 2) |
||
| 308 | { |
||
| 309 | $temp_array['date'] = "about an hour ago"; |
||
| 310 | } elseif ($dateArray['hours'] >= 2 && $dateArray['hours'] < 24) |
||
| 311 | { |
||
| 312 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
||
| 313 | } else { |
||
| 314 | $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
||
| 315 | } |
||
| 316 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
||
| 317 | $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
||
| 318 | $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
||
| 319 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
||
| 320 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
||
| 321 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
||
| 322 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
||
| 323 | $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
||
| 324 | $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
||
| 325 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
||
| 326 | } |
||
| 327 | } |
||
| 328 | } |
||
| 329 | |||
| 330 | if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') { |
||
| 331 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 332 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 333 | if (isset($row['aircraft_shadow'])) { |
||
| 334 | $temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
||
| 335 | } |
||
| 336 | } elseif (isset($row['aircraft_icao'])) { |
||
| 337 | $aircraft_array = $this->getAllAircraftInfo($row['aircraft_icao']); |
||
| 338 | if (count($aircraft_array) > 0) { |
||
| 339 | $temp_array['aircraft_name'] = $aircraft_array[0]['type']; |
||
| 340 | $temp_array['aircraft_manufacturer'] = $aircraft_array[0]['manufacturer']; |
||
| 341 | |||
| 342 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
||
| 343 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
||
| 344 | } else $temp_array['aircraft_shadow'] = 'default.png'; |
||
| 345 | } else { |
||
| 346 | $temp_array['aircraft_shadow'] = 'default.png'; |
||
| 347 | $temp_array['aircraft_name'] = 'N/A'; |
||
| 348 | $temp_array['aircraft_manufacturer'] = 'N/A'; |
||
| 349 | } |
||
| 350 | } |
||
| 351 | $fromsource = NULL; |
||
| 352 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
||
| 353 | elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
||
| 354 | elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
||
| 355 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
||
| 356 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
||
| 357 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
||
| 358 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
||
| 359 | if (is_numeric(substr($row['ident'], 2, 1))) { |
||
| 360 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource); |
||
| 361 | } elseif (is_numeric(substr($row['ident'], 3, 1))) { |
||
| 362 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
||
| 363 | } else { |
||
| 364 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 365 | } |
||
| 366 | } else { |
||
| 367 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 368 | } |
||
| 369 | if (count($airline_array) > 0) { |
||
| 370 | $temp_array['airline_icao'] = $airline_array[0]['icao']; |
||
| 371 | $temp_array['airline_iata'] = $airline_array[0]['iata']; |
||
| 372 | $temp_array['airline_name'] = $airline_array[0]['name']; |
||
| 373 | $temp_array['airline_country'] = $airline_array[0]['country']; |
||
| 374 | $temp_array['airline_callsign'] = $airline_array[0]['callsign']; |
||
| 375 | $temp_array['airline_type'] = $airline_array[0]['type']; |
||
| 376 | } |
||
| 377 | } else { |
||
| 378 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 379 | if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
||
| 380 | else $temp_array['airline_iata'] = 'N/A'; |
||
| 381 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 382 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 383 | if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
||
| 384 | else $temp_array['airline_callsign'] = 'N/A'; |
||
| 385 | $temp_array['airline_type'] = $row['airline_type']; |
||
| 386 | if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') { |
||
| 387 | $airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']); |
||
| 388 | if (count($airline_array) > 0) { |
||
| 389 | $temp_array['airline_icao'] = $airline_array[0]['icao']; |
||
| 390 | $temp_array['airline_iata'] = $airline_array[0]['iata']; |
||
| 391 | $temp_array['airline_name'] = $airline_array[0]['name']; |
||
| 392 | $temp_array['airline_country'] = $airline_array[0]['country']; |
||
| 393 | $temp_array['airline_callsign'] = $airline_array[0]['callsign']; |
||
| 394 | $temp_array['airline_type'] = $airline_array[0]['type']; |
||
| 395 | } |
||
| 396 | } |
||
| 397 | } |
||
| 398 | if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
||
| 399 | $acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3)); |
||
| 400 | //$acars_array = ACARS->getLiveAcarsData('BA40YL'); |
||
| 401 | if (count($acars_array) > 0) { |
||
| 402 | $temp_array['acars'] = $acars_array; |
||
| 403 | //print_r($acars_array); |
||
| 404 | } |
||
| 405 | } |
||
| 406 | if (isset($row['owner_name']) && $row['owner_name'] != '' && $row['owner_name'] != NULL) { |
||
| 407 | $temp_array['aircraft_owner'] = $row['owner_name']; |
||
| 408 | } |
||
| 409 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
||
| 410 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
||
| 411 | if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
||
| 412 | $temp_array['aircraft_base'] = $owner_info['base']; |
||
| 413 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
||
| 414 | } |
||
| 415 | |||
| 416 | if($temp_array['registration'] != "" || (($globalIVAO || $globalVATSIM || $globalphpVMS || $globalVAM) && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
||
| 417 | { |
||
| 418 | if ($globalIVAO) { |
||
| 419 | if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
||
| 420 | else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
||
| 421 | } elseif (isset($temp_array['aircraft_type'])) $image_array = $Image->getSpotterImage($temp_array['registration'],$temp_array['aircraft_type']); |
||
| 422 | else $image_array = $Image->getSpotterImage($temp_array['registration']); |
||
| 423 | if (count($image_array) > 0) { |
||
| 424 | $temp_array['image'] = $image_array[0]['image']; |
||
| 425 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 426 | $temp_array['image_source'] = $image_array[0]['image_source']; |
||
| 427 | $temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
||
| 428 | if ($temp_array['image_source_website'] == '' && $temp_array['image_source'] == 'planespotters') { |
||
| 429 | $planespotter_url_array = explode("_", $temp_array['image']); |
||
| 430 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
||
| 431 | $temp_array['image_source_website'] = 'http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
||
| 432 | } |
||
| 433 | $temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
||
| 434 | } |
||
| 435 | } |
||
| 436 | |||
| 437 | |||
| 438 | if (isset($row['departure_airport_time']) && $row['departure_airport_time'] != '') { |
||
| 439 | $temp_array['departure_airport_time'] = $row['departure_airport_time']; |
||
| 440 | } |
||
| 441 | if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') { |
||
| 442 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
||
| 443 | } |
||
| 444 | |||
| 445 | if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
||
| 446 | if ($schedules === true) { |
||
| 447 | $schedule_array = $Schedule->getSchedule($temp_array['ident']); |
||
| 448 | //print_r($schedule_array); |
||
| 449 | if (count($schedule_array) > 0) { |
||
| 450 | if ($schedule_array['departure_airport_icao'] != '') { |
||
| 451 | $row['departure_airport_icao'] = $schedule_array['departure_airport_icao']; |
||
| 452 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
||
| 453 | } |
||
| 454 | if ($schedule_array['arrival_airport_icao'] != '') { |
||
| 455 | $row['arrival_airport_icao'] = $schedule_array['arrival_airport_icao']; |
||
| 456 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
||
| 457 | } |
||
| 458 | $temp_array['departure_airport_time'] = $schedule_array['departure_airport_time']; |
||
| 459 | $temp_array['arrival_airport_time'] = $schedule_array['arrival_airport_time']; |
||
| 460 | } |
||
| 461 | } |
||
| 462 | } else { |
||
| 463 | if (isset($row['real_departure_airport_time']) && $row['real_departure_airport_time'] != '') { |
||
| 464 | $temp_array['departure_airport_time'] = $row['real_departure_airport_time']; |
||
| 465 | } |
||
| 466 | if (isset($row['real_arrival_airport_time']) && $row['real_arrival_airport_time'] != '') { |
||
| 467 | $temp_array['real_arrival_airport_time'] = $row['real_arrival_airport_time']; |
||
| 468 | } |
||
| 469 | } |
||
| 470 | |||
| 471 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
||
| 472 | if ($row['departure_airport_icao'] != '') { |
||
| 473 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
||
| 474 | if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 475 | /* |
||
| 476 | } elseif ($row['departure_airport_name'] != '') { |
||
| 477 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
||
| 478 | $temp_array['departure_airport_city'] = $row['departure_airport_city']; |
||
| 479 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 480 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
||
| 481 | */ |
||
| 482 | } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 483 | if (isset($departure_airport_array[0]['name'])) { |
||
| 484 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
||
| 485 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
||
| 486 | $temp_array['departure_airport_country'] = $departure_airport_array[0]['country']; |
||
| 487 | $temp_array['departure_airport_iata'] = $departure_airport_array[0]['iata']; |
||
| 488 | $temp_array['departure_airport_icao'] = $departure_airport_array[0]['icao']; |
||
| 489 | $temp_array['departure_airport_latitude'] = $departure_airport_array[0]['latitude']; |
||
| 490 | $temp_array['departure_airport_longitude'] = $departure_airport_array[0]['longitude']; |
||
| 491 | $temp_array['departure_airport_altitude'] = $departure_airport_array[0]['altitude']; |
||
| 492 | } |
||
| 493 | |||
| 494 | /* |
||
| 495 | if (isset($row['departure_airport_time'])) { |
||
| 496 | $temp_array['departure_airport_time'] = $row['departure_airport_time']; |
||
| 497 | } |
||
| 498 | */ |
||
| 499 | |||
| 500 | if ($row['arrival_airport_icao'] != '') { |
||
| 501 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
||
| 502 | if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 503 | } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 504 | if (isset($arrival_airport_array[0]['name'])) { |
||
| 505 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
||
| 506 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
||
| 507 | $temp_array['arrival_airport_country'] = $arrival_airport_array[0]['country']; |
||
| 508 | $temp_array['arrival_airport_iata'] = $arrival_airport_array[0]['iata']; |
||
| 509 | $temp_array['arrival_airport_icao'] = $arrival_airport_array[0]['icao']; |
||
| 510 | $temp_array['arrival_airport_latitude'] = $arrival_airport_array[0]['latitude']; |
||
| 511 | $temp_array['arrival_airport_longitude'] = $arrival_airport_array[0]['longitude']; |
||
| 512 | $temp_array['arrival_airport_altitude'] = $arrival_airport_array[0]['altitude']; |
||
| 513 | } |
||
| 514 | /* |
||
| 515 | if (isset($row['arrival_airport_time'])) { |
||
| 516 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
||
| 517 | } |
||
| 518 | */ |
||
| 519 | if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 520 | if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 521 | if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
||
| 522 | if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
||
| 523 | if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
||
| 524 | if (isset($row['squawk'])) { |
||
| 525 | $temp_array['squawk'] = $row['squawk']; |
||
| 526 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
||
| 527 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
||
| 528 | if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 529 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
||
| 530 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
||
| 531 | if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 532 | } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 533 | } |
||
| 534 | |||
| 535 | $temp_array['query_number_rows'] = $num_rows; |
||
| 536 | |||
| 537 | $spotter_array[] = $temp_array; |
||
| 538 | } |
||
| 539 | if ($num_rows == 0) return array(); |
||
| 540 | $spotter_array[0]['query_number_rows'] = $num_rows; |
||
| 541 | return $spotter_array; |
||
| 542 | } |
||
| 543 | |||
| 544 | |||
| 545 | /** |
||
| 546 | * Gets all the spotter information |
||
| 547 | * |
||
| 548 | * @return Array the spotter information |
||
| 549 | * |
||
| 550 | */ |
||
| 551 | 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 = '',$filters = array()) |
||
| 552 | { |
||
| 553 | global $globalTimezone, $globalDBdriver; |
||
| 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
||
| 555 | $Translation = new Translation(); |
||
| 556 | |||
| 557 | date_default_timezone_set('UTC'); |
||
| 558 | |||
| 559 | $query_values = array(); |
||
| 560 | $additional_query = ''; |
||
| 561 | $filter_query = $this->getFilter($filters,true,true); |
||
| 562 | if ($q != "") |
||
| 563 | { |
||
| 564 | if (!is_string($q)) |
||
| 565 | { |
||
| 566 | return false; |
||
| 567 | } else { |
||
| 568 | $q_array = explode(" ", $q); |
||
| 569 | foreach ($q_array as $q_item){ |
||
| 570 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
||
| 571 | $additional_query .= " AND ("; |
||
| 572 | if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
||
| 573 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
||
| 574 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
||
| 575 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
||
| 576 | $additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
||
| 577 | $additional_query .= "(spotter_output.airline_name like '%".$q_item."%') OR "; |
||
| 578 | $additional_query .= "(spotter_output.airline_country like '%".$q_item."%') OR "; |
||
| 579 | $additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
||
| 580 | $additional_query .= "(spotter_output.departure_airport_name like '%".$q_item."%') OR "; |
||
| 581 | $additional_query .= "(spotter_output.departure_airport_city like '%".$q_item."%') OR "; |
||
| 582 | $additional_query .= "(spotter_output.departure_airport_country like '%".$q_item."%') OR "; |
||
| 583 | $additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
||
| 584 | $additional_query .= "(spotter_output.arrival_airport_name like '%".$q_item."%') OR "; |
||
| 585 | $additional_query .= "(spotter_output.arrival_airport_city like '%".$q_item."%') OR "; |
||
| 586 | $additional_query .= "(spotter_output.arrival_airport_country like '%".$q_item."%') OR "; |
||
| 587 | $additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
||
| 588 | $additional_query .= "(spotter_output.owner_name like '%".$q_item."%') OR "; |
||
| 589 | $additional_query .= "(spotter_output.pilot_id like '%".$q_item."%') OR "; |
||
| 590 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
||
| 591 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
||
| 592 | $translate = $Translation->ident2icao($q_item); |
||
| 593 | if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
||
| 594 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
||
| 595 | $additional_query .= ")"; |
||
| 596 | } |
||
| 597 | } |
||
| 598 | } |
||
| 599 | |||
| 600 | if ($registration != "") |
||
| 601 | { |
||
| 602 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 603 | if (!is_string($registration)) |
||
| 604 | { |
||
| 605 | return false; |
||
| 606 | } else { |
||
| 607 | $additional_query .= " AND spotter_output.registration = :registration"; |
||
| 608 | $query_values = array_merge($query_values,array(':registration' => $registration)); |
||
| 609 | } |
||
| 610 | } |
||
| 611 | |||
| 612 | if ($aircraft_icao != "") |
||
| 613 | { |
||
| 614 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 615 | if (!is_string($aircraft_icao)) |
||
| 616 | { |
||
| 617 | return false; |
||
| 618 | } else { |
||
| 619 | $additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao"; |
||
| 620 | $query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao)); |
||
| 621 | } |
||
| 622 | } |
||
| 623 | |||
| 624 | if ($aircraft_manufacturer != "") |
||
| 625 | { |
||
| 626 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 627 | if (!is_string($aircraft_manufacturer)) |
||
| 628 | { |
||
| 629 | return false; |
||
| 630 | } else { |
||
| 631 | $additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer"; |
||
| 632 | $query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 633 | } |
||
| 634 | } |
||
| 635 | |||
| 636 | if ($highlights == "true") |
||
| 637 | { |
||
| 638 | if (!is_string($highlights)) |
||
| 639 | { |
||
| 640 | return false; |
||
| 641 | } else { |
||
| 642 | $additional_query .= " AND (spotter_output.highlight <> '')"; |
||
| 643 | } |
||
| 644 | } |
||
| 645 | |||
| 646 | if ($airline_icao != "") |
||
| 647 | { |
||
| 648 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 649 | if (!is_string($airline_icao)) |
||
| 650 | { |
||
| 651 | return false; |
||
| 652 | } else { |
||
| 653 | $additional_query .= " AND spotter_output.airline_icao = :airline_icao"; |
||
| 654 | $query_values = array_merge($query_values,array(':airline_icao' => $airline_icao)); |
||
| 655 | } |
||
| 656 | } |
||
| 657 | |||
| 658 | if ($airline_country != "") |
||
| 659 | { |
||
| 660 | $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
||
| 661 | if (!is_string($airline_country)) |
||
| 662 | { |
||
| 663 | return false; |
||
| 664 | } else { |
||
| 665 | $additional_query .= " AND spotter_output.airline_country = :airline_country"; |
||
| 666 | $query_values = array_merge($query_values,array(':airline_country' => $airline_country)); |
||
| 667 | } |
||
| 668 | } |
||
| 669 | |||
| 670 | if ($airline_type != "") |
||
| 671 | { |
||
| 672 | if (!is_string($airline_type)) |
||
| 673 | { |
||
| 674 | return false; |
||
| 675 | } else { |
||
| 676 | if ($airline_type == "passenger") |
||
| 677 | { |
||
| 678 | $additional_query .= " AND (spotter_output.airline_type = 'passenger')"; |
||
| 679 | } |
||
| 680 | if ($airline_type == "cargo") |
||
| 681 | { |
||
| 682 | $additional_query .= " AND (spotter_output.airline_type = 'cargo')"; |
||
| 683 | } |
||
| 684 | if ($airline_type == "military") |
||
| 685 | { |
||
| 686 | $additional_query .= " AND (spotter_output.airline_type = 'military')"; |
||
| 687 | } |
||
| 688 | } |
||
| 689 | } |
||
| 690 | |||
| 691 | if ($airport != "") |
||
| 692 | { |
||
| 693 | $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
||
| 694 | if (!is_string($airport)) |
||
| 695 | { |
||
| 696 | return false; |
||
| 697 | } else { |
||
| 698 | $additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)"; |
||
| 699 | $query_values = array_merge($query_values,array(':airport' => $airport)); |
||
| 700 | } |
||
| 701 | } |
||
| 702 | |||
| 703 | if ($airport_country != "") |
||
| 704 | { |
||
| 705 | $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
||
| 706 | if (!is_string($airport_country)) |
||
| 707 | { |
||
| 708 | return false; |
||
| 709 | } else { |
||
| 710 | $additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)"; |
||
| 711 | $query_values = array_merge($query_values,array(':airport_country' => $airport_country)); |
||
| 712 | } |
||
| 713 | } |
||
| 714 | |||
| 715 | if ($callsign != "") |
||
| 716 | { |
||
| 717 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
||
| 718 | if (!is_string($callsign)) |
||
| 719 | { |
||
| 720 | return false; |
||
| 721 | } else { |
||
| 722 | $translate = $Translation->ident2icao($callsign); |
||
| 723 | if ($translate != $callsign) { |
||
| 724 | $additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)"; |
||
| 725 | $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
||
| 726 | } else { |
||
| 727 | $additional_query .= " AND spotter_output.ident = :callsign"; |
||
| 728 | $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
||
| 729 | } |
||
| 730 | } |
||
| 731 | } |
||
| 732 | |||
| 733 | if ($owner != "") |
||
| 734 | { |
||
| 735 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 736 | if (!is_string($owner)) |
||
| 737 | { |
||
| 738 | return false; |
||
| 739 | } else { |
||
| 740 | $additional_query .= " AND spotter_output.owner_name = :owner"; |
||
| 741 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 742 | } |
||
| 743 | } |
||
| 744 | |||
| 745 | if ($pilot_name != "") |
||
| 746 | { |
||
| 747 | $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
||
| 748 | if (!is_string($pilot_name)) |
||
| 749 | { |
||
| 750 | return false; |
||
| 751 | } else { |
||
| 752 | $additional_query .= " AND spotter_output.pilot_name = :pilot_name"; |
||
| 753 | $query_values = array_merge($query_values,array(':pilot_name' => $pilot_name)); |
||
| 754 | } |
||
| 755 | } |
||
| 756 | |||
| 757 | if ($pilot_id != "") |
||
| 758 | { |
||
| 759 | $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
||
| 760 | if (!is_string($pilot_id)) |
||
| 761 | { |
||
| 762 | return false; |
||
| 763 | } else { |
||
| 764 | $additional_query .= " AND spotter_output.pilot_id = :pilot_id"; |
||
| 765 | $query_values = array_merge($query_values,array(':pilot_id' => $pilot_id)); |
||
| 766 | } |
||
| 767 | } |
||
| 768 | |||
| 769 | if ($departure_airport_route != "") |
||
| 770 | { |
||
| 771 | $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
||
| 772 | if (!is_string($departure_airport_route)) |
||
| 773 | { |
||
| 774 | return false; |
||
| 775 | } else { |
||
| 776 | $additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route"; |
||
| 777 | $query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route)); |
||
| 778 | } |
||
| 779 | } |
||
| 780 | |||
| 781 | if ($arrival_airport_route != "") |
||
| 782 | { |
||
| 783 | $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
||
| 784 | if (!is_string($arrival_airport_route)) |
||
| 785 | { |
||
| 786 | return false; |
||
| 787 | } else { |
||
| 788 | $additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route"; |
||
| 789 | $query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route)); |
||
| 790 | } |
||
| 791 | } |
||
| 792 | |||
| 793 | if ($altitude != "") |
||
| 794 | { |
||
| 795 | $altitude_array = explode(",", $altitude); |
||
| 796 | $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 797 | $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 798 | |||
| 799 | if ($altitude_array[1] != "") |
||
| 800 | { |
||
| 801 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
||
| 802 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
||
| 803 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
||
| 804 | } else { |
||
| 805 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
||
| 806 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
||
| 807 | } |
||
| 808 | } |
||
| 809 | |||
| 810 | if ($date_posted != "") |
||
| 811 | { |
||
| 812 | $date_array = explode(",", $date_posted); |
||
| 813 | $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
||
| 814 | $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
||
| 815 | |||
| 816 | if ($globalTimezone != '') { |
||
| 817 | date_default_timezone_set($globalTimezone); |
||
| 818 | $datetime = new DateTime(); |
||
| 819 | $offset = $datetime->format('P'); |
||
| 820 | } else $offset = '+00:00'; |
||
| 821 | |||
| 822 | if ($date_array[1] != "") |
||
| 823 | { |
||
| 824 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
||
| 825 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
||
| 826 | if ($globalDBdriver == 'mysql') { |
||
| 827 | $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]."' "; |
||
| 828 | } else { |
||
| 829 | $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]."' "; |
||
| 830 | } |
||
| 831 | } else { |
||
| 832 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
||
| 833 | if ($globalDBdriver == 'mysql') { |
||
| 834 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
||
| 835 | } else { |
||
| 836 | $additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' "; |
||
| 837 | } |
||
| 838 | } |
||
| 839 | } |
||
| 840 | |||
| 841 | if ($limit != "") |
||
| 842 | { |
||
| 843 | $limit_array = explode(",", $limit); |
||
| 844 | |||
| 845 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 846 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 847 | |||
| 848 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 849 | { |
||
| 850 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 851 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 852 | } else $limit_query = ""; |
||
| 853 | } else $limit_query = ""; |
||
| 854 | |||
| 855 | |||
| 856 | if ($sort != "") |
||
| 857 | { |
||
| 858 | $search_orderby_array = $this->getOrderBy(); |
||
| 859 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 860 | } else { |
||
| 861 | if ($origLat != "" && $origLon != "" && $dist != "") { |
||
| 862 | $orderby_query = " ORDER BY distance ASC"; |
||
| 863 | } else { |
||
| 864 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 865 | } |
||
| 866 | } |
||
| 867 | |||
| 868 | if ($includegeodata == "true") |
||
| 869 | { |
||
| 870 | $additional_query .= " AND spotter_output.waypoints <> ''"; |
||
| 871 | } |
||
| 872 | |||
| 873 | |||
| 874 | if ($origLat != "" && $origLon != "" && $dist != "") { |
||
| 875 | $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
||
| 876 | |||
| 877 | if ($globalDBdriver == 'mysql') { |
||
| 878 | $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 |
||
| 879 | FROM spotter_archive,spotter_output".$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)) |
||
| 880 | 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; |
||
| 881 | } else { |
||
| 882 | $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 |
||
| 883 | FROM spotter_archive,spotter_output".$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)) |
||
| 884 | 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; |
||
| 885 | } |
||
| 886 | } else { |
||
| 887 | $query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' |
||
| 888 | ".$additional_query." |
||
| 889 | ".$orderby_query; |
||
| 890 | } |
||
| 891 | $spotter_array = $this->getDataFromDB($query, $query_values,$limit_query); |
||
| 892 | return $spotter_array; |
||
| 893 | } |
||
| 894 | |||
| 895 | |||
| 896 | /** |
||
| 897 | * Gets all the spotter information based on the latest data entry |
||
| 898 | * |
||
| 899 | * @return Array the spotter information |
||
| 900 | * |
||
| 901 | */ |
||
| 902 | public function getLatestSpotterData($limit = '', $sort = '', $filter = array()) |
||
| 903 | { |
||
| 904 | global $global_query; |
||
| 905 | |||
| 906 | date_default_timezone_set('UTC'); |
||
| 907 | |||
| 908 | $filter_query = $this->getFilter($filter); |
||
| 909 | |||
| 910 | if ($limit != "") |
||
| 911 | { |
||
| 912 | $limit_array = explode(",", $limit); |
||
| 913 | |||
| 914 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 915 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 916 | |||
| 917 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 918 | { |
||
| 919 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 920 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 921 | } else $limit_query = ""; |
||
| 922 | } else $limit_query = ""; |
||
| 923 | |||
| 924 | if ($sort != "") |
||
| 925 | { |
||
| 926 | $search_orderby_array = $this->getOrderBy(); |
||
| 927 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 928 | } else { |
||
| 929 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 930 | } |
||
| 931 | |||
| 932 | $query = $global_query.$filter_query." ".$orderby_query; |
||
| 933 | |||
| 934 | $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
||
| 935 | |||
| 936 | return $spotter_array; |
||
| 937 | } |
||
| 938 | |||
| 939 | |||
| 940 | /** |
||
| 941 | * Gets all the spotter information based on a user's latitude and longitude |
||
| 942 | * |
||
| 943 | * @return Array the spotter information |
||
| 944 | * |
||
| 945 | */ |
||
| 946 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
||
| 947 | { |
||
| 948 | date_default_timezone_set('UTC'); |
||
| 949 | $limit_query = ''; |
||
| 950 | if ($lat != "") |
||
| 951 | { |
||
| 952 | if (!is_numeric($lat)) |
||
| 953 | { |
||
| 954 | return false; |
||
| 955 | } |
||
| 956 | } |
||
| 957 | |||
| 958 | if ($lng != "") |
||
| 959 | { |
||
| 960 | if (!is_numeric($lng)) |
||
| 961 | { |
||
| 962 | return false; |
||
| 963 | } |
||
| 964 | } |
||
| 965 | |||
| 966 | if ($radius != "") |
||
| 967 | { |
||
| 968 | if (!is_numeric($radius)) |
||
| 969 | { |
||
| 970 | return false; |
||
| 971 | } |
||
| 972 | } |
||
| 973 | $additional_query = ''; |
||
| 974 | if ($interval != "") |
||
| 975 | { |
||
| 976 | if (!is_string($interval)) |
||
| 977 | { |
||
| 978 | return false; |
||
| 979 | } else { |
||
| 980 | if ($interval == "30m"){ |
||
| 981 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date '; |
||
| 982 | } else if ($interval == "1h"){ |
||
| 983 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date '; |
||
| 984 | } else if ($interval == "3h"){ |
||
| 985 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date '; |
||
| 986 | } else if ($interval == "6h"){ |
||
| 987 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date '; |
||
| 988 | } else if ($interval == "12h"){ |
||
| 989 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date '; |
||
| 990 | } else if ($interval == "24h"){ |
||
| 991 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date '; |
||
| 992 | } else if ($interval == "7d"){ |
||
| 993 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date '; |
||
| 994 | } else if ($interval == "30d"){ |
||
| 995 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date '; |
||
| 996 | } |
||
| 997 | } |
||
| 998 | } |
||
| 999 | |||
| 1000 | $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 |
||
| 1001 | WHERE spotter_output.latitude <> '' |
||
| 1002 | AND spotter_output.longitude <> '' |
||
| 1003 | ".$additional_query." |
||
| 1004 | HAVING distance < :radius |
||
| 1005 | ORDER BY distance"; |
||
| 1006 | |||
| 1007 | $spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query); |
||
| 1008 | |||
| 1009 | return $spotter_array; |
||
| 1010 | } |
||
| 1011 | |||
| 1012 | |||
| 1013 | /** |
||
| 1014 | * Gets all the spotter information sorted by the newest aircraft type |
||
| 1015 | * |
||
| 1016 | * @return Array the spotter information |
||
| 1017 | * |
||
| 1018 | */ |
||
| 1019 | public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array()) |
||
| 1020 | { |
||
| 1021 | global $global_query; |
||
| 1022 | |||
| 1023 | date_default_timezone_set('UTC'); |
||
| 1024 | |||
| 1025 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1026 | |||
| 1027 | $limit_query = ''; |
||
| 1028 | if ($limit != "") |
||
| 1029 | { |
||
| 1030 | $limit_array = explode(",", $limit); |
||
| 1031 | |||
| 1032 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1033 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1034 | |||
| 1035 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1036 | { |
||
| 1037 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1038 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1039 | } |
||
| 1040 | } |
||
| 1041 | |||
| 1042 | if ($sort != "") |
||
| 1043 | { |
||
| 1044 | $search_orderby_array = $this->getOrderBy(); |
||
| 1045 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1046 | } else { |
||
| 1047 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | $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; |
||
| 1051 | |||
| 1052 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1053 | |||
| 1054 | return $spotter_array; |
||
| 1055 | } |
||
| 1056 | |||
| 1057 | |||
| 1058 | /** |
||
| 1059 | * Gets all the spotter information sorted by the newest aircraft registration |
||
| 1060 | * |
||
| 1061 | * @return Array the spotter information |
||
| 1062 | * |
||
| 1063 | */ |
||
| 1064 | public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array()) |
||
| 1065 | { |
||
| 1066 | global $global_query; |
||
| 1067 | |||
| 1068 | date_default_timezone_set('UTC'); |
||
| 1069 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1070 | |||
| 1071 | $limit_query = ''; |
||
| 1072 | if ($limit != "") |
||
| 1073 | { |
||
| 1074 | $limit_array = explode(",", $limit); |
||
| 1075 | |||
| 1076 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1077 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1078 | |||
| 1079 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1080 | { |
||
| 1081 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1082 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1083 | } |
||
| 1084 | } |
||
| 1085 | |||
| 1086 | if ($sort != "") |
||
| 1087 | { |
||
| 1088 | $search_orderby_array = $this->getOrderBy(); |
||
| 1089 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1090 | } else { |
||
| 1091 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | $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; |
||
| 1095 | |||
| 1096 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1097 | |||
| 1098 | return $spotter_array; |
||
| 1099 | } |
||
| 1100 | |||
| 1101 | |||
| 1102 | /** |
||
| 1103 | * Gets all the spotter information sorted by the newest airline |
||
| 1104 | * |
||
| 1105 | * @return Array the spotter information |
||
| 1106 | * |
||
| 1107 | */ |
||
| 1108 | public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array()) |
||
| 1109 | { |
||
| 1110 | global $global_query; |
||
| 1111 | |||
| 1112 | date_default_timezone_set('UTC'); |
||
| 1113 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1114 | |||
| 1115 | $limit_query = ''; |
||
| 1116 | if ($limit != "") |
||
| 1117 | { |
||
| 1118 | $limit_array = explode(",", $limit); |
||
| 1119 | |||
| 1120 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1121 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1122 | |||
| 1123 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1124 | { |
||
| 1125 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1126 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1127 | } |
||
| 1128 | } |
||
| 1129 | |||
| 1130 | if ($sort != "") |
||
| 1131 | { |
||
| 1132 | $search_orderby_array = $this->getOrderBy(); |
||
| 1133 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1134 | } else { |
||
| 1135 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1136 | } |
||
| 1137 | |||
| 1138 | $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; |
||
| 1139 | |||
| 1140 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1141 | |||
| 1142 | return $spotter_array; |
||
| 1143 | } |
||
| 1144 | |||
| 1145 | |||
| 1146 | /** |
||
| 1147 | * Gets all the spotter information sorted by the newest departure airport |
||
| 1148 | * |
||
| 1149 | * @return Array the spotter information |
||
| 1150 | * |
||
| 1151 | */ |
||
| 1152 | public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array()) |
||
| 1153 | { |
||
| 1154 | global $global_query; |
||
| 1155 | |||
| 1156 | date_default_timezone_set('UTC'); |
||
| 1157 | |||
| 1158 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1159 | |||
| 1160 | $limit_query = ''; |
||
| 1161 | |||
| 1162 | if ($limit != "") |
||
| 1163 | { |
||
| 1164 | $limit_array = explode(",", $limit); |
||
| 1165 | |||
| 1166 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1167 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1168 | |||
| 1169 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1170 | { |
||
| 1171 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1172 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1173 | } |
||
| 1174 | } |
||
| 1175 | |||
| 1176 | if ($sort != "") |
||
| 1177 | { |
||
| 1178 | $search_orderby_array = $this->getOrderBy(); |
||
| 1179 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1180 | } else { |
||
| 1181 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1182 | } |
||
| 1183 | |||
| 1184 | $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; |
||
| 1185 | |||
| 1186 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1187 | |||
| 1188 | return $spotter_array; |
||
| 1189 | } |
||
| 1190 | |||
| 1191 | |||
| 1192 | /** |
||
| 1193 | * Gets all the spotter information sorted by the newest arrival airport |
||
| 1194 | * |
||
| 1195 | * @return Array the spotter information |
||
| 1196 | * |
||
| 1197 | */ |
||
| 1198 | public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array()) |
||
| 1199 | { |
||
| 1200 | global $global_query; |
||
| 1201 | |||
| 1202 | date_default_timezone_set('UTC'); |
||
| 1203 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1204 | $limit_query = ''; |
||
| 1205 | if ($limit != "") |
||
| 1206 | { |
||
| 1207 | $limit_array = explode(",", $limit); |
||
| 1208 | |||
| 1209 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1210 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1211 | |||
| 1212 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1213 | { |
||
| 1214 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1215 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1216 | } |
||
| 1217 | } |
||
| 1218 | |||
| 1219 | if ($sort != "") |
||
| 1220 | { |
||
| 1221 | $search_orderby_array = $this->getOrderBy(); |
||
| 1222 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1223 | } else { |
||
| 1224 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1225 | } |
||
| 1226 | |||
| 1227 | $query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' 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; |
||
| 1228 | |||
| 1229 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1230 | |||
| 1231 | return $spotter_array; |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Gets all the spotter information based on the spotter id |
||
| 1237 | * |
||
| 1238 | * @return Array the spotter information |
||
| 1239 | * |
||
| 1240 | */ |
||
| 1241 | public function getSpotterDataByID($id = '') |
||
| 1242 | { |
||
| 1243 | global $global_query; |
||
| 1244 | |||
| 1245 | date_default_timezone_set('UTC'); |
||
| 1246 | if ($id == '') return array(); |
||
| 1247 | $additional_query = "spotter_output.spotter_id = :id"; |
||
| 1248 | $query_values = array(':id' => $id); |
||
| 1249 | |||
| 1250 | //$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." "; |
||
| 1251 | $query = $global_query." WHERE ".$additional_query." "; |
||
| 1252 | |||
| 1253 | $spotter_array = $this->getDataFromDB($query,$query_values); |
||
| 1254 | |||
| 1255 | return $spotter_array; |
||
| 1256 | } |
||
| 1257 | |||
| 1258 | |||
| 1259 | |||
| 1260 | |||
| 1261 | /** |
||
| 1262 | * Gets all the spotter information based on the callsign |
||
| 1263 | * |
||
| 1264 | * @return Array the spotter information |
||
| 1265 | * |
||
| 1266 | */ |
||
| 1267 | public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
||
| 1268 | { |
||
| 1269 | global $global_query; |
||
| 1270 | |||
| 1271 | date_default_timezone_set('UTC'); |
||
| 1272 | |||
| 1273 | $query_values = array(); |
||
| 1274 | $limit_query = ''; |
||
| 1275 | $additional_query = ''; |
||
| 1276 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1277 | if ($ident != "") |
||
| 1278 | { |
||
| 1279 | if (!is_string($ident)) |
||
| 1280 | { |
||
| 1281 | return false; |
||
| 1282 | } else { |
||
| 1283 | $additional_query = " AND (spotter_output.ident = :ident)"; |
||
| 1284 | $query_values = array(':ident' => $ident); |
||
| 1285 | } |
||
| 1286 | } |
||
| 1287 | |||
| 1288 | if ($limit != "") |
||
| 1289 | { |
||
| 1290 | $limit_array = explode(",", $limit); |
||
| 1291 | |||
| 1292 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1293 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1294 | |||
| 1295 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1296 | { |
||
| 1297 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1298 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1299 | } |
||
| 1300 | } |
||
| 1301 | |||
| 1302 | if ($sort != "") |
||
| 1303 | { |
||
| 1304 | $search_orderby_array = $this->getOrderBy(); |
||
| 1305 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1306 | } else { |
||
| 1307 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1308 | } |
||
| 1309 | |||
| 1310 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1311 | |||
| 1312 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1313 | |||
| 1314 | return $spotter_array; |
||
| 1315 | } |
||
| 1316 | |||
| 1317 | /** |
||
| 1318 | * Gets all the spotter information based on the owner |
||
| 1319 | * |
||
| 1320 | * @return Array the spotter information |
||
| 1321 | * |
||
| 1322 | */ |
||
| 1323 | public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
||
| 1324 | { |
||
| 1325 | global $global_query; |
||
| 1326 | |||
| 1327 | date_default_timezone_set('UTC'); |
||
| 1328 | |||
| 1329 | $query_values = array(); |
||
| 1330 | $limit_query = ''; |
||
| 1331 | $additional_query = ''; |
||
| 1332 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1333 | if ($owner != "") |
||
| 1334 | { |
||
| 1335 | if (!is_string($owner)) |
||
| 1336 | { |
||
| 1337 | return false; |
||
| 1338 | } else { |
||
| 1339 | $additional_query = " AND (spotter_output.owner_name = :owner)"; |
||
| 1340 | $query_values = array(':owner' => $owner); |
||
| 1341 | } |
||
| 1342 | } |
||
| 1343 | |||
| 1344 | if ($limit != "") |
||
| 1345 | { |
||
| 1346 | $limit_array = explode(",", $limit); |
||
| 1347 | |||
| 1348 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1349 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1350 | |||
| 1351 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1352 | { |
||
| 1353 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1354 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1355 | } |
||
| 1356 | } |
||
| 1357 | |||
| 1358 | if ($sort != "") |
||
| 1359 | { |
||
| 1360 | $search_orderby_array = $this->getOrderBy(); |
||
| 1361 | if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1362 | else $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1363 | } else { |
||
| 1364 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1365 | } |
||
| 1366 | |||
| 1367 | $query = $global_query.$filter_query." spotter_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
||
| 1368 | |||
| 1369 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1370 | |||
| 1371 | return $spotter_array; |
||
| 1372 | } |
||
| 1373 | |||
| 1374 | /** |
||
| 1375 | * Gets all the spotter information based on the pilot |
||
| 1376 | * |
||
| 1377 | * @return Array the spotter information |
||
| 1378 | * |
||
| 1379 | */ |
||
| 1380 | public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
||
| 1381 | { |
||
| 1382 | global $global_query; |
||
| 1383 | |||
| 1384 | date_default_timezone_set('UTC'); |
||
| 1385 | |||
| 1386 | $query_values = array(); |
||
| 1387 | $limit_query = ''; |
||
| 1388 | $additional_query = ''; |
||
| 1389 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1390 | if ($pilot != "") |
||
| 1391 | { |
||
| 1392 | $additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; |
||
| 1393 | $query_values = array(':pilot' => $pilot); |
||
| 1394 | } |
||
| 1395 | |||
| 1396 | if ($limit != "") |
||
| 1397 | { |
||
| 1398 | $limit_array = explode(",", $limit); |
||
| 1399 | |||
| 1400 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1401 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1402 | |||
| 1403 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1404 | { |
||
| 1405 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1406 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1407 | } |
||
| 1408 | } |
||
| 1409 | |||
| 1410 | if ($sort != "") |
||
| 1411 | { |
||
| 1412 | $search_orderby_array = $this->getOrderBy(); |
||
| 1413 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1414 | } else { |
||
| 1415 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1416 | } |
||
| 1417 | |||
| 1418 | $query = $global_query.$filter_query." spotter_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
||
| 1419 | |||
| 1420 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1421 | |||
| 1422 | return $spotter_array; |
||
| 1423 | } |
||
| 1424 | |||
| 1425 | |||
| 1426 | |||
| 1427 | /** |
||
| 1428 | * Gets all the spotter information based on the aircraft type |
||
| 1429 | * |
||
| 1430 | * @return Array the spotter information |
||
| 1431 | * |
||
| 1432 | */ |
||
| 1433 | public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array()) |
||
| 1434 | { |
||
| 1435 | global $global_query; |
||
| 1436 | |||
| 1437 | date_default_timezone_set('UTC'); |
||
| 1438 | |||
| 1439 | $query_values = array(); |
||
| 1440 | $limit_query = ''; |
||
| 1441 | $additional_query = ''; |
||
| 1442 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1443 | |||
| 1444 | if ($aircraft_type != "") |
||
| 1445 | { |
||
| 1446 | if (!is_string($aircraft_type)) |
||
| 1447 | { |
||
| 1448 | return false; |
||
| 1449 | } else { |
||
| 1450 | $additional_query = " AND (spotter_output.aircraft_icao = :aircraft_type)"; |
||
| 1451 | $query_values = array(':aircraft_type' => $aircraft_type); |
||
| 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 | |||
| 1479 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1480 | |||
| 1481 | return $spotter_array; |
||
| 1482 | } |
||
| 1483 | |||
| 1484 | |||
| 1485 | /** |
||
| 1486 | * Gets all the spotter information based on the aircraft registration |
||
| 1487 | * |
||
| 1488 | * @return Array the spotter information |
||
| 1489 | * |
||
| 1490 | */ |
||
| 1491 | public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array()) |
||
| 1492 | { |
||
| 1493 | global $global_query; |
||
| 1494 | |||
| 1495 | date_default_timezone_set('UTC'); |
||
| 1496 | |||
| 1497 | $query_values = array(); |
||
| 1498 | $limit_query = ''; |
||
| 1499 | $additional_query = ''; |
||
| 1500 | |||
| 1501 | if ($registration != "") |
||
| 1502 | { |
||
| 1503 | if (!is_string($registration)) |
||
| 1504 | { |
||
| 1505 | return false; |
||
| 1506 | } else { |
||
| 1507 | $additional_query = " (spotter_output.registration = :registration)"; |
||
| 1508 | $query_values = array(':registration' => $registration); |
||
| 1509 | } |
||
| 1510 | } |
||
| 1511 | |||
| 1512 | if ($limit != "") |
||
| 1513 | { |
||
| 1514 | $limit_array = explode(",", $limit); |
||
| 1515 | |||
| 1516 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1517 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1518 | |||
| 1519 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1520 | { |
||
| 1521 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1522 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1523 | } |
||
| 1524 | } |
||
| 1525 | |||
| 1526 | if ($sort != "") |
||
| 1527 | { |
||
| 1528 | $search_orderby_array = $this->getOrderBy(); |
||
| 1529 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1530 | } else { |
||
| 1531 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1532 | } |
||
| 1533 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1534 | |||
| 1535 | //$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1536 | $query = $global_query.$filter_query." ".$additional_query." ".$orderby_query; |
||
| 1537 | |||
| 1538 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1539 | |||
| 1540 | return $spotter_array; |
||
| 1541 | } |
||
| 1542 | |||
| 1543 | |||
| 1544 | |||
| 1545 | |||
| 1546 | /** |
||
| 1547 | * Gets all the spotter information based on the airline |
||
| 1548 | * |
||
| 1549 | * @return Array the spotter information |
||
| 1550 | * |
||
| 1551 | */ |
||
| 1552 | public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array()) |
||
| 1553 | { |
||
| 1554 | global $global_query; |
||
| 1555 | |||
| 1556 | date_default_timezone_set('UTC'); |
||
| 1557 | |||
| 1558 | $query_values = array(); |
||
| 1559 | $limit_query = ''; |
||
| 1560 | $additional_query = ''; |
||
| 1561 | $filter_query = $this->getFilter($filters,true,true); |
||
| 1562 | |||
| 1563 | if ($airline != "") |
||
| 1564 | { |
||
| 1565 | if (!is_string($airline)) |
||
| 1566 | { |
||
| 1567 | return false; |
||
| 1568 | } else { |
||
| 1569 | $additional_query = " AND (spotter_output.airline_icao = :airline)"; |
||
| 1570 | $query_values = array(':airline' => $airline); |
||
| 1571 | } |
||
| 1572 | } |
||
| 1573 | |||
| 1574 | if ($limit != "") |
||
| 1575 | { |
||
| 1576 | $limit_array = explode(",", $limit); |
||
| 1577 | |||
| 1578 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1579 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1580 | |||
| 1581 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1582 | { |
||
| 1583 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1584 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1585 | } |
||
| 1586 | } |
||
| 1587 | |||
| 1588 | if ($sort != "") |
||
| 1589 | { |
||
| 1590 | $search_orderby_array = $this->getOrderBy(); |
||
| 1591 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1592 | } else { |
||
| 1593 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1594 | } |
||
| 1595 | |||
| 1596 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1597 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1598 | |||
| 1599 | return $spotter_array; |
||
| 1600 | } |
||
| 1601 | |||
| 1602 | |||
| 1603 | /** |
||
| 1604 | * Gets all the spotter information based on the airport |
||
| 1605 | * |
||
| 1606 | * @return Array the spotter information |
||
| 1607 | * |
||
| 1608 | */ |
||
| 1609 | public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
||
| 1610 | { |
||
| 1611 | global $global_query; |
||
| 1612 | |||
| 1613 | date_default_timezone_set('UTC'); |
||
| 1614 | $query_values = array(); |
||
| 1615 | $limit_query = ''; |
||
| 1616 | $additional_query = ''; |
||
| 1617 | $filter_query = $this->getFilter($filters,true,true); |
||
| 1618 | |||
| 1619 | if ($airport != "") |
||
| 1620 | { |
||
| 1621 | if (!is_string($airport)) |
||
| 1622 | { |
||
| 1623 | return false; |
||
| 1624 | } else { |
||
| 1625 | $additional_query .= " AND ((spotter_output.departure_airport_icao = :airport) OR (spotter_output.arrival_airport_icao = :airport))"; |
||
| 1626 | $query_values = array(':airport' => $airport); |
||
| 1627 | } |
||
| 1628 | } |
||
| 1629 | |||
| 1630 | if ($limit != "") |
||
| 1631 | { |
||
| 1632 | $limit_array = explode(",", $limit); |
||
| 1633 | |||
| 1634 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1635 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1636 | |||
| 1637 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1638 | { |
||
| 1639 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1640 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1641 | } |
||
| 1642 | } |
||
| 1643 | |||
| 1644 | if ($sort != "") |
||
| 1645 | { |
||
| 1646 | $search_orderby_array = $this->getOrderBy(); |
||
| 1647 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1648 | } else { |
||
| 1649 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1650 | } |
||
| 1651 | |||
| 1652 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." AND ((spotter_output.departure_airport_icao <> 'NA') AND (spotter_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
||
| 1653 | |||
| 1654 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1655 | |||
| 1656 | return $spotter_array; |
||
| 1657 | } |
||
| 1658 | |||
| 1659 | |||
| 1660 | |||
| 1661 | /** |
||
| 1662 | * Gets all the spotter information based on the date |
||
| 1663 | * |
||
| 1664 | * @return Array the spotter information |
||
| 1665 | * |
||
| 1666 | */ |
||
| 1667 | public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
||
| 1668 | { |
||
| 1669 | global $global_query, $globalTimezone, $globalDBdriver; |
||
| 1670 | |||
| 1671 | $query_values = array(); |
||
| 1672 | $limit_query = ''; |
||
| 1673 | $additional_query = ''; |
||
| 1674 | |||
| 1675 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1676 | |||
| 1677 | if ($date != "") |
||
| 1678 | { |
||
| 1679 | if ($globalTimezone != '') { |
||
| 1680 | date_default_timezone_set($globalTimezone); |
||
| 1681 | $datetime = new DateTime($date); |
||
| 1682 | $offset = $datetime->format('P'); |
||
| 1683 | } else { |
||
| 1684 | date_default_timezone_set('UTC'); |
||
| 1685 | $datetime = new DateTime($date); |
||
| 1686 | $offset = '+00:00'; |
||
| 1687 | } |
||
| 1688 | if ($globalDBdriver == 'mysql') { |
||
| 1689 | $additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date "; |
||
| 1690 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset); |
||
| 1691 | } elseif ($globalDBdriver == 'pgsql') { |
||
| 1692 | //$globalTimezone = 'UTC'; |
||
| 1693 | $additional_query = " AND to_char(spotter_output.date AT TIME ZONE :timezone,'YYYY-mm-dd') = :date "; |
||
| 1694 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':timezone' => $globalTimezone); |
||
| 1695 | //$additional_query = " AND to_char(spotter_output.date,'YYYY-mm-dd') = :date "; |
||
| 1696 | //$query_values = array(':date' => $datetime->format('Y-m-d')); |
||
| 1697 | } |
||
| 1698 | } |
||
| 1699 | |||
| 1700 | if ($limit != "") |
||
| 1701 | { |
||
| 1702 | $limit_array = explode(",", $limit); |
||
| 1703 | |||
| 1704 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1705 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1706 | |||
| 1707 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1708 | { |
||
| 1709 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1710 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1711 | } |
||
| 1712 | } |
||
| 1713 | |||
| 1714 | if ($sort != "") |
||
| 1715 | { |
||
| 1716 | $search_orderby_array = $this->getOrderBy(); |
||
| 1717 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1718 | } else { |
||
| 1719 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1720 | } |
||
| 1721 | |||
| 1722 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query.$orderby_query; |
||
| 1723 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1724 | return $spotter_array; |
||
| 1725 | } |
||
| 1726 | |||
| 1727 | |||
| 1728 | |||
| 1729 | /** |
||
| 1730 | * Gets all the spotter information based on the country name |
||
| 1731 | * |
||
| 1732 | * @return Array the spotter information |
||
| 1733 | * |
||
| 1734 | */ |
||
| 1735 | public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array()) |
||
| 1736 | { |
||
| 1737 | global $global_query; |
||
| 1738 | |||
| 1739 | date_default_timezone_set('UTC'); |
||
| 1740 | |||
| 1741 | $query_values = array(); |
||
| 1742 | $limit_query = ''; |
||
| 1743 | $additional_query = ''; |
||
| 1744 | $filter_query = $this->getFilter($filters,true,true); |
||
| 1745 | if ($country != "") |
||
| 1746 | { |
||
| 1747 | if (!is_string($country)) |
||
| 1748 | { |
||
| 1749 | return false; |
||
| 1750 | } else { |
||
| 1751 | $additional_query .= " AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country))"; |
||
| 1752 | $additional_query .= " OR spotter_output.airline_country = :country"; |
||
| 1753 | $query_values = array(':country' => $country); |
||
| 1754 | } |
||
| 1755 | } |
||
| 1756 | |||
| 1757 | if ($limit != "") |
||
| 1758 | { |
||
| 1759 | $limit_array = explode(",", $limit); |
||
| 1760 | |||
| 1761 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1762 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1763 | |||
| 1764 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1765 | { |
||
| 1766 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1767 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1768 | } |
||
| 1769 | } |
||
| 1770 | |||
| 1771 | if ($sort != "") |
||
| 1772 | { |
||
| 1773 | $search_orderby_array = $this->getOrderBy(); |
||
| 1774 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1775 | } else { |
||
| 1776 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1777 | } |
||
| 1778 | |||
| 1779 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1780 | |||
| 1781 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1782 | |||
| 1783 | return $spotter_array; |
||
| 1784 | } |
||
| 1785 | |||
| 1786 | |||
| 1787 | /** |
||
| 1788 | * Gets all the spotter information based on the manufacturer name |
||
| 1789 | * |
||
| 1790 | * @return Array the spotter information |
||
| 1791 | * |
||
| 1792 | */ |
||
| 1793 | public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array()) |
||
| 1794 | { |
||
| 1795 | global $global_query; |
||
| 1796 | |||
| 1797 | date_default_timezone_set('UTC'); |
||
| 1798 | |||
| 1799 | $query_values = array(); |
||
| 1800 | $additional_query = ''; |
||
| 1801 | $limit_query = ''; |
||
| 1802 | $filter_query = $this->getFilter($filters,true,true); |
||
| 1803 | |||
| 1804 | if ($aircraft_manufacturer != "") |
||
| 1805 | { |
||
| 1806 | if (!is_string($aircraft_manufacturer)) |
||
| 1807 | { |
||
| 1808 | return false; |
||
| 1809 | } else { |
||
| 1810 | $additional_query .= " AND (spotter_output.aircraft_manufacturer = :aircraft_manufacturer)"; |
||
| 1811 | $query_values = array(':aircraft_manufacturer' => $aircraft_manufacturer); |
||
| 1812 | } |
||
| 1813 | } |
||
| 1814 | |||
| 1815 | if ($limit != "") |
||
| 1816 | { |
||
| 1817 | $limit_array = explode(",", $limit); |
||
| 1818 | |||
| 1819 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1820 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1821 | |||
| 1822 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1823 | { |
||
| 1824 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1825 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1826 | } |
||
| 1827 | } |
||
| 1828 | |||
| 1829 | if ($sort != "") |
||
| 1830 | { |
||
| 1831 | $search_orderby_array = $this->getOrderBy(); |
||
| 1832 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1833 | } else { |
||
| 1834 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1835 | } |
||
| 1836 | |||
| 1837 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1838 | |||
| 1839 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1840 | |||
| 1841 | return $spotter_array; |
||
| 1842 | } |
||
| 1843 | |||
| 1844 | |||
| 1845 | |||
| 1846 | |||
| 1847 | /** |
||
| 1848 | * Gets a list of all aircraft that take a route |
||
| 1849 | * |
||
| 1850 | * @param String $departure_airport_icao ICAO code of departure airport |
||
| 1851 | * @param String $arrival_airport_icao ICAO code of arrival airport |
||
| 1852 | * @return Array the spotter information |
||
| 1853 | * |
||
| 1854 | */ |
||
| 1855 | public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array()) |
||
| 1856 | { |
||
| 1857 | global $global_query; |
||
| 1858 | |||
| 1859 | $query_values = array(); |
||
| 1860 | $additional_query = ''; |
||
| 1861 | $limit_query = ''; |
||
| 1862 | $filter_query = $this->getFilter($filters,true,true); |
||
| 1863 | if ($departure_airport_icao != "") |
||
| 1864 | { |
||
| 1865 | if (!is_string($departure_airport_icao)) |
||
| 1866 | { |
||
| 1867 | return false; |
||
| 1868 | } else { |
||
| 1869 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 1870 | $additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)"; |
||
| 1871 | //$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao"; |
||
| 1872 | $query_values = array(':departure_airport_icao' => $departure_airport_icao); |
||
| 1873 | } |
||
| 1874 | } |
||
| 1875 | |||
| 1876 | if ($arrival_airport_icao != "") |
||
| 1877 | { |
||
| 1878 | if (!is_string($arrival_airport_icao)) |
||
| 1879 | { |
||
| 1880 | return false; |
||
| 1881 | } else { |
||
| 1882 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 1883 | $additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)"; |
||
| 1884 | //$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)"; |
||
| 1885 | $query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 1886 | } |
||
| 1887 | } |
||
| 1888 | |||
| 1889 | if ($limit != "") |
||
| 1890 | { |
||
| 1891 | $limit_array = explode(",", $limit); |
||
| 1892 | |||
| 1893 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1894 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1895 | |||
| 1896 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1897 | { |
||
| 1898 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1899 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1900 | } |
||
| 1901 | } |
||
| 1902 | |||
| 1903 | if ($sort != "") |
||
| 1904 | { |
||
| 1905 | $search_orderby_array = $this->getOrderBy(); |
||
| 1906 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1907 | } else { |
||
| 1908 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1909 | } |
||
| 1910 | |||
| 1911 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1912 | |||
| 1913 | //$result = mysqli_query($GLOBALS["___mysqli_ston"], $query); |
||
| 1914 | |||
| 1915 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1916 | |||
| 1917 | return $spotter_array; |
||
| 1918 | } |
||
| 1919 | |||
| 1920 | |||
| 1921 | |||
| 1922 | /** |
||
| 1923 | * Gets all the spotter information based on the special column in the table |
||
| 1924 | * |
||
| 1925 | * @return Array the spotter information |
||
| 1926 | * |
||
| 1927 | */ |
||
| 1928 | public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array()) |
||
| 1929 | { |
||
| 1930 | global $global_query; |
||
| 1931 | |||
| 1932 | date_default_timezone_set('UTC'); |
||
| 1933 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1934 | $limit_query = ''; |
||
| 1935 | |||
| 1936 | if ($limit != "") |
||
| 1937 | { |
||
| 1938 | $limit_array = explode(",", $limit); |
||
| 1939 | |||
| 1940 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1941 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1942 | |||
| 1943 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1944 | { |
||
| 1945 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1946 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1947 | } |
||
| 1948 | } |
||
| 1949 | |||
| 1950 | if ($sort != "") |
||
| 1951 | { |
||
| 1952 | $search_orderby_array = $this->getOrderBy(); |
||
| 1953 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1954 | } else { |
||
| 1955 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1956 | } |
||
| 1957 | |||
| 1958 | $query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query; |
||
| 1959 | |||
| 1960 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1961 | |||
| 1962 | return $spotter_array; |
||
| 1963 | } |
||
| 1964 | |||
| 1965 | /** |
||
| 1966 | * Gets all the highlight based on a aircraft registration |
||
| 1967 | * |
||
| 1968 | * @return String the highlight text |
||
| 1969 | * |
||
| 1970 | */ |
||
| 1971 | public function getHighlightByRegistration($registration,$filter = array()) |
||
| 1972 | { |
||
| 1973 | global $global_query; |
||
| 1974 | |||
| 1975 | date_default_timezone_set('UTC'); |
||
| 1976 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1977 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 1978 | |||
| 1979 | $query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; |
||
| 1980 | $sth = $this->db->prepare($query); |
||
| 1981 | $sth->execute(array(':registration' => $registration)); |
||
| 1982 | |||
| 1983 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1984 | { |
||
| 1985 | $highlight = $row['highlight']; |
||
| 1986 | } |
||
| 1987 | if (isset($highlight)) return $highlight; |
||
| 1988 | } |
||
| 1989 | |||
| 1990 | |||
| 1991 | /** |
||
| 1992 | * Gets the squawk usage from squawk code |
||
| 1993 | * |
||
| 1994 | * @param String $squawk squawk code |
||
| 1995 | * @param String $country country |
||
| 1996 | * @return String usage |
||
| 1997 | * |
||
| 1998 | */ |
||
| 1999 | public function getSquawkUsage($squawk = '',$country = 'FR') |
||
| 2000 | { |
||
| 2001 | |||
| 2002 | $squawk = filter_var($squawk,FILTER_SANITIZE_STRING); |
||
| 2003 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 2004 | |||
| 2005 | $query = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1"; |
||
| 2006 | $query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country); |
||
| 2007 | |||
| 2008 | $sth = $this->db->prepare($query); |
||
| 2009 | $sth->execute($query_values); |
||
| 2010 | |||
| 2011 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2012 | $sth->closeCursor(); |
||
| 2013 | if (count($row) > 0) { |
||
| 2014 | return $row['usage']; |
||
| 2015 | } else return ''; |
||
| 2016 | } |
||
| 2017 | |||
| 2018 | /** |
||
| 2019 | * Gets the airport icao from the iata |
||
| 2020 | * |
||
| 2021 | * @param String $airport_iata the iata code of the airport |
||
| 2022 | * @return String airport iata |
||
| 2023 | * |
||
| 2024 | */ |
||
| 2025 | public function getAirportIcao($airport_iata = '') |
||
| 2026 | { |
||
| 2027 | |||
| 2028 | $airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING); |
||
| 2029 | |||
| 2030 | $query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; |
||
| 2031 | $query_values = array(':airport' => $airport_iata); |
||
| 2032 | |||
| 2033 | $sth = $this->db->prepare($query); |
||
| 2034 | $sth->execute($query_values); |
||
| 2035 | |||
| 2036 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2037 | $sth->closeCursor(); |
||
| 2038 | if (count($row) > 0) { |
||
| 2039 | return $row['icao']; |
||
| 2040 | } else return ''; |
||
| 2041 | } |
||
| 2042 | |||
| 2043 | /** |
||
| 2044 | * Gets the airport distance |
||
| 2045 | * |
||
| 2046 | * @param String $airport_icao the icao code of the airport |
||
| 2047 | * @param Float $latitude the latitude |
||
| 2048 | * @param Float $longitude the longitude |
||
| 2049 | * @return Float distance to the airport |
||
| 2050 | * |
||
| 2051 | */ |
||
| 2052 | public function getAirportDistance($airport_icao,$latitude,$longitude) |
||
| 2053 | { |
||
| 2054 | |||
| 2055 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 2056 | |||
| 2057 | $query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; |
||
| 2058 | $query_values = array(':airport' => $airport_icao); |
||
| 2059 | $sth = $this->db->prepare($query); |
||
| 2060 | $sth->execute($query_values); |
||
| 2061 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2062 | $sth->closeCursor(); |
||
| 2063 | if (count($row) > 0) { |
||
| 2064 | $airport_latitude = $row['latitude']; |
||
| 2065 | $airport_longitude = $row['longitude']; |
||
| 2066 | $Common = new Common(); |
||
| 2067 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
||
| 2068 | } else return ''; |
||
| 2069 | } |
||
| 2070 | |||
| 2071 | /** |
||
| 2072 | * Gets the airport info based on the icao |
||
| 2073 | * |
||
| 2074 | * @param String $airport the icao code of the airport |
||
| 2075 | * @return Array airport information |
||
| 2076 | * |
||
| 2077 | */ |
||
| 2078 | public function getAllAirportInfo($airport = '') |
||
| 2079 | { |
||
| 2080 | |||
| 2081 | $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
||
| 2082 | |||
| 2083 | $query_values = array(); |
||
| 2084 | if ($airport == 'NA') { |
||
| 2085 | 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' => '')); |
||
| 2086 | } elseif ($airport == '') { |
||
| 2087 | $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"; |
||
| 2088 | } else { |
||
| 2089 | $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"; |
||
| 2090 | $query_values = array(':airport' => $airport); |
||
| 2091 | } |
||
| 2092 | |||
| 2093 | $sth = $this->db->prepare($query); |
||
| 2094 | $sth->execute($query_values); |
||
| 2095 | /* |
||
| 2096 | $airport_array = array(); |
||
| 2097 | $temp_array = array(); |
||
| 2098 | |||
| 2099 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2100 | { |
||
| 2101 | $temp_array['name'] = $row['name']; |
||
| 2102 | $temp_array['city'] = $row['city']; |
||
| 2103 | $temp_array['country'] = $row['country']; |
||
| 2104 | $temp_array['iata'] = $row['iata']; |
||
| 2105 | $temp_array['icao'] = $row['icao']; |
||
| 2106 | $temp_array['latitude'] = $row['latitude']; |
||
| 2107 | $temp_array['longitude'] = $row['longitude']; |
||
| 2108 | $temp_array['altitude'] = $row['altitude']; |
||
| 2109 | $temp_array['home_link'] = $row['home_link']; |
||
| 2110 | $temp_array['wikipedia_link'] = $row['wikipedia_link']; |
||
| 2111 | $temp_array['image'] = $row['image']; |
||
| 2112 | $temp_array['image_thumb'] = $row['image_thumb']; |
||
| 2113 | |||
| 2114 | $airport_array[] = $temp_array; |
||
| 2115 | } |
||
| 2116 | |||
| 2117 | return $airport_array; |
||
| 2118 | */ |
||
| 2119 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2120 | } |
||
| 2121 | |||
| 2122 | /** |
||
| 2123 | * Gets the airport info based on the country |
||
| 2124 | * |
||
| 2125 | * @param Array $countries Airports countries |
||
| 2126 | * @return Array airport information |
||
| 2127 | * |
||
| 2128 | */ |
||
| 2129 | public function getAllAirportInfobyCountry($countries) |
||
| 2130 | { |
||
| 2131 | $lst_countries = ''; |
||
| 2132 | foreach ($countries as $country) { |
||
| 2133 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 2134 | if ($lst_countries == '') { |
||
| 2135 | $lst_countries = "'".$country."'"; |
||
| 2136 | } else { |
||
| 2137 | $lst_countries .= ",'".$country."'"; |
||
| 2138 | } |
||
| 2139 | } |
||
| 2140 | $query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; |
||
| 2141 | |||
| 2142 | $sth = $this->db->prepare($query); |
||
| 2143 | $sth->execute(); |
||
| 2144 | |||
| 2145 | $airport_array = array(); |
||
| 2146 | $temp_array = array(); |
||
| 2147 | |||
| 2148 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2149 | { |
||
| 2150 | $temp_array['name'] = $row['name']; |
||
| 2151 | $temp_array['city'] = $row['city']; |
||
| 2152 | $temp_array['country'] = $row['country']; |
||
| 2153 | $temp_array['iata'] = $row['iata']; |
||
| 2154 | $temp_array['icao'] = $row['icao']; |
||
| 2155 | $temp_array['latitude'] = $row['latitude']; |
||
| 2156 | $temp_array['longitude'] = $row['longitude']; |
||
| 2157 | $temp_array['altitude'] = $row['altitude']; |
||
| 2158 | |||
| 2159 | $airport_array[] = $temp_array; |
||
| 2160 | } |
||
| 2161 | |||
| 2162 | return $airport_array; |
||
| 2163 | } |
||
| 2164 | |||
| 2165 | /** |
||
| 2166 | * Gets airports info based on the coord |
||
| 2167 | * |
||
| 2168 | * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max |
||
| 2169 | * @return Array airport information |
||
| 2170 | * |
||
| 2171 | */ |
||
| 2172 | public function getAllAirportInfobyCoord($coord) |
||
| 2173 | { |
||
| 2174 | global $globalDBdriver; |
||
| 2175 | if (is_array($coord)) { |
||
| 2176 | $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2177 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2178 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2179 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2180 | } else return array(); |
||
| 2181 | if ($globalDBdriver == 'mysql') { |
||
| 2182 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
||
| 2183 | } else { |
||
| 2184 | $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'"; |
||
| 2185 | } |
||
| 2186 | $sth = $this->db->prepare($query); |
||
| 2187 | $sth->execute(); |
||
| 2188 | |||
| 2189 | $airport_array = array(); |
||
| 2190 | |||
| 2191 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2192 | { |
||
| 2193 | $temp_array = $row; |
||
| 2194 | |||
| 2195 | $airport_array[] = $temp_array; |
||
| 2196 | } |
||
| 2197 | |||
| 2198 | return $airport_array; |
||
| 2199 | } |
||
| 2200 | |||
| 2201 | /** |
||
| 2202 | * Gets waypoints info based on the coord |
||
| 2203 | * |
||
| 2204 | * @param Array $coord waypoints coord |
||
| 2205 | * @return Array airport information |
||
| 2206 | * |
||
| 2207 | */ |
||
| 2208 | public function getAllWaypointsInfobyCoord($coord) |
||
| 2209 | { |
||
| 2210 | if (is_array($coord)) { |
||
| 2211 | $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2212 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2213 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2214 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 2215 | } else return array(); |
||
| 2216 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
||
| 2217 | $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.")"; |
||
| 2218 | //$query = "SELECT waypoints.* FROM waypoints"; |
||
| 2219 | //$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"; |
||
| 2220 | //$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; |
||
| 2221 | //$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; |
||
| 2222 | //echo $query; |
||
| 2223 | |||
| 2224 | $sth = $this->db->prepare($query); |
||
| 2225 | $sth->execute(); |
||
| 2226 | |||
| 2227 | $waypoints_array = array(); |
||
| 2228 | |||
| 2229 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2230 | { |
||
| 2231 | $temp_array = $row; |
||
| 2232 | |||
| 2233 | $waypoints_array[] = $temp_array; |
||
| 2234 | } |
||
| 2235 | |||
| 2236 | return $waypoints_array; |
||
| 2237 | } |
||
| 2238 | |||
| 2239 | |||
| 2240 | /** |
||
| 2241 | * Gets the airline info based on the icao code or iata code |
||
| 2242 | * |
||
| 2243 | * @param String $airline_icao the iata code of the airport |
||
| 2244 | * @return Array airport information |
||
| 2245 | * |
||
| 2246 | */ |
||
| 2247 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
||
| 2248 | { |
||
| 2249 | global $globalUseRealAirlines; |
||
| 2250 | if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
||
| 2251 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
||
| 2252 | if ($airline_icao == 'NA') { |
||
| 2253 | $airline_array = array(); |
||
| 2254 | $airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); |
||
| 2255 | return $airline_array; |
||
| 2256 | } else { |
||
| 2257 | if (strlen($airline_icao) == 2) { |
||
| 2258 | if ($fromsource === NULL) { |
||
| 2259 | $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"; |
||
| 2260 | } else { |
||
| 2261 | $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"; |
||
| 2262 | } |
||
| 2263 | } else { |
||
| 2264 | if ($fromsource === NULL) { |
||
| 2265 | $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"; |
||
| 2266 | } else { |
||
| 2267 | $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"; |
||
| 2268 | } |
||
| 2269 | } |
||
| 2270 | |||
| 2271 | $sth = $this->db->prepare($query); |
||
| 2272 | if ($fromsource === NULL) { |
||
| 2273 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 2274 | } else { |
||
| 2275 | $sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource)); |
||
| 2276 | } |
||
| 2277 | /* |
||
| 2278 | $airline_array = array(); |
||
| 2279 | $temp_array = array(); |
||
| 2280 | |||
| 2281 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2282 | { |
||
| 2283 | $temp_array['name'] = $row['name']; |
||
| 2284 | $temp_array['iata'] = $row['iata']; |
||
| 2285 | $temp_array['icao'] = $row['icao']; |
||
| 2286 | $temp_array['callsign'] = $row['callsign']; |
||
| 2287 | $temp_array['country'] = $row['country']; |
||
| 2288 | $temp_array['type'] = $row['type']; |
||
| 2289 | $airline_array[] = $temp_array; |
||
| 2290 | } |
||
| 2291 | return $airline_array; |
||
| 2292 | */ |
||
| 2293 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2294 | if (empty($result) && $fromsource !== NULL) { |
||
| 2295 | /* |
||
| 2296 | $query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; |
||
| 2297 | $sth = $this->db->prepare($query); |
||
| 2298 | $sth->execute(array(':fromsource' => $fromsource)); |
||
| 2299 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2300 | $sth->closeCursor(); |
||
| 2301 | if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); |
||
| 2302 | */ |
||
| 2303 | $result = $this->getAllAirlineInfo($airline_icao); |
||
| 2304 | } |
||
| 2305 | return $result; |
||
| 2306 | } |
||
| 2307 | } |
||
| 2308 | |||
| 2309 | /** |
||
| 2310 | * Gets the airline info based on the airline name |
||
| 2311 | * |
||
| 2312 | * @param String $airline_name the name of the airline |
||
| 2313 | * @return Array airline information |
||
| 2314 | * |
||
| 2315 | */ |
||
| 2316 | public function getAllAirlineInfoByName($airline_name, $fromsource = NULL) |
||
| 2317 | { |
||
| 2318 | global $globalUseRealAirlines; |
||
| 2319 | if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
||
| 2320 | $airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING)); |
||
| 2321 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
||
| 2322 | $sth = $this->db->prepare($query); |
||
| 2323 | if ($fromsource === NULL) { |
||
| 2324 | $sth->execute(array(':airline_name' => $airline_name)); |
||
| 2325 | } else { |
||
| 2326 | $sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource)); |
||
| 2327 | } |
||
| 2328 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2329 | if (empty($result) && $fromsource !== NULL) { |
||
| 2330 | $query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; |
||
| 2331 | $sth = $this->db->prepare($query); |
||
| 2332 | $sth->execute(array(':fromsource' => $fromsource)); |
||
| 2333 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2334 | $sth->closeCursor(); |
||
| 2335 | if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name); |
||
| 2336 | } |
||
| 2337 | return $result; |
||
| 2338 | } |
||
| 2339 | |||
| 2340 | |||
| 2341 | |||
| 2342 | /** |
||
| 2343 | * Gets the aircraft info based on the aircraft type |
||
| 2344 | * |
||
| 2345 | * @param String $aircraft_type the aircraft type |
||
| 2346 | * @return Array aircraft information |
||
| 2347 | * |
||
| 2348 | */ |
||
| 2349 | public function getAllAircraftInfo($aircraft_type) |
||
| 2350 | { |
||
| 2351 | $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
||
| 2352 | |||
| 2353 | if ($aircraft_type == 'NA') { |
||
| 2354 | return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); |
||
| 2355 | } |
||
| 2356 | $query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type"; |
||
| 2357 | |||
| 2358 | $sth = $this->db->prepare($query); |
||
| 2359 | $sth->execute(array(':aircraft_type' => $aircraft_type)); |
||
| 2360 | /* |
||
| 2361 | $aircraft_array = array(); |
||
| 2362 | $temp_array = array(); |
||
| 2363 | |||
| 2364 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2365 | { |
||
| 2366 | $temp_array = array(); |
||
| 2367 | $temp_array['icao'] = $row['icao']; |
||
| 2368 | $temp_array['type'] = $row['type']; |
||
| 2369 | $temp_array['manufacturer'] = $row['manufacturer']; |
||
| 2370 | $temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
||
| 2371 | |||
| 2372 | $aircraft_array[] = $temp_array; |
||
| 2373 | } |
||
| 2374 | return $aircraft_array; |
||
| 2375 | */ |
||
| 2376 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2377 | } |
||
| 2378 | |||
| 2379 | /** |
||
| 2380 | * Gets the aircraft icao based on the aircraft name/type |
||
| 2381 | * |
||
| 2382 | * @param String $aircraft_type the aircraft type |
||
| 2383 | * @return String aircraft information |
||
| 2384 | * |
||
| 2385 | */ |
||
| 2386 | public function getAircraftIcao($aircraft_type) |
||
| 2387 | { |
||
| 2388 | $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
||
| 2389 | $all_aircraft = array('737-300' => 'B733', |
||
| 2390 | '777-200' => 'B772', |
||
| 2391 | '777-200ER' => 'B772', |
||
| 2392 | '777-300ER' => 'B77W', |
||
| 2393 | 'c172p' => 'C172', |
||
| 2394 | 'aerostar' => 'AEST', |
||
| 2395 | 'A320-211' => 'A320', |
||
| 2396 | '747-8i' => 'B748', |
||
| 2397 | 'A380' => 'A388'); |
||
| 2398 | if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
||
| 2399 | |||
| 2400 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
||
| 2401 | $aircraft_type = strtoupper($aircraft_type); |
||
| 2402 | $sth = $this->db->prepare($query); |
||
| 2403 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
||
| 2404 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2405 | if (isset($result[0]['icao'])) return $result[0]['icao']; |
||
| 2406 | else return ''; |
||
| 2407 | } |
||
| 2408 | |||
| 2409 | /** |
||
| 2410 | * Gets the aircraft info based on the aircraft modes |
||
| 2411 | * |
||
| 2412 | * @param String $aircraft_modes the aircraft ident (hex) |
||
| 2413 | * @return String aircraft type |
||
| 2414 | * |
||
| 2415 | */ |
||
| 2416 | public function getAllAircraftType($aircraft_modes,$source_type = '') |
||
| 2417 | { |
||
| 2418 | $aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
||
| 2419 | $source_type = filter_var($source_type,FILTER_SANITIZE_STRING); |
||
| 2420 | |||
| 2421 | if ($source_type == '' || $source_type == 'modes') { |
||
| 2422 | $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1"; |
||
| 2423 | } else { |
||
| 2424 | $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'flarm' ORDER BY FirstCreated DESC LIMIT 1"; |
||
| 2425 | } |
||
| 2426 | |||
| 2427 | $sth = $this->db->prepare($query); |
||
| 2428 | $sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
||
| 2429 | |||
| 2430 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2431 | $sth->closeCursor(); |
||
| 2432 | if (isset($row['icaotypecode'])) { |
||
| 2433 | $icao = $row['icaotypecode']; |
||
| 2434 | if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao]; |
||
| 2435 | return $icao; |
||
| 2436 | } elseif ($source_type == 'flarm') { |
||
| 2437 | return $this->getAllAircraftType($aircraft_modes); |
||
| 2438 | } else return ''; |
||
| 2439 | } |
||
| 2440 | |||
| 2441 | /** |
||
| 2442 | * Gets the aircraft info based on the aircraft registration |
||
| 2443 | * |
||
| 2444 | * @param String $registration the aircraft registration |
||
| 2445 | * @return String aircraft type |
||
| 2446 | * |
||
| 2447 | */ |
||
| 2448 | public function getAllAircraftTypeByRegistration($registration) |
||
| 2449 | { |
||
| 2450 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2451 | |||
| 2452 | $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1"; |
||
| 2453 | |||
| 2454 | $sth = $this->db->prepare($query); |
||
| 2455 | $sth->execute(array(':registration' => $registration)); |
||
| 2456 | |||
| 2457 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2458 | $sth->closeCursor(); |
||
| 2459 | if (isset($row['icaotypecode'])) { |
||
| 2460 | return $row['icaotypecode']; |
||
| 2461 | } else return ''; |
||
| 2462 | } |
||
| 2463 | |||
| 2464 | /** |
||
| 2465 | * Gets the spotter_id and flightaware_id based on the aircraft registration |
||
| 2466 | * |
||
| 2467 | * @param String $registration the aircraft registration |
||
| 2468 | * @return Array spotter_id and flightaware_id |
||
| 2469 | * |
||
| 2470 | */ |
||
| 2471 | public function getAllIDByRegistration($registration) |
||
| 2472 | { |
||
| 2473 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2474 | |||
| 2475 | $query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration"; |
||
| 2476 | |||
| 2477 | $sth = $this->db->prepare($query); |
||
| 2478 | $sth->execute(array(':registration' => $registration)); |
||
| 2479 | |||
| 2480 | $idarray = array(); |
||
| 2481 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
||
| 2482 | $date = $row['date']; |
||
| 2483 | $idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']); |
||
| 2484 | } |
||
| 2485 | return $idarray; |
||
| 2486 | } |
||
| 2487 | |||
| 2488 | /** |
||
| 2489 | * Gets correct aircraft operator code |
||
| 2490 | * |
||
| 2491 | * @param String $operator the aircraft operator code (callsign) |
||
| 2492 | * @return String aircraft operator code |
||
| 2493 | * |
||
| 2494 | */ |
||
| 2495 | public function getOperator($operator) |
||
| 2496 | { |
||
| 2497 | $operator = filter_var($operator,FILTER_SANITIZE_STRING); |
||
| 2498 | $query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; |
||
| 2499 | |||
| 2500 | $sth = $this->db->prepare($query); |
||
| 2501 | $sth->execute(array(':operator' => $operator)); |
||
| 2502 | |||
| 2503 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2504 | $sth->closeCursor(); |
||
| 2505 | if (isset($row['operator_correct'])) { |
||
| 2506 | return $row['operator_correct']; |
||
| 2507 | } else return $operator; |
||
| 2508 | } |
||
| 2509 | |||
| 2510 | /** |
||
| 2511 | * Gets the aircraft route based on the aircraft callsign |
||
| 2512 | * |
||
| 2513 | * @param String $callsign the aircraft callsign |
||
| 2514 | * @return Array aircraft type |
||
| 2515 | * |
||
| 2516 | */ |
||
| 2517 | public function getRouteInfo($callsign) |
||
| 2518 | { |
||
| 2519 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
||
| 2520 | if ($callsign == '') return array(); |
||
| 2521 | $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"; |
||
| 2522 | |||
| 2523 | $sth = $this->db->prepare($query); |
||
| 2524 | $sth->execute(array(':callsign' => $callsign)); |
||
| 2525 | |||
| 2526 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2527 | $sth->closeCursor(); |
||
| 2528 | if (count($row) > 0) { |
||
| 2529 | return $row; |
||
| 2530 | } else return array(); |
||
| 2531 | } |
||
| 2532 | |||
| 2533 | /** |
||
| 2534 | * Gets the aircraft info based on the aircraft registration |
||
| 2535 | * |
||
| 2536 | * @param String $registration the aircraft registration |
||
| 2537 | * @return Array aircraft information |
||
| 2538 | * |
||
| 2539 | */ |
||
| 2540 | public function getAircraftInfoByRegistration($registration) |
||
| 2541 | { |
||
| 2542 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2543 | |||
| 2544 | $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"; |
||
| 2545 | |||
| 2546 | $sth = $this->db->prepare($query); |
||
| 2547 | $sth->execute(array(':registration' => $registration)); |
||
| 2548 | |||
| 2549 | $aircraft_array = array(); |
||
| 2550 | $temp_array = array(); |
||
| 2551 | |||
| 2552 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2553 | { |
||
| 2554 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 2555 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 2556 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2557 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2558 | |||
| 2559 | $aircraft_array[] = $temp_array; |
||
| 2560 | } |
||
| 2561 | |||
| 2562 | return $aircraft_array; |
||
| 2563 | } |
||
| 2564 | |||
| 2565 | /** |
||
| 2566 | * Gets the aircraft owner & base based on the aircraft registration |
||
| 2567 | * |
||
| 2568 | * @param String $registration the aircraft registration |
||
| 2569 | * @return Array aircraft information |
||
| 2570 | * |
||
| 2571 | */ |
||
| 2572 | public function getAircraftOwnerByRegistration($registration) |
||
| 2573 | { |
||
| 2574 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2575 | $Connection = new Connection($this->db); |
||
| 2576 | if ($Connection->tableExists('aircraft_owner')) { |
||
| 2577 | $query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1"; |
||
| 2578 | $sth = $this->db->prepare($query); |
||
| 2579 | $sth->execute(array(':registration' => $registration)); |
||
| 2580 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2581 | $sth->closeCursor(); |
||
| 2582 | return $result; |
||
| 2583 | } else return array(); |
||
| 2584 | } |
||
| 2585 | |||
| 2586 | |||
| 2587 | /** |
||
| 2588 | * Gets all flights (but with only little info) |
||
| 2589 | * |
||
| 2590 | * @return Array basic flight information |
||
| 2591 | * |
||
| 2592 | */ |
||
| 2593 | public function getAllFlightsforSitemap() |
||
| 2594 | { |
||
| 2595 | //$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 "; |
||
| 2596 | $query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; |
||
| 2597 | |||
| 2598 | $sth = $this->db->prepare($query); |
||
| 2599 | $sth->execute(); |
||
| 2600 | /* |
||
| 2601 | $flight_array = array(); |
||
| 2602 | $temp_array = array(); |
||
| 2603 | |||
| 2604 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2605 | { |
||
| 2606 | $temp_array['spotter_id'] = $row['spotter_id']; |
||
| 2607 | // $temp_array['ident'] = $row['ident']; |
||
| 2608 | // $temp_array['airline_name'] = $row['airline_name']; |
||
| 2609 | // $temp_array['aircraft_type'] = $row['aircraft_icao']; |
||
| 2610 | // $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2611 | //$temp_array['image'] = $row['image']; |
||
| 2612 | |||
| 2613 | $flight_array[] = $temp_array; |
||
| 2614 | } |
||
| 2615 | |||
| 2616 | return $flight_array; |
||
| 2617 | */ |
||
| 2618 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2619 | } |
||
| 2620 | |||
| 2621 | /** |
||
| 2622 | * Gets a list of all aircraft manufacturers |
||
| 2623 | * |
||
| 2624 | * @return Array list of aircraft types |
||
| 2625 | * |
||
| 2626 | */ |
||
| 2627 | public function getAllManufacturers() |
||
| 2628 | { |
||
| 2629 | /* |
||
| 2630 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer AS aircraft_manufacturer |
||
| 2631 | FROM spotter_output |
||
| 2632 | WHERE spotter_output.aircraft_manufacturer <> '' |
||
| 2633 | ORDER BY spotter_output.aircraft_manufacturer ASC"; |
||
| 2634 | */ |
||
| 2635 | |||
| 2636 | $query = "SELECT DISTINCT manufacturer AS aircraft_manufacturer FROM aircraft WHERE manufacturer <> '' ORDER BY manufacturer ASC"; |
||
| 2637 | $sth = $this->db->prepare($query); |
||
| 2638 | $sth->execute(); |
||
| 2639 | |||
| 2640 | $manufacturer_array = array(); |
||
| 2641 | $temp_array = array(); |
||
| 2642 | |||
| 2643 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2644 | { |
||
| 2645 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2646 | |||
| 2647 | $manufacturer_array[] = $temp_array; |
||
| 2648 | } |
||
| 2649 | |||
| 2650 | return $manufacturer_array; |
||
| 2651 | } |
||
| 2652 | |||
| 2653 | |||
| 2654 | /** |
||
| 2655 | * Gets a list of all aircraft types |
||
| 2656 | * |
||
| 2657 | * @return Array list of aircraft types |
||
| 2658 | * |
||
| 2659 | */ |
||
| 2660 | public function getAllAircraftTypes($filters = array()) |
||
|
|
|||
| 2661 | { |
||
| 2662 | /* |
||
| 2663 | $query = "SELECT DISTINCT spotter_output.aircraft_icao AS aircraft_icao, spotter_output.aircraft_name AS aircraft_name |
||
| 2664 | FROM spotter_output |
||
| 2665 | WHERE spotter_output.aircraft_icao <> '' |
||
| 2666 | ORDER BY spotter_output.aircraft_name ASC"; |
||
| 2667 | |||
| 2668 | */ |
||
| 2669 | //$filter_query = $this->getFilter($filters,true,true); |
||
| 2670 | //$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"; |
||
| 2671 | |||
| 2672 | $query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft WHERE icao <> '' ORDER BY aircraft_manufacturer ASC"; |
||
| 2673 | |||
| 2674 | $sth = $this->db->prepare($query); |
||
| 2675 | $sth->execute(); |
||
| 2676 | |||
| 2677 | $aircraft_array = array(); |
||
| 2678 | $temp_array = array(); |
||
| 2679 | |||
| 2680 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2681 | { |
||
| 2682 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 2683 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2684 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2685 | |||
| 2686 | $aircraft_array[] = $temp_array; |
||
| 2687 | } |
||
| 2688 | |||
| 2689 | return $aircraft_array; |
||
| 2690 | } |
||
| 2691 | |||
| 2692 | |||
| 2693 | /** |
||
| 2694 | * Gets a list of all aircraft registrations |
||
| 2695 | * |
||
| 2696 | * @return Array list of aircraft registrations |
||
| 2697 | * |
||
| 2698 | */ |
||
| 2699 | public function getAllAircraftRegistrations($filters = array()) |
||
| 2700 | { |
||
| 2701 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2702 | $query = "SELECT DISTINCT spotter_output.registration |
||
| 2703 | FROM spotter_output".$filter_query." spotter_output.registration <> '' |
||
| 2704 | ORDER BY spotter_output.registration ASC"; |
||
| 2705 | |||
| 2706 | $sth = $this->db->prepare($query); |
||
| 2707 | $sth->execute(); |
||
| 2708 | |||
| 2709 | $aircraft_array = array(); |
||
| 2710 | $temp_array = array(); |
||
| 2711 | |||
| 2712 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2713 | { |
||
| 2714 | $temp_array['registration'] = $row['registration']; |
||
| 2715 | |||
| 2716 | $aircraft_array[] = $temp_array; |
||
| 2717 | } |
||
| 2718 | |||
| 2719 | return $aircraft_array; |
||
| 2720 | } |
||
| 2721 | |||
| 2722 | /** |
||
| 2723 | * Gets all source name |
||
| 2724 | * |
||
| 2725 | * @param String type format of source |
||
| 2726 | * @return Array list of source name |
||
| 2727 | * |
||
| 2728 | */ |
||
| 2729 | public function getAllSourceName($type = '',$filters = array()) |
||
| 2730 | { |
||
| 2731 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2732 | $query_values = array(); |
||
| 2733 | $query = "SELECT DISTINCT spotter_output.source_name |
||
| 2734 | FROM spotter_output".$filter_query." spotter_output.source_name <> ''"; |
||
| 2735 | if ($type != '') { |
||
| 2736 | $query_values = array(':type' => $type); |
||
| 2737 | $query .= " AND format_source = :type"; |
||
| 2738 | } |
||
| 2739 | $query .= " ORDER BY spotter_output.source_name ASC"; |
||
| 2740 | |||
| 2741 | $sth = $this->db->prepare($query); |
||
| 2742 | if (!empty($query_values)) $sth->execute($query_values); |
||
| 2743 | else $sth->execute(); |
||
| 2744 | |||
| 2745 | $source_array = array(); |
||
| 2746 | $temp_array = array(); |
||
| 2747 | |||
| 2748 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2749 | { |
||
| 2750 | $temp_array['source_name'] = $row['source_name']; |
||
| 2751 | $source_array[] = $temp_array; |
||
| 2752 | } |
||
| 2753 | return $source_array; |
||
| 2754 | } |
||
| 2755 | |||
| 2756 | |||
| 2757 | |||
| 2758 | /** |
||
| 2759 | * Gets a list of all airline names |
||
| 2760 | * |
||
| 2761 | * @return Array list of airline names |
||
| 2762 | * |
||
| 2763 | */ |
||
| 2764 | public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array()) |
||
| 2765 | { |
||
| 2766 | global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
||
| 2767 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2768 | $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
||
| 2769 | if ($airline_type == '' || $airline_type == 'all') { |
||
| 2770 | /* |
||
| 2771 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
||
| 2772 | FROM spotter_output |
||
| 2773 | WHERE spotter_output.airline_icao <> '' |
||
| 2774 | ORDER BY spotter_output.airline_name ASC"; |
||
| 2775 | */ |
||
| 2776 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
||
| 2777 | elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
||
| 2778 | elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
||
| 2779 | if ($forsource === NULL) { |
||
| 2780 | $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"; |
||
| 2781 | $query_data = array(); |
||
| 2782 | } else { |
||
| 2783 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource = :forsource ORDER BY name ASC"; |
||
| 2784 | $query_data = array(':forsource' => $forsource); |
||
| 2785 | } |
||
| 2786 | } else { |
||
| 2787 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
||
| 2788 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
||
| 2789 | AND spotter_output.airline_type = :airline_type |
||
| 2790 | ORDER BY spotter_output.airline_icao ASC"; |
||
| 2791 | $query_data = array(':airline_type' => $airline_type); |
||
| 2792 | } |
||
| 2793 | |||
| 2794 | $sth = $this->db->prepare($query); |
||
| 2795 | $sth->execute($query_data); |
||
| 2796 | |||
| 2797 | $airline_array = array(); |
||
| 2798 | $temp_array = array(); |
||
| 2799 | |||
| 2800 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2801 | { |
||
| 2802 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 2803 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 2804 | $temp_array['airline_type'] = $row['airline_type']; |
||
| 2805 | |||
| 2806 | $airline_array[] = $temp_array; |
||
| 2807 | } |
||
| 2808 | return $airline_array; |
||
| 2809 | } |
||
| 2810 | |||
| 2811 | /** |
||
| 2812 | * Gets a list of all alliance names |
||
| 2813 | * |
||
| 2814 | * @return Array list of alliance names |
||
| 2815 | * |
||
| 2816 | */ |
||
| 2817 | public function getAllAllianceNames($forsource = NULL,$filters = array()) |
||
| 2818 | { |
||
| 2819 | global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
||
| 2820 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2821 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
||
| 2822 | elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
||
| 2823 | elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
||
| 2824 | if ($forsource === NULL) { |
||
| 2825 | $query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC"; |
||
| 2826 | $query_data = array(); |
||
| 2827 | } else { |
||
| 2828 | $query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource = :forsource ORDER BY alliance ASC"; |
||
| 2829 | $query_data = array(':forsource' => $forsource); |
||
| 2830 | } |
||
| 2831 | |||
| 2832 | $sth = $this->db->prepare($query); |
||
| 2833 | $sth->execute($query_data); |
||
| 2834 | |||
| 2835 | $alliance_array = array(); |
||
| 2836 | $alliance_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2837 | return $alliance_array; |
||
| 2838 | } |
||
| 2839 | |||
| 2840 | /** |
||
| 2841 | * Gets a list of all airline countries |
||
| 2842 | * |
||
| 2843 | * @return Array list of airline countries |
||
| 2844 | * |
||
| 2845 | */ |
||
| 2846 | public function getAllAirlineCountries($filters = array()) |
||
| 2847 | { |
||
| 2848 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2849 | $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
||
| 2850 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
||
| 2851 | ORDER BY spotter_output.airline_country ASC"; |
||
| 2852 | |||
| 2853 | //$query = "SELECT DISTINCT country AS airline_country FROM airlines WHERE country <> '' AND active = 'Y' ORDER BY country ASC"; |
||
| 2854 | $sth = $this->db->prepare($query); |
||
| 2855 | $sth->execute(); |
||
| 2856 | |||
| 2857 | $airline_array = array(); |
||
| 2858 | $temp_array = array(); |
||
| 2859 | |||
| 2860 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2861 | { |
||
| 2862 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 2863 | |||
| 2864 | $airline_array[] = $temp_array; |
||
| 2865 | } |
||
| 2866 | |||
| 2867 | return $airline_array; |
||
| 2868 | } |
||
| 2869 | |||
| 2870 | |||
| 2871 | |||
| 2872 | /** |
||
| 2873 | * Gets a list of all departure & arrival names |
||
| 2874 | * |
||
| 2875 | * @return Array list of airport names |
||
| 2876 | * |
||
| 2877 | */ |
||
| 2878 | public function getAllAirportNames($filters = array()) |
||
| 2879 | { |
||
| 2880 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2881 | $airport_array = array(); |
||
| 2882 | $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 |
||
| 2883 | FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' |
||
| 2884 | ORDER BY spotter_output.departure_airport_city ASC"; |
||
| 2885 | |||
| 2886 | //$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"; |
||
| 2887 | $sth = $this->db->prepare($query); |
||
| 2888 | $sth->execute(); |
||
| 2889 | |||
| 2890 | $temp_array = array(); |
||
| 2891 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2892 | { |
||
| 2893 | $temp_array['airport_icao'] = $row['airport_icao']; |
||
| 2894 | $temp_array['airport_name'] = $row['airport_name']; |
||
| 2895 | $temp_array['airport_city'] = $row['airport_city']; |
||
| 2896 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2897 | |||
| 2898 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
||
| 2899 | } |
||
| 2900 | |||
| 2901 | $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 |
||
| 2902 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' |
||
| 2903 | ORDER BY spotter_output.arrival_airport_city ASC"; |
||
| 2904 | |||
| 2905 | $sth = $this->db->prepare($query); |
||
| 2906 | $sth->execute(); |
||
| 2907 | |||
| 2908 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2909 | { |
||
| 2910 | // if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao']) |
||
| 2911 | // { |
||
| 2912 | $temp_array['airport_icao'] = $row['airport_icao']; |
||
| 2913 | $temp_array['airport_name'] = $row['airport_name']; |
||
| 2914 | $temp_array['airport_city'] = $row['airport_city']; |
||
| 2915 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2916 | |||
| 2917 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
||
| 2918 | // } |
||
| 2919 | } |
||
| 2920 | |||
| 2921 | return $airport_array; |
||
| 2922 | } |
||
| 2923 | |||
| 2924 | /** |
||
| 2925 | * Gets a list of all owner names |
||
| 2926 | * |
||
| 2927 | * @return Array list of owner names |
||
| 2928 | * |
||
| 2929 | */ |
||
| 2930 | public function getAllOwnerNames($filters = array()) |
||
| 2931 | { |
||
| 2932 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2933 | $query = "SELECT DISTINCT spotter_output.owner_name |
||
| 2934 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' |
||
| 2935 | ORDER BY spotter_output.owner_name ASC"; |
||
| 2936 | |||
| 2937 | $sth = $this->db->prepare($query); |
||
| 2938 | $sth->execute(); |
||
| 2939 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2940 | } |
||
| 2941 | |||
| 2942 | /** |
||
| 2943 | * Gets a list of all pilot names and pilot ids |
||
| 2944 | * |
||
| 2945 | * @return Array list of pilot names and pilot ids |
||
| 2946 | * |
||
| 2947 | */ |
||
| 2948 | public function getAllPilotNames($filters = array()) |
||
| 2949 | { |
||
| 2950 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2951 | $query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id |
||
| 2952 | FROM spotter_output".$filter_query." spotter_output.pilot_name <> '' |
||
| 2953 | ORDER BY spotter_output.pilot_name ASC"; |
||
| 2954 | |||
| 2955 | $sth = $this->db->prepare($query); |
||
| 2956 | $sth->execute(); |
||
| 2957 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2958 | } |
||
| 2959 | |||
| 2960 | |||
| 2961 | /** |
||
| 2962 | * Gets a list of all departure & arrival airport countries |
||
| 2963 | * |
||
| 2964 | * @return Array list of airport countries |
||
| 2965 | * |
||
| 2966 | */ |
||
| 2967 | public function getAllAirportCountries($filters = array()) |
||
| 2968 | { |
||
| 2969 | $airport_array = array(); |
||
| 2970 | |||
| 2971 | /* |
||
| 2972 | $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
||
| 2973 | FROM spotter_output |
||
| 2974 | WHERE spotter_output.departure_airport_country <> '' |
||
| 2975 | ORDER BY spotter_output.departure_airport_country ASC"; |
||
| 2976 | */ |
||
| 2977 | $query = "SELECT DISTINCT country AS airport_country FROM airport ORDER BY country ASC"; |
||
| 2978 | |||
| 2979 | $sth = $this->db->prepare($query); |
||
| 2980 | $sth->execute(); |
||
| 2981 | |||
| 2982 | $temp_array = array(); |
||
| 2983 | |||
| 2984 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2985 | { |
||
| 2986 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2987 | |||
| 2988 | $airport_array[$row['airport_country']] = $temp_array; |
||
| 2989 | } |
||
| 2990 | $filter_query = $this->getFilter($filters,true,true); |
||
| 2991 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
||
| 2992 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
||
| 2993 | ORDER BY spotter_output.arrival_airport_country ASC"; |
||
| 2994 | |||
| 2995 | $sth = $this->db->prepare($query); |
||
| 2996 | $sth->execute(); |
||
| 2997 | |||
| 2998 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2999 | { |
||
| 3000 | if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country']) |
||
| 3001 | { |
||
| 3002 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 3003 | $airport_array[$row['airport_country']] = $temp_array; |
||
| 3004 | } |
||
| 3005 | } |
||
| 3006 | |||
| 3007 | return $airport_array; |
||
| 3008 | } |
||
| 3009 | |||
| 3010 | |||
| 3011 | |||
| 3012 | |||
| 3013 | /** |
||
| 3014 | * Gets a list of all countries (airline, departure airport & arrival airport) |
||
| 3015 | * |
||
| 3016 | * @return Array list of countries |
||
| 3017 | * |
||
| 3018 | */ |
||
| 3019 | public function getAllCountries($filters = array()) |
||
| 3020 | { |
||
| 3021 | $Connection= new Connection($this->db); |
||
| 3022 | if ($Connection->tableExists('countries')) { |
||
| 3023 | $query = "SELECT countries.name AS airport_country |
||
| 3024 | FROM countries |
||
| 3025 | ORDER BY countries.name ASC"; |
||
| 3026 | $sth = $this->db->prepare($query); |
||
| 3027 | $sth->execute(); |
||
| 3028 | |||
| 3029 | $temp_array = array(); |
||
| 3030 | $country_array = array(); |
||
| 3031 | |||
| 3032 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3033 | { |
||
| 3034 | $temp_array['country'] = $row['airport_country']; |
||
| 3035 | $country_array[$row['airport_country']] = $temp_array; |
||
| 3036 | } |
||
| 3037 | } else { |
||
| 3038 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3039 | $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
||
| 3040 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' |
||
| 3041 | ORDER BY spotter_output.departure_airport_country ASC"; |
||
| 3042 | |||
| 3043 | $sth = $this->db->prepare($query); |
||
| 3044 | $sth->execute(); |
||
| 3045 | |||
| 3046 | $temp_array = array(); |
||
| 3047 | $country_array = array(); |
||
| 3048 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3049 | { |
||
| 3050 | $temp_array['country'] = $row['airport_country']; |
||
| 3051 | $country_array[$row['airport_country']] = $temp_array; |
||
| 3052 | } |
||
| 3053 | |||
| 3054 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
||
| 3055 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
||
| 3056 | ORDER BY spotter_output.arrival_airport_country ASC"; |
||
| 3057 | |||
| 3058 | $sth = $this->db->prepare($query); |
||
| 3059 | $sth->execute(); |
||
| 3060 | |||
| 3061 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3062 | { |
||
| 3063 | if ($country_array[$row['airport_country']]['country'] != $row['airport_country']) |
||
| 3064 | { |
||
| 3065 | $temp_array['country'] = $row['airport_country']; |
||
| 3066 | |||
| 3067 | $country_array[$row['country']] = $temp_array; |
||
| 3068 | } |
||
| 3069 | } |
||
| 3070 | |||
| 3071 | $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
||
| 3072 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
||
| 3073 | ORDER BY spotter_output.airline_country ASC"; |
||
| 3074 | |||
| 3075 | $sth = $this->db->prepare($query); |
||
| 3076 | $sth->execute(); |
||
| 3077 | |||
| 3078 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3079 | { |
||
| 3080 | if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country']) |
||
| 3081 | { |
||
| 3082 | $temp_array['country'] = $row['airline_country']; |
||
| 3083 | |||
| 3084 | $country_array[$row['country']] = $temp_array; |
||
| 3085 | } |
||
| 3086 | } |
||
| 3087 | } |
||
| 3088 | return $country_array; |
||
| 3089 | } |
||
| 3090 | |||
| 3091 | |||
| 3092 | |||
| 3093 | |||
| 3094 | /** |
||
| 3095 | * Gets a list of all idents/callsigns |
||
| 3096 | * |
||
| 3097 | * @return Array list of ident/callsign names |
||
| 3098 | * |
||
| 3099 | */ |
||
| 3100 | public function getAllIdents($filters = array()) |
||
| 3101 | { |
||
| 3102 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3103 | $query = "SELECT DISTINCT spotter_output.ident |
||
| 3104 | FROM spotter_output".$filter_query." spotter_output.ident <> '' |
||
| 3105 | ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0"; |
||
| 3106 | |||
| 3107 | $sth = $this->db->prepare($query); |
||
| 3108 | $sth->execute(); |
||
| 3109 | |||
| 3110 | $ident_array = array(); |
||
| 3111 | $temp_array = array(); |
||
| 3112 | |||
| 3113 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3114 | { |
||
| 3115 | $temp_array['ident'] = $row['ident']; |
||
| 3116 | $ident_array[] = $temp_array; |
||
| 3117 | } |
||
| 3118 | |||
| 3119 | return $ident_array; |
||
| 3120 | } |
||
| 3121 | |||
| 3122 | /** |
||
| 3123 | * Get a list of flights from airport since 7 days |
||
| 3124 | * @return Array number, icao, name and city of airports |
||
| 3125 | */ |
||
| 3126 | |||
| 3127 | public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) { |
||
| 3128 | global $globalTimezone, $globalDBdriver; |
||
| 3129 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3130 | if ($globalTimezone != '') { |
||
| 3131 | date_default_timezone_set($globalTimezone); |
||
| 3132 | $datetime = new DateTime(); |
||
| 3133 | $offset = $datetime->format('P'); |
||
| 3134 | } else $offset = '+00:00'; |
||
| 3135 | if ($airport_icao == '') { |
||
| 3136 | if ($globalDBdriver == 'mysql') { |
||
| 3137 | $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' AND departure_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"; |
||
| 3138 | } else { |
||
| 3139 | $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' AND departure_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"; |
||
| 3140 | } |
||
| 3141 | $sth = $this->db->prepare($query); |
||
| 3142 | $sth->execute(array(':offset' => $offset)); |
||
| 3143 | } else { |
||
| 3144 | if ($globalDBdriver == 'mysql') { |
||
| 3145 | $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"; |
||
| 3146 | } else { |
||
| 3147 | $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"; |
||
| 3148 | } |
||
| 3149 | $sth = $this->db->prepare($query); |
||
| 3150 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3151 | } |
||
| 3152 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3153 | } |
||
| 3154 | |||
| 3155 | /** |
||
| 3156 | * Get a list of flights from airport since 7 days |
||
| 3157 | * @return Array number, icao, name and city of airports |
||
| 3158 | */ |
||
| 3159 | |||
| 3160 | public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') { |
||
| 3161 | global $globalTimezone, $globalDBdriver; |
||
| 3162 | if ($globalTimezone != '') { |
||
| 3163 | date_default_timezone_set($globalTimezone); |
||
| 3164 | $datetime = new DateTime(); |
||
| 3165 | $offset = $datetime->format('P'); |
||
| 3166 | } else $offset = '+00:00'; |
||
| 3167 | if ($airport_icao == '') { |
||
| 3168 | if ($globalDBdriver == 'mysql') { |
||
| 3169 | $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 departure_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"; |
||
| 3170 | } else { |
||
| 3171 | $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 departure_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"; |
||
| 3172 | } |
||
| 3173 | $sth = $this->db->prepare($query); |
||
| 3174 | $sth->execute(array(':offset' => $offset)); |
||
| 3175 | } else { |
||
| 3176 | if ($globalDBdriver == 'mysql') { |
||
| 3177 | $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"; |
||
| 3178 | } else { |
||
| 3179 | $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"; |
||
| 3180 | } |
||
| 3181 | $sth = $this->db->prepare($query); |
||
| 3182 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3183 | } |
||
| 3184 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3185 | } |
||
| 3186 | |||
| 3187 | /** |
||
| 3188 | * Get a list of flights from detected airport since 7 days |
||
| 3189 | * @return Array number, icao, name and city of airports |
||
| 3190 | */ |
||
| 3191 | |||
| 3192 | public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) { |
||
| 3193 | global $globalTimezone, $globalDBdriver; |
||
| 3194 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3195 | if ($globalTimezone != '') { |
||
| 3196 | date_default_timezone_set($globalTimezone); |
||
| 3197 | $datetime = new DateTime(); |
||
| 3198 | $offset = $datetime->format('P'); |
||
| 3199 | } else $offset = '+00:00'; |
||
| 3200 | if ($airport_icao == '') { |
||
| 3201 | if ($globalDBdriver == 'mysql') { |
||
| 3202 | $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 |
||
| 3203 | 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' AND real_departure_airport_icao <> '' |
||
| 3204 | 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"; |
||
| 3205 | } else { |
||
| 3206 | $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 |
||
| 3207 | 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' AND real_departure_airport_icao <> '' |
||
| 3208 | 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"; |
||
| 3209 | } |
||
| 3210 | $sth = $this->db->prepare($query); |
||
| 3211 | $sth->execute(array(':offset' => $offset)); |
||
| 3212 | } else { |
||
| 3213 | if ($globalDBdriver == 'mysql') { |
||
| 3214 | $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 |
||
| 3215 | 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 |
||
| 3216 | 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"; |
||
| 3217 | } else { |
||
| 3218 | $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 |
||
| 3219 | 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"; |
||
| 3220 | } |
||
| 3221 | $sth = $this->db->prepare($query); |
||
| 3222 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3223 | } |
||
| 3224 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3225 | } |
||
| 3226 | |||
| 3227 | /** |
||
| 3228 | * Get a list of flights from detected airport since 7 days |
||
| 3229 | * @return Array number, icao, name and city of airports |
||
| 3230 | */ |
||
| 3231 | |||
| 3232 | public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') { |
||
| 3233 | global $globalTimezone, $globalDBdriver; |
||
| 3234 | if ($globalTimezone != '') { |
||
| 3235 | date_default_timezone_set($globalTimezone); |
||
| 3236 | $datetime = new DateTime(); |
||
| 3237 | $offset = $datetime->format('P'); |
||
| 3238 | } else $offset = '+00:00'; |
||
| 3239 | if ($airport_icao == '') { |
||
| 3240 | if ($globalDBdriver == 'mysql') { |
||
| 3241 | $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 |
||
| 3242 | FROM `spotter_output`, airport |
||
| 3243 | 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' AND real_departure_airport_icao <> '' |
||
| 3244 | 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"; |
||
| 3245 | } else { |
||
| 3246 | $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 |
||
| 3247 | FROM spotter_output, airport |
||
| 3248 | 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' AND real_departure_airport_icao <> '' |
||
| 3249 | 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"; |
||
| 3250 | } |
||
| 3251 | $sth = $this->db->prepare($query); |
||
| 3252 | $sth->execute(array(':offset' => $offset)); |
||
| 3253 | } else { |
||
| 3254 | if ($globalDBdriver == 'mysql') { |
||
| 3255 | $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 |
||
| 3256 | FROM `spotter_output`, airport |
||
| 3257 | 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 |
||
| 3258 | 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"; |
||
| 3259 | } else { |
||
| 3260 | $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 |
||
| 3261 | FROM spotter_output, airport |
||
| 3262 | 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"; |
||
| 3263 | } |
||
| 3264 | $sth = $this->db->prepare($query); |
||
| 3265 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3266 | } |
||
| 3267 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3268 | } |
||
| 3269 | |||
| 3270 | |||
| 3271 | /** |
||
| 3272 | * Get a list of flights to airport since 7 days |
||
| 3273 | * @return Array number, icao, name and city of airports |
||
| 3274 | */ |
||
| 3275 | |||
| 3276 | public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) { |
||
| 3277 | global $globalTimezone, $globalDBdriver; |
||
| 3278 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3279 | if ($globalTimezone != '') { |
||
| 3280 | date_default_timezone_set($globalTimezone); |
||
| 3281 | $datetime = new DateTime(); |
||
| 3282 | $offset = $datetime->format('P'); |
||
| 3283 | } else $offset = '+00:00'; |
||
| 3284 | if ($airport_icao == '') { |
||
| 3285 | if ($globalDBdriver == 'mysql') { |
||
| 3286 | $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' AND arrival_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"; |
||
| 3287 | } else { |
||
| 3288 | $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' AND arrival_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"; |
||
| 3289 | } |
||
| 3290 | $sth = $this->db->prepare($query); |
||
| 3291 | $sth->execute(array(':offset' => $offset)); |
||
| 3292 | } else { |
||
| 3293 | if ($globalDBdriver == 'mysql') { |
||
| 3294 | $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"; |
||
| 3295 | } else { |
||
| 3296 | $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"; |
||
| 3297 | } |
||
| 3298 | $sth = $this->db->prepare($query); |
||
| 3299 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3300 | } |
||
| 3301 | |||
| 3302 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3303 | } |
||
| 3304 | |||
| 3305 | |||
| 3306 | /** |
||
| 3307 | * Get a list of flights detected to airport since 7 days |
||
| 3308 | * @return Array number, icao, name and city of airports |
||
| 3309 | */ |
||
| 3310 | |||
| 3311 | public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) { |
||
| 3312 | global $globalTimezone, $globalDBdriver; |
||
| 3313 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3314 | if ($globalTimezone != '') { |
||
| 3315 | date_default_timezone_set($globalTimezone); |
||
| 3316 | $datetime = new DateTime(); |
||
| 3317 | $offset = $datetime->format('P'); |
||
| 3318 | } else $offset = '+00:00'; |
||
| 3319 | if ($airport_icao == '') { |
||
| 3320 | if ($globalDBdriver == 'mysql') { |
||
| 3321 | $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 |
||
| 3322 | 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' AND arrival_airport_icao <> '' |
||
| 3323 | 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"; |
||
| 3324 | } else { |
||
| 3325 | $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 |
||
| 3326 | 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' AND arrival_airport_icao <> '' |
||
| 3327 | 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"; |
||
| 3328 | } |
||
| 3329 | $sth = $this->db->prepare($query); |
||
| 3330 | $sth->execute(array(':offset' => $offset)); |
||
| 3331 | } else { |
||
| 3332 | if ($globalDBdriver == 'mysql') { |
||
| 3333 | $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 |
||
| 3334 | 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 |
||
| 3335 | 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"; |
||
| 3336 | } else { |
||
| 3337 | $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 |
||
| 3338 | 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 |
||
| 3339 | 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"; |
||
| 3340 | } |
||
| 3341 | $sth = $this->db->prepare($query); |
||
| 3342 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3343 | } |
||
| 3344 | |||
| 3345 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3346 | } |
||
| 3347 | |||
| 3348 | |||
| 3349 | /** |
||
| 3350 | * Get a list of flights to airport since 7 days |
||
| 3351 | * @return Array number, icao, name and city of airports |
||
| 3352 | */ |
||
| 3353 | |||
| 3354 | public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') { |
||
| 3355 | global $globalTimezone, $globalDBdriver; |
||
| 3356 | if ($globalTimezone != '') { |
||
| 3357 | date_default_timezone_set($globalTimezone); |
||
| 3358 | $datetime = new DateTime(); |
||
| 3359 | $offset = $datetime->format('P'); |
||
| 3360 | } else $offset = '+00:00'; |
||
| 3361 | if ($airport_icao == '') { |
||
| 3362 | if ($globalDBdriver == 'mysql') { |
||
| 3363 | $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 arrival_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"; |
||
| 3364 | } else { |
||
| 3365 | $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 arrival_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"; |
||
| 3366 | } |
||
| 3367 | $sth = $this->db->prepare($query); |
||
| 3368 | $sth->execute(array(':offset' => $offset)); |
||
| 3369 | } else { |
||
| 3370 | if ($globalDBdriver == 'mysql') { |
||
| 3371 | $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"; |
||
| 3372 | } else { |
||
| 3373 | $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"; |
||
| 3374 | } |
||
| 3375 | $sth = $this->db->prepare($query); |
||
| 3376 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3377 | } |
||
| 3378 | |||
| 3379 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3380 | } |
||
| 3381 | |||
| 3382 | |||
| 3383 | /** |
||
| 3384 | * Get a list of flights detected to airport since 7 days |
||
| 3385 | * @return Array number, icao, name and city of airports |
||
| 3386 | */ |
||
| 3387 | |||
| 3388 | public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') { |
||
| 3389 | global $globalTimezone, $globalDBdriver; |
||
| 3390 | if ($globalTimezone != '') { |
||
| 3391 | date_default_timezone_set($globalTimezone); |
||
| 3392 | $datetime = new DateTime(); |
||
| 3393 | $offset = $datetime->format('P'); |
||
| 3394 | } else $offset = '+00:00'; |
||
| 3395 | if ($airport_icao == '') { |
||
| 3396 | if ($globalDBdriver == 'mysql') { |
||
| 3397 | $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 |
||
| 3398 | FROM `spotter_output`, airport |
||
| 3399 | 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' AND arrival_airport_icao <> '' |
||
| 3400 | 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"; |
||
| 3401 | } else { |
||
| 3402 | $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 |
||
| 3403 | FROM spotter_output, airport |
||
| 3404 | 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' AND arrival_airport_icao <> '' |
||
| 3405 | 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"; |
||
| 3406 | } |
||
| 3407 | $sth = $this->db->prepare($query); |
||
| 3408 | $sth->execute(array(':offset' => $offset)); |
||
| 3409 | } else { |
||
| 3410 | if ($globalDBdriver == 'mysql') { |
||
| 3411 | $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 |
||
| 3412 | FROM `spotter_output`, airport |
||
| 3413 | 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 |
||
| 3414 | 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"; |
||
| 3415 | } else { |
||
| 3416 | $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 |
||
| 3417 | FROM spotter_output, airport |
||
| 3418 | 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 |
||
| 3419 | 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"; |
||
| 3420 | } |
||
| 3421 | $sth = $this->db->prepare($query); |
||
| 3422 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3423 | } |
||
| 3424 | |||
| 3425 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3426 | } |
||
| 3427 | |||
| 3428 | |||
| 3429 | /** |
||
| 3430 | * Gets a list of all dates |
||
| 3431 | * |
||
| 3432 | * @return Array list of date names |
||
| 3433 | * |
||
| 3434 | */ |
||
| 3435 | public function getAllDates() |
||
| 3436 | { |
||
| 3437 | global $globalTimezone, $globalDBdriver; |
||
| 3438 | if ($globalTimezone != '') { |
||
| 3439 | date_default_timezone_set($globalTimezone); |
||
| 3440 | $datetime = new DateTime(); |
||
| 3441 | $offset = $datetime->format('P'); |
||
| 3442 | } else $offset = '+00:00'; |
||
| 3443 | |||
| 3444 | if ($globalDBdriver == 'mysql') { |
||
| 3445 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
||
| 3446 | FROM spotter_output |
||
| 3447 | WHERE spotter_output.date <> '' |
||
| 3448 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
||
| 3449 | } else { |
||
| 3450 | $query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 3451 | FROM spotter_output |
||
| 3452 | WHERE spotter_output.date <> '' |
||
| 3453 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
||
| 3454 | } |
||
| 3455 | |||
| 3456 | $sth = $this->db->prepare($query); |
||
| 3457 | $sth->execute(array(':offset' => $offset)); |
||
| 3458 | |||
| 3459 | $date_array = array(); |
||
| 3460 | $temp_array = array(); |
||
| 3461 | |||
| 3462 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3463 | { |
||
| 3464 | $temp_array['date'] = $row['date']; |
||
| 3465 | |||
| 3466 | $date_array[] = $temp_array; |
||
| 3467 | } |
||
| 3468 | |||
| 3469 | return $date_array; |
||
| 3470 | } |
||
| 3471 | |||
| 3472 | |||
| 3473 | |||
| 3474 | /** |
||
| 3475 | * Gets all route combinations |
||
| 3476 | * |
||
| 3477 | * @return Array the route list |
||
| 3478 | * |
||
| 3479 | */ |
||
| 3480 | public function getAllRoutes() |
||
| 3481 | { |
||
| 3482 | $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 |
||
| 3483 | FROM spotter_output |
||
| 3484 | WHERE spotter_output.ident <> '' |
||
| 3485 | GROUP BY route |
||
| 3486 | ORDER BY route ASC"; |
||
| 3487 | |||
| 3488 | $sth = $this->db->prepare($query); |
||
| 3489 | $sth->execute(); |
||
| 3490 | |||
| 3491 | $routes_array = array(); |
||
| 3492 | $temp_array = array(); |
||
| 3493 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3494 | { |
||
| 3495 | $temp_array['route'] = $row['route']; |
||
| 3496 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 3497 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 3498 | |||
| 3499 | $routes_array[] = $temp_array; |
||
| 3500 | } |
||
| 3501 | return $routes_array; |
||
| 3502 | } |
||
| 3503 | |||
| 3504 | /** |
||
| 3505 | * Update ident spotter data |
||
| 3506 | * |
||
| 3507 | * @param String $flightaware_id the ID from flightaware |
||
| 3508 | * @param String $ident the flight ident |
||
| 3509 | * @return String success or false |
||
| 3510 | * |
||
| 3511 | */ |
||
| 3512 | public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL) |
||
| 3513 | { |
||
| 3514 | if (!is_numeric(substr($ident, 0, 3))) |
||
| 3515 | { |
||
| 3516 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
| 3517 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
||
| 3518 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
| 3519 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
||
| 3520 | } else { |
||
| 3521 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3522 | } |
||
| 3523 | if (count($airline_array) == 0) { |
||
| 3524 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3525 | } |
||
| 3526 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
||
| 3527 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3528 | } |
||
| 3529 | } else { |
||
| 3530 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3531 | } |
||
| 3532 | $airline_name = $airline_array[0]['name']; |
||
| 3533 | $airline_icao = $airline_array[0]['icao']; |
||
| 3534 | $airline_country = $airline_array[0]['country']; |
||
| 3535 | $airline_type = $airline_array[0]['type']; |
||
| 3536 | |||
| 3537 | |||
| 3538 | $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'; |
||
| 3539 | $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); |
||
| 3540 | |||
| 3541 | try { |
||
| 3542 | $sth = $this->db->prepare($query); |
||
| 3543 | $sth->execute($query_values); |
||
| 3544 | } catch (PDOException $e) { |
||
| 3545 | return "error : ".$e->getMessage(); |
||
| 3546 | } |
||
| 3547 | |||
| 3548 | return "success"; |
||
| 3549 | |||
| 3550 | } |
||
| 3551 | /** |
||
| 3552 | * Update latest spotter data |
||
| 3553 | * |
||
| 3554 | * @param String $flightaware_id the ID from flightaware |
||
| 3555 | * @param String $ident the flight ident |
||
| 3556 | * @param String $arrival_airport_icao the arrival airport |
||
| 3557 | * @return String success or false |
||
| 3558 | * |
||
| 3559 | */ |
||
| 3560 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
||
| 3561 | { |
||
| 3562 | if ($groundspeed == '') $groundspeed = NULL; |
||
| 3563 | $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'; |
||
| 3564 | $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); |
||
| 3565 | |||
| 3566 | try { |
||
| 3567 | $sth = $this->db->prepare($query); |
||
| 3568 | $sth->execute($query_values); |
||
| 3569 | } catch (PDOException $e) { |
||
| 3570 | return "error : ".$e->getMessage(); |
||
| 3571 | } |
||
| 3572 | |||
| 3573 | return "success"; |
||
| 3574 | |||
| 3575 | } |
||
| 3576 | |||
| 3577 | /** |
||
| 3578 | * Adds a new spotter data |
||
| 3579 | * |
||
| 3580 | * @param String $flightaware_id the ID from flightaware |
||
| 3581 | * @param String $ident the flight ident |
||
| 3582 | * @param String $aircraft_icao the aircraft type |
||
| 3583 | * @param String $departure_airport_icao the departure airport |
||
| 3584 | * @param String $arrival_airport_icao the arrival airport |
||
| 3585 | * @param String $latitude latitude of flight |
||
| 3586 | * @param String $longitude latitude of flight |
||
| 3587 | * @param String $waypoints waypoints of flight |
||
| 3588 | * @param String $altitude altitude of flight |
||
| 3589 | * @param String $heading heading of flight |
||
| 3590 | * @param String $groundspeed speed of flight |
||
| 3591 | * @param String $date date of flight |
||
| 3592 | * @param String $departure_airport_time departure time of flight |
||
| 3593 | * @param String $arrival_airport_time arrival time of flight |
||
| 3594 | * @param String $squawk squawk code of flight |
||
| 3595 | * @param String $route_stop route stop of flight |
||
| 3596 | * @param String $highlight highlight or not |
||
| 3597 | * @param String $ModeS ModesS code of flight |
||
| 3598 | * @param String $registration registration code of flight |
||
| 3599 | * @param String $pilot_id pilot id of flight (for virtual airlines) |
||
| 3600 | * @param String $pilot_name pilot name of flight (for virtual airlines) |
||
| 3601 | * @param String $verticalrate vertival rate of flight |
||
| 3602 | * @return String success or false |
||
| 3603 | */ |
||
| 3604 | public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '',$source_type = '') |
||
| 3605 | { |
||
| 3606 | global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM; |
||
| 3607 | |||
| 3608 | //if (isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
||
| 3609 | $Image = new Image($this->db); |
||
| 3610 | $Common = new Common(); |
||
| 3611 | |||
| 3612 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
||
| 3613 | if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
||
| 3614 | if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
||
| 3615 | if (!isset($globalVAM)) $globalVAM = FALSE; |
||
| 3616 | date_default_timezone_set('UTC'); |
||
| 3617 | |||
| 3618 | //getting the registration |
||
| 3619 | if ($flightaware_id != "" && $registration == '') |
||
| 3620 | { |
||
| 3621 | if (!is_string($flightaware_id)) |
||
| 3622 | { |
||
| 3623 | return false; |
||
| 3624 | } else { |
||
| 3625 | if ($ModeS != '') { |
||
| 3626 | $timeelapsed = microtime(true); |
||
| 3627 | $registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type); |
||
| 3628 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3629 | } else { |
||
| 3630 | $myhex = explode('-',$flightaware_id); |
||
| 3631 | if (count($myhex) > 0) { |
||
| 3632 | $timeelapsed = microtime(true); |
||
| 3633 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type); |
||
| 3634 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3635 | } |
||
| 3636 | } |
||
| 3637 | } |
||
| 3638 | } |
||
| 3639 | $fromsource = NULL; |
||
| 3640 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
||
| 3641 | elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
||
| 3642 | elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
||
| 3643 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
||
| 3644 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
||
| 3645 | //getting the airline information |
||
| 3646 | if ($ident != "") |
||
| 3647 | { |
||
| 3648 | if (!is_string($ident)) |
||
| 3649 | { |
||
| 3650 | return false; |
||
| 3651 | } else { |
||
| 3652 | if (!is_numeric(substr($ident, 0, 3)) && !((substr($ident, 0, 3) == 'OGN' || substr($ident, 0, 3) == 'FLR' || substr($ident, 0, 3) == 'ICA') && $format_source == 'aprs')) |
||
| 3653 | { |
||
| 3654 | $timeelapsed = microtime(true); |
||
| 3655 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
| 3656 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
||
| 3657 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
| 3658 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
||
| 3659 | } else { |
||
| 3660 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3661 | } |
||
| 3662 | if (count($airline_array) == 0) { |
||
| 3663 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3664 | } |
||
| 3665 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
||
| 3666 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3667 | } |
||
| 3668 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3669 | |||
| 3670 | } else { |
||
| 3671 | $timeelapsed = microtime(true); |
||
| 3672 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3673 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3674 | } |
||
| 3675 | } |
||
| 3676 | } else $airline_array = array(); |
||
| 3677 | |||
| 3678 | //getting the aircraft information |
||
| 3679 | $aircraft_array = array(); |
||
| 3680 | if ($aircraft_icao != '') |
||
| 3681 | { |
||
| 3682 | if (!is_string($aircraft_icao)) |
||
| 3683 | { |
||
| 3684 | return false; |
||
| 3685 | } else { |
||
| 3686 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
||
| 3687 | { |
||
| 3688 | $timeelapsed = microtime(true); |
||
| 3689 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
||
| 3690 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3691 | } else { |
||
| 3692 | $timeelapsed = microtime(true); |
||
| 3693 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
||
| 3694 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3695 | } |
||
| 3696 | } |
||
| 3697 | } else { |
||
| 3698 | if ($ModeS != '') { |
||
| 3699 | $timeelapsed = microtime(true); |
||
| 3700 | $aircraft_icao = $this->getAllAircraftType($ModeS,$source_type); |
||
| 3701 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3702 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
||
| 3703 | { |
||
| 3704 | $timeelapsed = microtime(true); |
||
| 3705 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
||
| 3706 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3707 | } else { |
||
| 3708 | $timeelapsed = microtime(true); |
||
| 3709 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
||
| 3710 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3711 | } |
||
| 3712 | } |
||
| 3713 | } |
||
| 3714 | |||
| 3715 | //getting the departure airport information |
||
| 3716 | $departure_airport_array = array(); |
||
| 3717 | $departure_airport_icao = trim($departure_airport_icao); |
||
| 3718 | if ($departure_airport_icao != '') |
||
| 3719 | { |
||
| 3720 | if (!is_string($departure_airport_icao)) |
||
| 3721 | { |
||
| 3722 | return false; |
||
| 3723 | } else { |
||
| 3724 | $timeelapsed = microtime(true); |
||
| 3725 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
||
| 3726 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3727 | } |
||
| 3728 | } |
||
| 3729 | |||
| 3730 | //getting the arrival airport information |
||
| 3731 | $arrival_airport_array = array(); |
||
| 3732 | $arrival_airport_icao = trim($arrival_airport_icao); |
||
| 3733 | if ($arrival_airport_icao != '') |
||
| 3734 | { |
||
| 3735 | if (!is_string($arrival_airport_icao)) |
||
| 3736 | { |
||
| 3737 | return false; |
||
| 3738 | } else { |
||
| 3739 | $timeelapsed = microtime(true); |
||
| 3740 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
||
| 3741 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3742 | } |
||
| 3743 | } |
||
| 3744 | |||
| 3745 | if ($latitude != "") |
||
| 3746 | { |
||
| 3747 | if (!is_numeric($latitude)) |
||
| 3748 | { |
||
| 3749 | return false; |
||
| 3750 | } |
||
| 3751 | } |
||
| 3752 | |||
| 3753 | if ($longitude != "") |
||
| 3754 | { |
||
| 3755 | if (!is_numeric($longitude)) |
||
| 3756 | { |
||
| 3757 | return false; |
||
| 3758 | } |
||
| 3759 | } |
||
| 3760 | |||
| 3761 | if ($waypoints != "") |
||
| 3762 | { |
||
| 3763 | if (!is_string($waypoints)) |
||
| 3764 | { |
||
| 3765 | return false; |
||
| 3766 | } |
||
| 3767 | } |
||
| 3768 | |||
| 3769 | if ($altitude != "") |
||
| 3770 | { |
||
| 3771 | if (!is_numeric($altitude)) |
||
| 3772 | { |
||
| 3773 | return false; |
||
| 3774 | } |
||
| 3775 | } else $altitude = 0; |
||
| 3776 | |||
| 3777 | if ($heading != "") |
||
| 3778 | { |
||
| 3779 | if (!is_numeric($heading)) |
||
| 3780 | { |
||
| 3781 | return false; |
||
| 3782 | } |
||
| 3783 | } |
||
| 3784 | |||
| 3785 | if ($groundspeed != "") |
||
| 3786 | { |
||
| 3787 | if (!is_numeric($groundspeed)) |
||
| 3788 | { |
||
| 3789 | return false; |
||
| 3790 | } |
||
| 3791 | } |
||
| 3792 | |||
| 3793 | |||
| 3794 | if ($date == "" || strtotime($date) < time()-20*60) |
||
| 3795 | { |
||
| 3796 | $date = date("Y-m-d H:i:s", time()); |
||
| 3797 | } |
||
| 3798 | |||
| 3799 | //getting the aircraft image |
||
| 3800 | if (($registration != "" || $registration != 'NA') && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM) |
||
| 3801 | { |
||
| 3802 | $timeelapsed = microtime(true); |
||
| 3803 | $image_array = $Image->getSpotterImage($registration); |
||
| 3804 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3805 | if (!isset($image_array[0]['registration'])) |
||
| 3806 | { |
||
| 3807 | //echo "Add image !!!! \n"; |
||
| 3808 | $Image->addSpotterImage($registration); |
||
| 3809 | } |
||
| 3810 | $timeelapsed = microtime(true); |
||
| 3811 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
||
| 3812 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3813 | if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
||
| 3814 | } |
||
| 3815 | |||
| 3816 | if (($globalIVAO || $globalVATSIM || $globalphpVMS || $globalVAM) && $aircraft_icao != '') |
||
| 3817 | { |
||
| 3818 | if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
||
| 3819 | else $airline_icao = ''; |
||
| 3820 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
||
| 3821 | if (!isset($image_array[0]['registration'])) |
||
| 3822 | { |
||
| 3823 | //echo "Add image !!!! \n"; |
||
| 3824 | $Image->addSpotterImage('',$aircraft_icao,$airline_icao); |
||
| 3825 | } |
||
| 3826 | } |
||
| 3827 | |||
| 3828 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
||
| 3829 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 3830 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 3831 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3832 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 3833 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 3834 | $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3835 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3836 | $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
||
| 3837 | $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3838 | $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
||
| 3839 | $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3840 | $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
||
| 3841 | $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
||
| 3842 | $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
||
| 3843 | $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
||
| 3844 | $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
||
| 3845 | $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
||
| 3846 | $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
||
| 3847 | |||
| 3848 | if (count($airline_array) == 0) |
||
| 3849 | { |
||
| 3850 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 3851 | } |
||
| 3852 | if (count($aircraft_array) == 0) |
||
| 3853 | { |
||
| 3854 | $aircraft_array = $this->getAllAircraftInfo('NA'); |
||
| 3855 | } |
||
| 3856 | if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') |
||
| 3857 | { |
||
| 3858 | $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 3859 | } |
||
| 3860 | if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') |
||
| 3861 | { |
||
| 3862 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 3863 | } |
||
| 3864 | if ($registration == '') $registration = 'NA'; |
||
| 3865 | if ($latitude == '' && $longitude == '') { |
||
| 3866 | $latitude = 0; |
||
| 3867 | $longitude = 0; |
||
| 3868 | } |
||
| 3869 | if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
||
| 3870 | if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
||
| 3871 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
||
| 3872 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
||
| 3873 | if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
||
| 3874 | $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) |
||
| 3875 | 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)"; |
||
| 3876 | |||
| 3877 | $airline_name = $airline_array[0]['name']; |
||
| 3878 | $airline_icao = $airline_array[0]['icao']; |
||
| 3879 | $airline_country = $airline_array[0]['country']; |
||
| 3880 | $airline_type = $airline_array[0]['type']; |
||
| 3881 | if ($airline_type == '') { |
||
| 3882 | $timeelapsed = microtime(true); |
||
| 3883 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
||
| 3884 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3885 | } |
||
| 3886 | if ($airline_type == null) $airline_type = ''; |
||
| 3887 | $aircraft_type = $aircraft_array[0]['type']; |
||
| 3888 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
||
| 3889 | $departure_airport_name = $departure_airport_array[0]['name']; |
||
| 3890 | $departure_airport_city = $departure_airport_array[0]['city']; |
||
| 3891 | $departure_airport_country = $departure_airport_array[0]['country']; |
||
| 3892 | |||
| 3893 | $arrival_airport_name = $arrival_airport_array[0]['name']; |
||
| 3894 | $arrival_airport_city = $arrival_airport_array[0]['city']; |
||
| 3895 | $arrival_airport_country = $arrival_airport_array[0]['country']; |
||
| 3896 | $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); |
||
| 3897 | |||
| 3898 | try { |
||
| 3899 | |||
| 3900 | $sth = $this->db->prepare($query); |
||
| 3901 | $sth->execute($query_values); |
||
| 3902 | $this->db = null; |
||
| 3903 | } catch (PDOException $e) { |
||
| 3904 | return "error : ".$e->getMessage(); |
||
| 3905 | } |
||
| 3906 | |||
| 3907 | return "success"; |
||
| 3908 | |||
| 3909 | } |
||
| 3910 | |||
| 3911 | |||
| 3912 | /** |
||
| 3913 | * Gets the aircraft ident within the last hour |
||
| 3914 | * |
||
| 3915 | * @return String the ident |
||
| 3916 | * |
||
| 3917 | */ |
||
| 3918 | public function getIdentFromLastHour($ident) |
||
| 3919 | { |
||
| 3920 | global $globalDBdriver, $globalTimezone; |
||
| 3921 | if ($globalDBdriver == 'mysql') { |
||
| 3922 | $query = "SELECT spotter_output.ident FROM spotter_output |
||
| 3923 | WHERE spotter_output.ident = :ident |
||
| 3924 | AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
||
| 3925 | AND spotter_output.date < UTC_TIMESTAMP()"; |
||
| 3926 | $query_data = array(':ident' => $ident); |
||
| 3927 | } else { |
||
| 3928 | $query = "SELECT spotter_output.ident FROM spotter_output |
||
| 3929 | WHERE spotter_output.ident = :ident |
||
| 3930 | AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
||
| 3931 | AND spotter_output.date < now() AT TIME ZONE 'UTC'"; |
||
| 3932 | $query_data = array(':ident' => $ident); |
||
| 3933 | } |
||
| 3934 | |||
| 3935 | $sth = $this->db->prepare($query); |
||
| 3936 | $sth->execute($query_data); |
||
| 3937 | $ident_result=''; |
||
| 3938 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3939 | { |
||
| 3940 | $ident_result = $row['ident']; |
||
| 3941 | } |
||
| 3942 | |||
| 3943 | return $ident_result; |
||
| 3944 | } |
||
| 3945 | |||
| 3946 | |||
| 3947 | /** |
||
| 3948 | * Gets the aircraft data from the last 20 seconds |
||
| 3949 | * |
||
| 3950 | * @return Array the spotter data |
||
| 3951 | * |
||
| 3952 | */ |
||
| 3953 | public function getRealTimeData($q = '') |
||
| 3954 | { |
||
| 3955 | global $globalDBdriver; |
||
| 3956 | $additional_query = ''; |
||
| 3957 | if ($q != "") |
||
| 3958 | { |
||
| 3959 | if (!is_string($q)) |
||
| 3960 | { |
||
| 3961 | return false; |
||
| 3962 | } else { |
||
| 3963 | $q_array = explode(" ", $q); |
||
| 3964 | foreach ($q_array as $q_item){ |
||
| 3965 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
||
| 3966 | $additional_query .= " AND ("; |
||
| 3967 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
||
| 3968 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
||
| 3969 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
||
| 3970 | $additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
||
| 3971 | $additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
||
| 3972 | $additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
||
| 3973 | $additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
||
| 3974 | $additional_query .= "(spotter_output.ident like '%".$q_item."%')"; |
||
| 3975 | $additional_query .= ")"; |
||
| 3976 | } |
||
| 3977 | } |
||
| 3978 | } |
||
| 3979 | if ($globalDBdriver == 'mysql') { |
||
| 3980 | $query = "SELECT spotter_output.* FROM spotter_output |
||
| 3981 | WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
||
| 3982 | AND spotter_output.date < UTC_TIMESTAMP()"; |
||
| 3983 | } else { |
||
| 3984 | $query = "SELECT spotter_output.* FROM spotter_output |
||
| 3985 | WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
||
| 3986 | AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
||
| 3987 | } |
||
| 3988 | $spotter_array = $this->getDataFromDB($query, array()); |
||
| 3989 | |||
| 3990 | return $spotter_array; |
||
| 3991 | } |
||
| 3992 | |||
| 3993 | |||
| 3994 | |||
| 3995 | /** |
||
| 3996 | * Gets all airlines that have flown over |
||
| 3997 | * |
||
| 3998 | * @return Array the airline list |
||
| 3999 | * |
||
| 4000 | */ |
||
| 4001 | public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '') |
||
| 4002 | { |
||
| 4003 | global $globalDBdriver; |
||
| 4004 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4005 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4006 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'"; |
||
| 4007 | if ($olderthanmonths > 0) { |
||
| 4008 | if ($globalDBdriver == 'mysql') { |
||
| 4009 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 4010 | } else { |
||
| 4011 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 4012 | } |
||
| 4013 | } |
||
| 4014 | if ($sincedate != '') { |
||
| 4015 | if ($globalDBdriver == 'mysql') { |
||
| 4016 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 4017 | } else { |
||
| 4018 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4019 | } |
||
| 4020 | } |
||
| 4021 | $query_values = array(); |
||
| 4022 | if ($year != '') { |
||
| 4023 | if ($globalDBdriver == 'mysql') { |
||
| 4024 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 4025 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4026 | } else { |
||
| 4027 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 4028 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4029 | } |
||
| 4030 | } |
||
| 4031 | if ($month != '') { |
||
| 4032 | if ($globalDBdriver == 'mysql') { |
||
| 4033 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 4034 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4035 | } else { |
||
| 4036 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 4037 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4038 | } |
||
| 4039 | } |
||
| 4040 | if ($day != '') { |
||
| 4041 | if ($globalDBdriver == 'mysql') { |
||
| 4042 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 4043 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4044 | } else { |
||
| 4045 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 4046 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4047 | } |
||
| 4048 | } |
||
| 4049 | $query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
||
| 4050 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4051 | |||
| 4052 | $sth = $this->db->prepare($query); |
||
| 4053 | $sth->execute($query_values); |
||
| 4054 | $airline_array = array(); |
||
| 4055 | $temp_array = array(); |
||
| 4056 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4057 | { |
||
| 4058 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4059 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4060 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4061 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4062 | $airline_array[] = $temp_array; |
||
| 4063 | } |
||
| 4064 | return $airline_array; |
||
| 4065 | } |
||
| 4066 | |||
| 4067 | /** |
||
| 4068 | * Gets all pilots that have flown over |
||
| 4069 | * |
||
| 4070 | * @return Array the pilots list |
||
| 4071 | * |
||
| 4072 | */ |
||
| 4073 | public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '') |
||
| 4074 | { |
||
| 4075 | global $globalDBdriver; |
||
| 4076 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4077 | $query = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
||
| 4078 | FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''"; |
||
| 4079 | if ($olderthanmonths > 0) { |
||
| 4080 | if ($globalDBdriver == 'mysql') { |
||
| 4081 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 4082 | } else { |
||
| 4083 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 4084 | } |
||
| 4085 | } |
||
| 4086 | if ($sincedate != '') { |
||
| 4087 | if ($globalDBdriver == 'mysql') { |
||
| 4088 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 4089 | } else { |
||
| 4090 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4091 | } |
||
| 4092 | } |
||
| 4093 | $query_values = array(); |
||
| 4094 | if ($year != '') { |
||
| 4095 | if ($globalDBdriver == 'mysql') { |
||
| 4096 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 4097 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4098 | } else { |
||
| 4099 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 4100 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4101 | } |
||
| 4102 | } |
||
| 4103 | if ($month != '') { |
||
| 4104 | if ($globalDBdriver == 'mysql') { |
||
| 4105 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 4106 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4107 | } else { |
||
| 4108 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 4109 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4110 | } |
||
| 4111 | } |
||
| 4112 | if ($day != '') { |
||
| 4113 | if ($globalDBdriver == 'mysql') { |
||
| 4114 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 4115 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4116 | } else { |
||
| 4117 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 4118 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4119 | } |
||
| 4120 | } |
||
| 4121 | |||
| 4122 | $query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
||
| 4123 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4124 | |||
| 4125 | |||
| 4126 | $sth = $this->db->prepare($query); |
||
| 4127 | $sth->execute($query_values); |
||
| 4128 | $airline_array = array(); |
||
| 4129 | $temp_array = array(); |
||
| 4130 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4131 | { |
||
| 4132 | $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 4133 | $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 4134 | $temp_array['pilot_count'] = $row['pilot_count']; |
||
| 4135 | $temp_array['format_source'] = $row['format_source']; |
||
| 4136 | $airline_array[] = $temp_array; |
||
| 4137 | } |
||
| 4138 | return $airline_array; |
||
| 4139 | } |
||
| 4140 | |||
| 4141 | /** |
||
| 4142 | * Gets all pilots that have flown over |
||
| 4143 | * |
||
| 4144 | * @return Array the pilots list |
||
| 4145 | * |
||
| 4146 | */ |
||
| 4147 | public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
||
| 4148 | { |
||
| 4149 | global $globalDBdriver; |
||
| 4150 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
||
| 4151 | FROM spotter_output WHERE spotter_output.pilot_id <> '' "; |
||
| 4152 | if ($olderthanmonths > 0) { |
||
| 4153 | if ($globalDBdriver == 'mysql') { |
||
| 4154 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 4155 | } else { |
||
| 4156 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 4157 | } |
||
| 4158 | } |
||
| 4159 | if ($sincedate != '') { |
||
| 4160 | if ($globalDBdriver == 'mysql') { |
||
| 4161 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 4162 | } else { |
||
| 4163 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4164 | } |
||
| 4165 | } |
||
| 4166 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
||
| 4167 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4168 | |||
| 4169 | |||
| 4170 | $sth = $this->db->prepare($query); |
||
| 4171 | $sth->execute(); |
||
| 4172 | |||
| 4173 | $airline_array = array(); |
||
| 4174 | $temp_array = array(); |
||
| 4175 | |||
| 4176 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4177 | { |
||
| 4178 | $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 4179 | $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 4180 | $temp_array['pilot_count'] = $row['pilot_count']; |
||
| 4181 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4182 | $temp_array['format_source'] = $row['format_source']; |
||
| 4183 | $airline_array[] = $temp_array; |
||
| 4184 | } |
||
| 4185 | return $airline_array; |
||
| 4186 | } |
||
| 4187 | |||
| 4188 | /** |
||
| 4189 | * Gets all owner that have flown over |
||
| 4190 | * |
||
| 4191 | * @return Array the pilots list |
||
| 4192 | * |
||
| 4193 | */ |
||
| 4194 | public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
||
| 4195 | { |
||
| 4196 | global $globalDBdriver; |
||
| 4197 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4198 | $query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
||
| 4199 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL"; |
||
| 4200 | if ($olderthanmonths > 0) { |
||
| 4201 | if ($globalDBdriver == 'mysql') { |
||
| 4202 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 4203 | } else { |
||
| 4204 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 4205 | } |
||
| 4206 | } |
||
| 4207 | if ($sincedate != '') { |
||
| 4208 | if ($globalDBdriver == 'mysql') { |
||
| 4209 | $query .= " AND spotter_output.date > '".$sincedate."' "; |
||
| 4210 | } else { |
||
| 4211 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4212 | } |
||
| 4213 | } |
||
| 4214 | $query_values = array(); |
||
| 4215 | if ($year != '') { |
||
| 4216 | if ($globalDBdriver == 'mysql') { |
||
| 4217 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 4218 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4219 | } else { |
||
| 4220 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 4221 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4222 | } |
||
| 4223 | } |
||
| 4224 | if ($month != '') { |
||
| 4225 | if ($globalDBdriver == 'mysql') { |
||
| 4226 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 4227 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4228 | } else { |
||
| 4229 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 4230 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4231 | } |
||
| 4232 | } |
||
| 4233 | if ($day != '') { |
||
| 4234 | if ($globalDBdriver == 'mysql') { |
||
| 4235 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 4236 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4237 | } else { |
||
| 4238 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 4239 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4240 | } |
||
| 4241 | } |
||
| 4242 | $query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
||
| 4243 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4244 | |||
| 4245 | $sth = $this->db->prepare($query); |
||
| 4246 | $sth->execute($query_values); |
||
| 4247 | $airline_array = array(); |
||
| 4248 | $temp_array = array(); |
||
| 4249 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4250 | { |
||
| 4251 | $temp_array['owner_name'] = $row['owner_name']; |
||
| 4252 | $temp_array['owner_count'] = $row['owner_count']; |
||
| 4253 | $airline_array[] = $temp_array; |
||
| 4254 | } |
||
| 4255 | return $airline_array; |
||
| 4256 | } |
||
| 4257 | |||
| 4258 | /** |
||
| 4259 | * Gets all owner that have flown over |
||
| 4260 | * |
||
| 4261 | * @return Array the pilots list |
||
| 4262 | * |
||
| 4263 | */ |
||
| 4264 | public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 4265 | { |
||
| 4266 | global $globalDBdriver; |
||
| 4267 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4268 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
||
| 4269 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
||
| 4270 | if ($olderthanmonths > 0) { |
||
| 4271 | if ($globalDBdriver == 'mysql') { |
||
| 4272 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 4273 | } else { |
||
| 4274 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 4275 | } |
||
| 4276 | } |
||
| 4277 | if ($sincedate != '') { |
||
| 4278 | if ($globalDBdriver == 'mysql') { |
||
| 4279 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 4280 | } else { |
||
| 4281 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4282 | } |
||
| 4283 | } |
||
| 4284 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
||
| 4285 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4286 | |||
| 4287 | |||
| 4288 | $sth = $this->db->prepare($query); |
||
| 4289 | $sth->execute(); |
||
| 4290 | |||
| 4291 | $airline_array = array(); |
||
| 4292 | $temp_array = array(); |
||
| 4293 | |||
| 4294 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4295 | { |
||
| 4296 | $temp_array['owner_name'] = $row['owner_name']; |
||
| 4297 | $temp_array['owner_count'] = $row['owner_count']; |
||
| 4298 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4299 | $airline_array[] = $temp_array; |
||
| 4300 | } |
||
| 4301 | return $airline_array; |
||
| 4302 | } |
||
| 4303 | |||
| 4304 | /** |
||
| 4305 | * Gets all airlines that have flown over by aircraft |
||
| 4306 | * |
||
| 4307 | * @return Array the airline list |
||
| 4308 | * |
||
| 4309 | */ |
||
| 4310 | public function countAllAirlinesByAircraft($aircraft_icao,$filters = array()) |
||
| 4311 | { |
||
| 4312 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 4313 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4314 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4315 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 4316 | GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
||
| 4317 | ORDER BY airline_count DESC"; |
||
| 4318 | |||
| 4319 | |||
| 4320 | $sth = $this->db->prepare($query); |
||
| 4321 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 4322 | |||
| 4323 | $airline_array = array(); |
||
| 4324 | $temp_array = array(); |
||
| 4325 | |||
| 4326 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4327 | { |
||
| 4328 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4329 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4330 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4331 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4332 | |||
| 4333 | $airline_array[] = $temp_array; |
||
| 4334 | } |
||
| 4335 | |||
| 4336 | return $airline_array; |
||
| 4337 | } |
||
| 4338 | |||
| 4339 | |||
| 4340 | /** |
||
| 4341 | * Gets all airline countries that have flown over by aircraft |
||
| 4342 | * |
||
| 4343 | * @return Array the airline country list |
||
| 4344 | * |
||
| 4345 | */ |
||
| 4346 | public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 4347 | { |
||
| 4348 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 4349 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4350 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3 |
||
| 4351 | FROM spotter_output, countries ".$filter_query." countries.name = spotter_output.airline_country AND spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 4352 | GROUP BY spotter_output.airline_country, countries.iso3 |
||
| 4353 | ORDER BY airline_country_count DESC |
||
| 4354 | LIMIT 10 OFFSET 0"; |
||
| 4355 | |||
| 4356 | |||
| 4357 | $sth = $this->db->prepare($query); |
||
| 4358 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 4359 | |||
| 4360 | $airline_country_array = array(); |
||
| 4361 | $temp_array = array(); |
||
| 4362 | |||
| 4363 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4364 | { |
||
| 4365 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4366 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4367 | $temp_array['airline_country_iso3'] = $row['airline_country_iso3']; |
||
| 4368 | |||
| 4369 | $airline_country_array[] = $temp_array; |
||
| 4370 | } |
||
| 4371 | return $airline_country_array; |
||
| 4372 | } |
||
| 4373 | |||
| 4374 | |||
| 4375 | |||
| 4376 | |||
| 4377 | /** |
||
| 4378 | * Gets all airlines that have flown over by airport |
||
| 4379 | * |
||
| 4380 | * @return Array the airline list |
||
| 4381 | * |
||
| 4382 | */ |
||
| 4383 | public function countAllAirlinesByAirport($airport_icao,$filters = array()) |
||
| 4384 | { |
||
| 4385 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 4386 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4387 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4388 | 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 ) |
||
| 4389 | GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
||
| 4390 | ORDER BY airline_count DESC"; |
||
| 4391 | |||
| 4392 | |||
| 4393 | $sth = $this->db->prepare($query); |
||
| 4394 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 4395 | |||
| 4396 | $airline_array = array(); |
||
| 4397 | $temp_array = array(); |
||
| 4398 | |||
| 4399 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4400 | { |
||
| 4401 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4402 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4403 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4404 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4405 | |||
| 4406 | $airline_array[] = $temp_array; |
||
| 4407 | } |
||
| 4408 | return $airline_array; |
||
| 4409 | } |
||
| 4410 | |||
| 4411 | |||
| 4412 | /** |
||
| 4413 | * Gets all airline countries that have flown over by airport icao |
||
| 4414 | * |
||
| 4415 | * @return Array the airline country list |
||
| 4416 | * |
||
| 4417 | */ |
||
| 4418 | public function countAllAirlineCountriesByAirport($airport_icao,$filters = array()) |
||
| 4419 | { |
||
| 4420 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 4421 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4422 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3 |
||
| 4423 | FROM countries, spotter_output".$filter_query." countries.name = spotter_output.airline_country AND spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
||
| 4424 | GROUP BY spotter_output.airline_country, countries.iso3 |
||
| 4425 | ORDER BY airline_country_count DESC |
||
| 4426 | LIMIT 10 OFFSET 0"; |
||
| 4427 | |||
| 4428 | |||
| 4429 | $sth = $this->db->prepare($query); |
||
| 4430 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 4431 | |||
| 4432 | $airline_country_array = array(); |
||
| 4433 | $temp_array = array(); |
||
| 4434 | |||
| 4435 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4436 | { |
||
| 4437 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4438 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4439 | $temp_array['airline_country_iso3'] = $row['airline_country_iso3']; |
||
| 4440 | |||
| 4441 | $airline_country_array[] = $temp_array; |
||
| 4442 | } |
||
| 4443 | return $airline_country_array; |
||
| 4444 | } |
||
| 4445 | |||
| 4446 | |||
| 4447 | /** |
||
| 4448 | * Gets all airlines that have flown over by aircraft manufacturer |
||
| 4449 | * |
||
| 4450 | * @return Array the airline list |
||
| 4451 | * |
||
| 4452 | */ |
||
| 4453 | public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 4454 | { |
||
| 4455 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 4456 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4457 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4458 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 4459 | GROUP BY spotter_output.airline_name |
||
| 4460 | ORDER BY airline_count DESC"; |
||
| 4461 | |||
| 4462 | $sth = $this->db->prepare($query); |
||
| 4463 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 4464 | |||
| 4465 | $airline_array = array(); |
||
| 4466 | $temp_array = array(); |
||
| 4467 | |||
| 4468 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4469 | { |
||
| 4470 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4471 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4472 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4473 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4474 | |||
| 4475 | $airline_array[] = $temp_array; |
||
| 4476 | } |
||
| 4477 | return $airline_array; |
||
| 4478 | } |
||
| 4479 | |||
| 4480 | |||
| 4481 | |||
| 4482 | /** |
||
| 4483 | * Gets all airline countries that have flown over by aircraft manufacturer |
||
| 4484 | * |
||
| 4485 | * @return Array the airline country list |
||
| 4486 | * |
||
| 4487 | */ |
||
| 4488 | public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 4489 | { |
||
| 4490 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 4491 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4492 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4493 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 4494 | GROUP BY spotter_output.airline_country |
||
| 4495 | ORDER BY airline_country_count DESC |
||
| 4496 | LIMIT 10 OFFSET 0"; |
||
| 4497 | |||
| 4498 | |||
| 4499 | $sth = $this->db->prepare($query); |
||
| 4500 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 4501 | |||
| 4502 | $airline_country_array = array(); |
||
| 4503 | $temp_array = array(); |
||
| 4504 | |||
| 4505 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4506 | { |
||
| 4507 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4508 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4509 | $airline_country_array[] = $temp_array; |
||
| 4510 | } |
||
| 4511 | return $airline_country_array; |
||
| 4512 | } |
||
| 4513 | |||
| 4514 | |||
| 4515 | /** |
||
| 4516 | * Gets all airlines that have flown over by date |
||
| 4517 | * |
||
| 4518 | * @return Array the airline list |
||
| 4519 | * |
||
| 4520 | */ |
||
| 4521 | public function countAllAirlinesByDate($date,$filters = array()) |
||
| 4522 | { |
||
| 4523 | global $globalTimezone, $globalDBdriver; |
||
| 4524 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4525 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4526 | if ($globalTimezone != '') { |
||
| 4527 | date_default_timezone_set($globalTimezone); |
||
| 4528 | $datetime = new DateTime($date); |
||
| 4529 | $offset = $datetime->format('P'); |
||
| 4530 | } else $offset = '+00:00'; |
||
| 4531 | |||
| 4532 | if ($globalDBdriver == 'mysql') { |
||
| 4533 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4534 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4535 | GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country |
||
| 4536 | ORDER BY airline_count DESC"; |
||
| 4537 | } else { |
||
| 4538 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4539 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4540 | GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country |
||
| 4541 | ORDER BY airline_count DESC"; |
||
| 4542 | } |
||
| 4543 | |||
| 4544 | $sth = $this->db->prepare($query); |
||
| 4545 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4546 | |||
| 4547 | $airline_array = array(); |
||
| 4548 | $temp_array = array(); |
||
| 4549 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4550 | { |
||
| 4551 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4552 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4553 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4554 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4555 | |||
| 4556 | $airline_array[] = $temp_array; |
||
| 4557 | } |
||
| 4558 | |||
| 4559 | return $airline_array; |
||
| 4560 | } |
||
| 4561 | |||
| 4562 | |||
| 4563 | /** |
||
| 4564 | * Gets all airline countries that have flown over by date |
||
| 4565 | * |
||
| 4566 | * @return Array the airline country list |
||
| 4567 | * |
||
| 4568 | */ |
||
| 4569 | public function countAllAirlineCountriesByDate($date,$filters = array()) |
||
| 4570 | { |
||
| 4571 | global $globalTimezone, $globalDBdriver; |
||
| 4572 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4573 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4574 | if ($globalTimezone != '') { |
||
| 4575 | date_default_timezone_set($globalTimezone); |
||
| 4576 | $datetime = new DateTime($date); |
||
| 4577 | $offset = $datetime->format('P'); |
||
| 4578 | } else $offset = '+00:00'; |
||
| 4579 | |||
| 4580 | if ($globalDBdriver == 'mysql') { |
||
| 4581 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4582 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4583 | GROUP BY spotter_output.airline_country |
||
| 4584 | ORDER BY airline_country_count DESC |
||
| 4585 | LIMIT 10 OFFSET 0"; |
||
| 4586 | } else { |
||
| 4587 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4588 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4589 | GROUP BY spotter_output.airline_country |
||
| 4590 | ORDER BY airline_country_count DESC |
||
| 4591 | LIMIT 10 OFFSET 0"; |
||
| 4592 | } |
||
| 4593 | |||
| 4594 | $sth = $this->db->prepare($query); |
||
| 4595 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4596 | |||
| 4597 | $airline_country_array = array(); |
||
| 4598 | $temp_array = array(); |
||
| 4599 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4600 | { |
||
| 4601 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4602 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4603 | |||
| 4604 | $airline_country_array[] = $temp_array; |
||
| 4605 | } |
||
| 4606 | return $airline_country_array; |
||
| 4607 | } |
||
| 4608 | |||
| 4609 | |||
| 4610 | /** |
||
| 4611 | * Gets all airlines that have flown over by ident/callsign |
||
| 4612 | * |
||
| 4613 | * @return Array the airline list |
||
| 4614 | * |
||
| 4615 | */ |
||
| 4616 | public function countAllAirlinesByIdent($ident,$filters = array()) |
||
| 4617 | { |
||
| 4618 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 4619 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4620 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4621 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
||
| 4622 | GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country |
||
| 4623 | ORDER BY airline_count DESC"; |
||
| 4624 | |||
| 4625 | |||
| 4626 | $sth = $this->db->prepare($query); |
||
| 4627 | $sth->execute(array(':ident' => $ident)); |
||
| 4628 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4629 | } |
||
| 4630 | |||
| 4631 | /** |
||
| 4632 | * Gets all airlines by owner |
||
| 4633 | * |
||
| 4634 | * @return Array the airline list |
||
| 4635 | * |
||
| 4636 | */ |
||
| 4637 | public function countAllAirlinesByOwner($owner,$filters = array()) |
||
| 4638 | { |
||
| 4639 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 4640 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4641 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4642 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner |
||
| 4643 | GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country |
||
| 4644 | ORDER BY airline_count DESC"; |
||
| 4645 | |||
| 4646 | |||
| 4647 | $sth = $this->db->prepare($query); |
||
| 4648 | $sth->execute(array(':owner' => $owner)); |
||
| 4649 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4650 | } |
||
| 4651 | |||
| 4652 | /** |
||
| 4653 | * Gets flight duration by owner |
||
| 4654 | * |
||
| 4655 | * @return String Duration of all flights |
||
| 4656 | * |
||
| 4657 | */ |
||
| 4658 | public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
||
| 4659 | { |
||
| 4660 | global $globalDBdriver; |
||
| 4661 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 4662 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4663 | $query = "SELECT SUM(last_seen - date) AS duration |
||
| 4664 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner |
||
| 4665 | AND last_seen > date"; |
||
| 4666 | $query_values = array(); |
||
| 4667 | if ($year != '') { |
||
| 4668 | if ($globalDBdriver == 'mysql') { |
||
| 4669 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 4670 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4671 | } else { |
||
| 4672 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 4673 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4674 | } |
||
| 4675 | } |
||
| 4676 | if ($month != '') { |
||
| 4677 | if ($globalDBdriver == 'mysql') { |
||
| 4678 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 4679 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4680 | } else { |
||
| 4681 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 4682 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4683 | } |
||
| 4684 | } |
||
| 4685 | if ($day != '') { |
||
| 4686 | if ($globalDBdriver == 'mysql') { |
||
| 4687 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 4688 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4689 | } else { |
||
| 4690 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 4691 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4692 | } |
||
| 4693 | } |
||
| 4694 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 4695 | $sth = $this->db->prepare($query); |
||
| 4696 | $sth->execute($query_values); |
||
| 4697 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4698 | if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
||
| 4699 | elseif ($result[0]['duration'] == '') return 0; |
||
| 4700 | else return $result[0]['duration']; |
||
| 4701 | } |
||
| 4702 | |||
| 4703 | /** |
||
| 4704 | * Count flights by owner |
||
| 4705 | * |
||
| 4706 | * @return String Duration of all flights |
||
| 4707 | * |
||
| 4708 | */ |
||
| 4709 | public function countFlightsByOwner($owner,$filters = array()) |
||
| 4710 | { |
||
| 4711 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 4712 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4713 | $query = "SELECT COUNT(*) AS nb |
||
| 4714 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner"; |
||
| 4715 | $query_values = array(); |
||
| 4716 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 4717 | $sth = $this->db->prepare($query); |
||
| 4718 | $sth->execute($query_values); |
||
| 4719 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4720 | return $result[0]['nb']; |
||
| 4721 | } |
||
| 4722 | |||
| 4723 | /** |
||
| 4724 | * Count flights by pilot |
||
| 4725 | * |
||
| 4726 | * @return String Duration of all flights |
||
| 4727 | * |
||
| 4728 | */ |
||
| 4729 | public function countFlightsByPilot($pilot,$filters = array()) |
||
| 4730 | { |
||
| 4731 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 4732 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4733 | $query = "SELECT COUNT(*) AS nb |
||
| 4734 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilod_id = :pilot)"; |
||
| 4735 | $query_values = array(); |
||
| 4736 | $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
||
| 4737 | $sth = $this->db->prepare($query); |
||
| 4738 | $sth->execute($query_values); |
||
| 4739 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4740 | return $result[0]['nb']; |
||
| 4741 | } |
||
| 4742 | |||
| 4743 | /** |
||
| 4744 | * Gets flight duration by pilot |
||
| 4745 | * |
||
| 4746 | * @return String Duration of all flights |
||
| 4747 | * |
||
| 4748 | */ |
||
| 4749 | public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
||
| 4750 | { |
||
| 4751 | global $globalDBdriver; |
||
| 4752 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 4753 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4754 | $query = "SELECT SUM(last_seen - date) AS duration |
||
| 4755 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
||
| 4756 | AND last_seen > date"; |
||
| 4757 | $query_values = array(); |
||
| 4758 | if ($year != '') { |
||
| 4759 | if ($globalDBdriver == 'mysql') { |
||
| 4760 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 4761 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4762 | } else { |
||
| 4763 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 4764 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4765 | } |
||
| 4766 | } |
||
| 4767 | if ($month != '') { |
||
| 4768 | if ($globalDBdriver == 'mysql') { |
||
| 4769 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 4770 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4771 | } else { |
||
| 4772 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 4773 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4774 | } |
||
| 4775 | } |
||
| 4776 | if ($day != '') { |
||
| 4777 | if ($globalDBdriver == 'mysql') { |
||
| 4778 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 4779 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4780 | } else { |
||
| 4781 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 4782 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4783 | } |
||
| 4784 | } |
||
| 4785 | $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
||
| 4786 | $sth = $this->db->prepare($query); |
||
| 4787 | $sth->execute($query_values); |
||
| 4788 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4789 | if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
||
| 4790 | else return $result[0]['duration']; |
||
| 4791 | } |
||
| 4792 | |||
| 4793 | /** |
||
| 4794 | * Gets all airlines used by pilot |
||
| 4795 | * |
||
| 4796 | * @return Array the airline list |
||
| 4797 | * |
||
| 4798 | */ |
||
| 4799 | public function countAllAirlinesByPilot($pilot,$filters = array()) |
||
| 4800 | { |
||
| 4801 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 4802 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4803 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4804 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
||
| 4805 | GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country |
||
| 4806 | ORDER BY airline_count DESC"; |
||
| 4807 | |||
| 4808 | |||
| 4809 | $sth = $this->db->prepare($query); |
||
| 4810 | $sth->execute(array(':pilot' => $pilot)); |
||
| 4811 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 4812 | } |
||
| 4813 | |||
| 4814 | /** |
||
| 4815 | * Gets all airlines that have flown over by route |
||
| 4816 | * |
||
| 4817 | * @return Array the airline list |
||
| 4818 | * |
||
| 4819 | */ |
||
| 4820 | public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 4821 | { |
||
| 4822 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4823 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4824 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4825 | |||
| 4826 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4827 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 4828 | GROUP BY spotter_output.airline_name |
||
| 4829 | ORDER BY airline_count DESC"; |
||
| 4830 | |||
| 4831 | |||
| 4832 | $sth = $this->db->prepare($query); |
||
| 4833 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 4834 | |||
| 4835 | $airline_array = array(); |
||
| 4836 | $temp_array = array(); |
||
| 4837 | |||
| 4838 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4839 | { |
||
| 4840 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4841 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4842 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4843 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4844 | |||
| 4845 | $airline_array[] = $temp_array; |
||
| 4846 | } |
||
| 4847 | return $airline_array; |
||
| 4848 | } |
||
| 4849 | |||
| 4850 | /** |
||
| 4851 | * Gets all airline countries that have flown over by route |
||
| 4852 | * |
||
| 4853 | * @return Array the airline country list |
||
| 4854 | * |
||
| 4855 | */ |
||
| 4856 | public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array()) |
||
| 4857 | { |
||
| 4858 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4859 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4860 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4861 | |||
| 4862 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4863 | 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) |
||
| 4864 | GROUP BY spotter_output.airline_country |
||
| 4865 | ORDER BY airline_country_count DESC |
||
| 4866 | LIMIT 10 OFFSET 0"; |
||
| 4867 | |||
| 4868 | |||
| 4869 | $sth = $this->db->prepare($query); |
||
| 4870 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 4871 | |||
| 4872 | $airline_country_array = array(); |
||
| 4873 | $temp_array = array(); |
||
| 4874 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4875 | { |
||
| 4876 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4877 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4878 | |||
| 4879 | $airline_country_array[] = $temp_array; |
||
| 4880 | } |
||
| 4881 | |||
| 4882 | return $airline_country_array; |
||
| 4883 | } |
||
| 4884 | |||
| 4885 | |||
| 4886 | /** |
||
| 4887 | * Gets all airlines that have flown over by country |
||
| 4888 | * |
||
| 4889 | * @return Array the airline list |
||
| 4890 | * |
||
| 4891 | */ |
||
| 4892 | public function countAllAirlinesByCountry($country,$filters = array()) |
||
| 4893 | { |
||
| 4894 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 4895 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4896 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4897 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 4898 | GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
||
| 4899 | ORDER BY airline_count DESC"; |
||
| 4900 | |||
| 4901 | |||
| 4902 | $sth = $this->db->prepare($query); |
||
| 4903 | $sth->execute(array(':country' => $country)); |
||
| 4904 | |||
| 4905 | $airline_array = array(); |
||
| 4906 | $temp_array = array(); |
||
| 4907 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4908 | { |
||
| 4909 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4910 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4911 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4912 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4913 | |||
| 4914 | $airline_array[] = $temp_array; |
||
| 4915 | } |
||
| 4916 | return $airline_array; |
||
| 4917 | } |
||
| 4918 | |||
| 4919 | |||
| 4920 | /** |
||
| 4921 | * Gets all airline countries that have flown over by country |
||
| 4922 | * |
||
| 4923 | * @return Array the airline country list |
||
| 4924 | * |
||
| 4925 | */ |
||
| 4926 | public function countAllAirlineCountriesByCountry($country,$filters = array()) |
||
| 4927 | { |
||
| 4928 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4929 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 4930 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3 |
||
| 4931 | FROM countries,spotter_output".$filter_query." countries.name = spotter_output.airline_country AND spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country) OR spotter_output.airline_country = :country) |
||
| 4932 | GROUP BY spotter_output.airline_country, countries.iso3 |
||
| 4933 | ORDER BY airline_country_count DESC |
||
| 4934 | LIMIT 10 OFFSET 0"; |
||
| 4935 | |||
| 4936 | $sth = $this->db->prepare($query); |
||
| 4937 | $sth->execute(array(':country' => $country)); |
||
| 4938 | |||
| 4939 | $airline_country_array = array(); |
||
| 4940 | $temp_array = array(); |
||
| 4941 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4942 | { |
||
| 4943 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4944 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4945 | $temp_array['airline_country_iso3'] = $row['airline_country_iso3']; |
||
| 4946 | $airline_country_array[] = $temp_array; |
||
| 4947 | } |
||
| 4948 | return $airline_country_array; |
||
| 4949 | } |
||
| 4950 | |||
| 4951 | |||
| 4952 | /** |
||
| 4953 | * Gets all airlines countries |
||
| 4954 | * |
||
| 4955 | * @return Array the airline country list |
||
| 4956 | * |
||
| 4957 | */ |
||
| 4958 | public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '') |
||
| 4959 | { |
||
| 4960 | global $globalDBdriver; |
||
| 4961 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4962 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3 |
||
| 4963 | FROM countries, spotter_output".$filter_query." countries.name = spotter_output.airline_country AND spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'"; |
||
| 4964 | $query_values = array(); |
||
| 4965 | if ($year != '') { |
||
| 4966 | if ($globalDBdriver == 'mysql') { |
||
| 4967 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 4968 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4969 | } else { |
||
| 4970 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 4971 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 4972 | } |
||
| 4973 | } |
||
| 4974 | if ($month != '') { |
||
| 4975 | if ($globalDBdriver == 'mysql') { |
||
| 4976 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 4977 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4978 | } else { |
||
| 4979 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 4980 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 4981 | } |
||
| 4982 | } |
||
| 4983 | if ($day != '') { |
||
| 4984 | if ($globalDBdriver == 'mysql') { |
||
| 4985 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 4986 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4987 | } else { |
||
| 4988 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 4989 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 4990 | } |
||
| 4991 | } |
||
| 4992 | $query .= " GROUP BY spotter_output.airline_country, countries.iso3 |
||
| 4993 | ORDER BY airline_country_count DESC"; |
||
| 4994 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4995 | |||
| 4996 | $sth = $this->db->prepare($query); |
||
| 4997 | $sth->execute($query_values); |
||
| 4998 | |||
| 4999 | $airline_array = array(); |
||
| 5000 | $temp_array = array(); |
||
| 5001 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5002 | { |
||
| 5003 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 5004 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 5005 | $temp_array['airline_country_iso3'] = $row['airline_country_iso3']; |
||
| 5006 | |||
| 5007 | $airline_array[] = $temp_array; |
||
| 5008 | } |
||
| 5009 | return $airline_array; |
||
| 5010 | } |
||
| 5011 | |||
| 5012 | /** |
||
| 5013 | * Gets all number of flight over countries |
||
| 5014 | * |
||
| 5015 | * @return Array the airline country list |
||
| 5016 | * |
||
| 5017 | */ |
||
| 5018 | public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 5019 | { |
||
| 5020 | global $globalDBdriver; |
||
| 5021 | //$filter_query = $this->getFilter($filters,true,true); |
||
| 5022 | $Connection= new Connection($this->db); |
||
| 5023 | if (!$Connection->tableExists('countries')) return array(); |
||
| 5024 | /* |
||
| 5025 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
||
| 5026 | FROM countries c, spotter_output s |
||
| 5027 | WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; |
||
| 5028 | */ |
||
| 5029 | /* |
||
| 5030 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
||
| 5031 | FROM countries c, spotter_live s |
||
| 5032 | WHERE c.iso2 = s.over_country "; |
||
| 5033 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spottrer_live) l ON c.iso2 = l.over_country "; |
||
| 5034 | */ |
||
| 5035 | require_once('class.SpotterLive.php'); |
||
| 5036 | $SpotterLive = new SpotterLive(); |
||
| 5037 | $filter_query = $SpotterLive->getFilter($filters,true,true); |
||
| 5038 | $filter_query .= ' over_country IS NOT NULL'; |
||
| 5039 | if ($olderthanmonths > 0) { |
||
| 5040 | if ($globalDBdriver == 'mysql') { |
||
| 5041 | $filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5042 | } else { |
||
| 5043 | $filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 5044 | } |
||
| 5045 | } |
||
| 5046 | if ($sincedate != '') { |
||
| 5047 | if ($globalDBdriver == 'mysql') { |
||
| 5048 | $filter_query .= " AND spotter_live.date > '".$sincedate."' "; |
||
| 5049 | } else { |
||
| 5050 | $filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 5051 | } |
||
| 5052 | } |
||
| 5053 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country "; |
||
| 5054 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
||
| 5055 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5056 | |||
| 5057 | |||
| 5058 | $sth = $this->db->prepare($query); |
||
| 5059 | $sth->execute(); |
||
| 5060 | |||
| 5061 | $flight_array = array(); |
||
| 5062 | $temp_array = array(); |
||
| 5063 | |||
| 5064 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5065 | { |
||
| 5066 | $temp_array['flight_count'] = $row['nb']; |
||
| 5067 | $temp_array['flight_country'] = $row['name']; |
||
| 5068 | $temp_array['flight_country_iso3'] = $row['iso3']; |
||
| 5069 | $temp_array['flight_country_iso2'] = $row['iso2']; |
||
| 5070 | $flight_array[] = $temp_array; |
||
| 5071 | } |
||
| 5072 | return $flight_array; |
||
| 5073 | } |
||
| 5074 | |||
| 5075 | |||
| 5076 | /** |
||
| 5077 | * Gets all aircraft types that have flown over |
||
| 5078 | * |
||
| 5079 | * @return Array the aircraft list |
||
| 5080 | * |
||
| 5081 | */ |
||
| 5082 | public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
||
| 5083 | { |
||
| 5084 | global $globalDBdriver; |
||
| 5085 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5086 | $query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
||
| 5087 | FROM spotter_output ".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> ''"; |
||
| 5088 | if ($olderthanmonths > 0) { |
||
| 5089 | if ($globalDBdriver == 'mysql') { |
||
| 5090 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 5091 | } else { |
||
| 5092 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 5093 | } |
||
| 5094 | } |
||
| 5095 | if ($sincedate != '') { |
||
| 5096 | if ($globalDBdriver == 'mysql') { |
||
| 5097 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 5098 | } else { |
||
| 5099 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 5100 | } |
||
| 5101 | } |
||
| 5102 | $query_values = array(); |
||
| 5103 | if ($year != '') { |
||
| 5104 | if ($globalDBdriver == 'mysql') { |
||
| 5105 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 5106 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5107 | } else { |
||
| 5108 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 5109 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5110 | } |
||
| 5111 | } |
||
| 5112 | if ($month != '') { |
||
| 5113 | if ($globalDBdriver == 'mysql') { |
||
| 5114 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 5115 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5116 | } else { |
||
| 5117 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 5118 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5119 | } |
||
| 5120 | } |
||
| 5121 | if ($day != '') { |
||
| 5122 | if ($globalDBdriver == 'mysql') { |
||
| 5123 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 5124 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5125 | } else { |
||
| 5126 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 5127 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5128 | } |
||
| 5129 | } |
||
| 5130 | |||
| 5131 | $query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
||
| 5132 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5133 | |||
| 5134 | $sth = $this->db->prepare($query); |
||
| 5135 | $sth->execute($query_values); |
||
| 5136 | |||
| 5137 | $aircraft_array = array(); |
||
| 5138 | $temp_array = array(); |
||
| 5139 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5140 | { |
||
| 5141 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5142 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5143 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5144 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5145 | $aircraft_array[] = $temp_array; |
||
| 5146 | } |
||
| 5147 | return $aircraft_array; |
||
| 5148 | } |
||
| 5149 | |||
| 5150 | /** |
||
| 5151 | * Gets all aircraft types that have flown over by airline |
||
| 5152 | * |
||
| 5153 | * @return Array the aircraft list |
||
| 5154 | * |
||
| 5155 | */ |
||
| 5156 | public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '') |
||
| 5157 | { |
||
| 5158 | global $globalDBdriver; |
||
| 5159 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5160 | $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 |
||
| 5161 | 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'"; |
||
| 5162 | if ($olderthanmonths > 0) { |
||
| 5163 | if ($globalDBdriver == 'mysql') { |
||
| 5164 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 5165 | } else { |
||
| 5166 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 5167 | } |
||
| 5168 | } |
||
| 5169 | if ($sincedate != '') { |
||
| 5170 | if ($globalDBdriver == 'mysql') { |
||
| 5171 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 5172 | } else { |
||
| 5173 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 5174 | } |
||
| 5175 | } |
||
| 5176 | $query_values = array(); |
||
| 5177 | if ($year != '') { |
||
| 5178 | if ($globalDBdriver == 'mysql') { |
||
| 5179 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 5180 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5181 | } else { |
||
| 5182 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 5183 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5184 | } |
||
| 5185 | } |
||
| 5186 | if ($month != '') { |
||
| 5187 | if ($globalDBdriver == 'mysql') { |
||
| 5188 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 5189 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5190 | } else { |
||
| 5191 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 5192 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5193 | } |
||
| 5194 | } |
||
| 5195 | if ($day != '') { |
||
| 5196 | if ($globalDBdriver == 'mysql') { |
||
| 5197 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 5198 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5199 | } else { |
||
| 5200 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 5201 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5202 | } |
||
| 5203 | } |
||
| 5204 | |||
| 5205 | $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"; |
||
| 5206 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5207 | |||
| 5208 | $sth = $this->db->prepare($query); |
||
| 5209 | $sth->execute($query_values); |
||
| 5210 | |||
| 5211 | $aircraft_array = array(); |
||
| 5212 | $temp_array = array(); |
||
| 5213 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5214 | { |
||
| 5215 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 5216 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5217 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5218 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5219 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5220 | $aircraft_array[] = $temp_array; |
||
| 5221 | } |
||
| 5222 | return $aircraft_array; |
||
| 5223 | } |
||
| 5224 | |||
| 5225 | /** |
||
| 5226 | * Gets all aircraft types that have flown over by months |
||
| 5227 | * |
||
| 5228 | * @return Array the aircraft list |
||
| 5229 | * |
||
| 5230 | */ |
||
| 5231 | public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 5232 | { |
||
| 5233 | global $globalDBdriver; |
||
| 5234 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5235 | $query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
||
| 5236 | 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' "; |
||
| 5237 | if ($olderthanmonths > 0) { |
||
| 5238 | if ($globalDBdriver == 'mysql') { |
||
| 5239 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5240 | } else { |
||
| 5241 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 5242 | } |
||
| 5243 | } |
||
| 5244 | if ($sincedate != '') { |
||
| 5245 | if ($globalDBdriver == 'mysql') { |
||
| 5246 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 5247 | } else { |
||
| 5248 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 5249 | } |
||
| 5250 | } |
||
| 5251 | |||
| 5252 | $query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
||
| 5253 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5254 | |||
| 5255 | $sth = $this->db->prepare($query); |
||
| 5256 | $sth->execute(); |
||
| 5257 | |||
| 5258 | $aircraft_array = array(); |
||
| 5259 | $temp_array = array(); |
||
| 5260 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5261 | { |
||
| 5262 | //$temp_array['airline_icao'] = $row['airline_icao']; |
||
| 5263 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5264 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5265 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5266 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5267 | $aircraft_array[] = $temp_array; |
||
| 5268 | } |
||
| 5269 | return $aircraft_array; |
||
| 5270 | } |
||
| 5271 | |||
| 5272 | |||
| 5273 | /** |
||
| 5274 | * Gets all aircraft registration that have flown over by aircaft icao |
||
| 5275 | * |
||
| 5276 | * @return Array the aircraft list |
||
| 5277 | * |
||
| 5278 | */ |
||
| 5279 | public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array()) |
||
| 5280 | { |
||
| 5281 | $Image = new Image($this->db); |
||
| 5282 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5283 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 5284 | |||
| 5285 | $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 |
||
| 5286 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 5287 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
||
| 5288 | ORDER BY registration_count DESC"; |
||
| 5289 | |||
| 5290 | $sth = $this->db->prepare($query); |
||
| 5291 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 5292 | |||
| 5293 | $aircraft_array = array(); |
||
| 5294 | $temp_array = array(); |
||
| 5295 | |||
| 5296 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5297 | { |
||
| 5298 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5299 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5300 | $temp_array['registration'] = $row['registration']; |
||
| 5301 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5302 | $temp_array['image_thumbnail'] = ""; |
||
| 5303 | if($row['registration'] != "") |
||
| 5304 | { |
||
| 5305 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5306 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5307 | } |
||
| 5308 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5309 | |||
| 5310 | $aircraft_array[] = $temp_array; |
||
| 5311 | } |
||
| 5312 | return $aircraft_array; |
||
| 5313 | } |
||
| 5314 | |||
| 5315 | |||
| 5316 | /** |
||
| 5317 | * Gets all aircraft types that have flown over by airline icao |
||
| 5318 | * |
||
| 5319 | * @return Array the aircraft list |
||
| 5320 | * |
||
| 5321 | */ |
||
| 5322 | public function countAllAircraftTypesByAirline($airline_icao,$filters = array()) |
||
| 5323 | { |
||
| 5324 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5325 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 5326 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5327 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 5328 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 5329 | ORDER BY aircraft_icao_count DESC"; |
||
| 5330 | |||
| 5331 | $sth = $this->db->prepare($query); |
||
| 5332 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 5333 | |||
| 5334 | $aircraft_array = array(); |
||
| 5335 | $temp_array = array(); |
||
| 5336 | |||
| 5337 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5338 | { |
||
| 5339 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5340 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5341 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5342 | |||
| 5343 | $aircraft_array[] = $temp_array; |
||
| 5344 | } |
||
| 5345 | return $aircraft_array; |
||
| 5346 | } |
||
| 5347 | |||
| 5348 | |||
| 5349 | /** |
||
| 5350 | * Gets all aircraft registration that have flown over by airline icao |
||
| 5351 | * |
||
| 5352 | * @return Array the aircraft list |
||
| 5353 | * |
||
| 5354 | */ |
||
| 5355 | public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array()) |
||
| 5356 | { |
||
| 5357 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5358 | $Image = new Image($this->db); |
||
| 5359 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 5360 | |||
| 5361 | $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 |
||
| 5362 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 5363 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 5364 | ORDER BY registration_count DESC"; |
||
| 5365 | |||
| 5366 | $sth = $this->db->prepare($query); |
||
| 5367 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 5368 | |||
| 5369 | $aircraft_array = array(); |
||
| 5370 | $temp_array = array(); |
||
| 5371 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5372 | { |
||
| 5373 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5374 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5375 | $temp_array['registration'] = $row['registration']; |
||
| 5376 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5377 | $temp_array['image_thumbnail'] = ""; |
||
| 5378 | if($row['registration'] != "") |
||
| 5379 | { |
||
| 5380 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5381 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5382 | } |
||
| 5383 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5384 | |||
| 5385 | $aircraft_array[] = $temp_array; |
||
| 5386 | } |
||
| 5387 | return $aircraft_array; |
||
| 5388 | } |
||
| 5389 | |||
| 5390 | |||
| 5391 | /** |
||
| 5392 | * Gets all aircraft manufacturer that have flown over by airline icao |
||
| 5393 | * |
||
| 5394 | * @return Array the aircraft list |
||
| 5395 | * |
||
| 5396 | */ |
||
| 5397 | public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array()) |
||
| 5398 | { |
||
| 5399 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5400 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 5401 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5402 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 5403 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5404 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5405 | |||
| 5406 | $sth = $this->db->prepare($query); |
||
| 5407 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 5408 | |||
| 5409 | $aircraft_array = array(); |
||
| 5410 | $temp_array = array(); |
||
| 5411 | |||
| 5412 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5413 | { |
||
| 5414 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5415 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 5416 | |||
| 5417 | $aircraft_array[] = $temp_array; |
||
| 5418 | } |
||
| 5419 | return $aircraft_array; |
||
| 5420 | } |
||
| 5421 | |||
| 5422 | |||
| 5423 | /** |
||
| 5424 | * Gets all aircraft types that have flown over by airline icao |
||
| 5425 | * |
||
| 5426 | * @return Array the aircraft list |
||
| 5427 | * |
||
| 5428 | */ |
||
| 5429 | public function countAllAircraftTypesByAirport($airport_icao,$filters = array()) |
||
| 5430 | { |
||
| 5431 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5432 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 5433 | |||
| 5434 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5435 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
||
| 5436 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 5437 | ORDER BY aircraft_icao_count DESC"; |
||
| 5438 | |||
| 5439 | $sth = $this->db->prepare($query); |
||
| 5440 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 5441 | |||
| 5442 | $aircraft_array = array(); |
||
| 5443 | $temp_array = array(); |
||
| 5444 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5445 | { |
||
| 5446 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5447 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5448 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5449 | |||
| 5450 | $aircraft_array[] = $temp_array; |
||
| 5451 | } |
||
| 5452 | return $aircraft_array; |
||
| 5453 | } |
||
| 5454 | |||
| 5455 | |||
| 5456 | /** |
||
| 5457 | * Gets all aircraft registration that have flown over by airport icao |
||
| 5458 | * |
||
| 5459 | * @return Array the aircraft list |
||
| 5460 | * |
||
| 5461 | */ |
||
| 5462 | public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array()) |
||
| 5463 | { |
||
| 5464 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5465 | $Image = new Image($this->db); |
||
| 5466 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 5467 | |||
| 5468 | $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 |
||
| 5469 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
||
| 5470 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 5471 | ORDER BY registration_count DESC"; |
||
| 5472 | |||
| 5473 | $sth = $this->db->prepare($query); |
||
| 5474 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 5475 | |||
| 5476 | $aircraft_array = array(); |
||
| 5477 | $temp_array = array(); |
||
| 5478 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5479 | { |
||
| 5480 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5481 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5482 | $temp_array['registration'] = $row['registration']; |
||
| 5483 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5484 | $temp_array['image_thumbnail'] = ""; |
||
| 5485 | if($row['registration'] != "") |
||
| 5486 | { |
||
| 5487 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5488 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5489 | } |
||
| 5490 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5491 | $aircraft_array[] = $temp_array; |
||
| 5492 | } |
||
| 5493 | return $aircraft_array; |
||
| 5494 | } |
||
| 5495 | |||
| 5496 | |||
| 5497 | /** |
||
| 5498 | * Gets all aircraft manufacturer that have flown over by airport icao |
||
| 5499 | * |
||
| 5500 | * @return Array the aircraft list |
||
| 5501 | * |
||
| 5502 | */ |
||
| 5503 | public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array()) |
||
| 5504 | { |
||
| 5505 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5506 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 5507 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5508 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
||
| 5509 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5510 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5511 | |||
| 5512 | |||
| 5513 | $sth = $this->db->prepare($query); |
||
| 5514 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 5515 | |||
| 5516 | $aircraft_array = array(); |
||
| 5517 | $temp_array = array(); |
||
| 5518 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5519 | { |
||
| 5520 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5521 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 5522 | $aircraft_array[] = $temp_array; |
||
| 5523 | } |
||
| 5524 | return $aircraft_array; |
||
| 5525 | } |
||
| 5526 | |||
| 5527 | /** |
||
| 5528 | * Gets all aircraft types that have flown over by aircraft manufacturer |
||
| 5529 | * |
||
| 5530 | * @return Array the aircraft list |
||
| 5531 | * |
||
| 5532 | */ |
||
| 5533 | public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 5534 | { |
||
| 5535 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5536 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 5537 | |||
| 5538 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5539 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 5540 | GROUP BY spotter_output.aircraft_name |
||
| 5541 | ORDER BY aircraft_icao_count DESC"; |
||
| 5542 | |||
| 5543 | $sth = $this->db->prepare($query); |
||
| 5544 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 5545 | $aircraft_array = array(); |
||
| 5546 | $temp_array = array(); |
||
| 5547 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5548 | { |
||
| 5549 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5550 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5551 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5552 | $aircraft_array[] = $temp_array; |
||
| 5553 | } |
||
| 5554 | return $aircraft_array; |
||
| 5555 | } |
||
| 5556 | |||
| 5557 | |||
| 5558 | /** |
||
| 5559 | * Gets all aircraft registration that have flown over by aircaft manufacturer |
||
| 5560 | * |
||
| 5561 | * @return Array the aircraft list |
||
| 5562 | * |
||
| 5563 | */ |
||
| 5564 | public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array()) |
||
| 5565 | { |
||
| 5566 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5567 | $Image = new Image($this->db); |
||
| 5568 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 5569 | |||
| 5570 | $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 |
||
| 5571 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 5572 | GROUP BY spotter_output.registration |
||
| 5573 | ORDER BY registration_count DESC"; |
||
| 5574 | |||
| 5575 | |||
| 5576 | $sth = $this->db->prepare($query); |
||
| 5577 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 5578 | $aircraft_array = array(); |
||
| 5579 | $temp_array = array(); |
||
| 5580 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5581 | { |
||
| 5582 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5583 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5584 | $temp_array['registration'] = $row['registration']; |
||
| 5585 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5586 | $temp_array['image_thumbnail'] = ""; |
||
| 5587 | if($row['registration'] != "") |
||
| 5588 | { |
||
| 5589 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5590 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5591 | } |
||
| 5592 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5593 | $aircraft_array[] = $temp_array; |
||
| 5594 | } |
||
| 5595 | return $aircraft_array; |
||
| 5596 | } |
||
| 5597 | |||
| 5598 | /** |
||
| 5599 | * Gets all aircraft types that have flown over by date |
||
| 5600 | * |
||
| 5601 | * @return Array the aircraft list |
||
| 5602 | * |
||
| 5603 | */ |
||
| 5604 | public function countAllAircraftTypesByDate($date,$filters = array()) |
||
| 5605 | { |
||
| 5606 | global $globalTimezone, $globalDBdriver; |
||
| 5607 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5608 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 5609 | if ($globalTimezone != '') { |
||
| 5610 | date_default_timezone_set($globalTimezone); |
||
| 5611 | $datetime = new DateTime($date); |
||
| 5612 | $offset = $datetime->format('P'); |
||
| 5613 | } else $offset = '+00:00'; |
||
| 5614 | |||
| 5615 | if ($globalDBdriver == 'mysql') { |
||
| 5616 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5617 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 5618 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 5619 | ORDER BY aircraft_icao_count DESC"; |
||
| 5620 | } else { |
||
| 5621 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5622 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 5623 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 5624 | ORDER BY aircraft_icao_count DESC"; |
||
| 5625 | } |
||
| 5626 | |||
| 5627 | $sth = $this->db->prepare($query); |
||
| 5628 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 5629 | |||
| 5630 | $aircraft_array = array(); |
||
| 5631 | $temp_array = array(); |
||
| 5632 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5633 | { |
||
| 5634 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5635 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5636 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5637 | |||
| 5638 | $aircraft_array[] = $temp_array; |
||
| 5639 | } |
||
| 5640 | return $aircraft_array; |
||
| 5641 | } |
||
| 5642 | |||
| 5643 | |||
| 5644 | /** |
||
| 5645 | * Gets all aircraft registration that have flown over by date |
||
| 5646 | * |
||
| 5647 | * @return Array the aircraft list |
||
| 5648 | * |
||
| 5649 | */ |
||
| 5650 | public function countAllAircraftRegistrationByDate($date,$filters = array()) |
||
| 5651 | { |
||
| 5652 | global $globalTimezone, $globalDBdriver; |
||
| 5653 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5654 | $Image = new Image($this->db); |
||
| 5655 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 5656 | if ($globalTimezone != '') { |
||
| 5657 | date_default_timezone_set($globalTimezone); |
||
| 5658 | $datetime = new DateTime($date); |
||
| 5659 | $offset = $datetime->format('P'); |
||
| 5660 | } else $offset = '+00:00'; |
||
| 5661 | |||
| 5662 | if ($globalDBdriver == 'mysql') { |
||
| 5663 | $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 |
||
| 5664 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 5665 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 5666 | ORDER BY registration_count DESC"; |
||
| 5667 | } else { |
||
| 5668 | $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 |
||
| 5669 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 5670 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 5671 | ORDER BY registration_count DESC"; |
||
| 5672 | } |
||
| 5673 | |||
| 5674 | $sth = $this->db->prepare($query); |
||
| 5675 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 5676 | |||
| 5677 | $aircraft_array = array(); |
||
| 5678 | $temp_array = array(); |
||
| 5679 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5680 | { |
||
| 5681 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5682 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5683 | $temp_array['registration'] = $row['registration']; |
||
| 5684 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5685 | $temp_array['image_thumbnail'] = ""; |
||
| 5686 | if($row['registration'] != "") |
||
| 5687 | { |
||
| 5688 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5689 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5690 | } |
||
| 5691 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5692 | |||
| 5693 | $aircraft_array[] = $temp_array; |
||
| 5694 | } |
||
| 5695 | return $aircraft_array; |
||
| 5696 | } |
||
| 5697 | |||
| 5698 | |||
| 5699 | /** |
||
| 5700 | * Gets all aircraft manufacturer that have flown over by date |
||
| 5701 | * |
||
| 5702 | * @return Array the aircraft manufacturer list |
||
| 5703 | * |
||
| 5704 | */ |
||
| 5705 | public function countAllAircraftManufacturerByDate($date,$filters = array()) |
||
| 5706 | { |
||
| 5707 | global $globalTimezone, $globalDBdriver; |
||
| 5708 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5709 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 5710 | if ($globalTimezone != '') { |
||
| 5711 | date_default_timezone_set($globalTimezone); |
||
| 5712 | $datetime = new DateTime($date); |
||
| 5713 | $offset = $datetime->format('P'); |
||
| 5714 | } else $offset = '+00:00'; |
||
| 5715 | |||
| 5716 | if ($globalDBdriver == 'mysql') { |
||
| 5717 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5718 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 5719 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5720 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5721 | } else { |
||
| 5722 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5723 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 5724 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5725 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5726 | } |
||
| 5727 | |||
| 5728 | $sth = $this->db->prepare($query); |
||
| 5729 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 5730 | |||
| 5731 | $aircraft_array = array(); |
||
| 5732 | $temp_array = array(); |
||
| 5733 | |||
| 5734 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5735 | { |
||
| 5736 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5737 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 5738 | |||
| 5739 | $aircraft_array[] = $temp_array; |
||
| 5740 | } |
||
| 5741 | return $aircraft_array; |
||
| 5742 | } |
||
| 5743 | |||
| 5744 | |||
| 5745 | /** |
||
| 5746 | * Gets all aircraft types that have flown over by ident/callsign |
||
| 5747 | * |
||
| 5748 | * @return Array the aircraft list |
||
| 5749 | * |
||
| 5750 | */ |
||
| 5751 | public function countAllAircraftTypesByIdent($ident,$filters = array()) |
||
| 5752 | { |
||
| 5753 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5754 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 5755 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5756 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
||
| 5757 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 5758 | ORDER BY aircraft_icao_count DESC"; |
||
| 5759 | |||
| 5760 | $sth = $this->db->prepare($query); |
||
| 5761 | $sth->execute(array(':ident' => $ident)); |
||
| 5762 | |||
| 5763 | $aircraft_array = array(); |
||
| 5764 | $temp_array = array(); |
||
| 5765 | |||
| 5766 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5767 | { |
||
| 5768 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5769 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5770 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5771 | |||
| 5772 | $aircraft_array[] = $temp_array; |
||
| 5773 | } |
||
| 5774 | return $aircraft_array; |
||
| 5775 | } |
||
| 5776 | |||
| 5777 | /** |
||
| 5778 | * Gets all aircraft types that have flown over by pilot |
||
| 5779 | * |
||
| 5780 | * @return Array the aircraft list |
||
| 5781 | * |
||
| 5782 | */ |
||
| 5783 | public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
||
| 5784 | { |
||
| 5785 | global $globalDBdriver; |
||
| 5786 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5787 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 5788 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5789 | FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)"; |
||
| 5790 | $query_values = array(); |
||
| 5791 | if ($year != '') { |
||
| 5792 | if ($globalDBdriver == 'mysql') { |
||
| 5793 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 5794 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5795 | } else { |
||
| 5796 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 5797 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5798 | } |
||
| 5799 | } |
||
| 5800 | if ($month != '') { |
||
| 5801 | if ($globalDBdriver == 'mysql') { |
||
| 5802 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 5803 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5804 | } else { |
||
| 5805 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 5806 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5807 | } |
||
| 5808 | } |
||
| 5809 | if ($day != '') { |
||
| 5810 | if ($globalDBdriver == 'mysql') { |
||
| 5811 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 5812 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5813 | } else { |
||
| 5814 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 5815 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5816 | } |
||
| 5817 | } |
||
| 5818 | |||
| 5819 | $query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 5820 | ORDER BY aircraft_icao_count DESC"; |
||
| 5821 | $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
||
| 5822 | $sth = $this->db->prepare($query); |
||
| 5823 | $sth->execute($query_values); |
||
| 5824 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 5825 | } |
||
| 5826 | |||
| 5827 | /** |
||
| 5828 | * Gets all aircraft types that have flown over by owner |
||
| 5829 | * |
||
| 5830 | * @return Array the aircraft list |
||
| 5831 | * |
||
| 5832 | */ |
||
| 5833 | public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
||
| 5834 | { |
||
| 5835 | global $globalDBdriver; |
||
| 5836 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5837 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 5838 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
||
| 5839 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner"; |
||
| 5840 | $query_values = array(); |
||
| 5841 | if ($year != '') { |
||
| 5842 | if ($globalDBdriver == 'mysql') { |
||
| 5843 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 5844 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5845 | } else { |
||
| 5846 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 5847 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5848 | } |
||
| 5849 | } |
||
| 5850 | if ($month != '') { |
||
| 5851 | if ($globalDBdriver == 'mysql') { |
||
| 5852 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 5853 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5854 | } else { |
||
| 5855 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 5856 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5857 | } |
||
| 5858 | } |
||
| 5859 | if ($day != '') { |
||
| 5860 | if ($globalDBdriver == 'mysql') { |
||
| 5861 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 5862 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5863 | } else { |
||
| 5864 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 5865 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5866 | } |
||
| 5867 | } |
||
| 5868 | $query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao |
||
| 5869 | ORDER BY aircraft_icao_count DESC"; |
||
| 5870 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 5871 | $sth = $this->db->prepare($query); |
||
| 5872 | $sth->execute($query_values); |
||
| 5873 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 5874 | } |
||
| 5875 | |||
| 5876 | /** |
||
| 5877 | * Gets all aircraft registration that have flown over by ident/callsign |
||
| 5878 | * |
||
| 5879 | * @return Array the aircraft list |
||
| 5880 | * |
||
| 5881 | */ |
||
| 5882 | public function countAllAircraftRegistrationByIdent($ident,$filters = array()) |
||
| 5883 | { |
||
| 5884 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5885 | $Image = new Image($this->db); |
||
| 5886 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 5887 | |||
| 5888 | $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 |
||
| 5889 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident |
||
| 5890 | GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 5891 | ORDER BY registration_count DESC"; |
||
| 5892 | |||
| 5893 | |||
| 5894 | $sth = $this->db->prepare($query); |
||
| 5895 | $sth->execute(array(':ident' => $ident)); |
||
| 5896 | |||
| 5897 | $aircraft_array = array(); |
||
| 5898 | $temp_array = array(); |
||
| 5899 | |||
| 5900 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5901 | { |
||
| 5902 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5903 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5904 | $temp_array['registration'] = $row['registration']; |
||
| 5905 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5906 | $temp_array['image_thumbnail'] = ""; |
||
| 5907 | if($row['registration'] != "") |
||
| 5908 | { |
||
| 5909 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5910 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5911 | else $temp_array['image_thumbnail'] = ''; |
||
| 5912 | } |
||
| 5913 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5914 | $aircraft_array[] = $temp_array; |
||
| 5915 | } |
||
| 5916 | return $aircraft_array; |
||
| 5917 | } |
||
| 5918 | |||
| 5919 | /** |
||
| 5920 | * Gets all aircraft registration that have flown over by owner |
||
| 5921 | * |
||
| 5922 | * @return Array the aircraft list |
||
| 5923 | * |
||
| 5924 | */ |
||
| 5925 | public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
||
| 5926 | { |
||
| 5927 | global $globalDBdriver; |
||
| 5928 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5929 | $Image = new Image($this->db); |
||
| 5930 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 5931 | |||
| 5932 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name |
||
| 5933 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner"; |
||
| 5934 | $query_values = array(); |
||
| 5935 | if ($year != '') { |
||
| 5936 | if ($globalDBdriver == 'mysql') { |
||
| 5937 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 5938 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5939 | } else { |
||
| 5940 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 5941 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 5942 | } |
||
| 5943 | } |
||
| 5944 | if ($month != '') { |
||
| 5945 | if ($globalDBdriver == 'mysql') { |
||
| 5946 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 5947 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5948 | } else { |
||
| 5949 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 5950 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 5951 | } |
||
| 5952 | } |
||
| 5953 | if ($day != '') { |
||
| 5954 | if ($globalDBdriver == 'mysql') { |
||
| 5955 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 5956 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5957 | } else { |
||
| 5958 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 5959 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 5960 | } |
||
| 5961 | } |
||
| 5962 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 5963 | |||
| 5964 | $query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name |
||
| 5965 | ORDER BY registration_count DESC"; |
||
| 5966 | |||
| 5967 | |||
| 5968 | $sth = $this->db->prepare($query); |
||
| 5969 | $sth->execute($query_values); |
||
| 5970 | |||
| 5971 | $aircraft_array = array(); |
||
| 5972 | $temp_array = array(); |
||
| 5973 | |||
| 5974 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5975 | { |
||
| 5976 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5977 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5978 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5979 | $temp_array['registration'] = $row['registration']; |
||
| 5980 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5981 | $temp_array['image_thumbnail'] = ""; |
||
| 5982 | if($row['registration'] != "") |
||
| 5983 | { |
||
| 5984 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5985 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5986 | else $temp_array['image_thumbnail'] = ''; |
||
| 5987 | } |
||
| 5988 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5989 | $aircraft_array[] = $temp_array; |
||
| 5990 | } |
||
| 5991 | return $aircraft_array; |
||
| 5992 | } |
||
| 5993 | |||
| 5994 | /** |
||
| 5995 | * Gets all aircraft registration that have flown over by pilot |
||
| 5996 | * |
||
| 5997 | * @return Array the aircraft list |
||
| 5998 | * |
||
| 5999 | */ |
||
| 6000 | public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
||
| 6001 | { |
||
| 6002 | global $globalDBdriver; |
||
| 6003 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6004 | $Image = new Image($this->db); |
||
| 6005 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 6006 | |||
| 6007 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name |
||
| 6008 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; |
||
| 6009 | $query_values = array(); |
||
| 6010 | if ($year != '') { |
||
| 6011 | if ($globalDBdriver == 'mysql') { |
||
| 6012 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6013 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6014 | } else { |
||
| 6015 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6016 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6017 | } |
||
| 6018 | } |
||
| 6019 | if ($month != '') { |
||
| 6020 | if ($globalDBdriver == 'mysql') { |
||
| 6021 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6022 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6023 | } else { |
||
| 6024 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6025 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6026 | } |
||
| 6027 | } |
||
| 6028 | if ($day != '') { |
||
| 6029 | if ($globalDBdriver == 'mysql') { |
||
| 6030 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6031 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6032 | } else { |
||
| 6033 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6034 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6035 | } |
||
| 6036 | } |
||
| 6037 | $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
||
| 6038 | |||
| 6039 | $query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name |
||
| 6040 | ORDER BY registration_count DESC"; |
||
| 6041 | |||
| 6042 | |||
| 6043 | $sth = $this->db->prepare($query); |
||
| 6044 | $sth->execute($query_values); |
||
| 6045 | |||
| 6046 | $aircraft_array = array(); |
||
| 6047 | $temp_array = array(); |
||
| 6048 | |||
| 6049 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6050 | { |
||
| 6051 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6052 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6053 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 6054 | $temp_array['registration'] = $row['registration']; |
||
| 6055 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 6056 | $temp_array['image_thumbnail'] = ""; |
||
| 6057 | if($row['registration'] != "") |
||
| 6058 | { |
||
| 6059 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 6060 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 6061 | else $temp_array['image_thumbnail'] = ''; |
||
| 6062 | } |
||
| 6063 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 6064 | $aircraft_array[] = $temp_array; |
||
| 6065 | } |
||
| 6066 | return $aircraft_array; |
||
| 6067 | } |
||
| 6068 | |||
| 6069 | |||
| 6070 | /** |
||
| 6071 | * Gets all aircraft manufacturer that have flown over by ident/callsign |
||
| 6072 | * |
||
| 6073 | * @return Array the aircraft manufacturer list |
||
| 6074 | * |
||
| 6075 | */ |
||
| 6076 | public function countAllAircraftManufacturerByIdent($ident,$filters = array()) |
||
| 6077 | { |
||
| 6078 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6079 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 6080 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 6081 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident |
||
| 6082 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 6083 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 6084 | |||
| 6085 | |||
| 6086 | $sth = $this->db->prepare($query); |
||
| 6087 | $sth->execute(array(':ident' => $ident)); |
||
| 6088 | $aircraft_array = array(); |
||
| 6089 | $temp_array = array(); |
||
| 6090 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6091 | { |
||
| 6092 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 6093 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 6094 | $aircraft_array[] = $temp_array; |
||
| 6095 | } |
||
| 6096 | return $aircraft_array; |
||
| 6097 | } |
||
| 6098 | |||
| 6099 | /** |
||
| 6100 | * Gets all aircraft manufacturer that have flown over by owner |
||
| 6101 | * |
||
| 6102 | * @return Array the aircraft manufacturer list |
||
| 6103 | * |
||
| 6104 | */ |
||
| 6105 | public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
||
| 6106 | { |
||
| 6107 | global $globalDBdriver; |
||
| 6108 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6109 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 6110 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 6111 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner"; |
||
| 6112 | $query_values = array(); |
||
| 6113 | if ($year != '') { |
||
| 6114 | if ($globalDBdriver == 'mysql') { |
||
| 6115 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6116 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6117 | } else { |
||
| 6118 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6119 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6120 | } |
||
| 6121 | } |
||
| 6122 | if ($month != '') { |
||
| 6123 | if ($globalDBdriver == 'mysql') { |
||
| 6124 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6125 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6126 | } else { |
||
| 6127 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6128 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6129 | } |
||
| 6130 | } |
||
| 6131 | if ($day != '') { |
||
| 6132 | if ($globalDBdriver == 'mysql') { |
||
| 6133 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6134 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6135 | } else { |
||
| 6136 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6137 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6138 | } |
||
| 6139 | } |
||
| 6140 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 6141 | |||
| 6142 | $query .= " GROUP BY spotter_output.aircraft_manufacturer |
||
| 6143 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 6144 | |||
| 6145 | |||
| 6146 | $sth = $this->db->prepare($query); |
||
| 6147 | $sth->execute($query_values); |
||
| 6148 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 6149 | } |
||
| 6150 | |||
| 6151 | /** |
||
| 6152 | * Gets all aircraft manufacturer that have flown over by pilot |
||
| 6153 | * |
||
| 6154 | * @return Array the aircraft manufacturer list |
||
| 6155 | * |
||
| 6156 | */ |
||
| 6157 | public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
||
| 6158 | { |
||
| 6159 | global $globalDBdriver; |
||
| 6160 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6161 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 6162 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 6163 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; |
||
| 6164 | $query_values = array(); |
||
| 6165 | if ($year != '') { |
||
| 6166 | if ($globalDBdriver == 'mysql') { |
||
| 6167 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6168 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6169 | } else { |
||
| 6170 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6171 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6172 | } |
||
| 6173 | } |
||
| 6174 | if ($month != '') { |
||
| 6175 | if ($globalDBdriver == 'mysql') { |
||
| 6176 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6177 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6178 | } else { |
||
| 6179 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6180 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6181 | } |
||
| 6182 | } |
||
| 6183 | if ($day != '') { |
||
| 6184 | if ($globalDBdriver == 'mysql') { |
||
| 6185 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6186 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6187 | } else { |
||
| 6188 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6189 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6190 | } |
||
| 6191 | } |
||
| 6192 | $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
||
| 6193 | |||
| 6194 | $query .= " GROUP BY spotter_output.aircraft_manufacturer |
||
| 6195 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 6196 | |||
| 6197 | |||
| 6198 | $sth = $this->db->prepare($query); |
||
| 6199 | $sth->execute($query_values); |
||
| 6200 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 6201 | } |
||
| 6202 | |||
| 6203 | |||
| 6204 | /** |
||
| 6205 | * Gets all aircraft types that have flown over by route |
||
| 6206 | * |
||
| 6207 | * @return Array the aircraft list |
||
| 6208 | * |
||
| 6209 | */ |
||
| 6210 | public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 6211 | { |
||
| 6212 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6213 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 6214 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 6215 | |||
| 6216 | |||
| 6217 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 6218 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 6219 | GROUP BY spotter_output.aircraft_name |
||
| 6220 | ORDER BY aircraft_icao_count DESC"; |
||
| 6221 | |||
| 6222 | |||
| 6223 | $sth = $this->db->prepare($query); |
||
| 6224 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 6225 | $aircraft_array = array(); |
||
| 6226 | $temp_array = array(); |
||
| 6227 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6228 | { |
||
| 6229 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6230 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6231 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 6232 | $aircraft_array[] = $temp_array; |
||
| 6233 | } |
||
| 6234 | return $aircraft_array; |
||
| 6235 | } |
||
| 6236 | |||
| 6237 | /** |
||
| 6238 | * Gets all aircraft registration that have flown over by route |
||
| 6239 | * |
||
| 6240 | * @return Array the aircraft list |
||
| 6241 | * |
||
| 6242 | */ |
||
| 6243 | public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 6244 | { |
||
| 6245 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6246 | $Image = new Image($this->db); |
||
| 6247 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 6248 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 6249 | |||
| 6250 | $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 |
||
| 6251 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 6252 | GROUP BY spotter_output.registration |
||
| 6253 | ORDER BY registration_count DESC"; |
||
| 6254 | |||
| 6255 | |||
| 6256 | $sth = $this->db->prepare($query); |
||
| 6257 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 6258 | |||
| 6259 | $aircraft_array = array(); |
||
| 6260 | $temp_array = array(); |
||
| 6261 | |||
| 6262 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6263 | { |
||
| 6264 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6265 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6266 | $temp_array['registration'] = $row['registration']; |
||
| 6267 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 6268 | $temp_array['image_thumbnail'] = ""; |
||
| 6269 | if($row['registration'] != "") |
||
| 6270 | { |
||
| 6271 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 6272 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 6273 | } |
||
| 6274 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 6275 | |||
| 6276 | $aircraft_array[] = $temp_array; |
||
| 6277 | } |
||
| 6278 | |||
| 6279 | return $aircraft_array; |
||
| 6280 | } |
||
| 6281 | |||
| 6282 | |||
| 6283 | /** |
||
| 6284 | * Gets all aircraft manufacturer that have flown over by route |
||
| 6285 | * |
||
| 6286 | * @return Array the aircraft manufacturer list |
||
| 6287 | * |
||
| 6288 | */ |
||
| 6289 | public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 6290 | { |
||
| 6291 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6292 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 6293 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 6294 | |||
| 6295 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 6296 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 6297 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 6298 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 6299 | |||
| 6300 | |||
| 6301 | $sth = $this->db->prepare($query); |
||
| 6302 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 6303 | |||
| 6304 | $aircraft_array = array(); |
||
| 6305 | $temp_array = array(); |
||
| 6306 | |||
| 6307 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6308 | { |
||
| 6309 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 6310 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 6311 | |||
| 6312 | $aircraft_array[] = $temp_array; |
||
| 6313 | } |
||
| 6314 | |||
| 6315 | return $aircraft_array; |
||
| 6316 | } |
||
| 6317 | |||
| 6318 | |||
| 6319 | |||
| 6320 | |||
| 6321 | /** |
||
| 6322 | * Gets all aircraft types that have flown over by country |
||
| 6323 | * |
||
| 6324 | * @return Array the aircraft list |
||
| 6325 | * |
||
| 6326 | */ |
||
| 6327 | public function countAllAircraftTypesByCountry($country,$filters = array()) |
||
| 6328 | { |
||
| 6329 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6330 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 6331 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 6332 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 6333 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 6334 | ORDER BY aircraft_icao_count DESC"; |
||
| 6335 | |||
| 6336 | |||
| 6337 | $sth = $this->db->prepare($query); |
||
| 6338 | $sth->execute(array(':country' => $country)); |
||
| 6339 | |||
| 6340 | $aircraft_array = array(); |
||
| 6341 | $temp_array = array(); |
||
| 6342 | |||
| 6343 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6344 | { |
||
| 6345 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6346 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6347 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 6348 | |||
| 6349 | $aircraft_array[] = $temp_array; |
||
| 6350 | } |
||
| 6351 | |||
| 6352 | return $aircraft_array; |
||
| 6353 | } |
||
| 6354 | |||
| 6355 | |||
| 6356 | /** |
||
| 6357 | * Gets all aircraft registration that have flown over by country |
||
| 6358 | * |
||
| 6359 | * @return Array the aircraft list |
||
| 6360 | * |
||
| 6361 | */ |
||
| 6362 | public function countAllAircraftRegistrationByCountry($country,$filters = array()) |
||
| 6363 | { |
||
| 6364 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6365 | $Image = new Image($this->db); |
||
| 6366 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 6367 | $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 |
||
| 6368 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) |
||
| 6369 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 6370 | ORDER BY registration_count DESC"; |
||
| 6371 | |||
| 6372 | |||
| 6373 | $sth = $this->db->prepare($query); |
||
| 6374 | $sth->execute(array(':country' => $country)); |
||
| 6375 | |||
| 6376 | $aircraft_array = array(); |
||
| 6377 | $temp_array = array(); |
||
| 6378 | |||
| 6379 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6380 | { |
||
| 6381 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6382 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6383 | $temp_array['registration'] = $row['registration']; |
||
| 6384 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 6385 | $temp_array['image_thumbnail'] = ""; |
||
| 6386 | if($row['registration'] != "") |
||
| 6387 | { |
||
| 6388 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 6389 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 6390 | } |
||
| 6391 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 6392 | |||
| 6393 | $aircraft_array[] = $temp_array; |
||
| 6394 | } |
||
| 6395 | |||
| 6396 | return $aircraft_array; |
||
| 6397 | } |
||
| 6398 | |||
| 6399 | |||
| 6400 | /** |
||
| 6401 | * Gets all aircraft manufacturer that have flown over by country |
||
| 6402 | * |
||
| 6403 | * @return Array the aircraft manufacturer list |
||
| 6404 | * |
||
| 6405 | */ |
||
| 6406 | public function countAllAircraftManufacturerByCountry($country,$filters = array()) |
||
| 6407 | { |
||
| 6408 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6409 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 6410 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 6411 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) |
||
| 6412 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 6413 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 6414 | |||
| 6415 | |||
| 6416 | $sth = $this->db->prepare($query); |
||
| 6417 | $sth->execute(array(':country' => $country)); |
||
| 6418 | |||
| 6419 | $aircraft_array = array(); |
||
| 6420 | $temp_array = array(); |
||
| 6421 | |||
| 6422 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6423 | { |
||
| 6424 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 6425 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 6426 | |||
| 6427 | $aircraft_array[] = $temp_array; |
||
| 6428 | } |
||
| 6429 | |||
| 6430 | return $aircraft_array; |
||
| 6431 | } |
||
| 6432 | |||
| 6433 | |||
| 6434 | |||
| 6435 | /** |
||
| 6436 | * Gets all aircraft manufacturers that have flown over |
||
| 6437 | * |
||
| 6438 | * @return Array the aircraft list |
||
| 6439 | * |
||
| 6440 | */ |
||
| 6441 | public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '') |
||
| 6442 | { |
||
| 6443 | global $globalDBdriver; |
||
| 6444 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6445 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 6446 | FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'"; |
||
| 6447 | $query_values = array(); |
||
| 6448 | if ($year != '') { |
||
| 6449 | if ($globalDBdriver == 'mysql') { |
||
| 6450 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6451 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6452 | } else { |
||
| 6453 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6454 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6455 | } |
||
| 6456 | } |
||
| 6457 | if ($month != '') { |
||
| 6458 | if ($globalDBdriver == 'mysql') { |
||
| 6459 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6460 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6461 | } else { |
||
| 6462 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6463 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6464 | } |
||
| 6465 | } |
||
| 6466 | if ($day != '') { |
||
| 6467 | if ($globalDBdriver == 'mysql') { |
||
| 6468 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6469 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6470 | } else { |
||
| 6471 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6472 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6473 | } |
||
| 6474 | } |
||
| 6475 | $query .= " GROUP BY spotter_output.aircraft_manufacturer |
||
| 6476 | ORDER BY aircraft_manufacturer_count DESC |
||
| 6477 | LIMIT 10"; |
||
| 6478 | |||
| 6479 | |||
| 6480 | $sth = $this->db->prepare($query); |
||
| 6481 | $sth->execute($query_values); |
||
| 6482 | |||
| 6483 | $manufacturer_array = array(); |
||
| 6484 | $temp_array = array(); |
||
| 6485 | |||
| 6486 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6487 | { |
||
| 6488 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 6489 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 6490 | |||
| 6491 | $manufacturer_array[] = $temp_array; |
||
| 6492 | } |
||
| 6493 | |||
| 6494 | return $manufacturer_array; |
||
| 6495 | } |
||
| 6496 | |||
| 6497 | |||
| 6498 | |||
| 6499 | /** |
||
| 6500 | * Gets all aircraft registrations that have flown over |
||
| 6501 | * |
||
| 6502 | * @return Array the aircraft list |
||
| 6503 | * |
||
| 6504 | */ |
||
| 6505 | public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
||
| 6506 | { |
||
| 6507 | global $globalDBdriver; |
||
| 6508 | $Image = new Image($this->db); |
||
| 6509 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6510 | $query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 6511 | FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'"; |
||
| 6512 | if ($olderthanmonths > 0) { |
||
| 6513 | if ($globalDBdriver == 'mysql') { |
||
| 6514 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 6515 | } else { |
||
| 6516 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 6517 | } |
||
| 6518 | } |
||
| 6519 | if ($sincedate != '') { |
||
| 6520 | if ($globalDBdriver == 'mysql') { |
||
| 6521 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 6522 | } else { |
||
| 6523 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 6524 | } |
||
| 6525 | } |
||
| 6526 | $query_values = array(); |
||
| 6527 | if ($year != '') { |
||
| 6528 | if ($globalDBdriver == 'mysql') { |
||
| 6529 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6530 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6531 | } else { |
||
| 6532 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6533 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6534 | } |
||
| 6535 | } |
||
| 6536 | if ($month != '') { |
||
| 6537 | if ($globalDBdriver == 'mysql') { |
||
| 6538 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6539 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6540 | } else { |
||
| 6541 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6542 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6543 | } |
||
| 6544 | } |
||
| 6545 | if ($day != '') { |
||
| 6546 | if ($globalDBdriver == 'mysql') { |
||
| 6547 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6548 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6549 | } else { |
||
| 6550 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6551 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6552 | } |
||
| 6553 | } |
||
| 6554 | $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
||
| 6555 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 6556 | |||
| 6557 | $sth = $this->db->prepare($query); |
||
| 6558 | $sth->execute($query_values); |
||
| 6559 | |||
| 6560 | $aircraft_array = array(); |
||
| 6561 | $temp_array = array(); |
||
| 6562 | |||
| 6563 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6564 | { |
||
| 6565 | $temp_array['registration'] = $row['registration']; |
||
| 6566 | $temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
||
| 6567 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6568 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6569 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 6570 | $temp_array['image_thumbnail'] = ""; |
||
| 6571 | if($row['registration'] != "") |
||
| 6572 | { |
||
| 6573 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 6574 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 6575 | } |
||
| 6576 | |||
| 6577 | $aircraft_array[] = $temp_array; |
||
| 6578 | } |
||
| 6579 | |||
| 6580 | return $aircraft_array; |
||
| 6581 | } |
||
| 6582 | |||
| 6583 | |||
| 6584 | /** |
||
| 6585 | * Gets all aircraft registrations that have flown over |
||
| 6586 | * |
||
| 6587 | * @return Array the aircraft list |
||
| 6588 | * |
||
| 6589 | */ |
||
| 6590 | public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 6591 | { |
||
| 6592 | global $globalDBdriver; |
||
| 6593 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6594 | $Image = new Image($this->db); |
||
| 6595 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 6596 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' "; |
||
| 6597 | if ($olderthanmonths > 0) { |
||
| 6598 | if ($globalDBdriver == 'mysql') { |
||
| 6599 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 6600 | } else { |
||
| 6601 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 6602 | } |
||
| 6603 | } |
||
| 6604 | if ($sincedate != '') { |
||
| 6605 | if ($globalDBdriver == 'mysql') { |
||
| 6606 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 6607 | } else { |
||
| 6608 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 6609 | } |
||
| 6610 | } |
||
| 6611 | |||
| 6612 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 6613 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 6614 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
||
| 6615 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 6616 | |||
| 6617 | $sth = $this->db->prepare($query); |
||
| 6618 | $sth->execute(); |
||
| 6619 | |||
| 6620 | $aircraft_array = array(); |
||
| 6621 | $temp_array = array(); |
||
| 6622 | |||
| 6623 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6624 | { |
||
| 6625 | $temp_array['registration'] = $row['registration']; |
||
| 6626 | $temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
||
| 6627 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 6628 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 6629 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 6630 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 6631 | $temp_array['image_thumbnail'] = ""; |
||
| 6632 | if($row['registration'] != "") |
||
| 6633 | { |
||
| 6634 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 6635 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 6636 | } |
||
| 6637 | |||
| 6638 | $aircraft_array[] = $temp_array; |
||
| 6639 | } |
||
| 6640 | |||
| 6641 | return $aircraft_array; |
||
| 6642 | } |
||
| 6643 | |||
| 6644 | |||
| 6645 | /** |
||
| 6646 | * Gets all departure airports of the airplanes that have flown over |
||
| 6647 | * |
||
| 6648 | * @return Array the airport list |
||
| 6649 | * |
||
| 6650 | */ |
||
| 6651 | public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
||
| 6652 | { |
||
| 6653 | global $globalDBdriver; |
||
| 6654 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6655 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude |
||
| 6656 | FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.departure_airport_icao AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''"; |
||
| 6657 | if ($olderthanmonths > 0) { |
||
| 6658 | if ($globalDBdriver == 'mysql') { |
||
| 6659 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 6660 | } else { |
||
| 6661 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 6662 | } |
||
| 6663 | } |
||
| 6664 | if ($sincedate != '') { |
||
| 6665 | if ($globalDBdriver == 'mysql') { |
||
| 6666 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 6667 | } else { |
||
| 6668 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 6669 | } |
||
| 6670 | } |
||
| 6671 | $query_values = array(); |
||
| 6672 | if ($year != '') { |
||
| 6673 | if ($globalDBdriver == 'mysql') { |
||
| 6674 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6675 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6676 | } else { |
||
| 6677 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6678 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6679 | } |
||
| 6680 | } |
||
| 6681 | if ($month != '') { |
||
| 6682 | if ($globalDBdriver == 'mysql') { |
||
| 6683 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6684 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6685 | } else { |
||
| 6686 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6687 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6688 | } |
||
| 6689 | } |
||
| 6690 | if ($day != '') { |
||
| 6691 | if ($globalDBdriver == 'mysql') { |
||
| 6692 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6693 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6694 | } else { |
||
| 6695 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6696 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6697 | } |
||
| 6698 | } |
||
| 6699 | $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude |
||
| 6700 | ORDER BY airport_departure_icao_count DESC"; |
||
| 6701 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 6702 | |||
| 6703 | $sth = $this->db->prepare($query); |
||
| 6704 | $sth->execute($query_values); |
||
| 6705 | |||
| 6706 | $airport_array = array(); |
||
| 6707 | $temp_array = array(); |
||
| 6708 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6709 | { |
||
| 6710 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 6711 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 6712 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 6713 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 6714 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 6715 | $temp_array['airport_departure_latitude'] = $row['latitude']; |
||
| 6716 | $temp_array['airport_departure_longitude'] = $row['longitude']; |
||
| 6717 | $airport_array[] = $temp_array; |
||
| 6718 | } |
||
| 6719 | return $airport_array; |
||
| 6720 | } |
||
| 6721 | |||
| 6722 | /** |
||
| 6723 | * Gets all departure airports of the airplanes that have flown over |
||
| 6724 | * |
||
| 6725 | * @return Array the airport list |
||
| 6726 | * |
||
| 6727 | */ |
||
| 6728 | public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 6729 | { |
||
| 6730 | global $globalDBdriver; |
||
| 6731 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6732 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 6733 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' "; |
||
| 6734 | if ($olderthanmonths > 0) { |
||
| 6735 | if ($globalDBdriver == 'mysql') { |
||
| 6736 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 6737 | } else { |
||
| 6738 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 6739 | } |
||
| 6740 | } |
||
| 6741 | if ($sincedate != '') { |
||
| 6742 | if ($globalDBdriver == 'mysql') { |
||
| 6743 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 6744 | } else { |
||
| 6745 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 6746 | } |
||
| 6747 | } |
||
| 6748 | |||
| 6749 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 6750 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 6751 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 6752 | ORDER BY airport_departure_icao_count DESC"; |
||
| 6753 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 6754 | |||
| 6755 | $sth = $this->db->prepare($query); |
||
| 6756 | $sth->execute(); |
||
| 6757 | |||
| 6758 | $airport_array = array(); |
||
| 6759 | $temp_array = array(); |
||
| 6760 | |||
| 6761 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6762 | { |
||
| 6763 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 6764 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 6765 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 6766 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 6767 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 6768 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 6769 | |||
| 6770 | $airport_array[] = $temp_array; |
||
| 6771 | } |
||
| 6772 | return $airport_array; |
||
| 6773 | } |
||
| 6774 | |||
| 6775 | /** |
||
| 6776 | * Gets all detected departure airports of the airplanes that have flown over |
||
| 6777 | * |
||
| 6778 | * @return Array the airport list |
||
| 6779 | * |
||
| 6780 | */ |
||
| 6781 | public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
||
| 6782 | { |
||
| 6783 | global $globalDBdriver; |
||
| 6784 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6785 | $query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country, airport.latitude as departure_airport_latitude, airport.longitude as departure_airport_longitude |
||
| 6786 | FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao"; |
||
| 6787 | if ($olderthanmonths > 0) { |
||
| 6788 | if ($globalDBdriver == 'mysql') { |
||
| 6789 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 6790 | } else { |
||
| 6791 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 6792 | } |
||
| 6793 | } |
||
| 6794 | if ($sincedate != '') { |
||
| 6795 | if ($globalDBdriver == 'mysql') { |
||
| 6796 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 6797 | } else { |
||
| 6798 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 6799 | } |
||
| 6800 | } |
||
| 6801 | $query_values = array(); |
||
| 6802 | if ($year != '') { |
||
| 6803 | if ($globalDBdriver == 'mysql') { |
||
| 6804 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 6805 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6806 | } else { |
||
| 6807 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 6808 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 6809 | } |
||
| 6810 | } |
||
| 6811 | if ($month != '') { |
||
| 6812 | if ($globalDBdriver == 'mysql') { |
||
| 6813 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 6814 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6815 | } else { |
||
| 6816 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 6817 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 6818 | } |
||
| 6819 | } |
||
| 6820 | if ($day != '') { |
||
| 6821 | if ($globalDBdriver == 'mysql') { |
||
| 6822 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 6823 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6824 | } else { |
||
| 6825 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 6826 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 6827 | } |
||
| 6828 | } |
||
| 6829 | $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude |
||
| 6830 | ORDER BY airport_departure_icao_count DESC"; |
||
| 6831 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 6832 | //echo $query; |
||
| 6833 | $sth = $this->db->prepare($query); |
||
| 6834 | $sth->execute($query_values); |
||
| 6835 | |||
| 6836 | $airport_array = array(); |
||
| 6837 | $temp_array = array(); |
||
| 6838 | |||
| 6839 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6840 | { |
||
| 6841 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 6842 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 6843 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 6844 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 6845 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 6846 | $temp_array['airport_departure_latitude'] = $row['departure_airport_latitude']; |
||
| 6847 | $temp_array['airport_departure_longitude'] = $row['departure_airport_longitude']; |
||
| 6848 | |||
| 6849 | $airport_array[] = $temp_array; |
||
| 6850 | } |
||
| 6851 | return $airport_array; |
||
| 6852 | } |
||
| 6853 | |||
| 6854 | /** |
||
| 6855 | * Gets all detected departure airports of the airplanes that have flown over |
||
| 6856 | * |
||
| 6857 | * @return Array the airport list |
||
| 6858 | * |
||
| 6859 | */ |
||
| 6860 | public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 6861 | { |
||
| 6862 | global $globalDBdriver; |
||
| 6863 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6864 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
||
| 6865 | FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao "; |
||
| 6866 | if ($olderthanmonths > 0) { |
||
| 6867 | if ($globalDBdriver == 'mysql') { |
||
| 6868 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 6869 | } else { |
||
| 6870 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 6871 | } |
||
| 6872 | } |
||
| 6873 | if ($sincedate != '') { |
||
| 6874 | if ($globalDBdriver == 'mysql') { |
||
| 6875 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 6876 | } else { |
||
| 6877 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
||
| 6878 | } |
||
| 6879 | } |
||
| 6880 | |||
| 6881 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 6882 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 6883 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
||
| 6884 | ORDER BY airport_departure_icao_count DESC"; |
||
| 6885 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 6886 | |||
| 6887 | $sth = $this->db->prepare($query); |
||
| 6888 | $sth->execute(); |
||
| 6889 | |||
| 6890 | $airport_array = array(); |
||
| 6891 | $temp_array = array(); |
||
| 6892 | |||
| 6893 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6894 | { |
||
| 6895 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 6896 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 6897 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 6898 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 6899 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 6900 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 6901 | |||
| 6902 | $airport_array[] = $temp_array; |
||
| 6903 | } |
||
| 6904 | return $airport_array; |
||
| 6905 | } |
||
| 6906 | |||
| 6907 | /** |
||
| 6908 | * Gets all departure airports of the airplanes that have flown over based on an airline icao |
||
| 6909 | * |
||
| 6910 | * @return Array the airport list |
||
| 6911 | * |
||
| 6912 | */ |
||
| 6913 | public function countAllDepartureAirportsByAirline($airline_icao,$filters = array()) |
||
| 6914 | { |
||
| 6915 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6916 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 6917 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 6918 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao AND spotter_output.departure_airport_icao <> '' |
||
| 6919 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 6920 | ORDER BY airport_departure_icao_count DESC"; |
||
| 6921 | |||
| 6922 | |||
| 6923 | $sth = $this->db->prepare($query); |
||
| 6924 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 6925 | |||
| 6926 | $airport_array = array(); |
||
| 6927 | $temp_array = array(); |
||
| 6928 | |||
| 6929 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6930 | { |
||
| 6931 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 6932 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 6933 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 6934 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 6935 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 6936 | |||
| 6937 | $airport_array[] = $temp_array; |
||
| 6938 | } |
||
| 6939 | |||
| 6940 | return $airport_array; |
||
| 6941 | } |
||
| 6942 | |||
| 6943 | |||
| 6944 | |||
| 6945 | /** |
||
| 6946 | * Gets all departure airports by country of the airplanes that have flown over based on an airline icao |
||
| 6947 | * |
||
| 6948 | * @return Array the airport list |
||
| 6949 | * |
||
| 6950 | */ |
||
| 6951 | public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array()) |
||
| 6952 | { |
||
| 6953 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6954 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 6955 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 |
||
| 6956 | FROM countries,spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 6957 | GROUP BY spotter_output.departure_airport_country, countries.iso3 |
||
| 6958 | ORDER BY airport_departure_country_count DESC"; |
||
| 6959 | |||
| 6960 | $sth = $this->db->prepare($query); |
||
| 6961 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 6962 | |||
| 6963 | $airport_array = array(); |
||
| 6964 | $temp_array = array(); |
||
| 6965 | |||
| 6966 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 6967 | { |
||
| 6968 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 6969 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 6970 | $temp_array['departure_airport_country_iso3'] = $row['departure_airport_country_iso3']; |
||
| 6971 | $airport_array[] = $temp_array; |
||
| 6972 | } |
||
| 6973 | return $airport_array; |
||
| 6974 | } |
||
| 6975 | |||
| 6976 | |||
| 6977 | |||
| 6978 | /** |
||
| 6979 | * Gets all departure airports of the airplanes that have flown over based on an aircraft icao |
||
| 6980 | * |
||
| 6981 | * @return Array the airport list |
||
| 6982 | * |
||
| 6983 | */ |
||
| 6984 | public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array()) |
||
| 6985 | { |
||
| 6986 | $filter_query = $this->getFilter($filters,true,true); |
||
| 6987 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 6988 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 6989 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao AND spotter_output.departure_airport_icao <> '' |
||
| 6990 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 6991 | ORDER BY airport_departure_icao_count DESC"; |
||
| 6992 | |||
| 6993 | |||
| 6994 | $sth = $this->db->prepare($query); |
||
| 6995 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 6996 | |||
| 6997 | $airport_array = array(); |
||
| 6998 | $temp_array = array(); |
||
| 6999 | |||
| 7000 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7001 | { |
||
| 7002 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7003 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7004 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7005 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7006 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7007 | |||
| 7008 | $airport_array[] = $temp_array; |
||
| 7009 | } |
||
| 7010 | |||
| 7011 | return $airport_array; |
||
| 7012 | } |
||
| 7013 | |||
| 7014 | |||
| 7015 | /** |
||
| 7016 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 7017 | * |
||
| 7018 | * @return Array the airport list |
||
| 7019 | * |
||
| 7020 | */ |
||
| 7021 | public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 7022 | { |
||
| 7023 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7024 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 7025 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 |
||
| 7026 | FROM countries, spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 7027 | GROUP BY spotter_output.departure_airport_country, countries.iso3 |
||
| 7028 | ORDER BY airport_departure_country_count DESC"; |
||
| 7029 | |||
| 7030 | |||
| 7031 | $sth = $this->db->prepare($query); |
||
| 7032 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 7033 | |||
| 7034 | $airport_array = array(); |
||
| 7035 | $temp_array = array(); |
||
| 7036 | |||
| 7037 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7038 | { |
||
| 7039 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7040 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7041 | $temp_array['departure_airport_country_iso3'] = $row['departure_airport_country_iso3']; |
||
| 7042 | $airport_array[] = $temp_array; |
||
| 7043 | } |
||
| 7044 | |||
| 7045 | return $airport_array; |
||
| 7046 | } |
||
| 7047 | |||
| 7048 | |||
| 7049 | /** |
||
| 7050 | * Gets all departure airports of the airplanes that have flown over based on an aircraft registration |
||
| 7051 | * |
||
| 7052 | * @return Array the airport list |
||
| 7053 | * |
||
| 7054 | */ |
||
| 7055 | public function countAllDepartureAirportsByRegistration($registration,$filters = array()) |
||
| 7056 | { |
||
| 7057 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7058 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 7059 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7060 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration AND spotter_output.departure_airport_icao <> '' |
||
| 7061 | GROUP BY spotter_output.departure_airport_icao |
||
| 7062 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7063 | |||
| 7064 | |||
| 7065 | $sth = $this->db->prepare($query); |
||
| 7066 | $sth->execute(array(':registration' => $registration)); |
||
| 7067 | |||
| 7068 | $airport_array = array(); |
||
| 7069 | $temp_array = array(); |
||
| 7070 | |||
| 7071 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7072 | { |
||
| 7073 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7074 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7075 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7076 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7077 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7078 | |||
| 7079 | $airport_array[] = $temp_array; |
||
| 7080 | } |
||
| 7081 | |||
| 7082 | return $airport_array; |
||
| 7083 | } |
||
| 7084 | |||
| 7085 | |||
| 7086 | /** |
||
| 7087 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration |
||
| 7088 | * |
||
| 7089 | * @return Array the airport list |
||
| 7090 | * |
||
| 7091 | */ |
||
| 7092 | public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array()) |
||
| 7093 | { |
||
| 7094 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7095 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 7096 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7097 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration |
||
| 7098 | GROUP BY spotter_output.departure_airport_country |
||
| 7099 | ORDER BY airport_departure_country_count DESC"; |
||
| 7100 | |||
| 7101 | |||
| 7102 | $sth = $this->db->prepare($query); |
||
| 7103 | $sth->execute(array(':registration' => $registration)); |
||
| 7104 | |||
| 7105 | $airport_array = array(); |
||
| 7106 | $temp_array = array(); |
||
| 7107 | |||
| 7108 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7109 | { |
||
| 7110 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7111 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7112 | |||
| 7113 | $airport_array[] = $temp_array; |
||
| 7114 | } |
||
| 7115 | |||
| 7116 | return $airport_array; |
||
| 7117 | } |
||
| 7118 | |||
| 7119 | |||
| 7120 | /** |
||
| 7121 | * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao |
||
| 7122 | * |
||
| 7123 | * @return Array the airport list |
||
| 7124 | * |
||
| 7125 | */ |
||
| 7126 | public function countAllDepartureAirportsByAirport($airport_icao,$filters = array()) |
||
| 7127 | { |
||
| 7128 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7129 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 7130 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7131 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao AND spotter_output.departure_airport_icao <> '' |
||
| 7132 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7133 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7134 | |||
| 7135 | |||
| 7136 | $sth = $this->db->prepare($query); |
||
| 7137 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 7138 | |||
| 7139 | $airport_array = array(); |
||
| 7140 | $temp_array = array(); |
||
| 7141 | |||
| 7142 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7143 | { |
||
| 7144 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7145 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7146 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7147 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7148 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7149 | |||
| 7150 | $airport_array[] = $temp_array; |
||
| 7151 | } |
||
| 7152 | |||
| 7153 | return $airport_array; |
||
| 7154 | } |
||
| 7155 | |||
| 7156 | |||
| 7157 | /** |
||
| 7158 | * Gets all departure airports by country of the airplanes that have flown over based on an airport icao |
||
| 7159 | * |
||
| 7160 | * @return Array the airport list |
||
| 7161 | * |
||
| 7162 | */ |
||
| 7163 | public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array()) |
||
| 7164 | { |
||
| 7165 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7166 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 7167 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 |
||
| 7168 | FROM countries,spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao |
||
| 7169 | GROUP BY spotter_output.departure_airport_country, countries.iso3 |
||
| 7170 | ORDER BY airport_departure_country_count DESC"; |
||
| 7171 | |||
| 7172 | $sth = $this->db->prepare($query); |
||
| 7173 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 7174 | |||
| 7175 | $airport_array = array(); |
||
| 7176 | $temp_array = array(); |
||
| 7177 | |||
| 7178 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7179 | { |
||
| 7180 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7181 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7182 | $temp_array['departure_airport_country_iso3'] = $row['departure_airport_country_iso3']; |
||
| 7183 | $airport_array[] = $temp_array; |
||
| 7184 | } |
||
| 7185 | return $airport_array; |
||
| 7186 | } |
||
| 7187 | |||
| 7188 | |||
| 7189 | |||
| 7190 | /** |
||
| 7191 | * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer |
||
| 7192 | * |
||
| 7193 | * @return Array the airport list |
||
| 7194 | * |
||
| 7195 | */ |
||
| 7196 | public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 7197 | { |
||
| 7198 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7199 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 7200 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7201 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer AND spotter_output.departure_airport_icao <> '' |
||
| 7202 | GROUP BY spotter_output.departure_airport_icao |
||
| 7203 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7204 | |||
| 7205 | |||
| 7206 | $sth = $this->db->prepare($query); |
||
| 7207 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 7208 | |||
| 7209 | $airport_array = array(); |
||
| 7210 | $temp_array = array(); |
||
| 7211 | |||
| 7212 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7213 | { |
||
| 7214 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7215 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7216 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7217 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7218 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7219 | |||
| 7220 | $airport_array[] = $temp_array; |
||
| 7221 | } |
||
| 7222 | |||
| 7223 | return $airport_array; |
||
| 7224 | } |
||
| 7225 | |||
| 7226 | |||
| 7227 | /** |
||
| 7228 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer |
||
| 7229 | * |
||
| 7230 | * @return Array the airport list |
||
| 7231 | * |
||
| 7232 | */ |
||
| 7233 | public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 7234 | { |
||
| 7235 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7236 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 7237 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7238 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 7239 | GROUP BY spotter_output.departure_airport_country |
||
| 7240 | ORDER BY airport_departure_country_count DESC"; |
||
| 7241 | |||
| 7242 | |||
| 7243 | $sth = $this->db->prepare($query); |
||
| 7244 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 7245 | |||
| 7246 | $airport_array = array(); |
||
| 7247 | $temp_array = array(); |
||
| 7248 | |||
| 7249 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7250 | { |
||
| 7251 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7252 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7253 | |||
| 7254 | $airport_array[] = $temp_array; |
||
| 7255 | } |
||
| 7256 | |||
| 7257 | return $airport_array; |
||
| 7258 | } |
||
| 7259 | |||
| 7260 | |||
| 7261 | /** |
||
| 7262 | * Gets all departure airports of the airplanes that have flown over based on a date |
||
| 7263 | * |
||
| 7264 | * @return Array the airport list |
||
| 7265 | * |
||
| 7266 | */ |
||
| 7267 | public function countAllDepartureAirportsByDate($date,$filters = array()) |
||
| 7268 | { |
||
| 7269 | global $globalTimezone, $globalDBdriver; |
||
| 7270 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7271 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 7272 | if ($globalTimezone != '') { |
||
| 7273 | date_default_timezone_set($globalTimezone); |
||
| 7274 | $datetime = new DateTime($date); |
||
| 7275 | $offset = $datetime->format('P'); |
||
| 7276 | } else $offset = '+00:00'; |
||
| 7277 | |||
| 7278 | if ($globalDBdriver == 'mysql') { |
||
| 7279 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7280 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 7281 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7282 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7283 | } else { |
||
| 7284 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7285 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 7286 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7287 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7288 | } |
||
| 7289 | |||
| 7290 | $sth = $this->db->prepare($query); |
||
| 7291 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 7292 | |||
| 7293 | $airport_array = array(); |
||
| 7294 | $temp_array = array(); |
||
| 7295 | |||
| 7296 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7297 | { |
||
| 7298 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7299 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7300 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7301 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7302 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7303 | |||
| 7304 | $airport_array[] = $temp_array; |
||
| 7305 | } |
||
| 7306 | return $airport_array; |
||
| 7307 | } |
||
| 7308 | |||
| 7309 | |||
| 7310 | |||
| 7311 | /** |
||
| 7312 | * Gets all departure airports by country of the airplanes that have flown over based on a date |
||
| 7313 | * |
||
| 7314 | * @return Array the airport list |
||
| 7315 | * |
||
| 7316 | */ |
||
| 7317 | public function countAllDepartureAirportCountriesByDate($date,$filters = array()) |
||
| 7318 | { |
||
| 7319 | global $globalTimezone, $globalDBdriver; |
||
| 7320 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7321 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 7322 | if ($globalTimezone != '') { |
||
| 7323 | date_default_timezone_set($globalTimezone); |
||
| 7324 | $datetime = new DateTime($date); |
||
| 7325 | $offset = $datetime->format('P'); |
||
| 7326 | } else $offset = '+00:00'; |
||
| 7327 | |||
| 7328 | if ($globalDBdriver == 'mysql') { |
||
| 7329 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7330 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 7331 | GROUP BY spotter_output.departure_airport_country |
||
| 7332 | ORDER BY airport_departure_country_count DESC"; |
||
| 7333 | } else { |
||
| 7334 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7335 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 7336 | GROUP BY spotter_output.departure_airport_country |
||
| 7337 | ORDER BY airport_departure_country_count DESC"; |
||
| 7338 | } |
||
| 7339 | |||
| 7340 | $sth = $this->db->prepare($query); |
||
| 7341 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 7342 | |||
| 7343 | $airport_array = array(); |
||
| 7344 | $temp_array = array(); |
||
| 7345 | |||
| 7346 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7347 | { |
||
| 7348 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7349 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7350 | |||
| 7351 | $airport_array[] = $temp_array; |
||
| 7352 | } |
||
| 7353 | return $airport_array; |
||
| 7354 | } |
||
| 7355 | |||
| 7356 | |||
| 7357 | |||
| 7358 | /** |
||
| 7359 | * Gets all departure airports of the airplanes that have flown over based on a ident/callsign |
||
| 7360 | * |
||
| 7361 | * @return Array the airport list |
||
| 7362 | * |
||
| 7363 | */ |
||
| 7364 | public function countAllDepartureAirportsByIdent($ident,$filters = array()) |
||
| 7365 | { |
||
| 7366 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7367 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 7368 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7369 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.ident = :ident |
||
| 7370 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7371 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7372 | |||
| 7373 | |||
| 7374 | $sth = $this->db->prepare($query); |
||
| 7375 | $sth->execute(array(':ident' => $ident)); |
||
| 7376 | |||
| 7377 | $airport_array = array(); |
||
| 7378 | $temp_array = array(); |
||
| 7379 | |||
| 7380 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7381 | { |
||
| 7382 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7383 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7384 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7385 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7386 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7387 | |||
| 7388 | $airport_array[] = $temp_array; |
||
| 7389 | } |
||
| 7390 | |||
| 7391 | return $airport_array; |
||
| 7392 | } |
||
| 7393 | |||
| 7394 | /** |
||
| 7395 | * Gets all departure airports of the airplanes that have flown over based on a owner |
||
| 7396 | * |
||
| 7397 | * @return Array the airport list |
||
| 7398 | * |
||
| 7399 | */ |
||
| 7400 | public function countAllDepartureAirportsByOwner($owner,$filters = array()) |
||
| 7401 | { |
||
| 7402 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7403 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 7404 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7405 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.owner_name = :owner |
||
| 7406 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7407 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7408 | |||
| 7409 | |||
| 7410 | $sth = $this->db->prepare($query); |
||
| 7411 | $sth->execute(array(':owner' => $owner)); |
||
| 7412 | |||
| 7413 | $airport_array = array(); |
||
| 7414 | $temp_array = array(); |
||
| 7415 | |||
| 7416 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7417 | { |
||
| 7418 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7419 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7420 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7421 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7422 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7423 | |||
| 7424 | $airport_array[] = $temp_array; |
||
| 7425 | } |
||
| 7426 | |||
| 7427 | return $airport_array; |
||
| 7428 | } |
||
| 7429 | |||
| 7430 | /** |
||
| 7431 | * Gets all departure airports of the airplanes that have flown over based on a pilot |
||
| 7432 | * |
||
| 7433 | * @return Array the airport list |
||
| 7434 | * |
||
| 7435 | */ |
||
| 7436 | public function countAllDepartureAirportsByPilot($pilot,$filters = array()) |
||
| 7437 | { |
||
| 7438 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7439 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 7440 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7441 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
||
| 7442 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7443 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7444 | |||
| 7445 | $sth = $this->db->prepare($query); |
||
| 7446 | $sth->execute(array(':pilot' => $pilot)); |
||
| 7447 | |||
| 7448 | $airport_array = array(); |
||
| 7449 | $temp_array = array(); |
||
| 7450 | |||
| 7451 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7452 | { |
||
| 7453 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7454 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7455 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7456 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7457 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7458 | |||
| 7459 | $airport_array[] = $temp_array; |
||
| 7460 | } |
||
| 7461 | |||
| 7462 | return $airport_array; |
||
| 7463 | } |
||
| 7464 | |||
| 7465 | |||
| 7466 | |||
| 7467 | /** |
||
| 7468 | * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident |
||
| 7469 | * |
||
| 7470 | * @return Array the airport list |
||
| 7471 | * |
||
| 7472 | */ |
||
| 7473 | public function countAllDepartureAirportCountriesByIdent($ident,$filters = array()) |
||
| 7474 | { |
||
| 7475 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7476 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 7477 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7478 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident |
||
| 7479 | GROUP BY spotter_output.departure_airport_country |
||
| 7480 | ORDER BY airport_departure_country_count DESC"; |
||
| 7481 | |||
| 7482 | |||
| 7483 | $sth = $this->db->prepare($query); |
||
| 7484 | $sth->execute(array(':ident' => $ident)); |
||
| 7485 | |||
| 7486 | $airport_array = array(); |
||
| 7487 | $temp_array = array(); |
||
| 7488 | |||
| 7489 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7490 | { |
||
| 7491 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7492 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7493 | |||
| 7494 | $airport_array[] = $temp_array; |
||
| 7495 | } |
||
| 7496 | |||
| 7497 | return $airport_array; |
||
| 7498 | } |
||
| 7499 | |||
| 7500 | /** |
||
| 7501 | * Gets all departure airports by country of the airplanes that have flown over based on owner |
||
| 7502 | * |
||
| 7503 | * @return Array the airport list |
||
| 7504 | * |
||
| 7505 | */ |
||
| 7506 | public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) |
||
| 7507 | { |
||
| 7508 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7509 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 7510 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7511 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner |
||
| 7512 | GROUP BY spotter_output.departure_airport_country |
||
| 7513 | ORDER BY airport_departure_country_count DESC"; |
||
| 7514 | |||
| 7515 | $sth = $this->db->prepare($query); |
||
| 7516 | $sth->execute(array(':owner' => $owner)); |
||
| 7517 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 7518 | } |
||
| 7519 | |||
| 7520 | /** |
||
| 7521 | * Gets all departure airports by country of the airplanes that have flown over based on pilot |
||
| 7522 | * |
||
| 7523 | * @return Array the airport list |
||
| 7524 | * |
||
| 7525 | */ |
||
| 7526 | public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array()) |
||
| 7527 | { |
||
| 7528 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7529 | $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
||
| 7530 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 7531 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
||
| 7532 | GROUP BY spotter_output.departure_airport_country |
||
| 7533 | ORDER BY airport_departure_country_count DESC"; |
||
| 7534 | |||
| 7535 | $sth = $this->db->prepare($query); |
||
| 7536 | $sth->execute(array(':pilot' => $pilot)); |
||
| 7537 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 7538 | } |
||
| 7539 | |||
| 7540 | |||
| 7541 | |||
| 7542 | /** |
||
| 7543 | * Gets all departure airports of the airplanes that have flown over based on a country |
||
| 7544 | * |
||
| 7545 | * @return Array the airport list |
||
| 7546 | * |
||
| 7547 | */ |
||
| 7548 | public function countAllDepartureAirportsByCountry($country,$filters = array()) |
||
| 7549 | { |
||
| 7550 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7551 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 7552 | |||
| 7553 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7554 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 7555 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
||
| 7556 | ORDER BY airport_departure_icao_count DESC"; |
||
| 7557 | |||
| 7558 | |||
| 7559 | $sth = $this->db->prepare($query); |
||
| 7560 | $sth->execute(array(':country' => $country)); |
||
| 7561 | |||
| 7562 | $airport_array = array(); |
||
| 7563 | $temp_array = array(); |
||
| 7564 | |||
| 7565 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7566 | { |
||
| 7567 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 7568 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 7569 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 7570 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 7571 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 7572 | |||
| 7573 | $airport_array[] = $temp_array; |
||
| 7574 | } |
||
| 7575 | |||
| 7576 | return $airport_array; |
||
| 7577 | } |
||
| 7578 | |||
| 7579 | |||
| 7580 | /** |
||
| 7581 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 7582 | * |
||
| 7583 | * @return Array the airport list |
||
| 7584 | * |
||
| 7585 | */ |
||
| 7586 | public function countAllDepartureAirportCountriesByCountry($country,$filters = array()) |
||
| 7587 | { |
||
| 7588 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7589 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 7590 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 |
||
| 7591 | FROM countries,spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country) OR spotter_output.airline_country = :country) |
||
| 7592 | GROUP BY spotter_output.departure_airport_country, countries.iso3 |
||
| 7593 | ORDER BY airport_departure_country_count DESC"; |
||
| 7594 | |||
| 7595 | $sth = $this->db->prepare($query); |
||
| 7596 | $sth->execute(array(':country' => $country)); |
||
| 7597 | $airport_array = array(); |
||
| 7598 | $temp_array = array(); |
||
| 7599 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7600 | { |
||
| 7601 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 7602 | $temp_array['departure_airport_country_iso3'] = $row['departure_airport_country_iso3']; |
||
| 7603 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
||
| 7604 | $airport_array[] = $temp_array; |
||
| 7605 | } |
||
| 7606 | return $airport_array; |
||
| 7607 | } |
||
| 7608 | |||
| 7609 | |||
| 7610 | /** |
||
| 7611 | * Gets all arrival airports of the airplanes that have flown over |
||
| 7612 | * |
||
| 7613 | * @param Boolean $limit Limit result to 10 or not |
||
| 7614 | * @param Integer $olderthanmonths Only show result older than x months |
||
| 7615 | * @param String $sincedate Only show result since x date |
||
| 7616 | * @param Boolean $icaoaskey Show result by ICAO |
||
| 7617 | * @param Array $filters Filter used here |
||
| 7618 | * @return Array the airport list |
||
| 7619 | * |
||
| 7620 | */ |
||
| 7621 | public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '') |
||
| 7622 | { |
||
| 7623 | global $globalDBdriver; |
||
| 7624 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7625 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude as arrival_airport_latitude, airport.longitude as arrival_airport_longitude |
||
| 7626 | FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.arrival_airport_icao AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''"; |
||
| 7627 | if ($olderthanmonths > 0) { |
||
| 7628 | if ($globalDBdriver == 'mysql') { |
||
| 7629 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 7630 | } else { |
||
| 7631 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 7632 | } |
||
| 7633 | } |
||
| 7634 | if ($sincedate != '') { |
||
| 7635 | if ($globalDBdriver == 'mysql') { |
||
| 7636 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 7637 | } else { |
||
| 7638 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 7639 | } |
||
| 7640 | } |
||
| 7641 | $query_values = array(); |
||
| 7642 | if ($year != '') { |
||
| 7643 | if ($globalDBdriver == 'mysql') { |
||
| 7644 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 7645 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 7646 | } else { |
||
| 7647 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 7648 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 7649 | } |
||
| 7650 | } |
||
| 7651 | if ($month != '') { |
||
| 7652 | if ($globalDBdriver == 'mysql') { |
||
| 7653 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 7654 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 7655 | } else { |
||
| 7656 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 7657 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 7658 | } |
||
| 7659 | } |
||
| 7660 | if ($day != '') { |
||
| 7661 | if ($globalDBdriver == 'mysql') { |
||
| 7662 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 7663 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 7664 | } else { |
||
| 7665 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 7666 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 7667 | } |
||
| 7668 | } |
||
| 7669 | $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude |
||
| 7670 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 7671 | if ($limit) $query .= " LIMIT 10"; |
||
| 7672 | |||
| 7673 | |||
| 7674 | $sth = $this->db->prepare($query); |
||
| 7675 | $sth->execute($query_values); |
||
| 7676 | |||
| 7677 | $airport_array = array(); |
||
| 7678 | $temp_array = array(); |
||
| 7679 | |||
| 7680 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7681 | { |
||
| 7682 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 7683 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 7684 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 7685 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 7686 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 7687 | $temp_array['airport_arrival_latitude'] = $row['arrival_airport_latitude']; |
||
| 7688 | $temp_array['airport_arrival_longitude'] = $row['arrival_airport_longitude']; |
||
| 7689 | |||
| 7690 | if ($icaoaskey) { |
||
| 7691 | $icao = $row['arrival_airport_icao']; |
||
| 7692 | $airport_array[$icao] = $temp_array; |
||
| 7693 | } else $airport_array[] = $temp_array; |
||
| 7694 | } |
||
| 7695 | |||
| 7696 | return $airport_array; |
||
| 7697 | } |
||
| 7698 | |||
| 7699 | /** |
||
| 7700 | * Gets all arrival airports of the airplanes that have flown over |
||
| 7701 | * |
||
| 7702 | * @return Array the airport list |
||
| 7703 | * |
||
| 7704 | */ |
||
| 7705 | public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
||
| 7706 | { |
||
| 7707 | global $globalDBdriver; |
||
| 7708 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7709 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, countries.iso3 AS arrival_airport_country_iso3 |
||
| 7710 | FROM countries,spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' "; |
||
| 7711 | if ($olderthanmonths > 0) { |
||
| 7712 | if ($globalDBdriver == 'mysql') { |
||
| 7713 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 7714 | } else { |
||
| 7715 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 7716 | } |
||
| 7717 | } |
||
| 7718 | if ($sincedate != '') { |
||
| 7719 | if ($globalDBdriver == 'mysql') { |
||
| 7720 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 7721 | } else { |
||
| 7722 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 7723 | } |
||
| 7724 | } |
||
| 7725 | |||
| 7726 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 7727 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 7728 | $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, countries.iso3 |
||
| 7729 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 7730 | if ($limit) $query .= " LIMIT 10"; |
||
| 7731 | |||
| 7732 | |||
| 7733 | $sth = $this->db->prepare($query); |
||
| 7734 | $sth->execute(); |
||
| 7735 | |||
| 7736 | $airport_array = array(); |
||
| 7737 | $temp_array = array(); |
||
| 7738 | |||
| 7739 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7740 | { |
||
| 7741 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 7742 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 7743 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 7744 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 7745 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 7746 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 7747 | $temp_array['airport_arrival_country_iso3'] = $row['arrival_airport_country_iso3']; |
||
| 7748 | |||
| 7749 | if ($icaoaskey) { |
||
| 7750 | $icao = $row['arrival_airport_icao']; |
||
| 7751 | $airport_array[$icao] = $temp_array; |
||
| 7752 | } else $airport_array[] = $temp_array; |
||
| 7753 | } |
||
| 7754 | |||
| 7755 | return $airport_array; |
||
| 7756 | } |
||
| 7757 | |||
| 7758 | |||
| 7759 | /** |
||
| 7760 | * Gets all detected arrival airports of the airplanes that have flown over |
||
| 7761 | * |
||
| 7762 | * @return Array the airport list |
||
| 7763 | * |
||
| 7764 | */ |
||
| 7765 | public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '') |
||
| 7766 | { |
||
| 7767 | global $globalDBdriver; |
||
| 7768 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7769 | $query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, airport.latitude AS arrival_airport_latitude, airport.longitude AS arrival_airport_longitude |
||
| 7770 | FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao"; |
||
| 7771 | if ($olderthanmonths > 0) { |
||
| 7772 | if ($globalDBdriver == 'mysql') { |
||
| 7773 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 7774 | } else { |
||
| 7775 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 7776 | } |
||
| 7777 | } |
||
| 7778 | if ($sincedate != '') { |
||
| 7779 | if ($globalDBdriver == 'mysql') { |
||
| 7780 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 7781 | } else { |
||
| 7782 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 7783 | } |
||
| 7784 | } |
||
| 7785 | $query_values = array(); |
||
| 7786 | if ($year != '') { |
||
| 7787 | if ($globalDBdriver == 'mysql') { |
||
| 7788 | $query .= " AND YEAR(spotter_output.date) = :year"; |
||
| 7789 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 7790 | } else { |
||
| 7791 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
||
| 7792 | $query_values = array_merge($query_values,array(':year' => $year)); |
||
| 7793 | } |
||
| 7794 | } |
||
| 7795 | if ($month != '') { |
||
| 7796 | if ($globalDBdriver == 'mysql') { |
||
| 7797 | $query .= " AND MONTH(spotter_output.date) = :month"; |
||
| 7798 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 7799 | } else { |
||
| 7800 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
||
| 7801 | $query_values = array_merge($query_values,array(':month' => $month)); |
||
| 7802 | } |
||
| 7803 | } |
||
| 7804 | if ($day != '') { |
||
| 7805 | if ($globalDBdriver == 'mysql') { |
||
| 7806 | $query .= " AND DAY(spotter_output.date) = :day"; |
||
| 7807 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 7808 | } else { |
||
| 7809 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
||
| 7810 | $query_values = array_merge($query_values,array(':day' => $day)); |
||
| 7811 | } |
||
| 7812 | } |
||
| 7813 | $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude |
||
| 7814 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 7815 | if ($limit) $query .= " LIMIT 10"; |
||
| 7816 | |||
| 7817 | |||
| 7818 | $sth = $this->db->prepare($query); |
||
| 7819 | $sth->execute($query_values); |
||
| 7820 | |||
| 7821 | $airport_array = array(); |
||
| 7822 | $temp_array = array(); |
||
| 7823 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7824 | { |
||
| 7825 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 7826 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 7827 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 7828 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 7829 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 7830 | |||
| 7831 | if ($icaoaskey) { |
||
| 7832 | $icao = $row['arrival_airport_icao']; |
||
| 7833 | $airport_array[$icao] = $temp_array; |
||
| 7834 | } else $airport_array[] = $temp_array; |
||
| 7835 | } |
||
| 7836 | |||
| 7837 | return $airport_array; |
||
| 7838 | } |
||
| 7839 | |||
| 7840 | /** |
||
| 7841 | * Gets all detected arrival airports of the airplanes that have flown over |
||
| 7842 | * |
||
| 7843 | * @return Array the airport list |
||
| 7844 | * |
||
| 7845 | */ |
||
| 7846 | public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
||
| 7847 | { |
||
| 7848 | global $globalDBdriver; |
||
| 7849 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7850 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
||
| 7851 | FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao "; |
||
| 7852 | if ($olderthanmonths > 0) { |
||
| 7853 | if ($globalDBdriver == 'mysql') { |
||
| 7854 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 7855 | } else { |
||
| 7856 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 7857 | } |
||
| 7858 | } |
||
| 7859 | if ($sincedate != '') { |
||
| 7860 | if ($globalDBdriver == 'mysql') { |
||
| 7861 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 7862 | } else { |
||
| 7863 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 7864 | } |
||
| 7865 | } |
||
| 7866 | |||
| 7867 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 7868 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 7869 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
||
| 7870 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 7871 | if ($limit) $query .= " LIMIT 10"; |
||
| 7872 | |||
| 7873 | |||
| 7874 | $sth = $this->db->prepare($query); |
||
| 7875 | $sth->execute(); |
||
| 7876 | |||
| 7877 | $airport_array = array(); |
||
| 7878 | $temp_array = array(); |
||
| 7879 | |||
| 7880 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7881 | { |
||
| 7882 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 7883 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 7884 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 7885 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 7886 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 7887 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 7888 | |||
| 7889 | if ($icaoaskey) { |
||
| 7890 | $icao = $row['arrival_airport_icao']; |
||
| 7891 | $airport_array[$icao] = $temp_array; |
||
| 7892 | } else $airport_array[] = $temp_array; |
||
| 7893 | } |
||
| 7894 | |||
| 7895 | return $airport_array; |
||
| 7896 | } |
||
| 7897 | |||
| 7898 | /** |
||
| 7899 | * Gets all arrival airports of the airplanes that have flown over based on an airline icao |
||
| 7900 | * |
||
| 7901 | * @return Array the airport list |
||
| 7902 | * |
||
| 7903 | */ |
||
| 7904 | public function countAllArrivalAirportsByAirline($airline_icao, $filters = array()) |
||
| 7905 | { |
||
| 7906 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7907 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 7908 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 7909 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 7910 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 7911 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 7912 | |||
| 7913 | $sth = $this->db->prepare($query); |
||
| 7914 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 7915 | |||
| 7916 | $airport_array = array(); |
||
| 7917 | $temp_array = array(); |
||
| 7918 | |||
| 7919 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7920 | { |
||
| 7921 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 7922 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 7923 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 7924 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 7925 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 7926 | |||
| 7927 | $airport_array[] = $temp_array; |
||
| 7928 | } |
||
| 7929 | |||
| 7930 | return $airport_array; |
||
| 7931 | } |
||
| 7932 | |||
| 7933 | |||
| 7934 | /** |
||
| 7935 | * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao |
||
| 7936 | * |
||
| 7937 | * @return Array the airport list |
||
| 7938 | * |
||
| 7939 | */ |
||
| 7940 | public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array()) |
||
| 7941 | { |
||
| 7942 | $filter_query = $this->getFilter($filters,true,true); |
||
| 7943 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 7944 | |||
| 7945 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS arrival_airport_country_iso3 |
||
| 7946 | FROM countries, spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 7947 | GROUP BY spotter_output.arrival_airport_country, countries.iso3 |
||
| 7948 | ORDER BY airport_arrival_country_count DESC"; |
||
| 7949 | |||
| 7950 | |||
| 7951 | $sth = $this->db->prepare($query); |
||
| 7952 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 7953 | |||
| 7954 | $airport_array = array(); |
||
| 7955 | $temp_array = array(); |
||
| 7956 | |||
| 7957 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 7958 | { |
||
| 7959 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
||
| 7960 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
||
| 7961 | $temp_array['arrival_airport_country_iso3'] = $row['arrival_airport_country_iso3']; |
||
| 7962 | $airport_array[] = $temp_array; |
||
| 7963 | } |
||
| 7964 | return $airport_array; |
||
| 7965 | } |
||
| 7966 | |||
| 7967 | |||
| 7968 | /** |
||
| 7969 | * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao |
||
| 7970 | * |
||
| 7971 | * @return Array the airport list |
||
| 7972 | * |
||
| 7973 | */ |
||
| 7974 | public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array()) |
||
| 8003 | |||
| 8004 | |||
| 8005 | |||
| 8006 | /** |
||
| 8007 | * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 8008 | * |
||
| 8009 | * @return Array the airport list |
||
| 8010 | * |
||
| 8011 | */ |
||
| 8012 | public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 8013 | { |
||
| 8014 | $filter_query = $this->getFilter($filters,true,true); |
||
| 8015 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 8016 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 |
||
| 8017 | FROM countries, spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 8018 | GROUP BY spotter_output.arrival_airport_country, countries.iso3 |
||
| 8019 | ORDER BY airport_arrival_country_count DESC"; |
||
| 8020 | |||
| 8021 | |||
| 8022 | $sth = $this->db->prepare($query); |
||
| 8023 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 8024 | |||
| 8025 | $airport_array = array(); |
||
| 8026 | $temp_array = array(); |
||
| 8027 | |||
| 8028 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 8029 | { |
||
| 8030 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
||
| 8031 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
||
| 8032 | $temp_array['arrival_airport_country_iso3'] = $row['airport_arrival_country_iso3']; |
||
| 8033 | $airport_array[] = $temp_array; |
||
| 8034 | } |
||
| 8035 | |||
| 8036 | return $airport_array; |
||
| 8037 | } |
||
| 8038 | |||
| 8039 | |||
| 8040 | /** |
||
| 8041 | * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration |
||
| 8042 | * |
||
| 8043 | * @return Array the airport list |
||
| 8044 | * |
||
| 8045 | */ |
||
| 8046 | public function countAllArrivalAirportsByRegistration($registration,$filters = array()) |
||
| 8076 | |||
| 8077 | |||
| 8078 | /** |
||
| 8079 | * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration |
||
| 8080 | * |
||
| 8081 | * @return Array the airport list |
||
| 8082 | * |
||
| 8083 | */ |
||
| 8084 | public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array()) |
||
| 8110 | |||
| 8111 | |||
| 8112 | |||
| 8113 | /** |
||
| 8114 | * Gets all arrival airports of the airplanes that have flown over based on an departure airport |
||
| 8115 | * |
||
| 8116 | * @return Array the airport list |
||
| 8117 | * |
||
| 8118 | */ |
||
| 8119 | public function countAllArrivalAirportsByAirport($airport_icao,$filters = array()) |
||
| 8148 | |||
| 8149 | |||
| 8150 | /** |
||
| 8151 | * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao |
||
| 8152 | * |
||
| 8153 | * @return Array the airport list |
||
| 8154 | * |
||
| 8155 | */ |
||
| 8156 | public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array()) |
||
| 8157 | { |
||
| 8158 | $filter_query = $this->getFilter($filters,true,true); |
||
| 8159 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 8160 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS arrival_airport_country_iso3 |
||
| 8161 | FROM countries, spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao |
||
| 8162 | GROUP BY spotter_output.arrival_airport_country, countries.iso3 |
||
| 8163 | ORDER BY airport_arrival_country_count DESC"; |
||
| 8164 | |||
| 8165 | $sth = $this->db->prepare($query); |
||
| 8166 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 8167 | |||
| 8168 | $airport_array = array(); |
||
| 8169 | $temp_array = array(); |
||
| 8170 | |||
| 8171 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 8172 | { |
||
| 8173 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
||
| 8174 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
||
| 8175 | $temp_array['arrival_airport_country_iso3'] = $row['arrival_airport_country_iso3']; |
||
| 8176 | $airport_array[] = $temp_array; |
||
| 8177 | } |
||
| 8178 | return $airport_array; |
||
| 8179 | } |
||
| 8180 | |||
| 8181 | |||
| 8182 | /** |
||
| 8183 | * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer |
||
| 8184 | * |
||
| 8185 | * @return Array the airport list |
||
| 8186 | * |
||
| 8187 | */ |
||
| 8188 | public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 8189 | { |
||
| 8190 | $filter_query = $this->getFilter($filters,true,true); |
||
| 8191 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 8192 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 8193 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 8194 | GROUP BY spotter_output.arrival_airport_icao |
||
| 8195 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 8196 | |||
| 8197 | |||
| 8198 | $sth = $this->db->prepare($query); |
||
| 8199 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 8200 | |||
| 8201 | $airport_array = array(); |
||
| 8202 | $temp_array = array(); |
||
| 8203 | |||
| 8204 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 8205 | { |
||
| 8206 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 8207 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 8208 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 8209 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 8210 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 8211 | |||
| 8212 | $airport_array[] = $temp_array; |
||
| 8213 | } |
||
| 8214 | |||
| 8215 | return $airport_array; |
||
| 8216 | } |
||
| 8217 | |||
| 8218 | |||
| 8219 | |||
| 8220 | /** |
||
| 8221 | * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer |
||
| 8222 | * |
||
| 8223 | * @return Array the airport list |
||
| 8224 | * |
||
| 8225 | */ |
||
| 8226 | public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 8227 | { |
||
| 8228 | $filter_query = $this->getFilter($filters,true,true); |
||
| 8229 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 8230 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
||
| 8231 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 8232 | GROUP BY spotter_output.arrival_airport_country |
||
| 8233 | ORDER BY airport_arrival_country_count DESC"; |
||
| 8234 | |||
| 8235 | |||
| 8236 | $sth = $this->db->prepare($query); |
||
| 8237 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 8238 | |||
| 8239 | $airport_array = array(); |
||
| 8240 | $temp_array = array(); |
||
| 8241 | |||
| 8242 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 8243 | { |
||
| 8244 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
||
| 8245 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
||
| 8246 | |||
| 8247 | $airport_array[] = $temp_array; |
||
| 8248 | } |
||
| 8249 | |||
| 8250 | return $airport_array; |
||
| 8251 | } |
||
| 8252 | |||
| 8253 | |||
| 8254 | |||
| 8255 | /** |
||
| 8256 | * Gets all arrival airports of the airplanes that have flown over based on a date |
||
| 8257 | * |
||
| 8258 | * @return Array the airport list |
||
| 8259 | * |
||
| 8260 | */ |
||
| 8261 | public function countAllArrivalAirportsByDate($date,$filters = array()) |
||
| 8262 | { |
||
| 8263 | global $globalTimezone, $globalDBdriver; |
||
| 8264 | $filter_query = $this->getFilter($filters,true,true); |
||
| 8265 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 8266 | if ($globalTimezone != '') { |
||
| 8267 | date_default_timezone_set($globalTimezone); |
||
| 8268 | $datetime = new DateTime($date); |
||
| 8269 | $offset = $datetime->format('P'); |
||
| 8270 | } else $offset = '+00:00'; |
||
| 8271 | |||
| 8272 | if ($globalDBdriver == 'mysql') { |
||
| 8273 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 8274 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 8275 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 8276 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 8277 | } else { |
||
| 8278 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 8279 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 8280 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
||
| 8281 | ORDER BY airport_arrival_icao_count DESC"; |
||
| 8282 | } |
||
| 8283 | |||
| 8284 | $sth = $this->db->prepare($query); |
||
| 8285 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 8286 | |||
| 8287 | $airport_array = array(); |
||
| 8288 | $temp_array = array(); |
||
| 8289 | |||
| 8290 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 8291 | { |
||
| 8292 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 8293 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
||
| 8294 | $temp_array['airport_arrival_name'] = $row['arrival_airport_name']; |
||
| 8295 | $temp_array['airport_arrival_city'] = $row['arrival_airport_city']; |
||
| 8296 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
||
| 8297 | |||
| 8298 | $airport_array[] = $temp_array; |
||
| 8299 | } |
||
| 8300 | return $airport_array; |
||
| 8301 | } |
||
| 8302 | |||
| 8303 | |||
| 8304 | |||
| 8305 | /** |
||
| 8306 | * Gets all arrival airports by country of the airplanes that have flown over based on a date |
||
| 8307 | * |
||
| 8308 | * @return Array the airport list |
||
| 8309 | * |
||
| 8310 | */ |
||
| 8311 | public function countAllArrivalAirportCountriesByDate($date, $filters = array()) |
||
| 8312 | { |
||
| 8349 | |||
| 8350 | |||
| 8351 | |||
| 8352 | /** |
||
| 8353 | * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign |
||
| 8354 | * |
||
| 8355 | * @return Array the airport list |
||
| 8356 | * |
||
| 8357 | */ |
||
| 8358 | public function countAllArrivalAirportsByIdent($ident,$filters = array()) |
||
| 8387 | |||
| 8388 | /** |
||
| 8389 | * Gets all arrival airports of the airplanes that have flown over based on a owner |
||
| 8390 | * |
||
| 8391 | * @return Array the airport list |
||
| 8392 | * |
||
| 8393 | */ |
||
| 8394 | public function countAllArrivalAirportsByOwner($owner,$filters = array()) |
||
| 8422 | |||
| 8423 | /** |
||
| 8424 | * Gets all arrival airports of the airplanes that have flown over based on a pilot |
||
| 8425 | * |
||
| 8426 | * @return Array the airport list |
||
| 8427 | * |
||
| 8428 | */ |
||
| 8429 | public function countAllArrivalAirportsByPilot($pilot,$filters = array()) |
||
| 8457 | |||
| 8458 | /** |
||
| 8459 | * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident |
||
| 8460 | * |
||
| 8461 | * @return Array the airport list |
||
| 8462 | * |
||
| 8463 | */ |
||
| 8464 | public function countAllArrivalAirportCountriesByIdent($ident, $filters = array()) |
||
| 8490 | |||
| 8491 | /** |
||
| 8492 | * Gets all arrival airports by country of the airplanes that have flown over based on a owner |
||
| 8493 | * |
||
| 8494 | * @return Array the airport list |
||
| 8495 | * |
||
| 8496 | */ |
||
| 8497 | public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) |
||
| 8510 | |||
| 8511 | /** |
||
| 8512 | * Gets all arrival airports by country of the airplanes that have flown over based on a pilot |
||
| 8513 | * |
||
| 8514 | * @return Array the airport list |
||
| 8515 | * |
||
| 8516 | */ |
||
| 8517 | public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array()) |
||
| 8530 | |||
| 8531 | |||
| 8532 | |||
| 8533 | /** |
||
| 8534 | * Gets all arrival airports of the airplanes that have flown over based on a country |
||
| 8535 | * |
||
| 8536 | * @return Array the airport list |
||
| 8537 | * |
||
| 8538 | */ |
||
| 8539 | public function countAllArrivalAirportsByCountry($country,$filters = array()) |
||
| 8568 | |||
| 8569 | |||
| 8570 | /** |
||
| 8571 | * Gets all arrival airports by country of the airplanes that have flown over based on a country |
||
| 8572 | * |
||
| 8573 | * @return Array the airport list |
||
| 8574 | * |
||
| 8575 | */ |
||
| 8576 | public function countAllArrivalAirportCountriesByCountry($country,$filters = array()) |
||
| 8599 | |||
| 8600 | |||
| 8601 | |||
| 8602 | /** |
||
| 8603 | * Counts all airport departure countries |
||
| 8604 | * |
||
| 8605 | * @return Array the airport departure list |
||
| 8606 | * |
||
| 8607 | */ |
||
| 8608 | public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '') |
||
| 8663 | |||
| 8664 | |||
| 8665 | /** |
||
| 8666 | * Counts all airport arrival countries |
||
| 8667 | * |
||
| 8668 | * @return Array the airport arrival list |
||
| 8669 | * |
||
| 8670 | */ |
||
| 8671 | public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '') |
||
| 8727 | |||
| 8728 | |||
| 8729 | |||
| 8730 | |||
| 8731 | |||
| 8732 | /** |
||
| 8733 | * Gets all route combinations |
||
| 8734 | * |
||
| 8735 | * @return Array the route list |
||
| 8736 | * |
||
| 8737 | */ |
||
| 8738 | public function countAllRoutes($filters = array()) |
||
| 8771 | |||
| 8772 | |||
| 8773 | |||
| 8774 | |||
| 8775 | /** |
||
| 8776 | * Gets all route combinations based on an aircraft |
||
| 8777 | * |
||
| 8778 | * @return Array the route list |
||
| 8779 | * |
||
| 8780 | */ |
||
| 8781 | public function countAllRoutesByAircraft($aircraft_icao,$filters = array()) |
||
| 8813 | |||
| 8814 | |||
| 8815 | /** |
||
| 8816 | * Gets all route combinations based on an aircraft registration |
||
| 8817 | * |
||
| 8818 | * @return Array the route list |
||
| 8819 | * |
||
| 8820 | */ |
||
| 8821 | public function countAllRoutesByRegistration($registration, $filters = array()) |
||
| 8854 | |||
| 8855 | |||
| 8856 | |||
| 8857 | /** |
||
| 8858 | * Gets all route combinations based on an airline |
||
| 8859 | * |
||
| 8860 | * @return Array the route list |
||
| 8861 | * |
||
| 8862 | */ |
||
| 8863 | public function countAllRoutesByAirline($airline_icao, $filters = array()) |
||
| 8896 | |||
| 8897 | |||
| 8898 | |||
| 8899 | /** |
||
| 8900 | * Gets all route combinations based on an airport |
||
| 8901 | * |
||
| 8902 | * @return Array the route list |
||
| 8903 | * |
||
| 8904 | */ |
||
| 8905 | public function countAllRoutesByAirport($airport_icao, $filters = array()) |
||
| 8937 | |||
| 8938 | |||
| 8939 | |||
| 8940 | /** |
||
| 8941 | * Gets all route combinations based on an country |
||
| 8942 | * |
||
| 8943 | * @return Array the route list |
||
| 8944 | * |
||
| 8945 | */ |
||
| 8946 | public function countAllRoutesByCountry($country, $filters = array()) |
||
| 8978 | |||
| 8979 | |||
| 8980 | /** |
||
| 8981 | * Gets all route combinations based on an date |
||
| 8982 | * |
||
| 8983 | * @return Array the route list |
||
| 8984 | * |
||
| 8985 | */ |
||
| 8986 | public function countAllRoutesByDate($date, $filters = array()) |
||
| 9032 | |||
| 9033 | |||
| 9034 | /** |
||
| 9035 | * Gets all route combinations based on an ident/callsign |
||
| 9036 | * |
||
| 9037 | * @return Array the route list |
||
| 9038 | * |
||
| 9039 | */ |
||
| 9040 | public function countAllRoutesByIdent($ident, $filters = array()) |
||
| 9073 | |||
| 9074 | /** |
||
| 9075 | * Gets all route combinations based on an owner |
||
| 9076 | * |
||
| 9077 | * @return Array the route list |
||
| 9078 | * |
||
| 9079 | */ |
||
| 9080 | public function countAllRoutesByOwner($owner,$filters = array()) |
||
| 9113 | |||
| 9114 | /** |
||
| 9115 | * Gets all route combinations based on a pilot |
||
| 9116 | * |
||
| 9117 | * @return Array the route list |
||
| 9118 | * |
||
| 9119 | */ |
||
| 9120 | public function countAllRoutesByPilot($pilot,$filters = array()) |
||
| 9153 | |||
| 9154 | |||
| 9155 | /** |
||
| 9156 | * Gets all route combinations based on an manufacturer |
||
| 9157 | * |
||
| 9158 | * @return Array the route list |
||
| 9159 | * |
||
| 9160 | */ |
||
| 9161 | public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array()) |
||
| 9194 | |||
| 9195 | |||
| 9196 | |||
| 9197 | /** |
||
| 9198 | * Gets all route combinations with waypoints |
||
| 9199 | * |
||
| 9200 | * @return Array the route list |
||
| 9201 | * |
||
| 9202 | */ |
||
| 9203 | public function countAllRoutesWithWaypoints($filters = array()) |
||
| 9237 | |||
| 9238 | /** |
||
| 9239 | * Gets all callsigns that have flown over |
||
| 9240 | * |
||
| 9241 | * @return Array the callsign list |
||
| 9242 | * |
||
| 9243 | */ |
||
| 9244 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
||
| 9307 | |||
| 9308 | /** |
||
| 9309 | * Gets all callsigns that have flown over |
||
| 9310 | * |
||
| 9311 | * @return Array the callsign list |
||
| 9312 | * |
||
| 9313 | */ |
||
| 9314 | public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
||
| 9349 | |||
| 9350 | |||
| 9351 | |||
| 9352 | |||
| 9353 | /** |
||
| 9354 | * Counts all dates |
||
| 9355 | * |
||
| 9356 | * @return Array the date list |
||
| 9357 | * |
||
| 9358 | */ |
||
| 9359 | public function countAllDates($filters = array()) |
||
| 9401 | |||
| 9402 | /** |
||
| 9403 | * Counts all dates |
||
| 9404 | * |
||
| 9405 | * @return Array the date list |
||
| 9406 | * |
||
| 9407 | */ |
||
| 9408 | public function countAllDatesByAirlines($filters = array()) |
||
| 9450 | |||
| 9451 | /** |
||
| 9452 | * Counts all dates during the last 7 days |
||
| 9453 | * |
||
| 9454 | * @return Array the date list |
||
| 9455 | * |
||
| 9456 | */ |
||
| 9457 | public function countAllDatesLast7Days($filters = array()) |
||
| 9496 | |||
| 9497 | /** |
||
| 9498 | * Counts all dates during the last month |
||
| 9499 | * |
||
| 9500 | * @return Array the date list |
||
| 9501 | * |
||
| 9502 | */ |
||
| 9503 | public function countAllDatesLastMonth($filters = array()) |
||
| 9542 | |||
| 9543 | |||
| 9544 | /** |
||
| 9545 | * Counts all dates during the last month |
||
| 9546 | * |
||
| 9547 | * @return Array the date list |
||
| 9548 | * |
||
| 9549 | */ |
||
| 9550 | public function countAllDatesLastMonthByAirlines($filters = array()) |
||
| 9591 | |||
| 9592 | |||
| 9593 | /** |
||
| 9594 | * Counts all month |
||
| 9595 | * |
||
| 9596 | * @return Array the month list |
||
| 9597 | * |
||
| 9598 | */ |
||
| 9599 | public function countAllMonths($filters = array()) |
||
| 9638 | |||
| 9639 | /** |
||
| 9640 | * Counts all month |
||
| 9641 | * |
||
| 9642 | * @return Array the month list |
||
| 9643 | * |
||
| 9644 | */ |
||
| 9645 | public function countAllMonthsByAirlines($filters = array()) |
||
| 9687 | |||
| 9688 | /** |
||
| 9689 | * Counts all military month |
||
| 9690 | * |
||
| 9691 | * @return Array the month list |
||
| 9692 | * |
||
| 9693 | */ |
||
| 9694 | public function countAllMilitaryMonths($filters = array()) |
||
| 9732 | |||
| 9733 | /** |
||
| 9734 | * Counts all month owners |
||
| 9735 | * |
||
| 9736 | * @return Array the month list |
||
| 9737 | * |
||
| 9738 | */ |
||
| 9739 | public function countAllMonthsOwners($filters = array()) |
||
| 9778 | |||
| 9779 | /** |
||
| 9780 | * Counts all month owners |
||
| 9781 | * |
||
| 9782 | * @return Array the month list |
||
| 9783 | * |
||
| 9784 | */ |
||
| 9785 | public function countAllMonthsOwnersByAirlines($filters = array()) |
||
| 9825 | |||
| 9826 | /** |
||
| 9827 | * Counts all month pilot |
||
| 9828 | * |
||
| 9829 | * @return Array the month list |
||
| 9830 | * |
||
| 9831 | */ |
||
| 9832 | public function countAllMonthsPilots($filters = array()) |
||
| 9871 | |||
| 9872 | /** |
||
| 9873 | * Counts all month pilot |
||
| 9874 | * |
||
| 9875 | * @return Array the month list |
||
| 9876 | * |
||
| 9877 | */ |
||
| 9878 | public function countAllMonthsPilotsByAirlines($filters = array()) |
||
| 9918 | |||
| 9919 | /** |
||
| 9920 | * Counts all month airline |
||
| 9921 | * |
||
| 9922 | * @return Array the month list |
||
| 9923 | * |
||
| 9924 | */ |
||
| 9925 | public function countAllMonthsAirlines($filters = array()) |
||
| 9964 | |||
| 9965 | /** |
||
| 9966 | * Counts all month aircraft |
||
| 9967 | * |
||
| 9968 | * @return Array the month list |
||
| 9969 | * |
||
| 9970 | */ |
||
| 9971 | public function countAllMonthsAircrafts($filters = array()) |
||
| 10010 | |||
| 10011 | |||
| 10012 | /** |
||
| 10013 | * Counts all month aircraft |
||
| 10014 | * |
||
| 10015 | * @return Array the month list |
||
| 10016 | * |
||
| 10017 | */ |
||
| 10018 | public function countAllMonthsAircraftsByAirlines($filters = array()) |
||
| 10058 | |||
| 10059 | /** |
||
| 10060 | * Counts all month real arrival |
||
| 10061 | * |
||
| 10062 | * @return Array the month list |
||
| 10063 | * |
||
| 10064 | */ |
||
| 10065 | public function countAllMonthsRealArrivals($filters = array()) |
||
| 10104 | |||
| 10105 | |||
| 10106 | /** |
||
| 10107 | * Counts all month real arrival |
||
| 10108 | * |
||
| 10109 | * @return Array the month list |
||
| 10110 | * |
||
| 10111 | */ |
||
| 10112 | public function countAllMonthsRealArrivalsByAirlines($filters = array()) |
||
| 10152 | |||
| 10153 | |||
| 10154 | /** |
||
| 10155 | * Counts all dates during the last year |
||
| 10156 | * |
||
| 10157 | * @return Array the date list |
||
| 10158 | * |
||
| 10159 | */ |
||
| 10160 | public function countAllMonthsLastYear($filters) |
||
| 10200 | |||
| 10201 | |||
| 10202 | |||
| 10203 | /** |
||
| 10204 | * Counts all hours |
||
| 10205 | * |
||
| 10206 | * @return Array the hour list |
||
| 10207 | * |
||
| 10208 | */ |
||
| 10209 | public function countAllHours($orderby,$filters = array()) |
||
| 10267 | |||
| 10268 | /** |
||
| 10269 | * Counts all hours |
||
| 10270 | * |
||
| 10271 | * @return Array the hour list |
||
| 10272 | * |
||
| 10273 | */ |
||
| 10274 | public function countAllHoursByAirlines($orderby, $filters = array()) |
||
| 10332 | |||
| 10333 | |||
| 10334 | |||
| 10335 | /** |
||
| 10336 | * Counts all hours by airline |
||
| 10337 | * |
||
| 10338 | * @return Array the hour list |
||
| 10339 | * |
||
| 10340 | */ |
||
| 10341 | public function countAllHoursByAirline($airline_icao, $filters = array()) |
||
| 10381 | |||
| 10382 | |||
| 10383 | |||
| 10384 | |||
| 10385 | /** |
||
| 10386 | * Counts all hours by aircraft |
||
| 10387 | * |
||
| 10388 | * @return Array the hour list |
||
| 10389 | * |
||
| 10390 | */ |
||
| 10391 | public function countAllHoursByAircraft($aircraft_icao, $filters = array()) |
||
| 10430 | |||
| 10431 | |||
| 10432 | /** |
||
| 10433 | * Counts all hours by aircraft registration |
||
| 10434 | * |
||
| 10435 | * @return Array the hour list |
||
| 10436 | * |
||
| 10437 | */ |
||
| 10438 | public function countAllHoursByRegistration($registration, $filters = array()) |
||
| 10477 | |||
| 10478 | |||
| 10479 | /** |
||
| 10480 | * Counts all hours by airport |
||
| 10481 | * |
||
| 10482 | * @return Array the hour list |
||
| 10483 | * |
||
| 10484 | */ |
||
| 10485 | public function countAllHoursByAirport($airport_icao, $filters = array()) |
||
| 10524 | |||
| 10525 | |||
| 10526 | |||
| 10527 | /** |
||
| 10528 | * Counts all hours by manufacturer |
||
| 10529 | * |
||
| 10530 | * @return Array the hour list |
||
| 10531 | * |
||
| 10532 | */ |
||
| 10533 | public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array()) |
||
| 10572 | |||
| 10573 | |||
| 10574 | |||
| 10575 | /** |
||
| 10576 | * Counts all hours by date |
||
| 10577 | * |
||
| 10578 | * @return Array the hour list |
||
| 10579 | * |
||
| 10580 | */ |
||
| 10581 | public function countAllHoursByDate($date, $filters = array()) |
||
| 10620 | |||
| 10621 | |||
| 10622 | |||
| 10623 | /** |
||
| 10624 | * Counts all hours by a ident/callsign |
||
| 10625 | * |
||
| 10626 | * @return Array the hour list |
||
| 10627 | * |
||
| 10628 | */ |
||
| 10629 | public function countAllHoursByIdent($ident, $filters = array()) |
||
| 10669 | |||
| 10670 | /** |
||
| 10671 | * Counts all hours by a owner |
||
| 10672 | * |
||
| 10673 | * @return Array the hour list |
||
| 10674 | * |
||
| 10675 | */ |
||
| 10676 | public function countAllHoursByOwner($owner, $filters = array()) |
||
| 10716 | |||
| 10717 | /** |
||
| 10718 | * Counts all hours by a pilot |
||
| 10719 | * |
||
| 10720 | * @return Array the hour list |
||
| 10721 | * |
||
| 10722 | */ |
||
| 10723 | public function countAllHoursByPilot($pilot, $filters = array()) |
||
| 10763 | |||
| 10764 | |||
| 10765 | |||
| 10766 | /** |
||
| 10767 | * Counts all hours by route |
||
| 10768 | * |
||
| 10769 | * @return Array the hour list |
||
| 10770 | * |
||
| 10771 | */ |
||
| 10772 | public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array()) |
||
| 10812 | |||
| 10813 | |||
| 10814 | /** |
||
| 10815 | * Counts all hours by country |
||
| 10816 | * |
||
| 10817 | * @return Array the hour list |
||
| 10818 | * |
||
| 10819 | */ |
||
| 10820 | public function countAllHoursByCountry($country, $filters = array()) |
||
| 10859 | |||
| 10860 | |||
| 10861 | |||
| 10862 | |||
| 10863 | /** |
||
| 10864 | * Counts all aircraft that have flown over |
||
| 10865 | * |
||
| 10866 | * @return Integer the number of aircrafts |
||
| 10867 | * |
||
| 10868 | */ |
||
| 10869 | public function countOverallAircrafts($filters = array(),$year = '',$month = '') |
||
| 10899 | |||
| 10900 | /** |
||
| 10901 | * Counts all flight that really arrival |
||
| 10902 | * |
||
| 10903 | * @return Integer the number of aircrafts |
||
| 10904 | * |
||
| 10905 | */ |
||
| 10906 | public function countOverallArrival($filters = array(),$year = '',$month = '') |
||
| 10936 | |||
| 10937 | /** |
||
| 10938 | * Counts all pilots that have flown over |
||
| 10939 | * |
||
| 10940 | * @return Integer the number of pilots |
||
| 10941 | * |
||
| 10942 | */ |
||
| 10943 | public function countOverallPilots($filters = array(),$year = '',$month = '') |
||
| 10972 | |||
| 10973 | /** |
||
| 10974 | * Counts all owners that have flown over |
||
| 10975 | * |
||
| 10976 | * @return Integer the number of owners |
||
| 10977 | * |
||
| 10978 | */ |
||
| 10979 | public function countOverallOwners($filters = array(),$year = '',$month = '') |
||
| 11008 | |||
| 11009 | |||
| 11010 | /** |
||
| 11011 | * Counts all flights that have flown over |
||
| 11012 | * |
||
| 11013 | * @return Integer the number of flights |
||
| 11014 | * |
||
| 11015 | */ |
||
| 11016 | public function countOverallFlights($filters = array(),$year = '',$month = '') |
||
| 11047 | |||
| 11048 | /** |
||
| 11049 | * Counts all military flights that have flown over |
||
| 11050 | * |
||
| 11051 | * @return Integer the number of flights |
||
| 11052 | * |
||
| 11053 | */ |
||
| 11054 | public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '') |
||
| 11084 | |||
| 11085 | |||
| 11086 | |||
| 11087 | /** |
||
| 11088 | * Counts all airlines that have flown over |
||
| 11089 | * |
||
| 11090 | * @return Integer the number of airlines |
||
| 11091 | * |
||
| 11092 | */ |
||
| 11093 | public function countOverallAirlines($filters = array(),$year = '',$month = '') |
||
| 11127 | |||
| 11128 | |||
| 11129 | /** |
||
| 11130 | * Counts all hours of today |
||
| 11131 | * |
||
| 11132 | * @return Array the hour list |
||
| 11133 | * |
||
| 11134 | */ |
||
| 11135 | public function countAllHoursFromToday($filters = array()) |
||
| 11172 | |||
| 11173 | /** |
||
| 11174 | * Gets all the spotter information based on calculated upcoming flights |
||
| 11175 | * |
||
| 11176 | * @return Array the spotter information |
||
| 11177 | * |
||
| 11178 | */ |
||
| 11179 | public function getUpcomingFlights($limit = '', $sort = '', $filters = array()) |
||
| 11251 | |||
| 11252 | |||
| 11253 | /** |
||
| 11254 | * Gets the Barrie Spotter ID based on the FlightAware ID |
||
| 11255 | * |
||
| 11256 | * @return Integer the Barrie Spotter ID |
||
| 11257 | q * |
||
| 11258 | */ |
||
| 11259 | public function getSpotterIDBasedOnFlightAwareID($flightaware_id) |
||
| 11276 | |||
| 11277 | |||
| 11278 | /** |
||
| 11279 | * Parses a date string |
||
| 11280 | * |
||
| 11281 | * @param String $dateString the date string |
||
| 11282 | * @param String $timezone the timezone of a user |
||
| 11283 | * @return Array the time information |
||
| 11284 | * |
||
| 11285 | */ |
||
| 11286 | public function parseDateString($dateString, $timezone = '') |
||
| 11316 | |||
| 11317 | |||
| 11318 | |||
| 11319 | |||
| 11320 | /** |
||
| 11321 | * Parses the direction degrees to working |
||
| 11322 | * |
||
| 11323 | * @param Float $direction the direction in degrees |
||
| 11324 | * @return Array the direction information |
||
| 11325 | * |
||
| 11326 | */ |
||
| 11327 | public function parseDirection($direction = 0) |
||
| 11402 | |||
| 11403 | |||
| 11404 | /** |
||
| 11405 | * Gets the aircraft registration |
||
| 11406 | * |
||
| 11407 | * @param String $flightaware_id the flight aware id |
||
| 11408 | * @return String the aircraft registration |
||
| 11409 | * |
||
| 11410 | */ |
||
| 11411 | |||
| 11412 | public function getAircraftRegistration($flightaware_id) |
||
| 11436 | |||
| 11437 | |||
| 11438 | /** |
||
| 11439 | * Gets the aircraft registration from ModeS |
||
| 11440 | * |
||
| 11441 | * @param String $aircraft_modes the flight ModeS in hex |
||
| 11442 | * @return String the aircraft registration |
||
| 11443 | * |
||
| 11444 | */ |
||
| 11445 | public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '') |
||
| 11467 | |||
| 11468 | /** |
||
| 11469 | * Gets the aircraft type from ModeS |
||
| 11470 | * |
||
| 11471 | * @param String $aircraft_modes the flight ModeS in hex |
||
| 11472 | * @return String the aircraft type |
||
| 11473 | * |
||
| 11474 | */ |
||
| 11475 | public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '') |
||
| 11498 | |||
| 11499 | /** |
||
| 11500 | * Gets Country from latitude/longitude |
||
| 11501 | * |
||
| 11502 | * @param Float $latitude latitute of the flight |
||
| 11503 | * @param Float $longitude longitute of the flight |
||
| 11504 | * @return String the countrie |
||
| 11505 | */ |
||
| 11506 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
||
| 11540 | |||
| 11541 | /** |
||
| 11542 | * Gets Country from iso2 |
||
| 11543 | * |
||
| 11544 | * @param String $iso2 ISO2 country code |
||
| 11545 | * @return String the countrie |
||
| 11546 | */ |
||
| 11547 | public function getCountryFromISO2($iso2) |
||
| 11572 | |||
| 11573 | /** |
||
| 11574 | * converts the registration code using the country prefix |
||
| 11575 | * |
||
| 11576 | * @param String $registration the aircraft registration |
||
| 11577 | * @return String the aircraft registration |
||
| 11578 | * |
||
| 11579 | */ |
||
| 11580 | public function convertAircraftRegistration($registration) |
||
| 11629 | |||
| 11630 | /** |
||
| 11631 | * Country from the registration code |
||
| 11632 | * |
||
| 11633 | * @param String $registration the aircraft registration |
||
| 11634 | * @return String the country |
||
| 11635 | * |
||
| 11636 | */ |
||
| 11637 | public function countryFromAircraftRegistration($registration) |
||
| 11690 | |||
| 11691 | /** |
||
| 11692 | * Registration prefix from the registration code |
||
| 11693 | * |
||
| 11694 | * @param String $registration the aircraft registration |
||
| 11695 | * @return String the registration prefix |
||
| 11696 | * |
||
| 11697 | */ |
||
| 11698 | public function registrationPrefixFromAircraftRegistration($registration) |
||
| 11750 | |||
| 11751 | |||
| 11752 | /** |
||
| 11753 | * Country from the registration code |
||
| 11754 | * |
||
| 11755 | * @param String $registration the aircraft registration |
||
| 11756 | * @return String the country |
||
| 11757 | * |
||
| 11758 | */ |
||
| 11759 | public function countryFromAircraftRegistrationCode($registration) |
||
| 11773 | |||
| 11774 | /** |
||
| 11775 | * Set a new highlight value for a flight |
||
| 11776 | * |
||
| 11777 | * @param String $flightaware_id flightaware_id from spotter_output table |
||
| 11778 | * @param String $highlight New highlight value |
||
| 11779 | */ |
||
| 11780 | public function setHighlightFlight($flightaware_id,$highlight) { |
||
| 11786 | |||
| 11787 | /** |
||
| 11788 | * Set a new highlight value for a flight by Registration |
||
| 11789 | * |
||
| 11790 | * @param String $registration Registration of the aircraft |
||
| 11791 | * @param String $date Date of spotted aircraft |
||
| 11792 | * @param String $highlight New highlight value |
||
| 11793 | */ |
||
| 11794 | public function setHighlightFlightByRegistration($registration,$highlight, $date = '') { |
||
| 11805 | |||
| 11806 | /** |
||
| 11807 | * Gets the short url from bit.ly |
||
| 11808 | * |
||
| 11809 | * @param String $url the full url |
||
| 11810 | * @return String the bit.ly url |
||
| 11811 | * |
||
| 11812 | */ |
||
| 11813 | public function getBitlyURL($url) |
||
| 11836 | |||
| 11837 | |||
| 11838 | public function getOrderBy() |
||
| 11845 | |||
| 11846 | /* |
||
| 11847 | public function importFromFlightAware() |
||
| 11848 | { |
||
| 11849 | global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore; |
||
| 11850 | $Spotter = new Spotter($this->db); |
||
| 11851 | $SpotterLive = new SpotterLive($this->db); |
||
| 11852 | $options = array( |
||
| 11853 | 'trace' => true, |
||
| 11854 | 'exceptions' => 0, |
||
| 11855 | 'login' => $globalFlightAwareUsername, |
||
| 11856 | 'password' => $globalFlightAwarePassword, |
||
| 11857 | ); |
||
| 11858 | $client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); |
||
| 11859 | $params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0'); |
||
| 11860 | $result = $client->SearchBirdseyeInFlight($params); |
||
| 11861 | $dataFound = false; |
||
| 11862 | $ignoreImport = false; |
||
| 11863 | if (isset($result->SearchBirdseyeInFlightResult)) |
||
| 11864 | { |
||
| 11865 | if (is_array($result->SearchBirdseyeInFlightResult->aircraft)) |
||
| 11866 | { |
||
| 11867 | foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft) |
||
| 11868 | { |
||
| 11869 | if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L ')) |
||
| 11870 | { |
||
| 11871 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 11872 | { |
||
| 11873 | if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
||
| 11874 | { |
||
| 11875 | $ignoreImport = true; |
||
| 11876 | } |
||
| 11877 | } |
||
| 11878 | if ($ignoreImport == false) |
||
| 11879 | { |
||
| 11880 | $flightaware_id = $aircraft->faFlightID; |
||
| 11881 | $ident = $aircraft->ident; |
||
| 11882 | $aircraft_type = $aircraft->type; |
||
| 11883 | $departure_airport = $aircraft->origin; |
||
| 11884 | $arrival_airport = $aircraft->destination; |
||
| 11885 | $latitude = $aircraft->latitude; |
||
| 11886 | $longitude = $aircraft->longitude; |
||
| 11887 | $waypoints = $aircraft->waypoints; |
||
| 11888 | $altitude = $aircraft->altitude; |
||
| 11889 | $heading = $aircraft->heading; |
||
| 11890 | $groundspeed = $aircraft->groundspeed; |
||
| 11891 | $dataFound = true; |
||
| 11892 | //gets the callsign from the last hour |
||
| 11893 | $last_hour_ident = $this->getIdentFromLastHour($ident); |
||
| 11894 | //change the departure/arrival airport to NA if its not available |
||
| 11895 | if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
||
| 11896 | if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
||
| 11897 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
||
| 11898 | if($last_hour_ident == "") |
||
| 11899 | { |
||
| 11900 | //adds the spotter data for the archive |
||
| 11901 | $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 11902 | } |
||
| 11903 | |||
| 11904 | //adds the spotter LIVE data |
||
| 11905 | $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 11906 | } |
||
| 11907 | } |
||
| 11908 | $ignoreImport = false; |
||
| 11909 | } |
||
| 11910 | } else { |
||
| 11911 | if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L ')) |
||
| 11912 | { |
||
| 11913 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 11914 | { |
||
| 11915 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 11916 | { |
||
| 11917 | if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
||
| 11918 | { |
||
| 11919 | $ignoreImport = true; |
||
| 11920 | } |
||
| 11921 | } |
||
| 11922 | if ($ignoreImport == false) |
||
| 11923 | { |
||
| 11924 | $flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID; |
||
| 11925 | $ident = $result->SearchBirdseyeInFlightResult->aircraft->ident; |
||
| 11926 | $aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type; |
||
| 11927 | $departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin; |
||
| 11928 | $arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination; |
||
| 11929 | $latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude; |
||
| 11930 | $longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude; |
||
| 11931 | $waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints; |
||
| 11932 | $altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude; |
||
| 11933 | $heading = $result->SearchBirdseyeInFlightResult->aircraft->heading; |
||
| 11934 | $groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed; |
||
| 11935 | $dataFound = true; |
||
| 11936 | //gets the callsign from the last hour |
||
| 11937 | $last_hour_ident = $this->getIdentFromLastHour($ident); |
||
| 11938 | //change the departure/arrival airport to NA if its not available |
||
| 11939 | if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
||
| 11940 | if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
||
| 11941 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
||
| 11942 | if($last_hour_ident == "") |
||
| 11943 | { |
||
| 11944 | //adds the spotter data for the archive |
||
| 11945 | $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 11946 | } |
||
| 11947 | //adds the spotter LIVE data |
||
| 11948 | $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 11949 | } |
||
| 11950 | $ignoreImport = false; |
||
| 11951 | } |
||
| 11952 | } |
||
| 11953 | } |
||
| 11954 | } |
||
| 11955 | } |
||
| 11956 | */ |
||
| 11957 | |||
| 11958 | // Update flights data when new data in DB |
||
| 11959 | public function updateFieldsFromOtherTables() |
||
| 12045 | |||
| 12046 | // Update arrival airports for data already in DB |
||
| 12047 | public function updateArrivalAirports() |
||
| 12088 | |||
| 12089 | public function closestAirports($origLat,$origLon,$dist = 10) { |
||
| 12110 | } |
||
| 12111 | /* |
||
| 12123 | ?> |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.