Complex classes like Spotter often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Spotter, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | class Spotter{ |
||
| 8 | public $db; |
||
| 9 | |||
| 10 | public function __construct($dbc = null) { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Get SQL query part for filter used |
||
| 17 | * @param Array $filter the filter |
||
| 18 | * @return Array the SQL part |
||
| 19 | */ |
||
| 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
||
| 21 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
||
| 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
||
| 23 | if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
||
| 24 | $filter_query_join = ''; |
||
| 25 | $filter_query_where = ''; |
||
| 26 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
||
| 27 | if ($filter['airlines'][0] != '') { |
||
| 28 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
||
| 33 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id "; |
||
| 34 | } |
||
| 35 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
||
| 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; |
||
| 37 | } |
||
| 38 | if (isset($filter['source']) && !empty($filter['source'])) { |
||
| 39 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
||
| 40 | } |
||
| 41 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
||
| 42 | if ($filter_query_where == '') { |
||
| 43 | $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
||
| 44 | } else { |
||
| 45 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
||
| 49 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
||
| 50 | $filter_query = $filter_query_join.$filter_query_where; |
||
| 51 | return $filter_query; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Executes the SQL statements to get the spotter information |
||
| 56 | * |
||
| 57 | * @param String $query the SQL query |
||
| 58 | * @param Array $params parameter of the query |
||
| 59 | * @param String $limitQuery the limit query |
||
| 60 | * @return Array the spotter information |
||
| 61 | * |
||
| 62 | */ |
||
| 63 | public function getDataFromDB($query, $params = array(), $limitQuery = '') |
||
| 64 | { |
||
| 65 | global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM; |
||
| 66 | $Image = new Image($this->db); |
||
| 67 | $Schedule = new Schedule($this->db); |
||
| 68 | $ACARS = new ACARS($this->db); |
||
| 69 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
||
| 70 | if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
||
| 71 | if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
||
| 72 | if (!isset($globalVAM)) $globalVAM = FALSE; |
||
| 73 | date_default_timezone_set('UTC'); |
||
| 74 | |||
| 75 | if (!is_string($query)) |
||
| 76 | { |
||
| 77 | return false; |
||
| 78 | } |
||
| 79 | |||
| 80 | if ($limitQuery != "") |
||
| 81 | { |
||
| 82 | if (!is_string($limitQuery)) |
||
| 83 | { |
||
| 84 | return false; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | |||
| 89 | try { |
||
| 90 | $sth = $this->db->prepare($query.$limitQuery); |
||
| 91 | $sth->execute($params); |
||
| 92 | } catch (PDOException $e) { |
||
| 93 | printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
||
| 94 | exit(); |
||
| 95 | } |
||
| 96 | |||
| 97 | // $num_rows = count($sth->fetchAll()); |
||
| 98 | $num_rows = 0; |
||
| 99 | |||
| 100 | $spotter_array = array(); |
||
| 101 | |||
| 102 | |||
| 103 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 104 | { |
||
| 105 | $num_rows++; |
||
| 106 | $temp_array = array(); |
||
| 107 | if (isset($row['spotter_live_id'])) { |
||
| 108 | //$temp_array['spotter_id'] = $row['spotter_live_id']; |
||
| 109 | $temp_array['spotter_id'] = $this->getSpotterIDBasedOnFlightAwareID($row['flightaware_id']); |
||
| 110 | } elseif (isset($row['spotter_archive_id'])) { |
||
| 111 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
||
| 112 | } elseif (isset($row['spotter_archive_output_id'])) { |
||
| 113 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
||
| 114 | } elseif (isset($row['spotter_id'])) { |
||
| 115 | $temp_array['spotter_id'] = $row['spotter_id']; |
||
| 116 | } else { |
||
| 117 | $temp_array['spotter_id'] = ''; |
||
| 118 | } |
||
| 119 | if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
||
| 120 | if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
||
| 121 | $temp_array['ident'] = $row['ident']; |
||
| 122 | if (isset($row['registration']) && $row['registration'] != '') { |
||
| 123 | $temp_array['registration'] = $row['registration']; |
||
| 124 | } elseif (isset($temp_array['modes'])) { |
||
| 125 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
||
| 126 | } else $temp_array['registration'] = ''; |
||
| 127 | if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
||
| 128 | |||
| 129 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
||
| 130 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
||
| 131 | if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
||
| 132 | if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
||
| 133 | if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
||
| 134 | /* |
||
| 135 | if (Connection->tableExists('countries')) { |
||
| 136 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
||
| 137 | if (is_array($country_info) && isset($country_info['name']) && isset($country_info['iso2'])) { |
||
| 138 | $temp_array['country'] = $country_info['name']; |
||
| 139 | $temp_array['country_iso2'] = $country_info['iso2']; |
||
| 140 | } |
||
| 141 | } |
||
| 142 | */ |
||
| 143 | if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
||
| 144 | if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
||
| 145 | if (isset($row['route_stop'])) { |
||
| 146 | $temp_array['route_stop'] = $row['route_stop']; |
||
| 147 | if ($row['route_stop'] != '') { |
||
| 148 | $allroute = explode(' ',$row['route_stop']); |
||
| 149 | |||
| 150 | foreach ($allroute as $route) { |
||
| 151 | $route_airport_array = $this->getAllAirportInfo($route); |
||
| 152 | if (isset($route_airport_array[0]['name'])) { |
||
| 153 | $route_stop_details = array(); |
||
| 154 | $route_stop_details['airport_name'] = $route_airport_array[0]['name']; |
||
| 155 | $route_stop_details['airport_city'] = $route_airport_array[0]['city']; |
||
| 156 | $route_stop_details['airport_country'] = $route_airport_array[0]['country']; |
||
| 157 | $route_stop_details['airport_icao'] = $route_airport_array[0]['icao']; |
||
| 158 | $temp_array['route_stop_details'][] = $route_stop_details; |
||
| 159 | } |
||
| 160 | } |
||
| 161 | } |
||
| 162 | } |
||
| 163 | if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
||
| 164 | if (isset($row['heading'])) { |
||
| 165 | $temp_array['heading'] = $row['heading']; |
||
| 166 | $heading_direction = $this->parseDirection($row['heading']); |
||
| 167 | if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
||
| 168 | } |
||
| 169 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
||
| 170 | $temp_array['image'] = ""; |
||
| 171 | $temp_array['image_thumbnail'] = ""; |
||
| 172 | $temp_array['image_source'] = ""; |
||
| 173 | $temp_array['image_copyright'] = ""; |
||
| 174 | |||
| 175 | if (isset($row['highlight'])) { |
||
| 176 | $temp_array['highlight'] = $row['highlight']; |
||
| 177 | } else $temp_array['highlight'] = ''; |
||
| 178 | |||
| 179 | if (isset($row['date'])) { |
||
| 180 | $dateArray = $this->parseDateString($row['date']); |
||
| 181 | if ($dateArray['seconds'] < 10) |
||
| 182 | { |
||
| 183 | $temp_array['date'] = "a few seconds ago"; |
||
| 184 | } elseif ($dateArray['seconds'] >= 5 && $dateArray['seconds'] < 30) |
||
| 185 | { |
||
| 186 | $temp_array['date'] = "half a minute ago"; |
||
| 187 | } elseif ($dateArray['seconds'] >= 30 && $dateArray['seconds'] < 60) |
||
| 188 | { |
||
| 189 | $temp_array['date'] = "about a minute ago"; |
||
| 190 | } elseif ($dateArray['minutes'] < 5) |
||
| 191 | { |
||
| 192 | $temp_array['date'] = "a few minutes ago"; |
||
| 193 | } elseif ($dateArray['minutes'] >= 5 && $dateArray['minutes'] < 60) |
||
| 194 | { |
||
| 195 | $temp_array['date'] = "about ".$dateArray['minutes']." minutes ago"; |
||
| 196 | } elseif ($dateArray['hours'] < 2) |
||
| 197 | { |
||
| 198 | $temp_array['date'] = "about an hour ago"; |
||
| 199 | } elseif ($dateArray['hours'] >= 2 && $dateArray['hours'] < 24) |
||
| 200 | { |
||
| 201 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
||
| 202 | } else { |
||
| 203 | $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
||
| 204 | } |
||
| 205 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
||
| 206 | $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
||
| 207 | $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
||
| 208 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
||
| 209 | } |
||
| 210 | |||
| 211 | if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') { |
||
| 212 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 213 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 214 | if (isset($row['aircraft_shadow'])) { |
||
| 215 | $temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
||
| 216 | } |
||
| 217 | } elseif (isset($row['aircraft_icao'])) { |
||
| 218 | $aircraft_array = $this->getAllAircraftInfo($row['aircraft_icao']); |
||
| 219 | if (count($aircraft_array) > 0) { |
||
| 220 | $temp_array['aircraft_name'] = $aircraft_array[0]['type']; |
||
| 221 | $temp_array['aircraft_manufacturer'] = $aircraft_array[0]['manufacturer']; |
||
| 222 | |||
| 223 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
||
| 224 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
||
| 225 | } else $temp_array['aircraft_shadow'] = 'default.png'; |
||
| 226 | } else { |
||
| 227 | $temp_array['aircraft_shadow'] = 'default.png'; |
||
| 228 | $temp_array['aircraft_name'] = 'N/A'; |
||
| 229 | $temp_array['aircraft_manufacturer'] = 'N/A'; |
||
| 230 | } |
||
| 231 | } |
||
| 232 | $fromsource = NULL; |
||
| 233 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
||
| 234 | elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
||
| 235 | elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
||
| 236 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
||
| 237 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
||
| 238 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
||
| 239 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
||
| 240 | if (is_numeric(substr($row['ident'], 2, 1))) { |
||
| 241 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource); |
||
| 242 | } elseif (is_numeric(substr($row['ident'], 3, 1))) { |
||
| 243 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
||
| 244 | } else { |
||
| 245 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 246 | } |
||
| 247 | } else { |
||
| 248 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 249 | } |
||
| 250 | if (count($airline_array) > 0) { |
||
| 251 | $temp_array['airline_icao'] = $airline_array[0]['icao']; |
||
| 252 | $temp_array['airline_iata'] = $airline_array[0]['iata']; |
||
| 253 | $temp_array['airline_name'] = $airline_array[0]['name']; |
||
| 254 | $temp_array['airline_country'] = $airline_array[0]['country']; |
||
| 255 | $temp_array['airline_callsign'] = $airline_array[0]['callsign']; |
||
| 256 | $temp_array['airline_type'] = $airline_array[0]['type']; |
||
| 257 | } |
||
| 258 | } else { |
||
| 259 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 260 | if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
||
| 261 | else $temp_array['airline_iata'] = ''; |
||
| 262 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 263 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 264 | if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
||
| 265 | else $temp_array['airline_callsign'] = 'N/A'; |
||
| 266 | $temp_array['airline_type'] = $row['airline_type']; |
||
| 267 | } |
||
| 268 | if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
||
| 269 | $acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3)); |
||
| 270 | //$acars_array = ACARS->getLiveAcarsData('BA40YL'); |
||
| 271 | if (count($acars_array) > 0) { |
||
| 272 | $temp_array['acars'] = $acars_array; |
||
| 273 | //print_r($acars_array); |
||
| 274 | } |
||
| 275 | } |
||
| 276 | if (isset($row['owner_name']) && $row['owner_name'] != '' && $row['owner_name'] != NULL) { |
||
| 277 | $temp_array['aircraft_owner'] = $row['owner_name']; |
||
| 278 | } |
||
| 279 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
||
| 280 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
||
| 281 | if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
||
| 282 | $temp_array['aircraft_base'] = $owner_info['base']; |
||
| 283 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
||
| 284 | } |
||
| 285 | |||
| 286 | if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
||
| 287 | { |
||
| 288 | if ($globalIVAO) { |
||
| 289 | if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
||
| 290 | else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
||
| 291 | } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
||
| 292 | if (count($image_array) > 0) { |
||
| 293 | $temp_array['image'] = $image_array[0]['image']; |
||
| 294 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 295 | $temp_array['image_source'] = $image_array[0]['image_source']; |
||
| 296 | $temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
||
| 297 | if ($temp_array['image_source_website'] == '' && $temp_array['image_source'] == 'planespotters') { |
||
| 298 | $planespotter_url_array = explode("_", $temp_array['image']); |
||
| 299 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
||
| 300 | $temp_array['image_source_website'] = 'http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
||
| 301 | } |
||
| 302 | $temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
||
| 303 | } |
||
| 304 | } |
||
| 305 | |||
| 306 | |||
| 307 | if (isset($row['departure_airport_time']) && $row['departure_airport_time'] != '') { |
||
| 308 | $temp_array['departure_airport_time'] = $row['departure_airport_time']; |
||
| 309 | } |
||
| 310 | if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') { |
||
| 311 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
||
| 312 | } |
||
| 313 | if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
||
| 314 | $schedule_array = $Schedule->getSchedule($temp_array['ident']); |
||
| 315 | //print_r($schedule_array); |
||
| 316 | if (count($schedule_array) > 0) { |
||
| 317 | if ($schedule_array['departure_airport_icao'] != '') { |
||
| 318 | $row['departure_airport_icao'] = $schedule_array['departure_airport_icao']; |
||
| 319 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
||
| 320 | } |
||
| 321 | if ($schedule_array['arrival_airport_icao'] != '') { |
||
| 322 | $row['arrival_airport_icao'] = $schedule_array['arrival_airport_icao']; |
||
| 323 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
||
| 324 | } |
||
| 325 | |||
| 326 | $temp_array['departure_airport_time'] = $schedule_array['departure_airport_time']; |
||
| 327 | $temp_array['arrival_airport_time'] = $schedule_array['arrival_airport_time']; |
||
| 328 | } |
||
| 329 | } else { |
||
| 330 | if (isset($row['real_departure_airport_time']) && $row['real_departure_airport_time'] != '') { |
||
| 331 | $temp_array['departure_airport_time'] = $row['real_departure_airport_time']; |
||
| 332 | } |
||
| 333 | if (isset($row['real_arrival_airport_time']) && $row['real_arrival_airport_time'] != '') { |
||
| 334 | $temp_array['real_arrival_airport_time'] = $row['real_arrival_airport_time']; |
||
| 335 | } |
||
| 336 | } |
||
| 337 | |||
| 338 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
||
| 339 | if ($row['departure_airport_icao'] != '') { |
||
| 340 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
||
| 341 | if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 342 | /* |
||
| 343 | } elseif ($row['departure_airport_name'] != '') { |
||
| 344 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
||
| 345 | $temp_array['departure_airport_city'] = $row['departure_airport_city']; |
||
| 346 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
||
| 347 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
||
| 348 | */ |
||
| 349 | } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 350 | if (isset($departure_airport_array[0]['name'])) { |
||
| 351 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
||
| 352 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
||
| 353 | $temp_array['departure_airport_country'] = $departure_airport_array[0]['country']; |
||
| 354 | $temp_array['departure_airport_iata'] = $departure_airport_array[0]['iata']; |
||
| 355 | $temp_array['departure_airport_icao'] = $departure_airport_array[0]['icao']; |
||
| 356 | $temp_array['departure_airport_latitude'] = $departure_airport_array[0]['latitude']; |
||
| 357 | $temp_array['departure_airport_longitude'] = $departure_airport_array[0]['longitude']; |
||
| 358 | $temp_array['departure_airport_altitude'] = $departure_airport_array[0]['altitude']; |
||
| 359 | } |
||
| 360 | |||
| 361 | /* |
||
| 362 | if (isset($row['departure_airport_time'])) { |
||
| 363 | $temp_array['departure_airport_time'] = $row['departure_airport_time']; |
||
| 364 | } |
||
| 365 | */ |
||
| 366 | |||
| 367 | if ($row['arrival_airport_icao'] != '') { |
||
| 368 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
||
| 369 | if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 370 | } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 371 | if (isset($arrival_airport_array[0]['name'])) { |
||
| 372 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
||
| 373 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
||
| 374 | $temp_array['arrival_airport_country'] = $arrival_airport_array[0]['country']; |
||
| 375 | $temp_array['arrival_airport_iata'] = $arrival_airport_array[0]['iata']; |
||
| 376 | $temp_array['arrival_airport_icao'] = $arrival_airport_array[0]['icao']; |
||
| 377 | $temp_array['arrival_airport_latitude'] = $arrival_airport_array[0]['latitude']; |
||
| 378 | $temp_array['arrival_airport_longitude'] = $arrival_airport_array[0]['longitude']; |
||
| 379 | $temp_array['arrival_airport_altitude'] = $arrival_airport_array[0]['altitude']; |
||
| 380 | } |
||
| 381 | /* |
||
| 382 | if (isset($row['arrival_airport_time'])) { |
||
| 383 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
||
| 384 | } |
||
| 385 | */ |
||
| 386 | if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 387 | if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 388 | if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
||
| 389 | if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
||
| 390 | if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
||
| 391 | if (isset($row['squawk'])) { |
||
| 392 | $temp_array['squawk'] = $row['squawk']; |
||
| 393 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
||
| 394 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
||
| 395 | if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 396 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
||
| 397 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
||
| 398 | if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 399 | } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
||
| 400 | } |
||
| 401 | |||
| 402 | $temp_array['query_number_rows'] = $num_rows; |
||
| 403 | |||
| 404 | $spotter_array[] = $temp_array; |
||
| 405 | } |
||
| 406 | if ($num_rows == 0) return array(); |
||
| 407 | $spotter_array[0]['query_number_rows'] = $num_rows; |
||
| 408 | return $spotter_array; |
||
| 409 | } |
||
| 410 | |||
| 411 | |||
| 412 | /** |
||
| 413 | * Gets all the spotter information |
||
| 414 | * |
||
| 415 | * @return Array the spotter information |
||
| 416 | * |
||
| 417 | */ |
||
| 418 | public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filter = array()) |
||
| 419 | { |
||
| 420 | global $globalTimezone, $globalDBdriver; |
||
| 421 | require_once(dirname(__FILE__).'/class.Translation.php'); |
||
| 422 | $Translation = new Translation(); |
||
| 423 | |||
| 424 | date_default_timezone_set('UTC'); |
||
| 425 | |||
| 426 | $query_values = array(); |
||
| 427 | $additional_query = ''; |
||
| 428 | $filter_query = $this->getFilter($filter,true,true); |
||
| 429 | if ($q != "") |
||
| 430 | { |
||
| 431 | if (!is_string($q)) |
||
| 432 | { |
||
| 433 | return false; |
||
| 434 | } else { |
||
| 435 | $q_array = explode(" ", $q); |
||
| 436 | foreach ($q_array as $q_item){ |
||
| 437 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
||
| 438 | $additional_query .= " AND ("; |
||
| 439 | if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
||
| 440 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
||
| 441 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
||
| 442 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
||
| 443 | $additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
||
| 444 | $additional_query .= "(spotter_output.airline_name like '%".$q_item."%') OR "; |
||
| 445 | $additional_query .= "(spotter_output.airline_country like '%".$q_item."%') OR "; |
||
| 446 | $additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
||
| 447 | $additional_query .= "(spotter_output.departure_airport_name like '%".$q_item."%') OR "; |
||
| 448 | $additional_query .= "(spotter_output.departure_airport_city like '%".$q_item."%') OR "; |
||
| 449 | $additional_query .= "(spotter_output.departure_airport_country like '%".$q_item."%') OR "; |
||
| 450 | $additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
||
| 451 | $additional_query .= "(spotter_output.arrival_airport_name like '%".$q_item."%') OR "; |
||
| 452 | $additional_query .= "(spotter_output.arrival_airport_city like '%".$q_item."%') OR "; |
||
| 453 | $additional_query .= "(spotter_output.arrival_airport_country like '%".$q_item."%') OR "; |
||
| 454 | $additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
||
| 455 | $additional_query .= "(spotter_output.owner_name like '%".$q_item."%') OR "; |
||
| 456 | $additional_query .= "(spotter_output.pilot_id like '%".$q_item."%') OR "; |
||
| 457 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
||
| 458 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
||
| 459 | $translate = $Translation->ident2icao($q_item); |
||
| 460 | if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
||
| 461 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
||
| 462 | $additional_query .= ")"; |
||
| 463 | } |
||
| 464 | } |
||
| 465 | } |
||
| 466 | |||
| 467 | if ($registration != "") |
||
| 468 | { |
||
| 469 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 470 | if (!is_string($registration)) |
||
| 471 | { |
||
| 472 | return false; |
||
| 473 | } else { |
||
| 474 | $additional_query .= " AND spotter_output.registration = :registration"; |
||
| 475 | $query_values = array_merge($query_values,array(':registration' => $registration)); |
||
| 476 | } |
||
| 477 | } |
||
| 478 | |||
| 479 | if ($aircraft_icao != "") |
||
| 480 | { |
||
| 481 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 482 | if (!is_string($aircraft_icao)) |
||
| 483 | { |
||
| 484 | return false; |
||
| 485 | } else { |
||
| 486 | $additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao"; |
||
| 487 | $query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao)); |
||
| 488 | } |
||
| 489 | } |
||
| 490 | |||
| 491 | if ($aircraft_manufacturer != "") |
||
| 492 | { |
||
| 493 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 494 | if (!is_string($aircraft_manufacturer)) |
||
| 495 | { |
||
| 496 | return false; |
||
| 497 | } else { |
||
| 498 | $additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer"; |
||
| 499 | $query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 500 | } |
||
| 501 | } |
||
| 502 | |||
| 503 | if ($highlights == "true") |
||
| 504 | { |
||
| 505 | if (!is_string($highlights)) |
||
| 506 | { |
||
| 507 | return false; |
||
| 508 | } else { |
||
| 509 | $additional_query .= " AND (spotter_output.highlight <> '')"; |
||
| 510 | } |
||
| 511 | } |
||
| 512 | |||
| 513 | if ($airline_icao != "") |
||
| 514 | { |
||
| 515 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 516 | if (!is_string($airline_icao)) |
||
| 517 | { |
||
| 518 | return false; |
||
| 519 | } else { |
||
| 520 | $additional_query .= " AND spotter_output.airline_icao = :airline_icao"; |
||
| 521 | $query_values = array_merge($query_values,array(':airline_icao' => $airline_icao)); |
||
| 522 | } |
||
| 523 | } |
||
| 524 | |||
| 525 | if ($airline_country != "") |
||
| 526 | { |
||
| 527 | $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
||
| 528 | if (!is_string($airline_country)) |
||
| 529 | { |
||
| 530 | return false; |
||
| 531 | } else { |
||
| 532 | $additional_query .= " AND spotter_output.airline_country = :airline_country"; |
||
| 533 | $query_values = array_merge($query_values,array(':airline_country' => $airline_country)); |
||
| 534 | } |
||
| 535 | } |
||
| 536 | |||
| 537 | if ($airline_type != "") |
||
| 538 | { |
||
| 539 | if (!is_string($airline_type)) |
||
| 540 | { |
||
| 541 | return false; |
||
| 542 | } else { |
||
| 543 | if ($airline_type == "passenger") |
||
| 544 | { |
||
| 545 | $additional_query .= " AND (spotter_output.airline_type = 'passenger')"; |
||
| 546 | } |
||
| 547 | if ($airline_type == "cargo") |
||
| 548 | { |
||
| 549 | $additional_query .= " AND (spotter_output.airline_type = 'cargo')"; |
||
| 550 | } |
||
| 551 | if ($airline_type == "military") |
||
| 552 | { |
||
| 553 | $additional_query .= " AND (spotter_output.airline_type = 'military')"; |
||
| 554 | } |
||
| 555 | } |
||
| 556 | } |
||
| 557 | |||
| 558 | if ($airport != "") |
||
| 559 | { |
||
| 560 | $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
||
| 561 | if (!is_string($airport)) |
||
| 562 | { |
||
| 563 | return false; |
||
| 564 | } else { |
||
| 565 | $additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)"; |
||
| 566 | $query_values = array_merge($query_values,array(':airport' => $airport)); |
||
| 567 | } |
||
| 568 | } |
||
| 569 | |||
| 570 | if ($airport_country != "") |
||
| 571 | { |
||
| 572 | $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
||
| 573 | if (!is_string($airport_country)) |
||
| 574 | { |
||
| 575 | return false; |
||
| 576 | } else { |
||
| 577 | $additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)"; |
||
| 578 | $query_values = array_merge($query_values,array(':airport_country' => $airport_country)); |
||
| 579 | } |
||
| 580 | } |
||
| 581 | |||
| 582 | if ($callsign != "") |
||
| 583 | { |
||
| 584 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
||
| 585 | if (!is_string($callsign)) |
||
| 586 | { |
||
| 587 | return false; |
||
| 588 | } else { |
||
| 589 | $translate = $Translation->ident2icao($callsign); |
||
| 590 | if ($translate != $callsign) { |
||
| 591 | $additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)"; |
||
| 592 | $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
||
| 593 | } else { |
||
| 594 | $additional_query .= " AND spotter_output.ident = :callsign"; |
||
| 595 | $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
||
| 596 | } |
||
| 597 | } |
||
| 598 | } |
||
| 599 | |||
| 600 | if ($owner != "") |
||
| 601 | { |
||
| 602 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
||
| 603 | if (!is_string($owner)) |
||
| 604 | { |
||
| 605 | return false; |
||
| 606 | } else { |
||
| 607 | $additional_query .= " AND spotter_output.owner_name = :owner"; |
||
| 608 | $query_values = array_merge($query_values,array(':owner' => $owner)); |
||
| 609 | } |
||
| 610 | } |
||
| 611 | |||
| 612 | if ($pilot_name != "") |
||
| 613 | { |
||
| 614 | $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
||
| 615 | if (!is_string($pilot_name)) |
||
| 616 | { |
||
| 617 | return false; |
||
| 618 | } else { |
||
| 619 | $additional_query .= " AND spotter_output.pilot_name = :pilot_name"; |
||
| 620 | $query_values = array_merge($query_values,array(':pilot_name' => $pilot_name)); |
||
| 621 | } |
||
| 622 | } |
||
| 623 | |||
| 624 | if ($pilot_id != "") |
||
| 625 | { |
||
| 626 | $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
||
| 627 | if (!is_string($pilot_id)) |
||
| 628 | { |
||
| 629 | return false; |
||
| 630 | } else { |
||
| 631 | $additional_query .= " AND spotter_output.pilot_id = :pilot_id"; |
||
| 632 | $query_values = array_merge($query_values,array(':pilot_id' => $pilot_id)); |
||
| 633 | } |
||
| 634 | } |
||
| 635 | |||
| 636 | if ($departure_airport_route != "") |
||
| 637 | { |
||
| 638 | $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
||
| 639 | if (!is_string($departure_airport_route)) |
||
| 640 | { |
||
| 641 | return false; |
||
| 642 | } else { |
||
| 643 | $additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route"; |
||
| 644 | $query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route)); |
||
| 645 | } |
||
| 646 | } |
||
| 647 | |||
| 648 | if ($arrival_airport_route != "") |
||
| 649 | { |
||
| 650 | $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
||
| 651 | if (!is_string($arrival_airport_route)) |
||
| 652 | { |
||
| 653 | return false; |
||
| 654 | } else { |
||
| 655 | $additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route"; |
||
| 656 | $query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route)); |
||
| 657 | } |
||
| 658 | } |
||
| 659 | |||
| 660 | if ($altitude != "") |
||
| 661 | { |
||
| 662 | $altitude_array = explode(",", $altitude); |
||
| 663 | $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 664 | $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 665 | |||
| 666 | if ($altitude_array[1] != "") |
||
| 667 | { |
||
| 668 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
||
| 669 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
||
| 670 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
||
| 671 | } else { |
||
| 672 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
||
| 673 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
||
| 674 | } |
||
| 675 | } |
||
| 676 | |||
| 677 | if ($date_posted != "") |
||
| 678 | { |
||
| 679 | $date_array = explode(",", $date_posted); |
||
| 680 | $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
||
| 681 | $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
||
| 682 | |||
| 683 | if ($globalTimezone != '') { |
||
| 684 | date_default_timezone_set($globalTimezone); |
||
| 685 | $datetime = new DateTime(); |
||
| 686 | $offset = $datetime->format('P'); |
||
| 687 | } else $offset = '+00:00'; |
||
| 688 | |||
| 689 | if ($date_array[1] != "") |
||
| 690 | { |
||
| 691 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
||
| 692 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
||
| 693 | if ($globalDBdriver == 'mysql') { |
||
| 694 | $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]."' "; |
||
| 695 | } else { |
||
| 696 | $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]."' "; |
||
| 697 | } |
||
| 698 | } else { |
||
| 699 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
||
| 700 | if ($globalDBdriver == 'mysql') { |
||
| 701 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
||
| 702 | } else { |
||
| 703 | $additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' "; |
||
| 704 | } |
||
| 705 | } |
||
| 706 | } |
||
| 707 | |||
| 708 | if ($limit != "") |
||
| 709 | { |
||
| 710 | $limit_array = explode(",", $limit); |
||
| 711 | |||
| 712 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 713 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 714 | |||
| 715 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 716 | { |
||
| 717 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 718 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 719 | } else $limit_query = ""; |
||
| 720 | } else $limit_query = ""; |
||
| 721 | |||
| 722 | |||
| 723 | if ($sort != "") |
||
| 724 | { |
||
| 725 | $search_orderby_array = $this->getOrderBy(); |
||
| 726 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 727 | } else { |
||
| 728 | if ($origLat != "" && $origLon != "" && $dist != "") { |
||
| 729 | $orderby_query = " ORDER BY distance ASC"; |
||
| 730 | } else { |
||
| 731 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 732 | } |
||
| 733 | } |
||
| 734 | |||
| 735 | if ($includegeodata == "true") |
||
| 736 | { |
||
| 737 | $additional_query .= " AND spotter_output.waypoints <> ''"; |
||
| 738 | } |
||
| 739 | |||
| 740 | |||
| 741 | if ($origLat != "" && $origLon != "" && $dist != "") { |
||
| 742 | $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
||
| 743 | |||
| 744 | if ($globalDBdriver == 'mysql') { |
||
| 745 | $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 |
||
| 746 | FROM spotter_output, spotter_archive".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
||
| 747 | 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; |
||
| 748 | } else { |
||
| 749 | $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 |
||
| 750 | FROM spotter_output, spotter_archive".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
||
| 751 | 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; |
||
| 752 | } |
||
| 753 | } else { |
||
| 754 | $query = "SELECT spotter_output.* FROM spotter_output ".$filter_query." spotter_output.ident <> '' |
||
| 755 | ".$additional_query." |
||
| 756 | ".$orderby_query; |
||
| 757 | } |
||
| 758 | $spotter_array = $this->getDataFromDB($query, $query_values,$limit_query); |
||
| 759 | return $spotter_array; |
||
| 760 | } |
||
| 761 | |||
| 762 | |||
| 763 | /** |
||
| 764 | * Gets all the spotter information based on the latest data entry |
||
| 765 | * |
||
| 766 | * @return Array the spotter information |
||
| 767 | * |
||
| 768 | */ |
||
| 769 | public function getLatestSpotterData($limit = '', $sort = '', $filter = array()) |
||
| 770 | { |
||
| 771 | global $global_query; |
||
| 772 | |||
| 773 | date_default_timezone_set('UTC'); |
||
| 774 | |||
| 775 | $filter_query = $this->getFilter($filter); |
||
| 776 | |||
| 777 | if ($limit != "") |
||
| 778 | { |
||
| 779 | $limit_array = explode(",", $limit); |
||
| 780 | |||
| 781 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 782 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 783 | |||
| 784 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 785 | { |
||
| 786 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 787 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 788 | } else $limit_query = ""; |
||
| 789 | } else $limit_query = ""; |
||
| 790 | |||
| 791 | if ($sort != "") |
||
| 792 | { |
||
| 793 | $search_orderby_array = $this->getOrderBy(); |
||
| 794 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 795 | } else { |
||
| 796 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 797 | } |
||
| 798 | |||
| 799 | $query = $global_query.$filter_query." ".$orderby_query; |
||
| 800 | |||
| 801 | $spotter_array = $this->getDataFromDB($query, array(),$limit_query); |
||
| 802 | |||
| 803 | return $spotter_array; |
||
| 804 | } |
||
| 805 | |||
| 806 | |||
| 807 | /** |
||
| 808 | * Gets all the spotter information based on a user's latitude and longitude |
||
| 809 | * |
||
| 810 | * @return Array the spotter information |
||
| 811 | * |
||
| 812 | */ |
||
| 813 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
||
| 814 | { |
||
| 815 | date_default_timezone_set('UTC'); |
||
| 816 | $limit_query = ''; |
||
| 817 | if ($lat != "") |
||
| 818 | { |
||
| 819 | if (!is_numeric($lat)) |
||
| 820 | { |
||
| 821 | return false; |
||
| 822 | } |
||
| 823 | } |
||
| 824 | |||
| 825 | if ($lng != "") |
||
| 826 | { |
||
| 827 | if (!is_numeric($lng)) |
||
| 828 | { |
||
| 829 | return false; |
||
| 830 | } |
||
| 831 | } |
||
| 832 | |||
| 833 | if ($radius != "") |
||
| 834 | { |
||
| 835 | if (!is_numeric($radius)) |
||
| 836 | { |
||
| 837 | return false; |
||
| 838 | } |
||
| 839 | } |
||
| 840 | $additional_query = ''; |
||
| 841 | if ($interval != "") |
||
| 842 | { |
||
| 843 | if (!is_string($interval)) |
||
| 844 | { |
||
| 845 | return false; |
||
| 846 | } else { |
||
| 847 | if ($interval == "30m"){ |
||
| 848 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date '; |
||
| 849 | } else if ($interval == "1h"){ |
||
| 850 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date '; |
||
| 851 | } else if ($interval == "3h"){ |
||
| 852 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date '; |
||
| 853 | } else if ($interval == "6h"){ |
||
| 854 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date '; |
||
| 855 | } else if ($interval == "12h"){ |
||
| 856 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date '; |
||
| 857 | } else if ($interval == "24h"){ |
||
| 858 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date '; |
||
| 859 | } else if ($interval == "7d"){ |
||
| 860 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date '; |
||
| 861 | } else if ($interval == "30d"){ |
||
| 862 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date '; |
||
| 863 | } |
||
| 864 | } |
||
| 865 | } |
||
| 866 | |||
| 867 | $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 |
||
| 868 | WHERE spotter_output.latitude <> '' |
||
| 869 | AND spotter_output.longitude <> '' |
||
| 870 | ".$additional_query." |
||
| 871 | HAVING distance < :radius |
||
| 872 | ORDER BY distance"; |
||
| 873 | |||
| 874 | $spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query); |
||
| 875 | |||
| 876 | return $spotter_array; |
||
| 877 | } |
||
| 878 | |||
| 879 | |||
| 880 | /** |
||
| 881 | * Gets all the spotter information sorted by the newest aircraft type |
||
| 882 | * |
||
| 883 | * @return Array the spotter information |
||
| 884 | * |
||
| 885 | */ |
||
| 886 | public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array()) |
||
| 887 | { |
||
| 888 | global $global_query; |
||
| 889 | |||
| 890 | date_default_timezone_set('UTC'); |
||
| 891 | |||
| 892 | $filter_query = $this->getFilter($filter,true,true); |
||
| 893 | |||
| 894 | $limit_query = ''; |
||
| 895 | if ($limit != "") |
||
| 896 | { |
||
| 897 | $limit_array = explode(",", $limit); |
||
| 898 | |||
| 899 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 900 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 901 | |||
| 902 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 903 | { |
||
| 904 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 905 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 906 | } |
||
| 907 | } |
||
| 908 | |||
| 909 | if ($sort != "") |
||
| 910 | { |
||
| 911 | $search_orderby_array = $this->getOrderBy(); |
||
| 912 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 913 | } else { |
||
| 914 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 915 | } |
||
| 916 | |||
| 917 | $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; |
||
| 918 | |||
| 919 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 920 | |||
| 921 | return $spotter_array; |
||
| 922 | } |
||
| 923 | |||
| 924 | |||
| 925 | /** |
||
| 926 | * Gets all the spotter information sorted by the newest aircraft registration |
||
| 927 | * |
||
| 928 | * @return Array the spotter information |
||
| 929 | * |
||
| 930 | */ |
||
| 931 | public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array()) |
||
| 932 | { |
||
| 933 | global $global_query; |
||
| 934 | |||
| 935 | date_default_timezone_set('UTC'); |
||
| 936 | $filter_query = $this->getFilter($filter,true,true); |
||
| 937 | |||
| 938 | $limit_query = ''; |
||
| 939 | if ($limit != "") |
||
| 940 | { |
||
| 941 | $limit_array = explode(",", $limit); |
||
| 942 | |||
| 943 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 944 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 945 | |||
| 946 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 947 | { |
||
| 948 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 949 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 950 | } |
||
| 951 | } |
||
| 952 | |||
| 953 | if ($sort != "") |
||
| 954 | { |
||
| 955 | $search_orderby_array = $this->getOrderBy(); |
||
| 956 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 957 | } else { |
||
| 958 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 959 | } |
||
| 960 | |||
| 961 | $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; |
||
| 962 | |||
| 963 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 964 | |||
| 965 | return $spotter_array; |
||
| 966 | } |
||
| 967 | |||
| 968 | |||
| 969 | /** |
||
| 970 | * Gets all the spotter information sorted by the newest airline |
||
| 971 | * |
||
| 972 | * @return Array the spotter information |
||
| 973 | * |
||
| 974 | */ |
||
| 975 | public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array()) |
||
| 976 | { |
||
| 977 | global $global_query; |
||
| 978 | |||
| 979 | date_default_timezone_set('UTC'); |
||
| 980 | $filter_query = $this->getFilter($filter,true,true); |
||
| 981 | |||
| 982 | $limit_query = ''; |
||
| 983 | if ($limit != "") |
||
| 984 | { |
||
| 985 | $limit_array = explode(",", $limit); |
||
| 986 | |||
| 987 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 988 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 989 | |||
| 990 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 991 | { |
||
| 992 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 993 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 994 | } |
||
| 995 | } |
||
| 996 | |||
| 997 | if ($sort != "") |
||
| 998 | { |
||
| 999 | $search_orderby_array = $this->getOrderBy(); |
||
| 1000 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1001 | } else { |
||
| 1002 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1003 | } |
||
| 1004 | |||
| 1005 | $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; |
||
| 1006 | |||
| 1007 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1008 | |||
| 1009 | return $spotter_array; |
||
| 1010 | } |
||
| 1011 | |||
| 1012 | |||
| 1013 | /** |
||
| 1014 | * Gets all the spotter information sorted by the newest departure airport |
||
| 1015 | * |
||
| 1016 | * @return Array the spotter information |
||
| 1017 | * |
||
| 1018 | */ |
||
| 1019 | public function getNewestSpotterDataSortedByDepartureAirport($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 | |||
| 1029 | if ($limit != "") |
||
| 1030 | { |
||
| 1031 | $limit_array = explode(",", $limit); |
||
| 1032 | |||
| 1033 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1034 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1035 | |||
| 1036 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1037 | { |
||
| 1038 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1039 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1040 | } |
||
| 1041 | } |
||
| 1042 | |||
| 1043 | if ($sort != "") |
||
| 1044 | { |
||
| 1045 | $search_orderby_array = $this->getOrderBy(); |
||
| 1046 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1047 | } else { |
||
| 1048 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
||
| 1049 | } |
||
| 1050 | |||
| 1051 | $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; |
||
| 1052 | |||
| 1053 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1054 | |||
| 1055 | return $spotter_array; |
||
| 1056 | } |
||
| 1057 | |||
| 1058 | |||
| 1059 | /** |
||
| 1060 | * Gets all the spotter information sorted by the newest arrival airport |
||
| 1061 | * |
||
| 1062 | * @return Array the spotter information |
||
| 1063 | * |
||
| 1064 | */ |
||
| 1065 | public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array()) |
||
| 1066 | { |
||
| 1067 | global $global_query; |
||
| 1068 | |||
| 1069 | date_default_timezone_set('UTC'); |
||
| 1070 | $filter_query = $this->getFilter($filter,true,true); |
||
| 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.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
||
| 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 based on the spotter id |
||
| 1104 | * |
||
| 1105 | * @return Array the spotter information |
||
| 1106 | * |
||
| 1107 | */ |
||
| 1108 | public function getSpotterDataByID($id = '') |
||
| 1109 | { |
||
| 1110 | global $global_query; |
||
| 1111 | |||
| 1112 | date_default_timezone_set('UTC'); |
||
| 1113 | if ($id == '') return array(); |
||
| 1114 | $additional_query = "spotter_output.spotter_id = :id"; |
||
| 1115 | $query_values = array(':id' => $id); |
||
| 1116 | |||
| 1117 | //$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." "; |
||
| 1118 | $query = $global_query." WHERE ".$additional_query." "; |
||
| 1119 | |||
| 1120 | $spotter_array = $this->getDataFromDB($query,$query_values); |
||
| 1121 | |||
| 1122 | return $spotter_array; |
||
| 1123 | } |
||
| 1124 | |||
| 1125 | |||
| 1126 | |||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Gets all the spotter information based on the callsign |
||
| 1130 | * |
||
| 1131 | * @return Array the spotter information |
||
| 1132 | * |
||
| 1133 | */ |
||
| 1134 | public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
||
| 1135 | { |
||
| 1136 | global $global_query; |
||
| 1137 | |||
| 1138 | date_default_timezone_set('UTC'); |
||
| 1139 | |||
| 1140 | $query_values = array(); |
||
| 1141 | $limit_query = ''; |
||
| 1142 | $additional_query = ''; |
||
| 1143 | if ($ident != "") |
||
| 1144 | { |
||
| 1145 | if (!is_string($ident)) |
||
| 1146 | { |
||
| 1147 | return false; |
||
| 1148 | } else { |
||
| 1149 | $additional_query = " AND (spotter_output.ident = :ident)"; |
||
| 1150 | $query_values = array(':ident' => $ident); |
||
| 1151 | } |
||
| 1152 | } |
||
| 1153 | |||
| 1154 | if ($limit != "") |
||
| 1155 | { |
||
| 1156 | $limit_array = explode(",", $limit); |
||
| 1157 | |||
| 1158 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1159 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1160 | |||
| 1161 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1162 | { |
||
| 1163 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1164 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1165 | } |
||
| 1166 | } |
||
| 1167 | |||
| 1168 | if ($sort != "") |
||
| 1169 | { |
||
| 1170 | $search_orderby_array = $this->getOrderBy(); |
||
| 1171 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1172 | } else { |
||
| 1173 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1174 | } |
||
| 1175 | |||
| 1176 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1177 | |||
| 1178 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1179 | |||
| 1180 | return $spotter_array; |
||
| 1181 | } |
||
| 1182 | |||
| 1183 | |||
| 1184 | |||
| 1185 | /** |
||
| 1186 | * Gets all the spotter information based on the aircraft type |
||
| 1187 | * |
||
| 1188 | * @return Array the spotter information |
||
| 1189 | * |
||
| 1190 | */ |
||
| 1191 | public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array()) |
||
| 1192 | { |
||
| 1193 | global $global_query; |
||
| 1194 | |||
| 1195 | date_default_timezone_set('UTC'); |
||
| 1196 | |||
| 1197 | $query_values = array(); |
||
| 1198 | $limit_query = ''; |
||
| 1199 | $additional_query = ''; |
||
| 1200 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1201 | |||
| 1202 | if ($aircraft_type != "") |
||
| 1203 | { |
||
| 1204 | if (!is_string($aircraft_type)) |
||
| 1205 | { |
||
| 1206 | return false; |
||
| 1207 | } else { |
||
| 1208 | $additional_query = " AND (spotter_output.aircraft_icao = :aircraft_type)"; |
||
| 1209 | $query_values = array(':aircraft_type' => $aircraft_type); |
||
| 1210 | } |
||
| 1211 | } |
||
| 1212 | |||
| 1213 | if ($limit != "") |
||
| 1214 | { |
||
| 1215 | $limit_array = explode(",", $limit); |
||
| 1216 | |||
| 1217 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1218 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1219 | |||
| 1220 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1221 | { |
||
| 1222 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1223 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1224 | } |
||
| 1225 | } |
||
| 1226 | |||
| 1227 | if ($sort != "") |
||
| 1228 | { |
||
| 1229 | $search_orderby_array = $this->getOrderBy(); |
||
| 1230 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1231 | } else { |
||
| 1232 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1233 | } |
||
| 1234 | |||
| 1235 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1236 | |||
| 1237 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1238 | |||
| 1239 | return $spotter_array; |
||
| 1240 | } |
||
| 1241 | |||
| 1242 | |||
| 1243 | /** |
||
| 1244 | * Gets all the spotter information based on the aircraft registration |
||
| 1245 | * |
||
| 1246 | * @return Array the spotter information |
||
| 1247 | * |
||
| 1248 | */ |
||
| 1249 | public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array()) |
||
| 1250 | { |
||
| 1251 | global $global_query; |
||
| 1252 | |||
| 1253 | date_default_timezone_set('UTC'); |
||
| 1254 | |||
| 1255 | $query_values = array(); |
||
| 1256 | $limit_query = ''; |
||
| 1257 | $additional_query = ''; |
||
| 1258 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1259 | |||
| 1260 | if ($registration != "") |
||
| 1261 | { |
||
| 1262 | if (!is_string($registration)) |
||
| 1263 | { |
||
| 1264 | return false; |
||
| 1265 | } else { |
||
| 1266 | $additional_query = " AND (spotter_output.registration = :registration)"; |
||
| 1267 | $query_values = array(':registration' => $registration); |
||
| 1268 | } |
||
| 1269 | } |
||
| 1270 | |||
| 1271 | if ($limit != "") |
||
| 1272 | { |
||
| 1273 | $limit_array = explode(",", $limit); |
||
| 1274 | |||
| 1275 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1276 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1277 | |||
| 1278 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1279 | { |
||
| 1280 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1281 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1282 | } |
||
| 1283 | } |
||
| 1284 | |||
| 1285 | if ($sort != "") |
||
| 1286 | { |
||
| 1287 | $search_orderby_array = $this->getOrderBy(); |
||
| 1288 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1289 | } else { |
||
| 1290 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1291 | } |
||
| 1292 | |||
| 1293 | $query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1294 | |||
| 1295 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1296 | |||
| 1297 | return $spotter_array; |
||
| 1298 | } |
||
| 1299 | |||
| 1300 | |||
| 1301 | |||
| 1302 | |||
| 1303 | /** |
||
| 1304 | * Gets all the spotter information based on the airline |
||
| 1305 | * |
||
| 1306 | * @return Array the spotter information |
||
| 1307 | * |
||
| 1308 | */ |
||
| 1309 | public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '') |
||
| 1310 | { |
||
| 1311 | global $global_query; |
||
| 1312 | |||
| 1313 | date_default_timezone_set('UTC'); |
||
| 1314 | |||
| 1315 | $query_values = array(); |
||
| 1316 | $limit_query = ''; |
||
| 1317 | $additional_query = ''; |
||
| 1318 | |||
| 1319 | if ($airline != "") |
||
| 1320 | { |
||
| 1321 | if (!is_string($airline)) |
||
| 1322 | { |
||
| 1323 | return false; |
||
| 1324 | } else { |
||
| 1325 | $additional_query = " AND (spotter_output.airline_icao = :airline)"; |
||
| 1326 | $query_values = array(':airline' => $airline); |
||
| 1327 | } |
||
| 1328 | } |
||
| 1329 | |||
| 1330 | if ($limit != "") |
||
| 1331 | { |
||
| 1332 | $limit_array = explode(",", $limit); |
||
| 1333 | |||
| 1334 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1335 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1336 | |||
| 1337 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1338 | { |
||
| 1339 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1340 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1341 | } |
||
| 1342 | } |
||
| 1343 | |||
| 1344 | if ($sort != "") |
||
| 1345 | { |
||
| 1346 | $search_orderby_array = $this->getOrderBy(); |
||
| 1347 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1348 | } else { |
||
| 1349 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1350 | } |
||
| 1351 | |||
| 1352 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1353 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1354 | |||
| 1355 | return $spotter_array; |
||
| 1356 | } |
||
| 1357 | |||
| 1358 | |||
| 1359 | /** |
||
| 1360 | * Gets all the spotter information based on the airport |
||
| 1361 | * |
||
| 1362 | * @return Array the spotter information |
||
| 1363 | * |
||
| 1364 | */ |
||
| 1365 | public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '') |
||
| 1366 | { |
||
| 1367 | global $global_query; |
||
| 1368 | |||
| 1369 | date_default_timezone_set('UTC'); |
||
| 1370 | $query_values = array(); |
||
| 1371 | $limit_query = ''; |
||
| 1372 | $additional_query = ''; |
||
| 1373 | |||
| 1374 | if ($airport != "") |
||
| 1375 | { |
||
| 1376 | if (!is_string($airport)) |
||
| 1377 | { |
||
| 1378 | return false; |
||
| 1379 | } else { |
||
| 1380 | $additional_query .= " AND ((spotter_output.departure_airport_icao = :airport) OR (spotter_output.arrival_airport_icao = :airport))"; |
||
| 1381 | $query_values = array(':airport' => $airport); |
||
| 1382 | } |
||
| 1383 | } |
||
| 1384 | |||
| 1385 | if ($limit != "") |
||
| 1386 | { |
||
| 1387 | $limit_array = explode(",", $limit); |
||
| 1388 | |||
| 1389 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1390 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1391 | |||
| 1392 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1393 | { |
||
| 1394 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1395 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1396 | } |
||
| 1397 | } |
||
| 1398 | |||
| 1399 | if ($sort != "") |
||
| 1400 | { |
||
| 1401 | $search_orderby_array = $this->getOrderBy(); |
||
| 1402 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1403 | } else { |
||
| 1404 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1405 | } |
||
| 1406 | |||
| 1407 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." AND ((spotter_output.departure_airport_icao <> 'NA') AND (spotter_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
||
| 1408 | |||
| 1409 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1410 | |||
| 1411 | return $spotter_array; |
||
| 1412 | } |
||
| 1413 | |||
| 1414 | |||
| 1415 | |||
| 1416 | /** |
||
| 1417 | * Gets all the spotter information based on the date |
||
| 1418 | * |
||
| 1419 | * @return Array the spotter information |
||
| 1420 | * |
||
| 1421 | */ |
||
| 1422 | public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
||
| 1423 | { |
||
| 1424 | global $global_query, $globalTimezone, $globalDBdriver; |
||
| 1425 | |||
| 1426 | $query_values = array(); |
||
| 1427 | $limit_query = ''; |
||
| 1428 | $additional_query = ''; |
||
| 1429 | |||
| 1430 | $filter_query = ''; |
||
| 1431 | if (isset($filter['source']) && !empty($filter['source'])) { |
||
| 1432 | $filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')"; |
||
| 1433 | } |
||
| 1434 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
||
| 1435 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
||
| 1436 | } |
||
| 1437 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
||
| 1438 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
||
| 1439 | } |
||
| 1440 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
||
| 1441 | $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
||
| 1442 | } |
||
| 1443 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
||
| 1444 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
||
| 1445 | } |
||
| 1446 | |||
| 1447 | |||
| 1448 | if ($date != "") |
||
| 1449 | { |
||
| 1450 | if ($globalTimezone != '') { |
||
| 1451 | date_default_timezone_set($globalTimezone); |
||
| 1452 | $datetime = new DateTime($date); |
||
| 1453 | $offset = $datetime->format('P'); |
||
| 1454 | } else { |
||
| 1455 | date_default_timezone_set('UTC'); |
||
| 1456 | $datetime = new DateTime($date); |
||
| 1457 | $offset = '+00:00'; |
||
| 1458 | } |
||
| 1459 | if ($globalDBdriver == 'mysql') { |
||
| 1460 | $additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date "; |
||
| 1461 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset); |
||
| 1462 | } elseif ($globalDBdriver == 'pgsql') { |
||
| 1463 | $additional_query = " AND to_char(spotter_output.date AT TIME ZONE :timezone,'YYYY-mm-dd') = :date "; |
||
| 1464 | $query_values = array(':date' => $datetime->format('Y-m-d'), ':timezone' => $globalTimezone); |
||
| 1465 | } |
||
| 1466 | } |
||
| 1467 | |||
| 1468 | if ($limit != "") |
||
| 1469 | { |
||
| 1470 | $limit_array = explode(",", $limit); |
||
| 1471 | |||
| 1472 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1473 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1474 | |||
| 1475 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1476 | { |
||
| 1477 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1478 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1479 | } |
||
| 1480 | } |
||
| 1481 | |||
| 1482 | if ($sort != "") |
||
| 1483 | { |
||
| 1484 | $search_orderby_array = $this->getOrderBy(); |
||
| 1485 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1486 | } else { |
||
| 1487 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1488 | } |
||
| 1489 | |||
| 1490 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query.$filter_query." ".$orderby_query; |
||
| 1491 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1492 | return $spotter_array; |
||
| 1493 | } |
||
| 1494 | |||
| 1495 | |||
| 1496 | |||
| 1497 | /** |
||
| 1498 | * Gets all the spotter information based on the country name |
||
| 1499 | * |
||
| 1500 | * @return Array the spotter information |
||
| 1501 | * |
||
| 1502 | */ |
||
| 1503 | public function getSpotterDataByCountry($country = '', $limit = '', $sort = '') |
||
| 1504 | { |
||
| 1505 | global $global_query; |
||
| 1506 | |||
| 1507 | date_default_timezone_set('UTC'); |
||
| 1508 | |||
| 1509 | $query_values = array(); |
||
| 1510 | $limit_query = ''; |
||
| 1511 | $additional_query = ''; |
||
| 1512 | if ($country != "") |
||
| 1513 | { |
||
| 1514 | if (!is_string($country)) |
||
| 1515 | { |
||
| 1516 | return false; |
||
| 1517 | } else { |
||
| 1518 | $additional_query .= " AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country))"; |
||
| 1519 | $additional_query .= " OR spotter_output.airline_country = :country"; |
||
| 1520 | $query_values = array(':country' => $country); |
||
| 1521 | } |
||
| 1522 | } |
||
| 1523 | |||
| 1524 | if ($limit != "") |
||
| 1525 | { |
||
| 1526 | $limit_array = explode(",", $limit); |
||
| 1527 | |||
| 1528 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1529 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1530 | |||
| 1531 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1532 | { |
||
| 1533 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1534 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1535 | } |
||
| 1536 | } |
||
| 1537 | |||
| 1538 | if ($sort != "") |
||
| 1539 | { |
||
| 1540 | $search_orderby_array = $this->getOrderBy(); |
||
| 1541 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1542 | } else { |
||
| 1543 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1544 | } |
||
| 1545 | |||
| 1546 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1547 | |||
| 1548 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1549 | |||
| 1550 | return $spotter_array; |
||
| 1551 | } |
||
| 1552 | |||
| 1553 | |||
| 1554 | /** |
||
| 1555 | * Gets all the spotter information based on the manufacturer name |
||
| 1556 | * |
||
| 1557 | * @return Array the spotter information |
||
| 1558 | * |
||
| 1559 | */ |
||
| 1560 | public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '') |
||
| 1561 | { |
||
| 1562 | global $global_query; |
||
| 1563 | |||
| 1564 | date_default_timezone_set('UTC'); |
||
| 1565 | |||
| 1566 | $query_values = array(); |
||
| 1567 | $additional_query = ''; |
||
| 1568 | $limit_query = ''; |
||
| 1569 | |||
| 1570 | if ($aircraft_manufacturer != "") |
||
| 1571 | { |
||
| 1572 | if (!is_string($aircraft_manufacturer)) |
||
| 1573 | { |
||
| 1574 | return false; |
||
| 1575 | } else { |
||
| 1576 | $additional_query .= " AND (spotter_output.aircraft_manufacturer = :aircraft_manufacturer)"; |
||
| 1577 | $query_values = array(':aircraft_manufacturer' => $aircraft_manufacturer); |
||
| 1578 | } |
||
| 1579 | } |
||
| 1580 | |||
| 1581 | if ($limit != "") |
||
| 1582 | { |
||
| 1583 | $limit_array = explode(",", $limit); |
||
| 1584 | |||
| 1585 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1586 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1587 | |||
| 1588 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1589 | { |
||
| 1590 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1591 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1592 | } |
||
| 1593 | } |
||
| 1594 | |||
| 1595 | if ($sort != "") |
||
| 1596 | { |
||
| 1597 | $search_orderby_array = $this->getOrderBy(); |
||
| 1598 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1599 | } else { |
||
| 1600 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1601 | } |
||
| 1602 | |||
| 1603 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1604 | |||
| 1605 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1606 | |||
| 1607 | return $spotter_array; |
||
| 1608 | } |
||
| 1609 | |||
| 1610 | |||
| 1611 | |||
| 1612 | |||
| 1613 | /** |
||
| 1614 | * Gets a list of all aircraft that take a route |
||
| 1615 | * |
||
| 1616 | * @param String $departure_airport_icao ICAO code of departure airport |
||
| 1617 | * @param String $arrival_airport_icao ICAO code of arrival airport |
||
| 1618 | * @return Array the spotter information |
||
| 1619 | * |
||
| 1620 | */ |
||
| 1621 | public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '') |
||
| 1622 | { |
||
| 1623 | global $global_query; |
||
| 1624 | |||
| 1625 | $query_values = array(); |
||
| 1626 | $additional_query = ''; |
||
| 1627 | $limit_query = ''; |
||
| 1628 | if ($departure_airport_icao != "") |
||
| 1629 | { |
||
| 1630 | if (!is_string($departure_airport_icao)) |
||
| 1631 | { |
||
| 1632 | return false; |
||
| 1633 | } else { |
||
| 1634 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 1635 | $additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)"; |
||
| 1636 | $query_values = array(':departure_airport_icao' => $departure_airport_icao); |
||
| 1637 | } |
||
| 1638 | } |
||
| 1639 | |||
| 1640 | if ($arrival_airport_icao != "") |
||
| 1641 | { |
||
| 1642 | if (!is_string($arrival_airport_icao)) |
||
| 1643 | { |
||
| 1644 | return false; |
||
| 1645 | } else { |
||
| 1646 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 1647 | $additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)"; |
||
| 1648 | $query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 1649 | } |
||
| 1650 | } |
||
| 1651 | |||
| 1652 | if ($limit != "") |
||
| 1653 | { |
||
| 1654 | $limit_array = explode(",", $limit); |
||
| 1655 | |||
| 1656 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1657 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1658 | |||
| 1659 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1660 | { |
||
| 1661 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1662 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1663 | } |
||
| 1664 | } |
||
| 1665 | |||
| 1666 | if ($sort != "") |
||
| 1667 | { |
||
| 1668 | $search_orderby_array = $this->getOrderBy(); |
||
| 1669 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1670 | } else { |
||
| 1671 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1672 | } |
||
| 1673 | |||
| 1674 | $query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
||
| 1675 | |||
| 1676 | //$result = mysqli_query($GLOBALS["___mysqli_ston"], $query); |
||
| 1677 | |||
| 1678 | $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
||
| 1679 | |||
| 1680 | return $spotter_array; |
||
| 1681 | } |
||
| 1682 | |||
| 1683 | |||
| 1684 | |||
| 1685 | /** |
||
| 1686 | * Gets all the spotter information based on the special column in the table |
||
| 1687 | * |
||
| 1688 | * @return Array the spotter information |
||
| 1689 | * |
||
| 1690 | */ |
||
| 1691 | public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array()) |
||
| 1692 | { |
||
| 1693 | global $global_query; |
||
| 1694 | |||
| 1695 | date_default_timezone_set('UTC'); |
||
| 1696 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1697 | $limit_query = ''; |
||
| 1698 | |||
| 1699 | if ($limit != "") |
||
| 1700 | { |
||
| 1701 | $limit_array = explode(",", $limit); |
||
| 1702 | |||
| 1703 | $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
||
| 1704 | $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
||
| 1705 | |||
| 1706 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
||
| 1707 | { |
||
| 1708 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
||
| 1709 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
||
| 1710 | } |
||
| 1711 | } |
||
| 1712 | |||
| 1713 | if ($sort != "") |
||
| 1714 | { |
||
| 1715 | $search_orderby_array = $this->getOrderBy(); |
||
| 1716 | $orderby_query = $search_orderby_array[$sort]['sql']; |
||
| 1717 | } else { |
||
| 1718 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
||
| 1719 | } |
||
| 1720 | |||
| 1721 | $query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query; |
||
| 1722 | |||
| 1723 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
||
| 1724 | |||
| 1725 | return $spotter_array; |
||
| 1726 | } |
||
| 1727 | |||
| 1728 | /** |
||
| 1729 | * Gets all the highlight based on a aircraft registration |
||
| 1730 | * |
||
| 1731 | * @return String the highlight text |
||
| 1732 | * |
||
| 1733 | */ |
||
| 1734 | public function getHighlightByRegistration($registration,$filter = array()) |
||
| 1735 | { |
||
| 1736 | global $global_query; |
||
| 1737 | |||
| 1738 | date_default_timezone_set('UTC'); |
||
| 1739 | $filter_query = $this->getFilter($filter,true,true); |
||
| 1740 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 1741 | |||
| 1742 | $query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; |
||
| 1743 | $sth = $this->db->prepare($query); |
||
| 1744 | $sth->execute(array(':registration' => $registration)); |
||
| 1745 | |||
| 1746 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1747 | { |
||
| 1748 | $highlight = $row['highlight']; |
||
| 1749 | } |
||
| 1750 | if (isset($highlight)) return $highlight; |
||
| 1751 | } |
||
| 1752 | |||
| 1753 | |||
| 1754 | /** |
||
| 1755 | * Gets the squawk usage from squawk code |
||
| 1756 | * |
||
| 1757 | * @param String $squawk squawk code |
||
| 1758 | * @param String $country country |
||
| 1759 | * @return String usage |
||
| 1760 | * |
||
| 1761 | */ |
||
| 1762 | public function getSquawkUsage($squawk = '',$country = 'FR') |
||
| 1763 | { |
||
| 1764 | |||
| 1765 | $squawk = filter_var($squawk,FILTER_SANITIZE_STRING); |
||
| 1766 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 1767 | |||
| 1768 | $query = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1"; |
||
| 1769 | $query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country); |
||
| 1770 | |||
| 1771 | $sth = $this->db->prepare($query); |
||
| 1772 | $sth->execute($query_values); |
||
| 1773 | |||
| 1774 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 1775 | $sth->closeCursor(); |
||
| 1776 | if (count($row) > 0) { |
||
| 1777 | return $row['usage']; |
||
| 1778 | } else return ''; |
||
| 1779 | } |
||
| 1780 | |||
| 1781 | /** |
||
| 1782 | * Gets the airport icao from the iata |
||
| 1783 | * |
||
| 1784 | * @param String $airport_iata the iata code of the airport |
||
| 1785 | * @return String airport iata |
||
| 1786 | * |
||
| 1787 | */ |
||
| 1788 | public function getAirportIcao($airport_iata = '') |
||
| 1789 | { |
||
| 1790 | |||
| 1791 | $airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING); |
||
| 1792 | |||
| 1793 | $query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; |
||
| 1794 | $query_values = array(':airport' => $airport_iata); |
||
| 1795 | |||
| 1796 | $sth = $this->db->prepare($query); |
||
| 1797 | $sth->execute($query_values); |
||
| 1798 | |||
| 1799 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 1800 | $sth->closeCursor(); |
||
| 1801 | if (count($row) > 0) { |
||
| 1802 | return $row['icao']; |
||
| 1803 | } else return ''; |
||
| 1804 | } |
||
| 1805 | |||
| 1806 | /** |
||
| 1807 | * Gets the airport distance |
||
| 1808 | * |
||
| 1809 | * @param String $airport_icao the icao code of the airport |
||
| 1810 | * @param Float $latitude the latitude |
||
| 1811 | * @param Float $longitude the longitude |
||
| 1812 | * @return Float distance to the airport |
||
| 1813 | * |
||
| 1814 | */ |
||
| 1815 | public function getAirportDistance($airport_icao,$latitude,$longitude) |
||
| 1816 | { |
||
| 1817 | |||
| 1818 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 1819 | |||
| 1820 | $query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; |
||
| 1821 | $query_values = array(':airport' => $airport_icao); |
||
| 1822 | $sth = $this->db->prepare($query); |
||
| 1823 | $sth->execute($query_values); |
||
| 1824 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 1825 | $sth->closeCursor(); |
||
| 1826 | if (count($row) > 0) { |
||
| 1827 | $airport_latitude = $row['latitude']; |
||
| 1828 | $airport_longitude = $row['longitude']; |
||
| 1829 | $Common = new Common(); |
||
| 1830 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
||
| 1831 | } else return ''; |
||
| 1832 | } |
||
| 1833 | |||
| 1834 | /** |
||
| 1835 | * Gets the airport info based on the icao |
||
| 1836 | * |
||
| 1837 | * @param String $airport the icao code of the airport |
||
| 1838 | * @return Array airport information |
||
| 1839 | * |
||
| 1840 | */ |
||
| 1841 | public function getAllAirportInfo($airport = '') |
||
| 1842 | { |
||
| 1843 | |||
| 1844 | $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
||
| 1845 | |||
| 1846 | $query_values = array(); |
||
| 1847 | if ($airport == 'NA') { |
||
| 1848 | 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' => '')); |
||
| 1849 | } elseif ($airport == '') { |
||
| 1850 | $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"; |
||
| 1851 | } else { |
||
| 1852 | $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"; |
||
| 1853 | $query_values = array(':airport' => $airport); |
||
| 1854 | } |
||
| 1855 | |||
| 1856 | $sth = $this->db->prepare($query); |
||
| 1857 | $sth->execute($query_values); |
||
| 1858 | /* |
||
| 1859 | $airport_array = array(); |
||
| 1860 | $temp_array = array(); |
||
| 1861 | |||
| 1862 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1863 | { |
||
| 1864 | $temp_array['name'] = $row['name']; |
||
| 1865 | $temp_array['city'] = $row['city']; |
||
| 1866 | $temp_array['country'] = $row['country']; |
||
| 1867 | $temp_array['iata'] = $row['iata']; |
||
| 1868 | $temp_array['icao'] = $row['icao']; |
||
| 1869 | $temp_array['latitude'] = $row['latitude']; |
||
| 1870 | $temp_array['longitude'] = $row['longitude']; |
||
| 1871 | $temp_array['altitude'] = $row['altitude']; |
||
| 1872 | $temp_array['home_link'] = $row['home_link']; |
||
| 1873 | $temp_array['wikipedia_link'] = $row['wikipedia_link']; |
||
| 1874 | $temp_array['image'] = $row['image']; |
||
| 1875 | $temp_array['image_thumb'] = $row['image_thumb']; |
||
| 1876 | |||
| 1877 | $airport_array[] = $temp_array; |
||
| 1878 | } |
||
| 1879 | |||
| 1880 | return $airport_array; |
||
| 1881 | */ |
||
| 1882 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 1883 | } |
||
| 1884 | |||
| 1885 | /** |
||
| 1886 | * Gets the airport info based on the country |
||
| 1887 | * |
||
| 1888 | * @param Array $countries Airports countries |
||
| 1889 | * @return Array airport information |
||
| 1890 | * |
||
| 1891 | */ |
||
| 1892 | public function getAllAirportInfobyCountry($countries) |
||
| 1893 | { |
||
| 1894 | $lst_countries = ''; |
||
| 1895 | foreach ($countries as $country) { |
||
| 1896 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 1897 | if ($lst_countries == '') { |
||
| 1898 | $lst_countries = "'".$country."'"; |
||
| 1899 | } else { |
||
| 1900 | $lst_countries .= ",'".$country."'"; |
||
| 1901 | } |
||
| 1902 | } |
||
| 1903 | $query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; |
||
| 1904 | |||
| 1905 | $sth = $this->db->prepare($query); |
||
| 1906 | $sth->execute(); |
||
| 1907 | |||
| 1908 | $airport_array = array(); |
||
| 1909 | $temp_array = array(); |
||
| 1910 | |||
| 1911 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1912 | { |
||
| 1913 | $temp_array['name'] = $row['name']; |
||
| 1914 | $temp_array['city'] = $row['city']; |
||
| 1915 | $temp_array['country'] = $row['country']; |
||
| 1916 | $temp_array['iata'] = $row['iata']; |
||
| 1917 | $temp_array['icao'] = $row['icao']; |
||
| 1918 | $temp_array['latitude'] = $row['latitude']; |
||
| 1919 | $temp_array['longitude'] = $row['longitude']; |
||
| 1920 | $temp_array['altitude'] = $row['altitude']; |
||
| 1921 | |||
| 1922 | $airport_array[] = $temp_array; |
||
| 1923 | } |
||
| 1924 | |||
| 1925 | return $airport_array; |
||
| 1926 | } |
||
| 1927 | |||
| 1928 | /** |
||
| 1929 | * Gets airports info based on the coord |
||
| 1930 | * |
||
| 1931 | * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max |
||
| 1932 | * @return Array airport information |
||
| 1933 | * |
||
| 1934 | */ |
||
| 1935 | public function getAllAirportInfobyCoord($coord) |
||
| 1936 | { |
||
| 1937 | global $globalDBdriver; |
||
| 1938 | if (is_array($coord)) { |
||
| 1939 | $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1940 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1941 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1942 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1943 | } else return array(); |
||
| 1944 | if ($globalDBdriver == 'mysql') { |
||
| 1945 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
||
| 1946 | } else { |
||
| 1947 | $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'"; |
||
| 1948 | } |
||
| 1949 | $sth = $this->db->prepare($query); |
||
| 1950 | $sth->execute(); |
||
| 1951 | |||
| 1952 | $airport_array = array(); |
||
| 1953 | |||
| 1954 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1955 | { |
||
| 1956 | $temp_array = $row; |
||
| 1957 | |||
| 1958 | $airport_array[] = $temp_array; |
||
| 1959 | } |
||
| 1960 | |||
| 1961 | return $airport_array; |
||
| 1962 | } |
||
| 1963 | |||
| 1964 | /** |
||
| 1965 | * Gets waypoints info based on the coord |
||
| 1966 | * |
||
| 1967 | * @param Array $coord waypoints coord |
||
| 1968 | * @return Array airport information |
||
| 1969 | * |
||
| 1970 | */ |
||
| 1971 | public function getAllWaypointsInfobyCoord($coord) |
||
| 1972 | { |
||
| 1973 | if (is_array($coord)) { |
||
| 1974 | $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1975 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1976 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1977 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 1978 | } else return array(); |
||
| 1979 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
||
| 1980 | $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.")"; |
||
| 1981 | //$query = "SELECT waypoints.* FROM waypoints"; |
||
| 1982 | //$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"; |
||
| 1983 | //$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; |
||
| 1984 | //$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; |
||
| 1985 | //echo $query; |
||
| 1986 | |||
| 1987 | $sth = $this->db->prepare($query); |
||
| 1988 | $sth->execute(); |
||
| 1989 | |||
| 1990 | $waypoints_array = array(); |
||
| 1991 | |||
| 1992 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 1993 | { |
||
| 1994 | $temp_array = $row; |
||
| 1995 | |||
| 1996 | $waypoints_array[] = $temp_array; |
||
| 1997 | } |
||
| 1998 | |||
| 1999 | return $waypoints_array; |
||
| 2000 | } |
||
| 2001 | |||
| 2002 | |||
| 2003 | /** |
||
| 2004 | * Gets the airline info based on the icao code or iata code |
||
| 2005 | * |
||
| 2006 | * @param String $airline_icao the iata code of the airport |
||
| 2007 | * @return Array airport information |
||
| 2008 | * |
||
| 2009 | */ |
||
| 2010 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
||
| 2011 | { |
||
| 2012 | global $globalUseRealAirlines; |
||
| 2013 | if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
||
| 2014 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
||
| 2015 | if ($airline_icao == 'NA') { |
||
| 2016 | $airline_array = array(); |
||
| 2017 | $airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); |
||
| 2018 | return $airline_array; |
||
| 2019 | } else { |
||
| 2020 | if (strlen($airline_icao) == 2) { |
||
| 2021 | if ($fromsource === NULL) { |
||
| 2022 | $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"; |
||
| 2023 | } else { |
||
| 2024 | $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"; |
||
| 2025 | } |
||
| 2026 | } else { |
||
| 2027 | if ($fromsource === NULL) { |
||
| 2028 | $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"; |
||
| 2029 | } else { |
||
| 2030 | $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"; |
||
| 2031 | } |
||
| 2032 | } |
||
| 2033 | |||
| 2034 | $sth = $this->db->prepare($query); |
||
| 2035 | if ($fromsource === NULL) { |
||
| 2036 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 2037 | } else { |
||
| 2038 | $sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource)); |
||
| 2039 | } |
||
| 2040 | /* |
||
| 2041 | $airline_array = array(); |
||
| 2042 | $temp_array = array(); |
||
| 2043 | |||
| 2044 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2045 | { |
||
| 2046 | $temp_array['name'] = $row['name']; |
||
| 2047 | $temp_array['iata'] = $row['iata']; |
||
| 2048 | $temp_array['icao'] = $row['icao']; |
||
| 2049 | $temp_array['callsign'] = $row['callsign']; |
||
| 2050 | $temp_array['country'] = $row['country']; |
||
| 2051 | $temp_array['type'] = $row['type']; |
||
| 2052 | $airline_array[] = $temp_array; |
||
| 2053 | } |
||
| 2054 | return $airline_array; |
||
| 2055 | */ |
||
| 2056 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2057 | if (empty($result) && $fromsource !== NULL) { |
||
| 2058 | $query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; |
||
| 2059 | $sth = $this->db->prepare($query); |
||
| 2060 | $sth->execute(array(':fromsource' => $fromsource)); |
||
| 2061 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2062 | $sth->closeCursor(); |
||
| 2063 | if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); |
||
| 2064 | } |
||
| 2065 | return $result; |
||
| 2066 | } |
||
| 2067 | } |
||
| 2068 | |||
| 2069 | |||
| 2070 | |||
| 2071 | /** |
||
| 2072 | * Gets the aircraft info based on the aircraft type |
||
| 2073 | * |
||
| 2074 | * @param String $aircraft_type the aircraft type |
||
| 2075 | * @return Array aircraft information |
||
| 2076 | * |
||
| 2077 | */ |
||
| 2078 | public function getAllAircraftInfo($aircraft_type) |
||
| 2079 | { |
||
| 2080 | $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
||
| 2081 | |||
| 2082 | if ($aircraft_type == 'NA') { |
||
| 2083 | return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); |
||
| 2084 | } |
||
| 2085 | $query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type"; |
||
| 2086 | |||
| 2087 | $sth = $this->db->prepare($query); |
||
| 2088 | $sth->execute(array(':aircraft_type' => $aircraft_type)); |
||
| 2089 | /* |
||
| 2090 | $aircraft_array = array(); |
||
| 2091 | $temp_array = array(); |
||
| 2092 | |||
| 2093 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2094 | { |
||
| 2095 | $temp_array = array(); |
||
| 2096 | $temp_array['icao'] = $row['icao']; |
||
| 2097 | $temp_array['type'] = $row['type']; |
||
| 2098 | $temp_array['manufacturer'] = $row['manufacturer']; |
||
| 2099 | $temp_array['aircraft_shadow'] = $row['aircraft_shadow']; |
||
| 2100 | |||
| 2101 | $aircraft_array[] = $temp_array; |
||
| 2102 | } |
||
| 2103 | return $aircraft_array; |
||
| 2104 | */ |
||
| 2105 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2106 | } |
||
| 2107 | |||
| 2108 | /** |
||
| 2109 | * Gets the aircraft icao based on the aircraft name/type |
||
| 2110 | * |
||
| 2111 | * @param String $aircraft_type the aircraft type |
||
| 2112 | * @return String aircraft information |
||
| 2113 | * |
||
| 2114 | */ |
||
| 2115 | public function getAircraftIcao($aircraft_type) |
||
| 2116 | { |
||
| 2117 | $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
||
| 2118 | $all_aircraft = array('737-300' => 'B733', |
||
| 2119 | '777-200' => 'B772', |
||
| 2120 | '777-200ER' => 'B772', |
||
| 2121 | '777-300ER' => 'B77W', |
||
| 2122 | 'c172p' => 'C172', |
||
| 2123 | 'aerostar' => 'AEST', |
||
| 2124 | 'A320-211' => 'A320', |
||
| 2125 | '747-8i' => 'B748', |
||
| 2126 | 'A380' => 'A388'); |
||
| 2127 | if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
||
| 2128 | |||
| 2129 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
||
| 2130 | $aircraft_type = strtoupper($aircraft_type); |
||
| 2131 | $sth = $this->db->prepare($query); |
||
| 2132 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
||
| 2133 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2134 | if (isset($result[0]['icao'])) return $result[0]['icao']; |
||
| 2135 | else return ''; |
||
| 2136 | } |
||
| 2137 | |||
| 2138 | /** |
||
| 2139 | * Gets the aircraft info based on the aircraft ident |
||
| 2140 | * |
||
| 2141 | * @param String $aircraft_modes the aircraft ident (hex) |
||
| 2142 | * @return String aircraft type |
||
| 2143 | * |
||
| 2144 | */ |
||
| 2145 | public function getAllAircraftType($aircraft_modes) |
||
| 2146 | { |
||
| 2147 | $aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
||
| 2148 | |||
| 2149 | $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1"; |
||
| 2150 | |||
| 2151 | $sth = $this->db->prepare($query); |
||
| 2152 | $sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
||
| 2153 | |||
| 2154 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2155 | $sth->closeCursor(); |
||
| 2156 | if (isset($row['icaotypecode'])) { |
||
| 2157 | return $row['icaotypecode']; |
||
| 2158 | } else return ''; |
||
| 2159 | } |
||
| 2160 | |||
| 2161 | /** |
||
| 2162 | * Gets correct aircraft operator corde |
||
| 2163 | * |
||
| 2164 | * @param String $operator the aircraft operator code (callsign) |
||
| 2165 | * @return String aircraft operator code |
||
| 2166 | * |
||
| 2167 | */ |
||
| 2168 | public function getOperator($operator) |
||
| 2169 | { |
||
| 2170 | $operator = filter_var($operator,FILTER_SANITIZE_STRING); |
||
| 2171 | $query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; |
||
| 2172 | |||
| 2173 | $sth = $this->db->prepare($query); |
||
| 2174 | $sth->execute(array(':operator' => $operator)); |
||
| 2175 | |||
| 2176 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2177 | $sth->closeCursor(); |
||
| 2178 | if (isset($row['operator_correct'])) { |
||
| 2179 | return $row['operator_correct']; |
||
| 2180 | } else return $operator; |
||
| 2181 | } |
||
| 2182 | |||
| 2183 | /** |
||
| 2184 | * Gets the aircraft route based on the aircraft callsign |
||
| 2185 | * |
||
| 2186 | * @param String $callsign the aircraft callsign |
||
| 2187 | * @return Array aircraft type |
||
| 2188 | * |
||
| 2189 | */ |
||
| 2190 | public function getRouteInfo($callsign) |
||
| 2191 | { |
||
| 2192 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
||
| 2193 | if ($callsign == '') return array(); |
||
| 2194 | $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"; |
||
| 2195 | |||
| 2196 | $sth = $this->db->prepare($query); |
||
| 2197 | $sth->execute(array(':callsign' => $callsign)); |
||
| 2198 | |||
| 2199 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2200 | $sth->closeCursor(); |
||
| 2201 | if (count($row) > 0) { |
||
| 2202 | return $row; |
||
| 2203 | } else return array(); |
||
| 2204 | } |
||
| 2205 | |||
| 2206 | /** |
||
| 2207 | * Gets the aircraft info based on the aircraft registration |
||
| 2208 | * |
||
| 2209 | * @param String $registration the aircraft registration |
||
| 2210 | * @return Array aircraft information |
||
| 2211 | * |
||
| 2212 | */ |
||
| 2213 | public function getAircraftInfoByRegistration($registration) |
||
| 2214 | { |
||
| 2215 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2216 | |||
| 2217 | $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"; |
||
| 2218 | |||
| 2219 | $sth = $this->db->prepare($query); |
||
| 2220 | $sth->execute(array(':registration' => $registration)); |
||
| 2221 | |||
| 2222 | $aircraft_array = array(); |
||
| 2223 | $temp_array = array(); |
||
| 2224 | |||
| 2225 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2226 | { |
||
| 2227 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 2228 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 2229 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2230 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2231 | |||
| 2232 | $aircraft_array[] = $temp_array; |
||
| 2233 | } |
||
| 2234 | |||
| 2235 | return $aircraft_array; |
||
| 2236 | } |
||
| 2237 | |||
| 2238 | /** |
||
| 2239 | * Gets the aircraft owner & base based on the aircraft registration |
||
| 2240 | * |
||
| 2241 | * @param String $registration the aircraft registration |
||
| 2242 | * @return Array aircraft information |
||
| 2243 | * |
||
| 2244 | */ |
||
| 2245 | public function getAircraftOwnerByRegistration($registration) |
||
| 2246 | { |
||
| 2247 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 2248 | $Connection = new Connection($this->db); |
||
| 2249 | if ($Connection->tableExists('aircraft_owner')) { |
||
| 2250 | $query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1"; |
||
| 2251 | $sth = $this->db->prepare($query); |
||
| 2252 | $sth->execute(array(':registration' => $registration)); |
||
| 2253 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
||
| 2254 | $sth->closeCursor(); |
||
| 2255 | return $result; |
||
| 2256 | } else return array(); |
||
| 2257 | } |
||
| 2258 | |||
| 2259 | |||
| 2260 | /** |
||
| 2261 | * Gets all flights (but with only little info) |
||
| 2262 | * |
||
| 2263 | * @return Array basic flight information |
||
| 2264 | * |
||
| 2265 | */ |
||
| 2266 | public function getAllFlightsforSitemap() |
||
| 2267 | { |
||
| 2268 | //$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 "; |
||
| 2269 | $query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; |
||
| 2270 | |||
| 2271 | $sth = $this->db->prepare($query); |
||
| 2272 | $sth->execute(); |
||
| 2273 | /* |
||
| 2274 | $flight_array = array(); |
||
| 2275 | $temp_array = array(); |
||
| 2276 | |||
| 2277 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2278 | { |
||
| 2279 | $temp_array['spotter_id'] = $row['spotter_id']; |
||
| 2280 | // $temp_array['ident'] = $row['ident']; |
||
| 2281 | // $temp_array['airline_name'] = $row['airline_name']; |
||
| 2282 | // $temp_array['aircraft_type'] = $row['aircraft_icao']; |
||
| 2283 | // $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2284 | //$temp_array['image'] = $row['image']; |
||
| 2285 | |||
| 2286 | $flight_array[] = $temp_array; |
||
| 2287 | } |
||
| 2288 | |||
| 2289 | return $flight_array; |
||
| 2290 | */ |
||
| 2291 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2292 | } |
||
| 2293 | |||
| 2294 | /** |
||
| 2295 | * Gets a list of all aircraft manufacturers |
||
| 2296 | * |
||
| 2297 | * @return Array list of aircraft types |
||
| 2298 | * |
||
| 2299 | */ |
||
| 2300 | public function getAllManufacturers() |
||
| 2301 | { |
||
| 2302 | /* |
||
| 2303 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer AS aircraft_manufacturer |
||
| 2304 | FROM spotter_output |
||
| 2305 | WHERE spotter_output.aircraft_manufacturer <> '' |
||
| 2306 | ORDER BY spotter_output.aircraft_manufacturer ASC"; |
||
| 2307 | */ |
||
| 2308 | |||
| 2309 | $query = "SELECT DISTINCT manufacturer AS aircraft_manufacturer FROM aircraft WHERE manufacturer <> '' ORDER BY manufacturer ASC"; |
||
| 2310 | $sth = $this->db->prepare($query); |
||
| 2311 | $sth->execute(); |
||
| 2312 | |||
| 2313 | $manufacturer_array = array(); |
||
| 2314 | $temp_array = array(); |
||
| 2315 | |||
| 2316 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2317 | { |
||
| 2318 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2319 | |||
| 2320 | $manufacturer_array[] = $temp_array; |
||
| 2321 | } |
||
| 2322 | |||
| 2323 | return $manufacturer_array; |
||
| 2324 | } |
||
| 2325 | |||
| 2326 | |||
| 2327 | /** |
||
| 2328 | * Gets a list of all aircraft types |
||
| 2329 | * |
||
| 2330 | * @return Array list of aircraft types |
||
| 2331 | * |
||
| 2332 | */ |
||
| 2333 | public function getAllAircraftTypes() |
||
| 2334 | { |
||
| 2335 | /* |
||
| 2336 | $query = "SELECT DISTINCT spotter_output.aircraft_icao AS aircraft_icao, spotter_output.aircraft_name AS aircraft_name |
||
| 2337 | FROM spotter_output |
||
| 2338 | WHERE spotter_output.aircraft_icao <> '' |
||
| 2339 | ORDER BY spotter_output.aircraft_name ASC"; |
||
| 2340 | |||
| 2341 | */ |
||
| 2342 | $query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft WHERE icao <> '' ORDER BY aircraft_manufacturer ASC"; |
||
| 2343 | |||
| 2344 | $sth = $this->db->prepare($query); |
||
| 2345 | $sth->execute(); |
||
| 2346 | |||
| 2347 | $aircraft_array = array(); |
||
| 2348 | $temp_array = array(); |
||
| 2349 | |||
| 2350 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2351 | { |
||
| 2352 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 2353 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 2354 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 2355 | |||
| 2356 | $aircraft_array[] = $temp_array; |
||
| 2357 | } |
||
| 2358 | |||
| 2359 | return $aircraft_array; |
||
| 2360 | } |
||
| 2361 | |||
| 2362 | |||
| 2363 | /** |
||
| 2364 | * Gets a list of all aircraft registrations |
||
| 2365 | * |
||
| 2366 | * @return Array list of aircraft registrations |
||
| 2367 | * |
||
| 2368 | */ |
||
| 2369 | public function getAllAircraftRegistrations() |
||
| 2370 | { |
||
| 2371 | $query = "SELECT DISTINCT spotter_output.registration |
||
| 2372 | FROM spotter_output |
||
| 2373 | WHERE spotter_output.registration <> '' |
||
| 2374 | ORDER BY spotter_output.registration ASC"; |
||
| 2375 | |||
| 2376 | $sth = $this->db->prepare($query); |
||
| 2377 | $sth->execute(); |
||
| 2378 | |||
| 2379 | $aircraft_array = array(); |
||
| 2380 | $temp_array = array(); |
||
| 2381 | |||
| 2382 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2383 | { |
||
| 2384 | $temp_array['registration'] = $row['registration']; |
||
| 2385 | |||
| 2386 | $aircraft_array[] = $temp_array; |
||
| 2387 | } |
||
| 2388 | |||
| 2389 | return $aircraft_array; |
||
| 2390 | } |
||
| 2391 | |||
| 2392 | /** |
||
| 2393 | * Gets all source name |
||
| 2394 | * |
||
| 2395 | * @param String type format of source |
||
| 2396 | * @return Array list of source name |
||
| 2397 | * |
||
| 2398 | */ |
||
| 2399 | public function getAllSourceName($type = '') |
||
| 2400 | { |
||
| 2401 | $query_values = array(); |
||
| 2402 | $query = "SELECT DISTINCT spotter_output.source_name |
||
| 2403 | FROM spotter_output |
||
| 2404 | WHERE spotter_output.source_name <> ''"; |
||
| 2405 | if ($type != '') { |
||
| 2406 | $query_values = array(':type' => $type); |
||
| 2407 | $query .= " AND format_source = :type"; |
||
| 2408 | } |
||
| 2409 | $query .= " ORDER BY spotter_output.source_name ASC"; |
||
| 2410 | |||
| 2411 | $sth = $this->db->prepare($query); |
||
| 2412 | if (!empty($query_values)) $sth->execute($query_values); |
||
| 2413 | else $sth->execute(); |
||
| 2414 | |||
| 2415 | $source_array = array(); |
||
| 2416 | $temp_array = array(); |
||
| 2417 | |||
| 2418 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2419 | { |
||
| 2420 | $temp_array['source_name'] = $row['source_name']; |
||
| 2421 | $source_array[] = $temp_array; |
||
| 2422 | } |
||
| 2423 | return $source_array; |
||
| 2424 | } |
||
| 2425 | |||
| 2426 | |||
| 2427 | |||
| 2428 | /** |
||
| 2429 | * Gets a list of all airline names |
||
| 2430 | * |
||
| 2431 | * @return Array list of airline names |
||
| 2432 | * |
||
| 2433 | */ |
||
| 2434 | public function getAllAirlineNames($airline_type = '',$forsource = NULL) |
||
| 2435 | { |
||
| 2436 | global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
||
| 2437 | $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
||
| 2438 | if ($airline_type == '' || $airline_type == 'all') { |
||
| 2439 | /* |
||
| 2440 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
||
| 2441 | FROM spotter_output |
||
| 2442 | WHERE spotter_output.airline_icao <> '' |
||
| 2443 | ORDER BY spotter_output.airline_name ASC"; |
||
| 2444 | */ |
||
| 2445 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
||
| 2446 | elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
||
| 2447 | elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
||
| 2448 | if ($forsource === NULL) { |
||
| 2449 | $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"; |
||
| 2450 | $query_data = array(); |
||
| 2451 | } else { |
||
| 2452 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource = :forsource ORDER BY name ASC"; |
||
| 2453 | $query_data = array(':forsource' => $forsource); |
||
| 2454 | } |
||
| 2455 | } else { |
||
| 2456 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
||
| 2457 | FROM spotter_output |
||
| 2458 | WHERE spotter_output.airline_icao <> '' |
||
| 2459 | AND spotter_output.airline_type = :airline_type |
||
| 2460 | ORDER BY spotter_output.airline_icao ASC"; |
||
| 2461 | $query_data = array(':airline_type' => $airline_type); |
||
| 2462 | } |
||
| 2463 | |||
| 2464 | $sth = $this->db->prepare($query); |
||
| 2465 | $sth->execute($query_data); |
||
| 2466 | |||
| 2467 | $airline_array = array(); |
||
| 2468 | $temp_array = array(); |
||
| 2469 | |||
| 2470 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2471 | { |
||
| 2472 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 2473 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 2474 | $temp_array['airline_type'] = $row['airline_type']; |
||
| 2475 | |||
| 2476 | $airline_array[] = $temp_array; |
||
| 2477 | } |
||
| 2478 | return $airline_array; |
||
| 2479 | } |
||
| 2480 | |||
| 2481 | |||
| 2482 | /** |
||
| 2483 | * Gets a list of all airline countries |
||
| 2484 | * |
||
| 2485 | * @return Array list of airline countries |
||
| 2486 | * |
||
| 2487 | */ |
||
| 2488 | public function getAllAirlineCountries() |
||
| 2489 | { |
||
| 2490 | |||
| 2491 | $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
||
| 2492 | FROM spotter_output |
||
| 2493 | WHERE spotter_output.airline_country <> '' |
||
| 2494 | ORDER BY spotter_output.airline_country ASC"; |
||
| 2495 | |||
| 2496 | //$query = "SELECT DISTINCT country AS airline_country FROM airlines WHERE country <> '' AND active = 'Y' ORDER BY country ASC"; |
||
| 2497 | $sth = $this->db->prepare($query); |
||
| 2498 | $sth->execute(); |
||
| 2499 | |||
| 2500 | $airline_array = array(); |
||
| 2501 | $temp_array = array(); |
||
| 2502 | |||
| 2503 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2504 | { |
||
| 2505 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 2506 | |||
| 2507 | $airline_array[] = $temp_array; |
||
| 2508 | } |
||
| 2509 | |||
| 2510 | return $airline_array; |
||
| 2511 | } |
||
| 2512 | |||
| 2513 | |||
| 2514 | |||
| 2515 | /** |
||
| 2516 | * Gets a list of all departure & arrival names |
||
| 2517 | * |
||
| 2518 | * @return Array list of airport names |
||
| 2519 | * |
||
| 2520 | */ |
||
| 2521 | public function getAllAirportNames() |
||
| 2522 | { |
||
| 2523 | $airport_array = array(); |
||
| 2524 | |||
| 2525 | $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 |
||
| 2526 | FROM spotter_output |
||
| 2527 | WHERE spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' |
||
| 2528 | ORDER BY spotter_output.departure_airport_city ASC"; |
||
| 2529 | |||
| 2530 | //$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"; |
||
| 2531 | $sth = $this->db->prepare($query); |
||
| 2532 | $sth->execute(); |
||
| 2533 | |||
| 2534 | $temp_array = array(); |
||
| 2535 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2536 | { |
||
| 2537 | $temp_array['airport_icao'] = $row['airport_icao']; |
||
| 2538 | $temp_array['airport_name'] = $row['airport_name']; |
||
| 2539 | $temp_array['airport_city'] = $row['airport_city']; |
||
| 2540 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2541 | |||
| 2542 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
||
| 2543 | } |
||
| 2544 | |||
| 2545 | $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 |
||
| 2546 | FROM spotter_output |
||
| 2547 | WHERE spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' |
||
| 2548 | ORDER BY spotter_output.arrival_airport_city ASC"; |
||
| 2549 | |||
| 2550 | $sth = $this->db->prepare($query); |
||
| 2551 | $sth->execute(); |
||
| 2552 | |||
| 2553 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2554 | { |
||
| 2555 | // if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao']) |
||
| 2556 | // { |
||
| 2557 | $temp_array['airport_icao'] = $row['airport_icao']; |
||
| 2558 | $temp_array['airport_name'] = $row['airport_name']; |
||
| 2559 | $temp_array['airport_city'] = $row['airport_city']; |
||
| 2560 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2561 | |||
| 2562 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
||
| 2563 | // } |
||
| 2564 | } |
||
| 2565 | |||
| 2566 | return $airport_array; |
||
| 2567 | } |
||
| 2568 | |||
| 2569 | |||
| 2570 | /** |
||
| 2571 | * Gets a list of all departure & arrival airport countries |
||
| 2572 | * |
||
| 2573 | * @return Array list of airport countries |
||
| 2574 | * |
||
| 2575 | */ |
||
| 2576 | public function getAllAirportCountries() |
||
| 2577 | { |
||
| 2578 | $airport_array = array(); |
||
| 2579 | |||
| 2580 | /* |
||
| 2581 | $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
||
| 2582 | FROM spotter_output |
||
| 2583 | WHERE spotter_output.departure_airport_country <> '' |
||
| 2584 | ORDER BY spotter_output.departure_airport_country ASC"; |
||
| 2585 | */ |
||
| 2586 | $query = "SELECT DISTINCT country AS airport_country FROM airport ORDER BY country ASC"; |
||
| 2587 | |||
| 2588 | $sth = $this->db->prepare($query); |
||
| 2589 | $sth->execute(); |
||
| 2590 | |||
| 2591 | $temp_array = array(); |
||
| 2592 | |||
| 2593 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2594 | { |
||
| 2595 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2596 | |||
| 2597 | $airport_array[$row['airport_country']] = $temp_array; |
||
| 2598 | } |
||
| 2599 | |||
| 2600 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
||
| 2601 | FROM spotter_output |
||
| 2602 | WHERE spotter_output.arrival_airport_country <> '' |
||
| 2603 | ORDER BY spotter_output.arrival_airport_country ASC"; |
||
| 2604 | |||
| 2605 | $sth = $this->db->prepare($query); |
||
| 2606 | $sth->execute(); |
||
| 2607 | |||
| 2608 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2609 | { |
||
| 2610 | if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country']) |
||
| 2611 | { |
||
| 2612 | $temp_array['airport_country'] = $row['airport_country']; |
||
| 2613 | $airport_array[$row['airport_country']] = $temp_array; |
||
| 2614 | } |
||
| 2615 | } |
||
| 2616 | |||
| 2617 | return $airport_array; |
||
| 2618 | } |
||
| 2619 | |||
| 2620 | |||
| 2621 | |||
| 2622 | |||
| 2623 | /** |
||
| 2624 | * Gets a list of all countries (airline, departure airport & arrival airport) |
||
| 2625 | * |
||
| 2626 | * @return Array list of countries |
||
| 2627 | * |
||
| 2628 | */ |
||
| 2629 | public function getAllCountries() |
||
| 2630 | { |
||
| 2631 | $Connection= new Connection($this->db); |
||
| 2632 | if ($Connection->tableExists('countries')) { |
||
| 2633 | $query = "SELECT countries.name AS airport_country |
||
| 2634 | FROM countries |
||
| 2635 | ORDER BY countries.name ASC"; |
||
| 2636 | $sth = $this->db->prepare($query); |
||
| 2637 | $sth->execute(); |
||
| 2638 | |||
| 2639 | $temp_array = array(); |
||
| 2640 | $country_array = array(); |
||
| 2641 | |||
| 2642 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2643 | { |
||
| 2644 | $temp_array['country'] = $row['airport_country']; |
||
| 2645 | $country_array[$row['airport_country']] = $temp_array; |
||
| 2646 | } |
||
| 2647 | } else { |
||
| 2648 | $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
||
| 2649 | FROM spotter_output |
||
| 2650 | WHERE spotter_output.departure_airport_country <> '' |
||
| 2651 | ORDER BY spotter_output.departure_airport_country ASC"; |
||
| 2652 | |||
| 2653 | $sth = $this->db->prepare($query); |
||
| 2654 | $sth->execute(); |
||
| 2655 | |||
| 2656 | $temp_array = array(); |
||
| 2657 | $country_array = array(); |
||
| 2658 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2659 | { |
||
| 2660 | $temp_array['country'] = $row['airport_country']; |
||
| 2661 | $country_array[$row['airport_country']] = $temp_array; |
||
| 2662 | } |
||
| 2663 | |||
| 2664 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
||
| 2665 | FROM spotter_output |
||
| 2666 | WHERE spotter_output.arrival_airport_country <> '' |
||
| 2667 | ORDER BY spotter_output.arrival_airport_country ASC"; |
||
| 2668 | |||
| 2669 | $sth = $this->db->prepare($query); |
||
| 2670 | $sth->execute(); |
||
| 2671 | |||
| 2672 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2673 | { |
||
| 2674 | if ($country_array[$row['airport_country']]['country'] != $row['airport_country']) |
||
| 2675 | { |
||
| 2676 | $temp_array['country'] = $row['airport_country']; |
||
| 2677 | |||
| 2678 | $country_array[$row['country']] = $temp_array; |
||
| 2679 | } |
||
| 2680 | } |
||
| 2681 | |||
| 2682 | $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
||
| 2683 | FROM spotter_output |
||
| 2684 | WHERE spotter_output.airline_country <> '' |
||
| 2685 | ORDER BY spotter_output.airline_country ASC"; |
||
| 2686 | |||
| 2687 | $sth = $this->db->prepare($query); |
||
| 2688 | $sth->execute(); |
||
| 2689 | |||
| 2690 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2691 | { |
||
| 2692 | if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country']) |
||
| 2693 | { |
||
| 2694 | $temp_array['country'] = $row['airline_country']; |
||
| 2695 | |||
| 2696 | $country_array[$row['country']] = $temp_array; |
||
| 2697 | } |
||
| 2698 | } |
||
| 2699 | } |
||
| 2700 | return $country_array; |
||
| 2701 | } |
||
| 2702 | |||
| 2703 | |||
| 2704 | |||
| 2705 | |||
| 2706 | /** |
||
| 2707 | * Gets a list of all idents/callsigns |
||
| 2708 | * |
||
| 2709 | * @return Array list of ident/callsign names |
||
| 2710 | * |
||
| 2711 | */ |
||
| 2712 | public function getAllIdents() |
||
| 2713 | { |
||
| 2714 | $query = "SELECT DISTINCT spotter_output.ident |
||
| 2715 | FROM spotter_output |
||
| 2716 | WHERE spotter_output.ident <> '' |
||
| 2717 | ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0"; |
||
| 2718 | |||
| 2719 | $sth = $this->db->prepare($query); |
||
| 2720 | $sth->execute(); |
||
| 2721 | |||
| 2722 | $ident_array = array(); |
||
| 2723 | $temp_array = array(); |
||
| 2724 | |||
| 2725 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 2726 | { |
||
| 2727 | $temp_array['ident'] = $row['ident']; |
||
| 2728 | $ident_array[] = $temp_array; |
||
| 2729 | } |
||
| 2730 | |||
| 2731 | return $ident_array; |
||
| 2732 | } |
||
| 2733 | |||
| 2734 | /** |
||
| 2735 | * Get a list of flights from airport since 7 days |
||
| 2736 | * @return Array number, icao, name and city of airports |
||
| 2737 | */ |
||
| 2738 | |||
| 2739 | public function getLast7DaysAirportsDeparture($airport_icao = '') { |
||
| 2740 | global $globalTimezone, $globalDBdriver; |
||
| 2741 | if ($globalTimezone != '') { |
||
| 2742 | date_default_timezone_set($globalTimezone); |
||
| 2743 | $datetime = new DateTime(); |
||
| 2744 | $offset = $datetime->format('P'); |
||
| 2745 | } else $offset = '+00:00'; |
||
| 2746 | if ($airport_icao == '') { |
||
| 2747 | if ($globalDBdriver == 'mysql') { |
||
| 2748 | $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` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2749 | } else { |
||
| 2750 | $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 WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2751 | } |
||
| 2752 | $sth = $this->db->prepare($query); |
||
| 2753 | $sth->execute(array(':offset' => $offset)); |
||
| 2754 | } else { |
||
| 2755 | if ($globalDBdriver == 'mysql') { |
||
| 2756 | $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` WHERE 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"; |
||
| 2757 | } else { |
||
| 2758 | $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 WHERE 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"; |
||
| 2759 | } |
||
| 2760 | $sth = $this->db->prepare($query); |
||
| 2761 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2762 | } |
||
| 2763 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2764 | } |
||
| 2765 | |||
| 2766 | /** |
||
| 2767 | * Get a list of flights from airport since 7 days |
||
| 2768 | * @return Array number, icao, name and city of airports |
||
| 2769 | */ |
||
| 2770 | |||
| 2771 | public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') { |
||
| 2772 | global $globalTimezone, $globalDBdriver; |
||
| 2773 | if ($globalTimezone != '') { |
||
| 2774 | date_default_timezone_set($globalTimezone); |
||
| 2775 | $datetime = new DateTime(); |
||
| 2776 | $offset = $datetime->format('P'); |
||
| 2777 | } else $offset = '+00:00'; |
||
| 2778 | if ($airport_icao == '') { |
||
| 2779 | if ($globalDBdriver == 'mysql') { |
||
| 2780 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2781 | } else { |
||
| 2782 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
||
| 2783 | } |
||
| 2784 | $sth = $this->db->prepare($query); |
||
| 2785 | $sth->execute(array(':offset' => $offset)); |
||
| 2786 | } else { |
||
| 2787 | if ($globalDBdriver == 'mysql') { |
||
| 2788 | $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"; |
||
| 2789 | } else { |
||
| 2790 | $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"; |
||
| 2791 | } |
||
| 2792 | $sth = $this->db->prepare($query); |
||
| 2793 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2794 | } |
||
| 2795 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2796 | } |
||
| 2797 | |||
| 2798 | /** |
||
| 2799 | * Get a list of flights from detected airport since 7 days |
||
| 2800 | * @return Array number, icao, name and city of airports |
||
| 2801 | */ |
||
| 2802 | |||
| 2803 | public function getLast7DaysDetectedAirportsDeparture($airport_icao = '') { |
||
| 2804 | global $globalTimezone, $globalDBdriver; |
||
| 2805 | if ($globalTimezone != '') { |
||
| 2806 | date_default_timezone_set($globalTimezone); |
||
| 2807 | $datetime = new DateTime(); |
||
| 2808 | $offset = $datetime->format('P'); |
||
| 2809 | } else $offset = '+00:00'; |
||
| 2810 | if ($airport_icao == '') { |
||
| 2811 | if ($globalDBdriver == 'mysql') { |
||
| 2812 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
||
| 2813 | FROM `spotter_output`, airport |
||
| 2814 | WHERE 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' |
||
| 2815 | 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"; |
||
| 2816 | } else { |
||
| 2817 | $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 |
||
| 2818 | FROM spotter_output, airport |
||
| 2819 | WHERE 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' |
||
| 2820 | 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"; |
||
| 2821 | } |
||
| 2822 | $sth = $this->db->prepare($query); |
||
| 2823 | $sth->execute(array(':offset' => $offset)); |
||
| 2824 | } else { |
||
| 2825 | if ($globalDBdriver == 'mysql') { |
||
| 2826 | $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 |
||
| 2827 | FROM `spotter_output`, airport |
||
| 2828 | WHERE 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 |
||
| 2829 | 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"; |
||
| 2830 | } else { |
||
| 2831 | $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 |
||
| 2832 | FROM spotter_output, airport |
||
| 2833 | WHERE 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"; |
||
| 2834 | } |
||
| 2835 | $sth = $this->db->prepare($query); |
||
| 2836 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2837 | } |
||
| 2838 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2839 | } |
||
| 2840 | |||
| 2841 | /** |
||
| 2842 | * Get a list of flights from detected airport since 7 days |
||
| 2843 | * @return Array number, icao, name and city of airports |
||
| 2844 | */ |
||
| 2845 | |||
| 2846 | public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') { |
||
| 2847 | global $globalTimezone, $globalDBdriver; |
||
| 2848 | if ($globalTimezone != '') { |
||
| 2849 | date_default_timezone_set($globalTimezone); |
||
| 2850 | $datetime = new DateTime(); |
||
| 2851 | $offset = $datetime->format('P'); |
||
| 2852 | } else $offset = '+00:00'; |
||
| 2853 | if ($airport_icao == '') { |
||
| 2854 | if ($globalDBdriver == 'mysql') { |
||
| 2855 | $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 |
||
| 2856 | FROM `spotter_output`, airport |
||
| 2857 | 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' |
||
| 2858 | 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"; |
||
| 2859 | } else { |
||
| 2860 | $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 |
||
| 2861 | FROM spotter_output, airport |
||
| 2862 | 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' |
||
| 2863 | 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"; |
||
| 2864 | } |
||
| 2865 | $sth = $this->db->prepare($query); |
||
| 2866 | $sth->execute(array(':offset' => $offset)); |
||
| 2867 | } else { |
||
| 2868 | if ($globalDBdriver == 'mysql') { |
||
| 2869 | $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 |
||
| 2870 | FROM `spotter_output`, airport |
||
| 2871 | 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 |
||
| 2872 | 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"; |
||
| 2873 | } else { |
||
| 2874 | $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 |
||
| 2875 | FROM spotter_output, airport |
||
| 2876 | 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"; |
||
| 2877 | } |
||
| 2878 | $sth = $this->db->prepare($query); |
||
| 2879 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2880 | } |
||
| 2881 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2882 | } |
||
| 2883 | |||
| 2884 | |||
| 2885 | /** |
||
| 2886 | * Get a list of flights to airport since 7 days |
||
| 2887 | * @return Array number, icao, name and city of airports |
||
| 2888 | */ |
||
| 2889 | |||
| 2890 | public function getLast7DaysAirportsArrival($airport_icao = '') { |
||
| 2891 | global $globalTimezone, $globalDBdriver; |
||
| 2892 | if ($globalTimezone != '') { |
||
| 2893 | date_default_timezone_set($globalTimezone); |
||
| 2894 | $datetime = new DateTime(); |
||
| 2895 | $offset = $datetime->format('P'); |
||
| 2896 | } else $offset = '+00:00'; |
||
| 2897 | if ($airport_icao == '') { |
||
| 2898 | if ($globalDBdriver == 'mysql') { |
||
| 2899 | $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` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2900 | } else { |
||
| 2901 | $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 WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2902 | } |
||
| 2903 | $sth = $this->db->prepare($query); |
||
| 2904 | $sth->execute(array(':offset' => $offset)); |
||
| 2905 | } else { |
||
| 2906 | if ($globalDBdriver == 'mysql') { |
||
| 2907 | $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` WHERE 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"; |
||
| 2908 | } else { |
||
| 2909 | $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 WHERE 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"; |
||
| 2910 | } |
||
| 2911 | $sth = $this->db->prepare($query); |
||
| 2912 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2913 | } |
||
| 2914 | |||
| 2915 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2916 | } |
||
| 2917 | |||
| 2918 | |||
| 2919 | /** |
||
| 2920 | * Get a list of flights detected to airport since 7 days |
||
| 2921 | * @return Array number, icao, name and city of airports |
||
| 2922 | */ |
||
| 2923 | |||
| 2924 | public function getLast7DaysDetectedAirportsArrival($airport_icao = '') { |
||
| 2925 | global $globalTimezone, $globalDBdriver; |
||
| 2926 | if ($globalTimezone != '') { |
||
| 2927 | date_default_timezone_set($globalTimezone); |
||
| 2928 | $datetime = new DateTime(); |
||
| 2929 | $offset = $datetime->format('P'); |
||
| 2930 | } else $offset = '+00:00'; |
||
| 2931 | if ($airport_icao == '') { |
||
| 2932 | if ($globalDBdriver == 'mysql') { |
||
| 2933 | $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 |
||
| 2934 | FROM `spotter_output`, airport |
||
| 2935 | WHERE airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' |
||
| 2936 | 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"; |
||
| 2937 | } else { |
||
| 2938 | $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 |
||
| 2939 | FROM spotter_output, airport |
||
| 2940 | WHERE 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' |
||
| 2941 | 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"; |
||
| 2942 | } |
||
| 2943 | $sth = $this->db->prepare($query); |
||
| 2944 | $sth->execute(array(':offset' => $offset)); |
||
| 2945 | } else { |
||
| 2946 | if ($globalDBdriver == 'mysql') { |
||
| 2947 | $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 |
||
| 2948 | FROM `spotter_output`, airport |
||
| 2949 | WHERE 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 |
||
| 2950 | 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"; |
||
| 2951 | } else { |
||
| 2952 | $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 |
||
| 2953 | FROM spotter_output, airport |
||
| 2954 | WHERE 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 |
||
| 2955 | 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"; |
||
| 2956 | } |
||
| 2957 | $sth = $this->db->prepare($query); |
||
| 2958 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2959 | } |
||
| 2960 | |||
| 2961 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2962 | } |
||
| 2963 | |||
| 2964 | |||
| 2965 | /** |
||
| 2966 | * Get a list of flights to airport since 7 days |
||
| 2967 | * @return Array number, icao, name and city of airports |
||
| 2968 | */ |
||
| 2969 | |||
| 2970 | public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') { |
||
| 2971 | global $globalTimezone, $globalDBdriver; |
||
| 2972 | if ($globalTimezone != '') { |
||
| 2973 | date_default_timezone_set($globalTimezone); |
||
| 2974 | $datetime = new DateTime(); |
||
| 2975 | $offset = $datetime->format('P'); |
||
| 2976 | } else $offset = '+00:00'; |
||
| 2977 | if ($airport_icao == '') { |
||
| 2978 | if ($globalDBdriver == 'mysql') { |
||
| 2979 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2980 | } else { |
||
| 2981 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
||
| 2982 | } |
||
| 2983 | $sth = $this->db->prepare($query); |
||
| 2984 | $sth->execute(array(':offset' => $offset)); |
||
| 2985 | } else { |
||
| 2986 | if ($globalDBdriver == 'mysql') { |
||
| 2987 | $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"; |
||
| 2988 | } else { |
||
| 2989 | $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"; |
||
| 2990 | } |
||
| 2991 | $sth = $this->db->prepare($query); |
||
| 2992 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 2993 | } |
||
| 2994 | |||
| 2995 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 2996 | } |
||
| 2997 | |||
| 2998 | |||
| 2999 | /** |
||
| 3000 | * Get a list of flights detected to airport since 7 days |
||
| 3001 | * @return Array number, icao, name and city of airports |
||
| 3002 | */ |
||
| 3003 | |||
| 3004 | public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') { |
||
| 3005 | global $globalTimezone, $globalDBdriver; |
||
| 3006 | if ($globalTimezone != '') { |
||
| 3007 | date_default_timezone_set($globalTimezone); |
||
| 3008 | $datetime = new DateTime(); |
||
| 3009 | $offset = $datetime->format('P'); |
||
| 3010 | } else $offset = '+00:00'; |
||
| 3011 | if ($airport_icao == '') { |
||
| 3012 | if ($globalDBdriver == 'mysql') { |
||
| 3013 | $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 |
||
| 3014 | FROM `spotter_output`, airport |
||
| 3015 | 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' |
||
| 3016 | 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"; |
||
| 3017 | } else { |
||
| 3018 | $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 |
||
| 3019 | FROM spotter_output, airport |
||
| 3020 | 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' |
||
| 3021 | 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"; |
||
| 3022 | } |
||
| 3023 | $sth = $this->db->prepare($query); |
||
| 3024 | $sth->execute(array(':offset' => $offset)); |
||
| 3025 | } else { |
||
| 3026 | if ($globalDBdriver == 'mysql') { |
||
| 3027 | $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 |
||
| 3028 | FROM `spotter_output`, airport |
||
| 3029 | 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 |
||
| 3030 | 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"; |
||
| 3031 | } else { |
||
| 3032 | $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 |
||
| 3033 | FROM spotter_output, airport |
||
| 3034 | 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 |
||
| 3035 | 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"; |
||
| 3036 | } |
||
| 3037 | $sth = $this->db->prepare($query); |
||
| 3038 | $sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); |
||
| 3039 | } |
||
| 3040 | |||
| 3041 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
||
| 3042 | } |
||
| 3043 | |||
| 3044 | |||
| 3045 | /** |
||
| 3046 | * Gets a list of all dates |
||
| 3047 | * |
||
| 3048 | * @return Array list of date names |
||
| 3049 | * |
||
| 3050 | */ |
||
| 3051 | public function getAllDates() |
||
| 3052 | { |
||
| 3053 | global $globalTimezone, $globalDBdriver; |
||
| 3054 | if ($globalTimezone != '') { |
||
| 3055 | date_default_timezone_set($globalTimezone); |
||
| 3056 | $datetime = new DateTime(); |
||
| 3057 | $offset = $datetime->format('P'); |
||
| 3058 | } else $offset = '+00:00'; |
||
| 3059 | |||
| 3060 | if ($globalDBdriver == 'mysql') { |
||
| 3061 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
||
| 3062 | FROM spotter_output |
||
| 3063 | WHERE spotter_output.date <> '' |
||
| 3064 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
||
| 3065 | } else { |
||
| 3066 | $query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
||
| 3067 | FROM spotter_output |
||
| 3068 | WHERE spotter_output.date <> '' |
||
| 3069 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
||
| 3070 | } |
||
| 3071 | |||
| 3072 | $sth = $this->db->prepare($query); |
||
| 3073 | $sth->execute(array(':offset' => $offset)); |
||
| 3074 | |||
| 3075 | $date_array = array(); |
||
| 3076 | $temp_array = array(); |
||
| 3077 | |||
| 3078 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3079 | { |
||
| 3080 | $temp_array['date'] = $row['date']; |
||
| 3081 | |||
| 3082 | $date_array[] = $temp_array; |
||
| 3083 | } |
||
| 3084 | |||
| 3085 | return $date_array; |
||
| 3086 | } |
||
| 3087 | |||
| 3088 | |||
| 3089 | |||
| 3090 | /** |
||
| 3091 | * Gets all route combinations |
||
| 3092 | * |
||
| 3093 | * @return Array the route list |
||
| 3094 | * |
||
| 3095 | */ |
||
| 3096 | public function getAllRoutes() |
||
| 3097 | { |
||
| 3098 | $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 |
||
| 3099 | FROM spotter_output |
||
| 3100 | WHERE spotter_output.ident <> '' |
||
| 3101 | GROUP BY route |
||
| 3102 | ORDER BY route ASC"; |
||
| 3103 | |||
| 3104 | $sth = $this->db->prepare($query); |
||
| 3105 | $sth->execute(); |
||
| 3106 | |||
| 3107 | $routes_array = array(); |
||
| 3108 | $temp_array = array(); |
||
| 3109 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3110 | { |
||
| 3111 | $temp_array['route'] = $row['route']; |
||
| 3112 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 3113 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
||
| 3114 | |||
| 3115 | $routes_array[] = $temp_array; |
||
| 3116 | } |
||
| 3117 | return $routes_array; |
||
| 3118 | } |
||
| 3119 | |||
| 3120 | /** |
||
| 3121 | * Update ident spotter data |
||
| 3122 | * |
||
| 3123 | * @param String $flightaware_id the ID from flightaware |
||
| 3124 | * @param String $ident the flight ident |
||
| 3125 | * @return String success or false |
||
| 3126 | * |
||
| 3127 | */ |
||
| 3128 | public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL) |
||
| 3129 | { |
||
| 3130 | if (!is_numeric(substr($ident, 0, 3))) |
||
| 3131 | { |
||
| 3132 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
| 3133 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
||
| 3134 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
| 3135 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
||
| 3136 | } else { |
||
| 3137 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3138 | } |
||
| 3139 | if (count($airline_array) == 0) { |
||
| 3140 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3141 | } |
||
| 3142 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
||
| 3143 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3144 | } |
||
| 3145 | } else { |
||
| 3146 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3147 | } |
||
| 3148 | $airline_name = $airline_array[0]['name']; |
||
| 3149 | $airline_icao = $airline_array[0]['icao']; |
||
| 3150 | $airline_country = $airline_array[0]['country']; |
||
| 3151 | $airline_type = $airline_array[0]['type']; |
||
| 3152 | |||
| 3153 | |||
| 3154 | $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'; |
||
| 3155 | $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); |
||
| 3156 | |||
| 3157 | try { |
||
| 3158 | $sth = $this->db->prepare($query); |
||
| 3159 | $sth->execute($query_values); |
||
| 3160 | } catch (PDOException $e) { |
||
| 3161 | return "error : ".$e->getMessage(); |
||
| 3162 | } |
||
| 3163 | |||
| 3164 | return "success"; |
||
| 3165 | |||
| 3166 | } |
||
| 3167 | /** |
||
| 3168 | * Update latest spotter data |
||
| 3169 | * |
||
| 3170 | * @param String $flightaware_id the ID from flightaware |
||
| 3171 | * @param String $ident the flight ident |
||
| 3172 | * @param String $arrival_airport_icao the arrival airport |
||
| 3173 | * @return String success or false |
||
| 3174 | * |
||
| 3175 | */ |
||
| 3176 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
||
| 3177 | { |
||
| 3178 | if ($groundspeed == '') $groundspeed = NULL; |
||
| 3179 | $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'; |
||
| 3180 | $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); |
||
| 3181 | |||
| 3182 | try { |
||
| 3183 | $sth = $this->db->prepare($query); |
||
| 3184 | $sth->execute($query_values); |
||
| 3185 | } catch (PDOException $e) { |
||
| 3186 | return "error : ".$e->getMessage(); |
||
| 3187 | } |
||
| 3188 | |||
| 3189 | return "success"; |
||
| 3190 | |||
| 3191 | } |
||
| 3192 | |||
| 3193 | /** |
||
| 3194 | * Adds a new spotter data |
||
| 3195 | * |
||
| 3196 | * @param String $flightaware_id the ID from flightaware |
||
| 3197 | * @param String $ident the flight ident |
||
| 3198 | * @param String $aircraft_icao the aircraft type |
||
| 3199 | * @param String $departure_airport_icao the departure airport |
||
| 3200 | * @param String $arrival_airport_icao the arrival airport |
||
| 3201 | * @param String $latitude latitude of flight |
||
| 3202 | * @param String $longitude latitude of flight |
||
| 3203 | * @param String $waypoints waypoints of flight |
||
| 3204 | * @param String $altitude altitude of flight |
||
| 3205 | * @param String $heading heading of flight |
||
| 3206 | * @param String $groundspeed speed of flight |
||
| 3207 | * @param String $date date of flight |
||
| 3208 | * @param String $departure_airport_time departure time of flight |
||
| 3209 | * @param String $arrival_airport_time arrival time of flight |
||
| 3210 | * @param String $squawk squawk code of flight |
||
| 3211 | * @param String $route_stop route stop of flight |
||
| 3212 | * @param String $highlight highlight or not |
||
| 3213 | * @param String $ModeS ModesS code of flight |
||
| 3214 | * @param String $registration registration code of flight |
||
| 3215 | * @param String $pilot_id pilot id of flight (for virtual airlines) |
||
| 3216 | * @param String $pilot_name pilot name of flight (for virtual airlines) |
||
| 3217 | * @param String $verticalrate vertival rate of flight |
||
| 3218 | * @return String success or false |
||
| 3219 | */ |
||
| 3220 | public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '') |
||
| 3221 | { |
||
| 3222 | global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM; |
||
| 3223 | |||
| 3224 | //if (isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
||
| 3225 | $Image = new Image($this->db); |
||
| 3226 | $Common = new Common(); |
||
| 3227 | |||
| 3228 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
||
| 3229 | if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
||
| 3230 | if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
||
| 3231 | if (!isset($globalVAM)) $globalVAM = FALSE; |
||
| 3232 | date_default_timezone_set('UTC'); |
||
| 3233 | |||
| 3234 | //getting the registration |
||
| 3235 | if ($flightaware_id != "" && $registration == '') |
||
| 3236 | { |
||
| 3237 | if (!is_string($flightaware_id)) |
||
| 3238 | { |
||
| 3239 | return false; |
||
| 3240 | } else { |
||
| 3241 | if ($ModeS != '') { |
||
| 3242 | $timeelapsed = microtime(true); |
||
| 3243 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
||
| 3244 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3245 | } else { |
||
| 3246 | $myhex = explode('-',$flightaware_id); |
||
| 3247 | if (count($myhex) > 0) { |
||
| 3248 | $timeelapsed = microtime(true); |
||
| 3249 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
||
| 3250 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3251 | } |
||
| 3252 | } |
||
| 3253 | } |
||
| 3254 | } |
||
| 3255 | $fromsource = NULL; |
||
| 3256 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
||
| 3257 | elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
||
| 3258 | elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
||
| 3259 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
||
| 3260 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
||
| 3261 | //getting the airline information |
||
| 3262 | if ($ident != "") |
||
| 3263 | { |
||
| 3264 | if (!is_string($ident)) |
||
| 3265 | { |
||
| 3266 | return false; |
||
| 3267 | } else { |
||
| 3268 | if (!is_numeric(substr($ident, 0, 3))) |
||
| 3269 | { |
||
| 3270 | $timeelapsed = microtime(true); |
||
| 3271 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
| 3272 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
||
| 3273 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
| 3274 | $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
||
| 3275 | } else { |
||
| 3276 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3277 | } |
||
| 3278 | if (count($airline_array) == 0) { |
||
| 3279 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3280 | } |
||
| 3281 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
||
| 3282 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3283 | } |
||
| 3284 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3285 | |||
| 3286 | } else { |
||
| 3287 | $timeelapsed = microtime(true); |
||
| 3288 | $airline_array = $this->getAllAirlineInfo("NA"); |
||
| 3289 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3290 | } |
||
| 3291 | } |
||
| 3292 | } else $airline_array = array(); |
||
| 3293 | |||
| 3294 | //getting the aircraft information |
||
| 3295 | $aircraft_array = array(); |
||
| 3296 | if ($aircraft_icao != "") |
||
| 3297 | { |
||
| 3298 | if (!is_string($aircraft_icao)) |
||
| 3299 | { |
||
| 3300 | return false; |
||
| 3301 | } else { |
||
| 3302 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
||
| 3303 | { |
||
| 3304 | $timeelapsed = microtime(true); |
||
| 3305 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
||
| 3306 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3307 | } else { |
||
| 3308 | $timeelapsed = microtime(true); |
||
| 3309 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
||
| 3310 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3311 | } |
||
| 3312 | } |
||
| 3313 | } else { |
||
| 3314 | if ($ModeS != '') { |
||
| 3315 | $timeelapsed = microtime(true); |
||
| 3316 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
||
| 3317 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3318 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
||
| 3319 | { |
||
| 3320 | $timeelapsed = microtime(true); |
||
| 3321 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
||
| 3322 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3323 | } else { |
||
| 3324 | $timeelapsed = microtime(true); |
||
| 3325 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
||
| 3326 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3327 | } |
||
| 3328 | } |
||
| 3329 | } |
||
| 3330 | |||
| 3331 | //getting the departure airport information |
||
| 3332 | $departure_airport_array = array(); |
||
| 3333 | if ($departure_airport_icao != "") |
||
| 3334 | { |
||
| 3335 | if (!is_string($departure_airport_icao)) |
||
| 3336 | { |
||
| 3337 | return false; |
||
| 3338 | } else { |
||
| 3339 | $timeelapsed = microtime(true); |
||
| 3340 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
||
| 3341 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3342 | } |
||
| 3343 | } |
||
| 3344 | |||
| 3345 | //getting the arrival airport information |
||
| 3346 | $arrival_airport_array = array(); |
||
| 3347 | if ($arrival_airport_icao != "") |
||
| 3348 | { |
||
| 3349 | if (!is_string($arrival_airport_icao)) |
||
| 3350 | { |
||
| 3351 | return false; |
||
| 3352 | } else { |
||
| 3353 | $timeelapsed = microtime(true); |
||
| 3354 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
||
| 3355 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3356 | } |
||
| 3357 | } |
||
| 3358 | |||
| 3359 | |||
| 3360 | if ($latitude != "") |
||
| 3361 | { |
||
| 3362 | if (!is_numeric($latitude)) |
||
| 3363 | { |
||
| 3364 | return false; |
||
| 3365 | } |
||
| 3366 | } |
||
| 3367 | |||
| 3368 | if ($longitude != "") |
||
| 3369 | { |
||
| 3370 | if (!is_numeric($longitude)) |
||
| 3371 | { |
||
| 3372 | return false; |
||
| 3373 | } |
||
| 3374 | } |
||
| 3375 | |||
| 3376 | if ($waypoints != "") |
||
| 3377 | { |
||
| 3378 | if (!is_string($waypoints)) |
||
| 3379 | { |
||
| 3380 | return false; |
||
| 3381 | } |
||
| 3382 | } |
||
| 3383 | |||
| 3384 | if ($altitude != "") |
||
| 3385 | { |
||
| 3386 | if (!is_numeric($altitude)) |
||
| 3387 | { |
||
| 3388 | return false; |
||
| 3389 | } |
||
| 3390 | } else $altitude = 0; |
||
| 3391 | |||
| 3392 | if ($heading != "") |
||
| 3393 | { |
||
| 3394 | if (!is_numeric($heading)) |
||
| 3395 | { |
||
| 3396 | return false; |
||
| 3397 | } |
||
| 3398 | } |
||
| 3399 | |||
| 3400 | if ($groundspeed != "") |
||
| 3401 | { |
||
| 3402 | if (!is_numeric($groundspeed)) |
||
| 3403 | { |
||
| 3404 | return false; |
||
| 3405 | } |
||
| 3406 | } |
||
| 3407 | |||
| 3408 | |||
| 3409 | if ($date == "") |
||
| 3410 | { |
||
| 3411 | $date = date("Y-m-d H:i:s", time()); |
||
| 3412 | } |
||
| 3413 | |||
| 3414 | //getting the aircraft image |
||
| 3415 | if (($registration != "" || $registration != 'NA') && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM) |
||
| 3416 | { |
||
| 3417 | $timeelapsed = microtime(true); |
||
| 3418 | $image_array = $Image->getSpotterImage($registration); |
||
| 3419 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3420 | if (!isset($image_array[0]['registration'])) |
||
| 3421 | { |
||
| 3422 | //echo "Add image !!!! \n"; |
||
| 3423 | $Image->addSpotterImage($registration); |
||
| 3424 | } |
||
| 3425 | $timeelapsed = microtime(true); |
||
| 3426 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
||
| 3427 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3428 | if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
||
| 3429 | } |
||
| 3430 | |||
| 3431 | if ($globalIVAO && $aircraft_icao != '') |
||
| 3432 | { |
||
| 3433 | if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
||
| 3434 | else $airline_icao = ''; |
||
| 3435 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
||
| 3436 | if (!isset($image_array[0]['registration'])) |
||
| 3437 | { |
||
| 3438 | //echo "Add image !!!! \n"; |
||
| 3439 | $Image->addSpotterImage('',$aircraft_icao,$airline_icao); |
||
| 3440 | } |
||
| 3441 | } |
||
| 3442 | |||
| 3443 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
||
| 3444 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 3445 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
||
| 3446 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3447 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 3448 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 3449 | $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3450 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3451 | $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
||
| 3452 | $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3453 | $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
||
| 3454 | $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
||
| 3455 | $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
||
| 3456 | $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
||
| 3457 | $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
||
| 3458 | $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
||
| 3459 | $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
||
| 3460 | $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
||
| 3461 | $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
||
| 3462 | |||
| 3463 | if (count($airline_array) == 0) |
||
| 3464 | { |
||
| 3465 | $airline_array = $this->getAllAirlineInfo('NA'); |
||
| 3466 | } |
||
| 3467 | if (count($aircraft_array) == 0) |
||
| 3468 | { |
||
| 3469 | $aircraft_array = $this->getAllAircraftInfo('NA'); |
||
| 3470 | } |
||
| 3471 | if (count($departure_airport_array) == 0) |
||
| 3472 | { |
||
| 3473 | $departure_airport_array = $this->getAllAirportInfo('NA'); |
||
| 3474 | } |
||
| 3475 | if (count($arrival_airport_array) == 0) |
||
| 3476 | { |
||
| 3477 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
||
| 3478 | } |
||
| 3479 | if ($registration == '') $registration = 'NA'; |
||
| 3480 | if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
||
| 3481 | if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
||
| 3482 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
||
| 3483 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
||
| 3484 | if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
||
| 3485 | $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) |
||
| 3486 | 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)"; |
||
| 3487 | |||
| 3488 | $airline_name = $airline_array[0]['name']; |
||
| 3489 | $airline_icao = $airline_array[0]['icao']; |
||
| 3490 | $airline_country = $airline_array[0]['country']; |
||
| 3491 | $airline_type = $airline_array[0]['type']; |
||
| 3492 | if ($airline_type == '') { |
||
| 3493 | $timeelapsed = microtime(true); |
||
| 3494 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
||
| 3495 | if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
||
| 3496 | } |
||
| 3497 | if ($airline_type == null) $airline_type = ''; |
||
| 3498 | $aircraft_type = $aircraft_array[0]['type']; |
||
| 3499 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
||
| 3500 | $departure_airport_name = $departure_airport_array[0]['name']; |
||
| 3501 | $departure_airport_city = $departure_airport_array[0]['city']; |
||
| 3502 | $departure_airport_country = $departure_airport_array[0]['country']; |
||
| 3503 | $arrival_airport_name = $arrival_airport_array[0]['name']; |
||
| 3504 | $arrival_airport_city = $arrival_airport_array[0]['city']; |
||
| 3505 | $arrival_airport_country = $arrival_airport_array[0]['country']; |
||
| 3506 | $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); |
||
| 3507 | |||
| 3508 | try { |
||
| 3509 | |||
| 3510 | $sth = $this->db->prepare($query); |
||
| 3511 | $sth->execute($query_values); |
||
| 3512 | $this->db = null; |
||
| 3513 | } catch (PDOException $e) { |
||
| 3514 | return "error : ".$e->getMessage(); |
||
| 3515 | } |
||
| 3516 | |||
| 3517 | return "success"; |
||
| 3518 | |||
| 3519 | } |
||
| 3520 | |||
| 3521 | |||
| 3522 | /** |
||
| 3523 | * Gets the aircraft ident within the last hour |
||
| 3524 | * |
||
| 3525 | * @return String the ident |
||
| 3526 | * |
||
| 3527 | */ |
||
| 3528 | public function getIdentFromLastHour($ident) |
||
| 3529 | { |
||
| 3530 | global $globalDBdriver, $globalTimezone; |
||
| 3531 | if ($globalDBdriver == 'mysql') { |
||
| 3532 | $query = "SELECT spotter_output.ident FROM spotter_output |
||
| 3533 | WHERE spotter_output.ident = :ident |
||
| 3534 | AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
||
| 3535 | AND spotter_output.date < UTC_TIMESTAMP()"; |
||
| 3536 | $query_data = array(':ident' => $ident); |
||
| 3537 | } else { |
||
| 3538 | $query = "SELECT spotter_output.ident FROM spotter_output |
||
| 3539 | WHERE spotter_output.ident = :ident |
||
| 3540 | AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
||
| 3541 | AND spotter_output.date < now() AT TIME ZONE 'UTC'"; |
||
| 3542 | $query_data = array(':ident' => $ident); |
||
| 3543 | } |
||
| 3544 | |||
| 3545 | $sth = $this->db->prepare($query); |
||
| 3546 | $sth->execute($query_data); |
||
| 3547 | $ident_result=''; |
||
| 3548 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3549 | { |
||
| 3550 | $ident_result = $row['ident']; |
||
| 3551 | } |
||
| 3552 | |||
| 3553 | return $ident_result; |
||
| 3554 | } |
||
| 3555 | |||
| 3556 | |||
| 3557 | /** |
||
| 3558 | * Gets the aircraft data from the last 20 seconds |
||
| 3559 | * |
||
| 3560 | * @return Array the spotter data |
||
| 3561 | * |
||
| 3562 | */ |
||
| 3563 | public function getRealTimeData($q = '') |
||
| 3564 | { |
||
| 3565 | global $globalDBdriver; |
||
| 3566 | $additional_query = ''; |
||
| 3567 | if ($q != "") |
||
| 3568 | { |
||
| 3569 | if (!is_string($q)) |
||
| 3570 | { |
||
| 3571 | return false; |
||
| 3572 | } else { |
||
| 3573 | $q_array = explode(" ", $q); |
||
| 3574 | foreach ($q_array as $q_item){ |
||
| 3575 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
||
| 3576 | $additional_query .= " AND ("; |
||
| 3577 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
||
| 3578 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
||
| 3579 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
||
| 3580 | $additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; |
||
| 3581 | $additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; |
||
| 3582 | $additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; |
||
| 3583 | $additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; |
||
| 3584 | $additional_query .= "(spotter_output.ident like '%".$q_item."%')"; |
||
| 3585 | $additional_query .= ")"; |
||
| 3586 | } |
||
| 3587 | } |
||
| 3588 | } |
||
| 3589 | if ($globalDBdriver == 'mysql') { |
||
| 3590 | $query = "SELECT spotter_output.* FROM spotter_output |
||
| 3591 | WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
||
| 3592 | AND spotter_output.date < UTC_TIMESTAMP()"; |
||
| 3593 | } else { |
||
| 3594 | $query = "SELECT spotter_output.* FROM spotter_output |
||
| 3595 | WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
||
| 3596 | AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
||
| 3597 | } |
||
| 3598 | $spotter_array = $this->getDataFromDB($query, array()); |
||
| 3599 | |||
| 3600 | return $spotter_array; |
||
| 3601 | } |
||
| 3602 | |||
| 3603 | |||
| 3604 | |||
| 3605 | /** |
||
| 3606 | * Gets all airlines that have flown over |
||
| 3607 | * |
||
| 3608 | * @return Array the airline list |
||
| 3609 | * |
||
| 3610 | */ |
||
| 3611 | public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3612 | { |
||
| 3613 | global $globalDBdriver; |
||
| 3614 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3615 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3616 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' "; |
||
| 3617 | if ($olderthanmonths > 0) { |
||
| 3618 | if ($globalDBdriver == 'mysql') { |
||
| 3619 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3620 | } else { |
||
| 3621 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3622 | } |
||
| 3623 | } |
||
| 3624 | if ($sincedate != '') { |
||
| 3625 | if ($globalDBdriver == 'mysql') { |
||
| 3626 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3627 | } else { |
||
| 3628 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3629 | } |
||
| 3630 | } |
||
| 3631 | $query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
||
| 3632 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3633 | |||
| 3634 | $sth = $this->db->prepare($query); |
||
| 3635 | $sth->execute(); |
||
| 3636 | |||
| 3637 | $airline_array = array(); |
||
| 3638 | $temp_array = array(); |
||
| 3639 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3640 | { |
||
| 3641 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3642 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3643 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3644 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3645 | $airline_array[] = $temp_array; |
||
| 3646 | } |
||
| 3647 | return $airline_array; |
||
| 3648 | } |
||
| 3649 | |||
| 3650 | /** |
||
| 3651 | * Gets all pilots that have flown over |
||
| 3652 | * |
||
| 3653 | * @return Array the pilots list |
||
| 3654 | * |
||
| 3655 | */ |
||
| 3656 | public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3657 | { |
||
| 3658 | global $globalDBdriver; |
||
| 3659 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3660 | $query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count |
||
| 3661 | FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' "; |
||
| 3662 | if ($olderthanmonths > 0) { |
||
| 3663 | if ($globalDBdriver == 'mysql') { |
||
| 3664 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3665 | } else { |
||
| 3666 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3667 | } |
||
| 3668 | } |
||
| 3669 | if ($sincedate != '') { |
||
| 3670 | if ($globalDBdriver == 'mysql') { |
||
| 3671 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3672 | } else { |
||
| 3673 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3674 | } |
||
| 3675 | } |
||
| 3676 | $query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
||
| 3677 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3678 | |||
| 3679 | |||
| 3680 | $sth = $this->db->prepare($query); |
||
| 3681 | $sth->execute(); |
||
| 3682 | |||
| 3683 | $airline_array = array(); |
||
| 3684 | $temp_array = array(); |
||
| 3685 | |||
| 3686 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3687 | { |
||
| 3688 | $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 3689 | $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 3690 | $temp_array['pilot_count'] = $row['pilot_count']; |
||
| 3691 | $airline_array[] = $temp_array; |
||
| 3692 | } |
||
| 3693 | return $airline_array; |
||
| 3694 | } |
||
| 3695 | |||
| 3696 | /** |
||
| 3697 | * Gets all pilots that have flown over |
||
| 3698 | * |
||
| 3699 | * @return Array the pilots list |
||
| 3700 | * |
||
| 3701 | */ |
||
| 3702 | public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
||
| 3703 | { |
||
| 3704 | global $globalDBdriver; |
||
| 3705 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count |
||
| 3706 | FROM spotter_output WHERE spotter_output.pilot_id <> '' "; |
||
| 3707 | if ($olderthanmonths > 0) { |
||
| 3708 | if ($globalDBdriver == 'mysql') { |
||
| 3709 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3710 | } else { |
||
| 3711 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3712 | } |
||
| 3713 | } |
||
| 3714 | if ($sincedate != '') { |
||
| 3715 | if ($globalDBdriver == 'mysql') { |
||
| 3716 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3717 | } else { |
||
| 3718 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3719 | } |
||
| 3720 | } |
||
| 3721 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC"; |
||
| 3722 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3723 | |||
| 3724 | |||
| 3725 | $sth = $this->db->prepare($query); |
||
| 3726 | $sth->execute(); |
||
| 3727 | |||
| 3728 | $airline_array = array(); |
||
| 3729 | $temp_array = array(); |
||
| 3730 | |||
| 3731 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3732 | { |
||
| 3733 | $temp_array['pilot_name'] = $row['pilot_name']; |
||
| 3734 | $temp_array['pilot_id'] = $row['pilot_id']; |
||
| 3735 | $temp_array['pilot_count'] = $row['pilot_count']; |
||
| 3736 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3737 | $airline_array[] = $temp_array; |
||
| 3738 | } |
||
| 3739 | return $airline_array; |
||
| 3740 | } |
||
| 3741 | |||
| 3742 | /** |
||
| 3743 | * Gets all owner that have flown over |
||
| 3744 | * |
||
| 3745 | * @return Array the pilots list |
||
| 3746 | * |
||
| 3747 | */ |
||
| 3748 | public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3749 | { |
||
| 3750 | global $globalDBdriver; |
||
| 3751 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3752 | $query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
||
| 3753 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
||
| 3754 | if ($olderthanmonths > 0) { |
||
| 3755 | if ($globalDBdriver == 'mysql') { |
||
| 3756 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3757 | } else { |
||
| 3758 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3759 | } |
||
| 3760 | } |
||
| 3761 | if ($sincedate != '') { |
||
| 3762 | if ($globalDBdriver == 'mysql') { |
||
| 3763 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3764 | } else { |
||
| 3765 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3766 | } |
||
| 3767 | } |
||
| 3768 | $query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
||
| 3769 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3770 | |||
| 3771 | |||
| 3772 | $sth = $this->db->prepare($query); |
||
| 3773 | $sth->execute(); |
||
| 3774 | |||
| 3775 | $airline_array = array(); |
||
| 3776 | $temp_array = array(); |
||
| 3777 | |||
| 3778 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3779 | { |
||
| 3780 | $temp_array['owner_name'] = $row['owner_name']; |
||
| 3781 | $temp_array['owner_count'] = $row['owner_count']; |
||
| 3782 | $airline_array[] = $temp_array; |
||
| 3783 | } |
||
| 3784 | return $airline_array; |
||
| 3785 | } |
||
| 3786 | |||
| 3787 | /** |
||
| 3788 | * Gets all owner that have flown over |
||
| 3789 | * |
||
| 3790 | * @return Array the pilots list |
||
| 3791 | * |
||
| 3792 | */ |
||
| 3793 | public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 3794 | { |
||
| 3795 | global $globalDBdriver; |
||
| 3796 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3797 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
||
| 3798 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
||
| 3799 | if ($olderthanmonths > 0) { |
||
| 3800 | if ($globalDBdriver == 'mysql') { |
||
| 3801 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 3802 | } else { |
||
| 3803 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 3804 | } |
||
| 3805 | } |
||
| 3806 | if ($sincedate != '') { |
||
| 3807 | if ($globalDBdriver == 'mysql') { |
||
| 3808 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 3809 | } else { |
||
| 3810 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 3811 | } |
||
| 3812 | } |
||
| 3813 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
||
| 3814 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 3815 | |||
| 3816 | |||
| 3817 | $sth = $this->db->prepare($query); |
||
| 3818 | $sth->execute(); |
||
| 3819 | |||
| 3820 | $airline_array = array(); |
||
| 3821 | $temp_array = array(); |
||
| 3822 | |||
| 3823 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3824 | { |
||
| 3825 | $temp_array['owner_name'] = $row['owner_name']; |
||
| 3826 | $temp_array['owner_count'] = $row['owner_count']; |
||
| 3827 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3828 | $airline_array[] = $temp_array; |
||
| 3829 | } |
||
| 3830 | return $airline_array; |
||
| 3831 | } |
||
| 3832 | |||
| 3833 | /** |
||
| 3834 | * Gets all airlines that have flown over by aircraft |
||
| 3835 | * |
||
| 3836 | * @return Array the airline list |
||
| 3837 | * |
||
| 3838 | */ |
||
| 3839 | public function countAllAirlinesByAircraft($aircraft_icao,$filters = array()) |
||
| 3840 | { |
||
| 3841 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3842 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3843 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3844 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 3845 | GROUP BY spotter_output.airline_name |
||
| 3846 | ORDER BY airline_count DESC"; |
||
| 3847 | |||
| 3848 | |||
| 3849 | $sth = $this->db->prepare($query); |
||
| 3850 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 3851 | |||
| 3852 | $airline_array = array(); |
||
| 3853 | $temp_array = array(); |
||
| 3854 | |||
| 3855 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3856 | { |
||
| 3857 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3858 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3859 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3860 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3861 | |||
| 3862 | $airline_array[] = $temp_array; |
||
| 3863 | } |
||
| 3864 | |||
| 3865 | return $airline_array; |
||
| 3866 | } |
||
| 3867 | |||
| 3868 | |||
| 3869 | /** |
||
| 3870 | * Gets all airline countries that have flown over by aircraft |
||
| 3871 | * |
||
| 3872 | * @return Array the airline country list |
||
| 3873 | * |
||
| 3874 | */ |
||
| 3875 | public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 3876 | { |
||
| 3877 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 3878 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3879 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 3880 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 3881 | GROUP BY spotter_output.airline_country |
||
| 3882 | ORDER BY airline_country_count DESC |
||
| 3883 | LIMIT 10 OFFSET 0"; |
||
| 3884 | |||
| 3885 | |||
| 3886 | $sth = $this->db->prepare($query); |
||
| 3887 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 3888 | |||
| 3889 | $airline_country_array = array(); |
||
| 3890 | $temp_array = array(); |
||
| 3891 | |||
| 3892 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3893 | { |
||
| 3894 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 3895 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3896 | |||
| 3897 | $airline_country_array[] = $temp_array; |
||
| 3898 | } |
||
| 3899 | return $airline_country_array; |
||
| 3900 | } |
||
| 3901 | |||
| 3902 | |||
| 3903 | |||
| 3904 | |||
| 3905 | /** |
||
| 3906 | * Gets all airlines that have flown over by airport |
||
| 3907 | * |
||
| 3908 | * @return Array the airline list |
||
| 3909 | * |
||
| 3910 | */ |
||
| 3911 | public function countAllAirlinesByAirport($airport_icao,$filters = array()) |
||
| 3912 | { |
||
| 3913 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 3914 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3915 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3916 | 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 ) |
||
| 3917 | GROUP BY spotter_output.airline_name |
||
| 3918 | ORDER BY airline_count DESC"; |
||
| 3919 | |||
| 3920 | |||
| 3921 | $sth = $this->db->prepare($query); |
||
| 3922 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 3923 | |||
| 3924 | $airline_array = array(); |
||
| 3925 | $temp_array = array(); |
||
| 3926 | |||
| 3927 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3928 | { |
||
| 3929 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3930 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3931 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 3932 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3933 | |||
| 3934 | $airline_array[] = $temp_array; |
||
| 3935 | } |
||
| 3936 | return $airline_array; |
||
| 3937 | } |
||
| 3938 | |||
| 3939 | |||
| 3940 | /** |
||
| 3941 | * Gets all airline countries that have flown over by airport icao |
||
| 3942 | * |
||
| 3943 | * @return Array the airline country list |
||
| 3944 | * |
||
| 3945 | */ |
||
| 3946 | public function countAllAirlineCountriesByAirport($airport_icao,$filters = array()) |
||
| 3947 | { |
||
| 3948 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 3949 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3950 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 3951 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
||
| 3952 | GROUP BY spotter_output.airline_country |
||
| 3953 | ORDER BY airline_country_count DESC |
||
| 3954 | LIMIT 10 OFFSET 0"; |
||
| 3955 | |||
| 3956 | |||
| 3957 | $sth = $this->db->prepare($query); |
||
| 3958 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 3959 | |||
| 3960 | $airline_country_array = array(); |
||
| 3961 | $temp_array = array(); |
||
| 3962 | |||
| 3963 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3964 | { |
||
| 3965 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 3966 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 3967 | |||
| 3968 | $airline_country_array[] = $temp_array; |
||
| 3969 | } |
||
| 3970 | return $airline_country_array; |
||
| 3971 | } |
||
| 3972 | |||
| 3973 | |||
| 3974 | /** |
||
| 3975 | * Gets all airlines that have flown over by aircraft manufacturer |
||
| 3976 | * |
||
| 3977 | * @return Array the airline list |
||
| 3978 | * |
||
| 3979 | */ |
||
| 3980 | public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 3981 | { |
||
| 3982 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 3983 | $filter_query = $this->getFilter($filters,true,true); |
||
| 3984 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 3985 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 3986 | GROUP BY spotter_output.airline_name |
||
| 3987 | ORDER BY airline_count DESC"; |
||
| 3988 | |||
| 3989 | $sth = $this->db->prepare($query); |
||
| 3990 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 3991 | |||
| 3992 | $airline_array = array(); |
||
| 3993 | $temp_array = array(); |
||
| 3994 | |||
| 3995 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 3996 | { |
||
| 3997 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 3998 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 3999 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4000 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4001 | |||
| 4002 | $airline_array[] = $temp_array; |
||
| 4003 | } |
||
| 4004 | return $airline_array; |
||
| 4005 | } |
||
| 4006 | |||
| 4007 | |||
| 4008 | |||
| 4009 | /** |
||
| 4010 | * Gets all airline countries that have flown over by aircraft manufacturer |
||
| 4011 | * |
||
| 4012 | * @return Array the airline country list |
||
| 4013 | * |
||
| 4014 | */ |
||
| 4015 | public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 4016 | { |
||
| 4017 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 4018 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4019 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4020 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 4021 | GROUP BY spotter_output.airline_country |
||
| 4022 | ORDER BY airline_country_count DESC |
||
| 4023 | LIMIT 10 OFFSET 0"; |
||
| 4024 | |||
| 4025 | |||
| 4026 | $sth = $this->db->prepare($query); |
||
| 4027 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 4028 | |||
| 4029 | $airline_country_array = array(); |
||
| 4030 | $temp_array = array(); |
||
| 4031 | |||
| 4032 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4033 | { |
||
| 4034 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4035 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4036 | $airline_country_array[] = $temp_array; |
||
| 4037 | } |
||
| 4038 | return $airline_country_array; |
||
| 4039 | } |
||
| 4040 | |||
| 4041 | |||
| 4042 | /** |
||
| 4043 | * Gets all airlines that have flown over by date |
||
| 4044 | * |
||
| 4045 | * @return Array the airline list |
||
| 4046 | * |
||
| 4047 | */ |
||
| 4048 | public function countAllAirlinesByDate($date,$filters = array()) |
||
| 4049 | { |
||
| 4050 | global $globalTimezone, $globalDBdriver; |
||
| 4051 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4052 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4053 | if ($globalTimezone != '') { |
||
| 4054 | date_default_timezone_set($globalTimezone); |
||
| 4055 | $datetime = new DateTime($date); |
||
| 4056 | $offset = $datetime->format('P'); |
||
| 4057 | } else $offset = '+00:00'; |
||
| 4058 | |||
| 4059 | if ($globalDBdriver == 'mysql') { |
||
| 4060 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4061 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4062 | GROUP BY spotter_output.airline_name |
||
| 4063 | ORDER BY airline_count DESC"; |
||
| 4064 | } else { |
||
| 4065 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4066 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4067 | GROUP BY spotter_output.airline_name |
||
| 4068 | ORDER BY airline_count DESC"; |
||
| 4069 | } |
||
| 4070 | |||
| 4071 | $sth = $this->db->prepare($query); |
||
| 4072 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4073 | |||
| 4074 | $airline_array = array(); |
||
| 4075 | $temp_array = array(); |
||
| 4076 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4077 | { |
||
| 4078 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4079 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4080 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4081 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4082 | |||
| 4083 | $airline_array[] = $temp_array; |
||
| 4084 | } |
||
| 4085 | |||
| 4086 | return $airline_array; |
||
| 4087 | } |
||
| 4088 | |||
| 4089 | |||
| 4090 | /** |
||
| 4091 | * Gets all airline countries that have flown over by date |
||
| 4092 | * |
||
| 4093 | * @return Array the airline country list |
||
| 4094 | * |
||
| 4095 | */ |
||
| 4096 | public function countAllAirlineCountriesByDate($date,$filters = array()) |
||
| 4097 | { |
||
| 4098 | global $globalTimezone, $globalDBdriver; |
||
| 4099 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4100 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4101 | if ($globalTimezone != '') { |
||
| 4102 | date_default_timezone_set($globalTimezone); |
||
| 4103 | $datetime = new DateTime($date); |
||
| 4104 | $offset = $datetime->format('P'); |
||
| 4105 | } else $offset = '+00:00'; |
||
| 4106 | |||
| 4107 | if ($globalDBdriver == 'mysql') { |
||
| 4108 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4109 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4110 | GROUP BY spotter_output.airline_country |
||
| 4111 | ORDER BY airline_country_count DESC |
||
| 4112 | LIMIT 10 OFFSET 0"; |
||
| 4113 | } else { |
||
| 4114 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4115 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4116 | GROUP BY spotter_output.airline_country |
||
| 4117 | ORDER BY airline_country_count DESC |
||
| 4118 | LIMIT 10 OFFSET 0"; |
||
| 4119 | } |
||
| 4120 | |||
| 4121 | $sth = $this->db->prepare($query); |
||
| 4122 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4123 | |||
| 4124 | $airline_country_array = array(); |
||
| 4125 | $temp_array = array(); |
||
| 4126 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4127 | { |
||
| 4128 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4129 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4130 | |||
| 4131 | $airline_country_array[] = $temp_array; |
||
| 4132 | } |
||
| 4133 | return $airline_country_array; |
||
| 4134 | } |
||
| 4135 | |||
| 4136 | |||
| 4137 | /** |
||
| 4138 | * Gets all airlines that have flown over by ident/callsign |
||
| 4139 | * |
||
| 4140 | * @return Array the airline list |
||
| 4141 | * |
||
| 4142 | */ |
||
| 4143 | public function countAllAirlinesByIdent($ident,$filters = array()) |
||
| 4144 | { |
||
| 4145 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 4146 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4147 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4148 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
||
| 4149 | GROUP BY spotter_output.airline_name |
||
| 4150 | ORDER BY airline_count DESC"; |
||
| 4151 | |||
| 4152 | |||
| 4153 | $sth = $this->db->prepare($query); |
||
| 4154 | $sth->execute(array(':ident' => $ident)); |
||
| 4155 | |||
| 4156 | $airline_array = array(); |
||
| 4157 | $temp_array = array(); |
||
| 4158 | |||
| 4159 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4160 | { |
||
| 4161 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4162 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4163 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4164 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4165 | |||
| 4166 | $airline_array[] = $temp_array; |
||
| 4167 | } |
||
| 4168 | return $airline_array; |
||
| 4169 | } |
||
| 4170 | |||
| 4171 | /** |
||
| 4172 | * Gets all airlines that have flown over by route |
||
| 4173 | * |
||
| 4174 | * @return Array the airline list |
||
| 4175 | * |
||
| 4176 | */ |
||
| 4177 | public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 4178 | { |
||
| 4179 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4180 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4181 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4182 | |||
| 4183 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4184 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 4185 | GROUP BY spotter_output.airline_name |
||
| 4186 | ORDER BY airline_count DESC"; |
||
| 4187 | |||
| 4188 | |||
| 4189 | $sth = $this->db->prepare($query); |
||
| 4190 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 4191 | |||
| 4192 | $airline_array = array(); |
||
| 4193 | $temp_array = array(); |
||
| 4194 | |||
| 4195 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4196 | { |
||
| 4197 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4198 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4199 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4200 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4201 | |||
| 4202 | $airline_array[] = $temp_array; |
||
| 4203 | } |
||
| 4204 | return $airline_array; |
||
| 4205 | } |
||
| 4206 | |||
| 4207 | /** |
||
| 4208 | * Gets all airline countries that have flown over by route |
||
| 4209 | * |
||
| 4210 | * @return Array the airline country list |
||
| 4211 | * |
||
| 4212 | */ |
||
| 4213 | public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array()) |
||
| 4214 | { |
||
| 4215 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4216 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4217 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 4218 | |||
| 4219 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4220 | 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) |
||
| 4221 | GROUP BY spotter_output.airline_country |
||
| 4222 | ORDER BY airline_country_count DESC |
||
| 4223 | LIMIT 10 OFFSET 0"; |
||
| 4224 | |||
| 4225 | |||
| 4226 | $sth = $this->db->prepare($query); |
||
| 4227 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 4228 | |||
| 4229 | $airline_country_array = array(); |
||
| 4230 | $temp_array = array(); |
||
| 4231 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4232 | { |
||
| 4233 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4234 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4235 | |||
| 4236 | $airline_country_array[] = $temp_array; |
||
| 4237 | } |
||
| 4238 | |||
| 4239 | return $airline_country_array; |
||
| 4240 | } |
||
| 4241 | |||
| 4242 | |||
| 4243 | /** |
||
| 4244 | * Gets all airlines that have flown over by country |
||
| 4245 | * |
||
| 4246 | * @return Array the airline list |
||
| 4247 | * |
||
| 4248 | */ |
||
| 4249 | public function countAllAirlinesByCountry($country,$filters = array()) |
||
| 4250 | { |
||
| 4251 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 4252 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4253 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
||
| 4254 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 4255 | GROUP BY spotter_output.airline_name |
||
| 4256 | ORDER BY airline_count DESC"; |
||
| 4257 | |||
| 4258 | |||
| 4259 | $sth = $this->db->prepare($query); |
||
| 4260 | $sth->execute(array(':country' => $country)); |
||
| 4261 | |||
| 4262 | $airline_array = array(); |
||
| 4263 | $temp_array = array(); |
||
| 4264 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4265 | { |
||
| 4266 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4267 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4268 | $temp_array['airline_count'] = $row['airline_count']; |
||
| 4269 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4270 | |||
| 4271 | $airline_array[] = $temp_array; |
||
| 4272 | } |
||
| 4273 | return $airline_array; |
||
| 4274 | } |
||
| 4275 | |||
| 4276 | |||
| 4277 | /** |
||
| 4278 | * Gets all airline countries that have flown over by country |
||
| 4279 | * |
||
| 4280 | * @return Array the airline country list |
||
| 4281 | * |
||
| 4282 | */ |
||
| 4283 | public function countAllAirlineCountriesByCountry($country,$filters = array()) |
||
| 4284 | { |
||
| 4285 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4286 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 4287 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4288 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 4289 | GROUP BY spotter_output.airline_country |
||
| 4290 | ORDER BY airline_country_count DESC |
||
| 4291 | LIMIT 10 OFFSET 0"; |
||
| 4292 | |||
| 4293 | |||
| 4294 | $sth = $this->db->prepare($query); |
||
| 4295 | $sth->execute(array(':country' => $country)); |
||
| 4296 | |||
| 4297 | $airline_country_array = array(); |
||
| 4298 | $temp_array = array(); |
||
| 4299 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4300 | { |
||
| 4301 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4302 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4303 | |||
| 4304 | $airline_country_array[] = $temp_array; |
||
| 4305 | } |
||
| 4306 | return $airline_country_array; |
||
| 4307 | } |
||
| 4308 | |||
| 4309 | |||
| 4310 | /** |
||
| 4311 | * Gets all airlines countries |
||
| 4312 | * |
||
| 4313 | * @return Array the airline country list |
||
| 4314 | * |
||
| 4315 | */ |
||
| 4316 | public function countAllAirlineCountries($limit = true, $filters = array()) |
||
| 4317 | { |
||
| 4318 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4319 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
||
| 4320 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' |
||
| 4321 | GROUP BY spotter_output.airline_country |
||
| 4322 | ORDER BY airline_country_count DESC"; |
||
| 4323 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4324 | |||
| 4325 | $sth = $this->db->prepare($query); |
||
| 4326 | $sth->execute(); |
||
| 4327 | |||
| 4328 | $airline_array = array(); |
||
| 4329 | $temp_array = array(); |
||
| 4330 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4331 | { |
||
| 4332 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
||
| 4333 | $temp_array['airline_country'] = $row['airline_country']; |
||
| 4334 | |||
| 4335 | $airline_array[] = $temp_array; |
||
| 4336 | } |
||
| 4337 | return $airline_array; |
||
| 4338 | } |
||
| 4339 | |||
| 4340 | /** |
||
| 4341 | * Gets all number of flight over countries |
||
| 4342 | * |
||
| 4343 | * @return Array the airline country list |
||
| 4344 | * |
||
| 4345 | */ |
||
| 4346 | public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
||
| 4347 | { |
||
| 4348 | global $globalDBdriver; |
||
| 4349 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4350 | $Connection= new Connection($this->db); |
||
| 4351 | if (!$Connection->tableExists('countries')) return array(); |
||
| 4352 | /* |
||
| 4353 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
||
| 4354 | FROM countries c, spotter_output s |
||
| 4355 | WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; |
||
| 4356 | */ |
||
| 4357 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
||
| 4358 | FROM countries c, spotter_live s |
||
| 4359 | WHERE c.iso2 = s.over_country "; |
||
| 4360 | if ($olderthanmonths > 0) { |
||
| 4361 | if ($globalDBdriver == 'mysql') { |
||
| 4362 | $query .= 'AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 4363 | } else { |
||
| 4364 | $query .= "AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 4365 | } |
||
| 4366 | } |
||
| 4367 | if ($sincedate != '') { |
||
| 4368 | if ($globalDBdriver == 'mysql') { |
||
| 4369 | $query .= "AND spotter_live.date > '".$sincedate."' "; |
||
| 4370 | } else { |
||
| 4371 | $query .= "AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4372 | } |
||
| 4373 | } |
||
| 4374 | |||
| 4375 | $query .= "GROUP BY c.name ORDER BY nb DESC"; |
||
| 4376 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4377 | |||
| 4378 | |||
| 4379 | $sth = $this->db->prepare($query); |
||
| 4380 | $sth->execute(); |
||
| 4381 | |||
| 4382 | $flight_array = array(); |
||
| 4383 | $temp_array = array(); |
||
| 4384 | |||
| 4385 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4386 | { |
||
| 4387 | $temp_array['flight_count'] = $row['nb']; |
||
| 4388 | $temp_array['flight_country'] = $row['name']; |
||
| 4389 | $temp_array['flight_country_iso3'] = $row['iso3']; |
||
| 4390 | $temp_array['flight_country_iso2'] = $row['iso2']; |
||
| 4391 | $flight_array[] = $temp_array; |
||
| 4392 | } |
||
| 4393 | return $flight_array; |
||
| 4394 | } |
||
| 4395 | |||
| 4396 | |||
| 4397 | /** |
||
| 4398 | * Gets all aircraft types that have flown over |
||
| 4399 | * |
||
| 4400 | * @return Array the aircraft list |
||
| 4401 | * |
||
| 4402 | */ |
||
| 4403 | public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 4404 | { |
||
| 4405 | global $globalDBdriver; |
||
| 4406 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4407 | |||
| 4408 | $query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
||
| 4409 | FROM spotter_output ".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> ''"; |
||
| 4410 | if ($olderthanmonths > 0) { |
||
| 4411 | if ($globalDBdriver == 'mysql') { |
||
| 4412 | $query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; |
||
| 4413 | } else { |
||
| 4414 | $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
||
| 4415 | } |
||
| 4416 | } |
||
| 4417 | if ($sincedate != '') { |
||
| 4418 | if ($globalDBdriver == 'mysql') { |
||
| 4419 | $query .= " AND spotter_output.date > '".$sincedate."'"; |
||
| 4420 | } else { |
||
| 4421 | $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4422 | } |
||
| 4423 | } |
||
| 4424 | |||
| 4425 | $query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
||
| 4426 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4427 | |||
| 4428 | $sth = $this->db->prepare($query); |
||
| 4429 | $sth->execute(); |
||
| 4430 | |||
| 4431 | $aircraft_array = array(); |
||
| 4432 | $temp_array = array(); |
||
| 4433 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4434 | { |
||
| 4435 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4436 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4437 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 4438 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4439 | $aircraft_array[] = $temp_array; |
||
| 4440 | } |
||
| 4441 | return $aircraft_array; |
||
| 4442 | } |
||
| 4443 | |||
| 4444 | /** |
||
| 4445 | * Gets all aircraft types that have flown over by airline |
||
| 4446 | * |
||
| 4447 | * @return Array the aircraft list |
||
| 4448 | * |
||
| 4449 | */ |
||
| 4450 | public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 4451 | { |
||
| 4452 | global $globalDBdriver; |
||
| 4453 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4454 | $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 |
||
| 4455 | 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' "; |
||
| 4456 | if ($olderthanmonths > 0) { |
||
| 4457 | if ($globalDBdriver == 'mysql') { |
||
| 4458 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 4459 | } else { |
||
| 4460 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 4461 | } |
||
| 4462 | } |
||
| 4463 | if ($sincedate != '') { |
||
| 4464 | if ($globalDBdriver == 'mysql') { |
||
| 4465 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 4466 | } else { |
||
| 4467 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 4468 | } |
||
| 4469 | } |
||
| 4470 | |||
| 4471 | $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"; |
||
| 4472 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 4473 | |||
| 4474 | $sth = $this->db->prepare($query); |
||
| 4475 | $sth->execute(); |
||
| 4476 | |||
| 4477 | $aircraft_array = array(); |
||
| 4478 | $temp_array = array(); |
||
| 4479 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4480 | { |
||
| 4481 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 4482 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4483 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4484 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 4485 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4486 | $aircraft_array[] = $temp_array; |
||
| 4487 | } |
||
| 4488 | return $aircraft_array; |
||
| 4489 | } |
||
| 4490 | |||
| 4491 | |||
| 4492 | /** |
||
| 4493 | * Gets all aircraft registration that have flown over by aircaft icao |
||
| 4494 | * |
||
| 4495 | * @return Array the aircraft list |
||
| 4496 | * |
||
| 4497 | */ |
||
| 4498 | public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array()) |
||
| 4499 | { |
||
| 4500 | $Image = new Image($this->db); |
||
| 4501 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4502 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
||
| 4503 | |||
| 4504 | $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 |
||
| 4505 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
||
| 4506 | GROUP BY spotter_output.registration |
||
| 4507 | ORDER BY registration_count DESC"; |
||
| 4508 | |||
| 4509 | $sth = $this->db->prepare($query); |
||
| 4510 | $sth->execute(array(':aircraft_icao' => $aircraft_icao)); |
||
| 4511 | |||
| 4512 | $aircraft_array = array(); |
||
| 4513 | $temp_array = array(); |
||
| 4514 | |||
| 4515 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4516 | { |
||
| 4517 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4518 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4519 | $temp_array['registration'] = $row['registration']; |
||
| 4520 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4521 | $temp_array['image_thumbnail'] = ""; |
||
| 4522 | if($row['registration'] != "") |
||
| 4523 | { |
||
| 4524 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 4525 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 4526 | } |
||
| 4527 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 4528 | |||
| 4529 | $aircraft_array[] = $temp_array; |
||
| 4530 | } |
||
| 4531 | return $aircraft_array; |
||
| 4532 | } |
||
| 4533 | |||
| 4534 | |||
| 4535 | /** |
||
| 4536 | * Gets all aircraft types that have flown over by airline icao |
||
| 4537 | * |
||
| 4538 | * @return Array the aircraft list |
||
| 4539 | * |
||
| 4540 | */ |
||
| 4541 | public function countAllAircraftTypesByAirline($airline_icao,$filters = array()) |
||
| 4542 | { |
||
| 4543 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4544 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 4545 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 4546 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 4547 | GROUP BY spotter_output.aircraft_name |
||
| 4548 | ORDER BY aircraft_icao_count DESC"; |
||
| 4549 | |||
| 4550 | $sth = $this->db->prepare($query); |
||
| 4551 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 4552 | |||
| 4553 | $aircraft_array = array(); |
||
| 4554 | $temp_array = array(); |
||
| 4555 | |||
| 4556 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4557 | { |
||
| 4558 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4559 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4560 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4561 | |||
| 4562 | $aircraft_array[] = $temp_array; |
||
| 4563 | } |
||
| 4564 | return $aircraft_array; |
||
| 4565 | } |
||
| 4566 | |||
| 4567 | |||
| 4568 | /** |
||
| 4569 | * Gets all aircraft registration that have flown over by airline icao |
||
| 4570 | * |
||
| 4571 | * @return Array the aircraft list |
||
| 4572 | * |
||
| 4573 | */ |
||
| 4574 | public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array()) |
||
| 4575 | { |
||
| 4576 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4577 | $Image = new Image($this->db); |
||
| 4578 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 4579 | |||
| 4580 | $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 |
||
| 4581 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 4582 | GROUP BY spotter_output.registration |
||
| 4583 | ORDER BY registration_count DESC"; |
||
| 4584 | |||
| 4585 | $sth = $this->db->prepare($query); |
||
| 4586 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 4587 | |||
| 4588 | $aircraft_array = array(); |
||
| 4589 | $temp_array = array(); |
||
| 4590 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4591 | { |
||
| 4592 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4593 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4594 | $temp_array['registration'] = $row['registration']; |
||
| 4595 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4596 | $temp_array['image_thumbnail'] = ""; |
||
| 4597 | if($row['registration'] != "") |
||
| 4598 | { |
||
| 4599 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 4600 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 4601 | } |
||
| 4602 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 4603 | |||
| 4604 | $aircraft_array[] = $temp_array; |
||
| 4605 | } |
||
| 4606 | return $aircraft_array; |
||
| 4607 | } |
||
| 4608 | |||
| 4609 | |||
| 4610 | /** |
||
| 4611 | * Gets all aircraft manufacturer that have flown over by airline icao |
||
| 4612 | * |
||
| 4613 | * @return Array the aircraft list |
||
| 4614 | * |
||
| 4615 | */ |
||
| 4616 | public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array()) |
||
| 4617 | { |
||
| 4618 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4619 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 4620 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 4621 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 4622 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 4623 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 4624 | |||
| 4625 | $sth = $this->db->prepare($query); |
||
| 4626 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 4627 | |||
| 4628 | $aircraft_array = array(); |
||
| 4629 | $temp_array = array(); |
||
| 4630 | |||
| 4631 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4632 | { |
||
| 4633 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 4634 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 4635 | |||
| 4636 | $aircraft_array[] = $temp_array; |
||
| 4637 | } |
||
| 4638 | return $aircraft_array; |
||
| 4639 | } |
||
| 4640 | |||
| 4641 | |||
| 4642 | /** |
||
| 4643 | * Gets all aircraft types that have flown over by airline icao |
||
| 4644 | * |
||
| 4645 | * @return Array the aircraft list |
||
| 4646 | * |
||
| 4647 | */ |
||
| 4648 | public function countAllAircraftTypesByAirport($airport_icao,$filters = array()) |
||
| 4649 | { |
||
| 4650 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4651 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 4652 | |||
| 4653 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 4654 | 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) |
||
| 4655 | GROUP BY spotter_output.aircraft_name |
||
| 4656 | ORDER BY aircraft_icao_count DESC"; |
||
| 4657 | |||
| 4658 | $sth = $this->db->prepare($query); |
||
| 4659 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 4660 | |||
| 4661 | $aircraft_array = array(); |
||
| 4662 | $temp_array = array(); |
||
| 4663 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4664 | { |
||
| 4665 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4666 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4667 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4668 | |||
| 4669 | $aircraft_array[] = $temp_array; |
||
| 4670 | } |
||
| 4671 | return $aircraft_array; |
||
| 4672 | } |
||
| 4673 | |||
| 4674 | |||
| 4675 | /** |
||
| 4676 | * Gets all aircraft registration that have flown over by airport icao |
||
| 4677 | * |
||
| 4678 | * @return Array the aircraft list |
||
| 4679 | * |
||
| 4680 | */ |
||
| 4681 | public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array()) |
||
| 4682 | { |
||
| 4683 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4684 | $Image = new Image($this->db); |
||
| 4685 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 4686 | |||
| 4687 | $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 |
||
| 4688 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
||
| 4689 | GROUP BY spotter_output.registration |
||
| 4690 | ORDER BY registration_count DESC"; |
||
| 4691 | |||
| 4692 | |||
| 4693 | $sth = $this->db->prepare($query); |
||
| 4694 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 4695 | |||
| 4696 | $aircraft_array = array(); |
||
| 4697 | $temp_array = array(); |
||
| 4698 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4699 | { |
||
| 4700 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4701 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4702 | $temp_array['registration'] = $row['registration']; |
||
| 4703 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4704 | $temp_array['image_thumbnail'] = ""; |
||
| 4705 | if($row['registration'] != "") |
||
| 4706 | { |
||
| 4707 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 4708 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 4709 | } |
||
| 4710 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 4711 | $aircraft_array[] = $temp_array; |
||
| 4712 | } |
||
| 4713 | return $aircraft_array; |
||
| 4714 | } |
||
| 4715 | |||
| 4716 | |||
| 4717 | /** |
||
| 4718 | * Gets all aircraft manufacturer that have flown over by airport icao |
||
| 4719 | * |
||
| 4720 | * @return Array the aircraft list |
||
| 4721 | * |
||
| 4722 | */ |
||
| 4723 | public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array()) |
||
| 4724 | { |
||
| 4725 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4726 | $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
||
| 4727 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 4728 | 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) |
||
| 4729 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 4730 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 4731 | |||
| 4732 | |||
| 4733 | $sth = $this->db->prepare($query); |
||
| 4734 | $sth->execute(array(':airport_icao' => $airport_icao)); |
||
| 4735 | |||
| 4736 | $aircraft_array = array(); |
||
| 4737 | $temp_array = array(); |
||
| 4738 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4739 | { |
||
| 4740 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 4741 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 4742 | $aircraft_array[] = $temp_array; |
||
| 4743 | } |
||
| 4744 | return $aircraft_array; |
||
| 4745 | } |
||
| 4746 | |||
| 4747 | /** |
||
| 4748 | * Gets all aircraft types that have flown over by aircraft manufacturer |
||
| 4749 | * |
||
| 4750 | * @return Array the aircraft list |
||
| 4751 | * |
||
| 4752 | */ |
||
| 4753 | public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 4754 | { |
||
| 4755 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4756 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 4757 | |||
| 4758 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 4759 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 4760 | GROUP BY spotter_output.aircraft_name |
||
| 4761 | ORDER BY aircraft_icao_count DESC"; |
||
| 4762 | |||
| 4763 | $sth = $this->db->prepare($query); |
||
| 4764 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 4765 | $aircraft_array = array(); |
||
| 4766 | $temp_array = array(); |
||
| 4767 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4768 | { |
||
| 4769 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4770 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4771 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4772 | $aircraft_array[] = $temp_array; |
||
| 4773 | } |
||
| 4774 | return $aircraft_array; |
||
| 4775 | } |
||
| 4776 | |||
| 4777 | |||
| 4778 | /** |
||
| 4779 | * Gets all aircraft registration that have flown over by aircaft manufacturer |
||
| 4780 | * |
||
| 4781 | * @return Array the aircraft list |
||
| 4782 | * |
||
| 4783 | */ |
||
| 4784 | public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array()) |
||
| 4785 | { |
||
| 4786 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4787 | $Image = new Image($this->db); |
||
| 4788 | $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
||
| 4789 | |||
| 4790 | $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 |
||
| 4791 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
||
| 4792 | GROUP BY spotter_output.registration |
||
| 4793 | ORDER BY registration_count DESC"; |
||
| 4794 | |||
| 4795 | |||
| 4796 | $sth = $this->db->prepare($query); |
||
| 4797 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
||
| 4798 | $aircraft_array = array(); |
||
| 4799 | $temp_array = array(); |
||
| 4800 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4801 | { |
||
| 4802 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4803 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4804 | $temp_array['registration'] = $row['registration']; |
||
| 4805 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4806 | $temp_array['image_thumbnail'] = ""; |
||
| 4807 | if($row['registration'] != "") |
||
| 4808 | { |
||
| 4809 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 4810 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 4811 | } |
||
| 4812 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 4813 | $aircraft_array[] = $temp_array; |
||
| 4814 | } |
||
| 4815 | return $aircraft_array; |
||
| 4816 | } |
||
| 4817 | |||
| 4818 | /** |
||
| 4819 | * Gets all aircraft types that have flown over by date |
||
| 4820 | * |
||
| 4821 | * @return Array the aircraft list |
||
| 4822 | * |
||
| 4823 | */ |
||
| 4824 | public function countAllAircraftTypesByDate($date,$filters = array()) |
||
| 4825 | { |
||
| 4826 | global $globalTimezone, $globalDBdriver; |
||
| 4827 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4828 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4829 | if ($globalTimezone != '') { |
||
| 4830 | date_default_timezone_set($globalTimezone); |
||
| 4831 | $datetime = new DateTime($date); |
||
| 4832 | $offset = $datetime->format('P'); |
||
| 4833 | } else $offset = '+00:00'; |
||
| 4834 | |||
| 4835 | if ($globalDBdriver == 'mysql') { |
||
| 4836 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 4837 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4838 | GROUP BY spotter_output.aircraft_name |
||
| 4839 | ORDER BY aircraft_icao_count DESC"; |
||
| 4840 | } else { |
||
| 4841 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 4842 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4843 | GROUP BY spotter_output.aircraft_name |
||
| 4844 | ORDER BY aircraft_icao_count DESC"; |
||
| 4845 | } |
||
| 4846 | |||
| 4847 | $sth = $this->db->prepare($query); |
||
| 4848 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4849 | |||
| 4850 | $aircraft_array = array(); |
||
| 4851 | $temp_array = array(); |
||
| 4852 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4853 | { |
||
| 4854 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4855 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4856 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4857 | |||
| 4858 | $aircraft_array[] = $temp_array; |
||
| 4859 | } |
||
| 4860 | return $aircraft_array; |
||
| 4861 | } |
||
| 4862 | |||
| 4863 | |||
| 4864 | /** |
||
| 4865 | * Gets all aircraft registration that have flown over by date |
||
| 4866 | * |
||
| 4867 | * @return Array the aircraft list |
||
| 4868 | * |
||
| 4869 | */ |
||
| 4870 | public function countAllAircraftRegistrationByDate($date,$filters = array()) |
||
| 4871 | { |
||
| 4872 | global $globalTimezone, $globalDBdriver; |
||
| 4873 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4874 | $Image = new Image($this->db); |
||
| 4875 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4876 | if ($globalTimezone != '') { |
||
| 4877 | date_default_timezone_set($globalTimezone); |
||
| 4878 | $datetime = new DateTime($date); |
||
| 4879 | $offset = $datetime->format('P'); |
||
| 4880 | } else $offset = '+00:00'; |
||
| 4881 | |||
| 4882 | if ($globalDBdriver == 'mysql') { |
||
| 4883 | $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 |
||
| 4884 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4885 | GROUP BY spotter_output.registration |
||
| 4886 | ORDER BY registration_count DESC"; |
||
| 4887 | } else { |
||
| 4888 | $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 |
||
| 4889 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4890 | GROUP BY spotter_output.registration |
||
| 4891 | ORDER BY registration_count DESC"; |
||
| 4892 | } |
||
| 4893 | |||
| 4894 | $sth = $this->db->prepare($query); |
||
| 4895 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4896 | |||
| 4897 | $aircraft_array = array(); |
||
| 4898 | $temp_array = array(); |
||
| 4899 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4900 | { |
||
| 4901 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4902 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4903 | $temp_array['registration'] = $row['registration']; |
||
| 4904 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 4905 | $temp_array['image_thumbnail'] = ""; |
||
| 4906 | if($row['registration'] != "") |
||
| 4907 | { |
||
| 4908 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 4909 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 4910 | } |
||
| 4911 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 4912 | |||
| 4913 | $aircraft_array[] = $temp_array; |
||
| 4914 | } |
||
| 4915 | return $aircraft_array; |
||
| 4916 | } |
||
| 4917 | |||
| 4918 | |||
| 4919 | /** |
||
| 4920 | * Gets all aircraft manufacturer that have flown over by date |
||
| 4921 | * |
||
| 4922 | * @return Array the aircraft manufacturer list |
||
| 4923 | * |
||
| 4924 | */ |
||
| 4925 | public function countAllAircraftManufacturerByDate($date,$filters = array()) |
||
| 4926 | { |
||
| 4927 | global $globalTimezone, $globalDBdriver; |
||
| 4928 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4929 | $date = filter_var($date,FILTER_SANITIZE_STRING); |
||
| 4930 | if ($globalTimezone != '') { |
||
| 4931 | date_default_timezone_set($globalTimezone); |
||
| 4932 | $datetime = new DateTime($date); |
||
| 4933 | $offset = $datetime->format('P'); |
||
| 4934 | } else $offset = '+00:00'; |
||
| 4935 | |||
| 4936 | if ($globalDBdriver == 'mysql') { |
||
| 4937 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 4938 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
||
| 4939 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 4940 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 4941 | } else { |
||
| 4942 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 4943 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
||
| 4944 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 4945 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 4946 | } |
||
| 4947 | |||
| 4948 | $sth = $this->db->prepare($query); |
||
| 4949 | $sth->execute(array(':date' => $date, ':offset' => $offset)); |
||
| 4950 | |||
| 4951 | $aircraft_array = array(); |
||
| 4952 | $temp_array = array(); |
||
| 4953 | |||
| 4954 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4955 | { |
||
| 4956 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 4957 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 4958 | |||
| 4959 | $aircraft_array[] = $temp_array; |
||
| 4960 | } |
||
| 4961 | return $aircraft_array; |
||
| 4962 | } |
||
| 4963 | |||
| 4964 | |||
| 4965 | /** |
||
| 4966 | * Gets all aircraft types that have flown over by ident/callsign |
||
| 4967 | * |
||
| 4968 | * @return Array the aircraft list |
||
| 4969 | * |
||
| 4970 | */ |
||
| 4971 | public function countAllAircraftTypesByIdent($ident,$filters = array()) |
||
| 4972 | { |
||
| 4973 | $filter_query = $this->getFilter($filters,true,true); |
||
| 4974 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 4975 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 4976 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
||
| 4977 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
||
| 4978 | ORDER BY aircraft_icao_count DESC"; |
||
| 4979 | |||
| 4980 | $sth = $this->db->prepare($query); |
||
| 4981 | $sth->execute(array(':ident' => $ident)); |
||
| 4982 | |||
| 4983 | $aircraft_array = array(); |
||
| 4984 | $temp_array = array(); |
||
| 4985 | |||
| 4986 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 4987 | { |
||
| 4988 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 4989 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 4990 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 4991 | |||
| 4992 | $aircraft_array[] = $temp_array; |
||
| 4993 | } |
||
| 4994 | return $aircraft_array; |
||
| 4995 | } |
||
| 4996 | |||
| 4997 | |||
| 4998 | /** |
||
| 4999 | * Gets all aircraft registration that have flown over by ident/callsign |
||
| 5000 | * |
||
| 5001 | * @return Array the aircraft list |
||
| 5002 | * |
||
| 5003 | */ |
||
| 5004 | public function countAllAircraftRegistrationByIdent($ident,$filters = array()) |
||
| 5005 | { |
||
| 5006 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5007 | $Image = new Image($this->db); |
||
| 5008 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 5009 | |||
| 5010 | $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 |
||
| 5011 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident |
||
| 5012 | GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
||
| 5013 | ORDER BY registration_count DESC"; |
||
| 5014 | |||
| 5015 | |||
| 5016 | $sth = $this->db->prepare($query); |
||
| 5017 | $sth->execute(array(':ident' => $ident)); |
||
| 5018 | |||
| 5019 | $aircraft_array = array(); |
||
| 5020 | $temp_array = array(); |
||
| 5021 | |||
| 5022 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5023 | { |
||
| 5024 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5025 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5026 | $temp_array['registration'] = $row['registration']; |
||
| 5027 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5028 | $temp_array['image_thumbnail'] = ""; |
||
| 5029 | if($row['registration'] != "") |
||
| 5030 | { |
||
| 5031 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5032 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5033 | else $temp_array['image_thumbnail'] = ''; |
||
| 5034 | } |
||
| 5035 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5036 | $aircraft_array[] = $temp_array; |
||
| 5037 | } |
||
| 5038 | return $aircraft_array; |
||
| 5039 | } |
||
| 5040 | |||
| 5041 | |||
| 5042 | /** |
||
| 5043 | * Gets all aircraft manufacturer that have flown over by ident/callsign |
||
| 5044 | * |
||
| 5045 | * @return Array the aircraft manufacturer list |
||
| 5046 | * |
||
| 5047 | */ |
||
| 5048 | public function countAllAircraftManufacturerByIdent($ident,$filters = array()) |
||
| 5049 | { |
||
| 5050 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5051 | $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
||
| 5052 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5053 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident |
||
| 5054 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5055 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5056 | |||
| 5057 | |||
| 5058 | $sth = $this->db->prepare($query); |
||
| 5059 | $sth->execute(array(':ident' => $ident)); |
||
| 5060 | $aircraft_array = array(); |
||
| 5061 | $temp_array = array(); |
||
| 5062 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5063 | { |
||
| 5064 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5065 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 5066 | $aircraft_array[] = $temp_array; |
||
| 5067 | } |
||
| 5068 | return $aircraft_array; |
||
| 5069 | } |
||
| 5070 | |||
| 5071 | |||
| 5072 | /** |
||
| 5073 | * Gets all aircraft types that have flown over by route |
||
| 5074 | * |
||
| 5075 | * @return Array the aircraft list |
||
| 5076 | * |
||
| 5077 | */ |
||
| 5078 | public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 5079 | { |
||
| 5080 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5081 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 5082 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 5083 | |||
| 5084 | |||
| 5085 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5086 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
||
| 5087 | GROUP BY spotter_output.aircraft_name |
||
| 5088 | ORDER BY aircraft_icao_count DESC"; |
||
| 5089 | |||
| 5090 | |||
| 5091 | $sth = $this->db->prepare($query); |
||
| 5092 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 5093 | $aircraft_array = array(); |
||
| 5094 | $temp_array = array(); |
||
| 5095 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5096 | { |
||
| 5097 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5098 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5099 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5100 | $aircraft_array[] = $temp_array; |
||
| 5101 | } |
||
| 5102 | return $aircraft_array; |
||
| 5103 | } |
||
| 5104 | |||
| 5105 | /** |
||
| 5106 | * Gets all aircraft registration that have flown over by route |
||
| 5107 | * |
||
| 5108 | * @return Array the aircraft list |
||
| 5109 | * |
||
| 5110 | */ |
||
| 5111 | public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 5112 | { |
||
| 5113 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5114 | $Image = new Image($this->db); |
||
| 5115 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 5116 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 5117 | |||
| 5118 | $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 |
||
| 5119 | 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) |
||
| 5120 | GROUP BY spotter_output.registration |
||
| 5121 | ORDER BY registration_count DESC"; |
||
| 5122 | |||
| 5123 | |||
| 5124 | $sth = $this->db->prepare($query); |
||
| 5125 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 5126 | |||
| 5127 | $aircraft_array = array(); |
||
| 5128 | $temp_array = array(); |
||
| 5129 | |||
| 5130 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5131 | { |
||
| 5132 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5133 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5134 | $temp_array['registration'] = $row['registration']; |
||
| 5135 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5136 | $temp_array['image_thumbnail'] = ""; |
||
| 5137 | if($row['registration'] != "") |
||
| 5138 | { |
||
| 5139 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5140 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5141 | } |
||
| 5142 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5143 | |||
| 5144 | $aircraft_array[] = $temp_array; |
||
| 5145 | } |
||
| 5146 | |||
| 5147 | return $aircraft_array; |
||
| 5148 | } |
||
| 5149 | |||
| 5150 | |||
| 5151 | /** |
||
| 5152 | * Gets all aircraft manufacturer that have flown over by route |
||
| 5153 | * |
||
| 5154 | * @return Array the aircraft manufacturer list |
||
| 5155 | * |
||
| 5156 | */ |
||
| 5157 | public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
||
| 5158 | { |
||
| 5159 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5160 | $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
||
| 5161 | $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
||
| 5162 | |||
| 5163 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5164 | 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) |
||
| 5165 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5166 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5167 | |||
| 5168 | |||
| 5169 | $sth = $this->db->prepare($query); |
||
| 5170 | $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
||
| 5171 | |||
| 5172 | $aircraft_array = array(); |
||
| 5173 | $temp_array = array(); |
||
| 5174 | |||
| 5175 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5176 | { |
||
| 5177 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5178 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 5179 | |||
| 5180 | $aircraft_array[] = $temp_array; |
||
| 5181 | } |
||
| 5182 | |||
| 5183 | return $aircraft_array; |
||
| 5184 | } |
||
| 5185 | |||
| 5186 | |||
| 5187 | |||
| 5188 | |||
| 5189 | /** |
||
| 5190 | * Gets all aircraft types that have flown over by country |
||
| 5191 | * |
||
| 5192 | * @return Array the aircraft list |
||
| 5193 | * |
||
| 5194 | */ |
||
| 5195 | public function countAllAircraftTypesByCountry($country,$filters = array()) |
||
| 5196 | { |
||
| 5197 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5198 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 5199 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
||
| 5200 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
||
| 5201 | GROUP BY spotter_output.aircraft_name |
||
| 5202 | ORDER BY aircraft_icao_count DESC"; |
||
| 5203 | |||
| 5204 | |||
| 5205 | $sth = $this->db->prepare($query); |
||
| 5206 | $sth->execute(array(':country' => $country)); |
||
| 5207 | |||
| 5208 | $aircraft_array = array(); |
||
| 5209 | $temp_array = array(); |
||
| 5210 | |||
| 5211 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5212 | { |
||
| 5213 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5214 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5215 | $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; |
||
| 5216 | |||
| 5217 | $aircraft_array[] = $temp_array; |
||
| 5218 | } |
||
| 5219 | |||
| 5220 | return $aircraft_array; |
||
| 5221 | } |
||
| 5222 | |||
| 5223 | |||
| 5224 | /** |
||
| 5225 | * Gets all aircraft registration that have flown over by country |
||
| 5226 | * |
||
| 5227 | * @return Array the aircraft list |
||
| 5228 | * |
||
| 5229 | */ |
||
| 5230 | public function countAllAircraftRegistrationByCountry($country,$filters = array()) |
||
| 5231 | { |
||
| 5232 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5233 | $Image = new Image($this->db); |
||
| 5234 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 5235 | $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 |
||
| 5236 | 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) |
||
| 5237 | GROUP BY spotter_output.registration |
||
| 5238 | ORDER BY registration_count DESC"; |
||
| 5239 | |||
| 5240 | |||
| 5241 | $sth = $this->db->prepare($query); |
||
| 5242 | $sth->execute(array(':country' => $country)); |
||
| 5243 | |||
| 5244 | $aircraft_array = array(); |
||
| 5245 | $temp_array = array(); |
||
| 5246 | |||
| 5247 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5248 | { |
||
| 5249 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5250 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5251 | $temp_array['registration'] = $row['registration']; |
||
| 5252 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5253 | $temp_array['image_thumbnail'] = ""; |
||
| 5254 | if($row['registration'] != "") |
||
| 5255 | { |
||
| 5256 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5257 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5258 | } |
||
| 5259 | $temp_array['registration_count'] = $row['registration_count']; |
||
| 5260 | |||
| 5261 | $aircraft_array[] = $temp_array; |
||
| 5262 | } |
||
| 5263 | |||
| 5264 | return $aircraft_array; |
||
| 5265 | } |
||
| 5266 | |||
| 5267 | |||
| 5268 | /** |
||
| 5269 | * Gets all aircraft manufacturer that have flown over by country |
||
| 5270 | * |
||
| 5271 | * @return Array the aircraft manufacturer list |
||
| 5272 | * |
||
| 5273 | */ |
||
| 5274 | public function countAllAircraftManufacturerByCountry($country,$filters = array()) |
||
| 5275 | { |
||
| 5276 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5277 | $country = filter_var($country,FILTER_SANITIZE_STRING); |
||
| 5278 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
||
| 5279 | 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) |
||
| 5280 | GROUP BY spotter_output.aircraft_manufacturer |
||
| 5281 | ORDER BY aircraft_manufacturer_count DESC"; |
||
| 5282 | |||
| 5283 | |||
| 5284 | $sth = $this->db->prepare($query); |
||
| 5285 | $sth->execute(array(':country' => $country)); |
||
| 5286 | |||
| 5287 | $aircraft_array = array(); |
||
| 5288 | $temp_array = array(); |
||
| 5289 | |||
| 5290 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5291 | { |
||
| 5292 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
||
| 5293 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
||
| 5294 | |||
| 5295 | $aircraft_array[] = $temp_array; |
||
| 5296 | } |
||
| 5297 | |||
| 5298 | return $aircraft_array; |
||
| 5299 | } |
||
| 5300 | |||
| 5301 | |||
| 5302 | |||
| 5303 | /** |
||
| 5304 | * Gets all aircraft manufacturers that have flown over |
||
| 5305 | * |
||
| 5306 | * @return Array the aircraft list |
||
| 5307 | * |
||
| 5308 | */ |
||
| 5309 | public function countAllAircraftManufacturers($filters = array()) |
||
| 5335 | |||
| 5336 | |||
| 5337 | |||
| 5338 | /** |
||
| 5339 | * Gets all aircraft registrations that have flown over |
||
| 5340 | * |
||
| 5341 | * @return Array the aircraft list |
||
| 5342 | * |
||
| 5343 | */ |
||
| 5344 | public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 5396 | |||
| 5397 | |||
| 5398 | /** |
||
| 5399 | * Gets all aircraft registrations that have flown over |
||
| 5400 | * |
||
| 5401 | * @return Array the aircraft list |
||
| 5402 | * |
||
| 5403 | */ |
||
| 5404 | public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
||
| 5405 | { |
||
| 5406 | global $globalDBdriver; |
||
| 5407 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5408 | $Image = new Image($this->db); |
||
| 5409 | $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 |
||
| 5410 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' "; |
||
| 5411 | if ($olderthanmonths > 0) { |
||
| 5412 | if ($globalDBdriver == 'mysql') { |
||
| 5413 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5414 | } else { |
||
| 5415 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 5416 | } |
||
| 5417 | } |
||
| 5418 | if ($sincedate != '') { |
||
| 5419 | if ($globalDBdriver == 'mysql') { |
||
| 5420 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 5421 | } else { |
||
| 5422 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 5423 | } |
||
| 5424 | } |
||
| 5425 | |||
| 5426 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5427 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 5428 | $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"; |
||
| 5429 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5430 | |||
| 5431 | $sth = $this->db->prepare($query); |
||
| 5432 | $sth->execute(); |
||
| 5433 | |||
| 5434 | $aircraft_array = array(); |
||
| 5435 | $temp_array = array(); |
||
| 5436 | |||
| 5437 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5438 | { |
||
| 5439 | $temp_array['registration'] = $row['registration']; |
||
| 5440 | $temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
||
| 5441 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 5442 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
||
| 5443 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
||
| 5444 | $temp_array['airline_name'] = $row['airline_name']; |
||
| 5445 | $temp_array['image_thumbnail'] = ""; |
||
| 5446 | if($row['registration'] != "") |
||
| 5447 | { |
||
| 5448 | $image_array = $Image->getSpotterImage($row['registration']); |
||
| 5449 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
||
| 5450 | } |
||
| 5451 | |||
| 5452 | $aircraft_array[] = $temp_array; |
||
| 5453 | } |
||
| 5454 | |||
| 5455 | return $aircraft_array; |
||
| 5456 | } |
||
| 5457 | |||
| 5458 | |||
| 5459 | /** |
||
| 5460 | * Gets all departure airports of the airplanes that have flown over |
||
| 5461 | * |
||
| 5462 | * @return Array the airport list |
||
| 5463 | * |
||
| 5464 | */ |
||
| 5465 | public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5510 | |||
| 5511 | /** |
||
| 5512 | * Gets all departure airports of the airplanes that have flown over |
||
| 5513 | * |
||
| 5514 | * @return Array the airport list |
||
| 5515 | * |
||
| 5516 | */ |
||
| 5517 | public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5518 | { |
||
| 5519 | global $globalDBdriver; |
||
| 5520 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5521 | $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 |
||
| 5522 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' "; |
||
| 5523 | if ($olderthanmonths > 0) { |
||
| 5524 | if ($globalDBdriver == 'mysql') { |
||
| 5525 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5526 | } else { |
||
| 5527 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 5528 | } |
||
| 5529 | } |
||
| 5530 | if ($sincedate != '') { |
||
| 5531 | if ($globalDBdriver == 'mysql') { |
||
| 5532 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 5533 | } else { |
||
| 5534 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
||
| 5535 | } |
||
| 5536 | } |
||
| 5537 | |||
| 5538 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5539 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 5540 | $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 |
||
| 5541 | ORDER BY airport_departure_icao_count DESC"; |
||
| 5542 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5543 | |||
| 5544 | $sth = $this->db->prepare($query); |
||
| 5545 | $sth->execute(); |
||
| 5546 | |||
| 5547 | $airport_array = array(); |
||
| 5548 | $temp_array = array(); |
||
| 5549 | |||
| 5550 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5551 | { |
||
| 5552 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 5553 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 5554 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 5555 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 5556 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 5557 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 5558 | |||
| 5559 | $airport_array[] = $temp_array; |
||
| 5560 | } |
||
| 5561 | return $airport_array; |
||
| 5562 | } |
||
| 5563 | |||
| 5564 | /** |
||
| 5565 | * Gets all detected departure airports of the airplanes that have flown over |
||
| 5566 | * |
||
| 5567 | * @return Array the airport list |
||
| 5568 | * |
||
| 5569 | */ |
||
| 5570 | public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5614 | |||
| 5615 | /** |
||
| 5616 | * Gets all detected departure airports of the airplanes that have flown over |
||
| 5617 | * |
||
| 5618 | * @return Array the airport list |
||
| 5619 | * |
||
| 5620 | */ |
||
| 5621 | public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 5622 | { |
||
| 5623 | global $globalDBdriver; |
||
| 5624 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5625 | $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 |
||
| 5626 | FROM spotter_output, airport".$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 "; |
||
| 5627 | if ($olderthanmonths > 0) { |
||
| 5628 | if ($globalDBdriver == 'mysql') { |
||
| 5629 | $query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5630 | } else { |
||
| 5631 | $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
||
| 5632 | } |
||
| 5633 | } |
||
| 5634 | if ($sincedate != '') { |
||
| 5635 | if ($globalDBdriver == 'mysql') { |
||
| 5636 | $query .= "AND spotter_output.date > '".$sincedate."' "; |
||
| 5637 | } else { |
||
| 5638 | $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
||
| 5639 | } |
||
| 5640 | } |
||
| 5641 | |||
| 5642 | //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
||
| 5643 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
||
| 5644 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
||
| 5645 | ORDER BY airport_departure_icao_count DESC"; |
||
| 5646 | if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
||
| 5647 | |||
| 5648 | $sth = $this->db->prepare($query); |
||
| 5649 | $sth->execute(); |
||
| 5650 | |||
| 5651 | $airport_array = array(); |
||
| 5652 | $temp_array = array(); |
||
| 5653 | |||
| 5654 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5655 | { |
||
| 5656 | $temp_array['airline_icao'] = $row['airline_icao']; |
||
| 5657 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 5658 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 5659 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 5660 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 5661 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 5662 | |||
| 5663 | $airport_array[] = $temp_array; |
||
| 5664 | } |
||
| 5665 | return $airport_array; |
||
| 5666 | } |
||
| 5667 | |||
| 5668 | /** |
||
| 5669 | * Gets all departure airports of the airplanes that have flown over based on an airline icao |
||
| 5670 | * |
||
| 5671 | * @return Array the airport list |
||
| 5672 | * |
||
| 5673 | */ |
||
| 5674 | public function countAllDepartureAirportsByAirline($airline_icao,$filters = array()) |
||
| 5675 | { |
||
| 5676 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5677 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 5678 | $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 |
||
| 5679 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao |
||
| 5680 | GROUP BY spotter_output.departure_airport_icao |
||
| 5681 | ORDER BY airport_departure_icao_count DESC"; |
||
| 5682 | |||
| 5683 | |||
| 5684 | $sth = $this->db->prepare($query); |
||
| 5685 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 5686 | |||
| 5687 | $airport_array = array(); |
||
| 5688 | $temp_array = array(); |
||
| 5689 | |||
| 5690 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
||
| 5691 | { |
||
| 5692 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
||
| 5693 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
||
| 5694 | $temp_array['airport_departure_name'] = $row['departure_airport_name']; |
||
| 5695 | $temp_array['airport_departure_city'] = $row['departure_airport_city']; |
||
| 5696 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
||
| 5697 | |||
| 5698 | $airport_array[] = $temp_array; |
||
| 5699 | } |
||
| 5700 | |||
| 5701 | return $airport_array; |
||
| 5702 | } |
||
| 5703 | |||
| 5704 | |||
| 5705 | |||
| 5706 | /** |
||
| 5707 | * Gets all departure airports by country of the airplanes that have flown over based on an airline icao |
||
| 5708 | * |
||
| 5709 | * @return Array the airport list |
||
| 5710 | * |
||
| 5711 | */ |
||
| 5712 | public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array()) |
||
| 5713 | { |
||
| 5714 | $filter_query = $this->getFilter($filters,true,true); |
||
| 5715 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
||
| 5716 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
||
| 5717 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
||
| 5718 | GROUP BY spotter_output.departure_airport_country |
||
| 5719 | ORDER BY airport_departure_country_count DESC"; |
||
| 5720 | |||
| 5721 | |||
| 5722 | $sth = $this->db->prepare($query); |
||
| 5723 | $sth->execute(array(':airline_icao' => $airline_icao)); |
||
| 5724 | |||
| 5738 | |||
| 5739 | |||
| 5740 | |||
| 5741 | /** |
||
| 5742 | * Gets all departure airports of the airplanes that have flown over based on an aircraft icao |
||
| 5743 | * |
||
| 5744 | * @return Array the airport list |
||
| 5745 | * |
||
| 5746 | */ |
||
| 5747 | public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array()) |
||
| 5776 | |||
| 5777 | |||
| 5778 | /** |
||
| 5779 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 5780 | * |
||
| 5781 | * @return Array the airport list |
||
| 5782 | * |
||
| 5783 | */ |
||
| 5784 | public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 5810 | |||
| 5811 | |||
| 5812 | /** |
||
| 5813 | * Gets all departure airports of the airplanes that have flown over based on an aircraft registration |
||
| 5814 | * |
||
| 5815 | * @return Array the airport list |
||
| 5816 | * |
||
| 5817 | */ |
||
| 5818 | public function countAllDepartureAirportsByRegistration($registration,$filters = array()) |
||
| 5847 | |||
| 5848 | |||
| 5849 | /** |
||
| 5850 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration |
||
| 5851 | * |
||
| 5852 | * @return Array the airport list |
||
| 5853 | * |
||
| 5854 | */ |
||
| 5855 | public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array()) |
||
| 5881 | |||
| 5882 | |||
| 5883 | /** |
||
| 5884 | * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao |
||
| 5885 | * |
||
| 5886 | * @return Array the airport list |
||
| 5887 | * |
||
| 5888 | */ |
||
| 5889 | public function countAllDepartureAirportsByAirport($airport_icao,$filters = array()) |
||
| 5918 | |||
| 5919 | |||
| 5920 | /** |
||
| 5921 | * Gets all departure airports by country of the airplanes that have flown over based on an airport icao |
||
| 5922 | * |
||
| 5923 | * @return Array the airport list |
||
| 5924 | * |
||
| 5925 | */ |
||
| 5926 | public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array()) |
||
| 5952 | |||
| 5953 | |||
| 5954 | |||
| 5955 | /** |
||
| 5956 | * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer |
||
| 5957 | * |
||
| 5958 | * @return Array the airport list |
||
| 5959 | * |
||
| 5960 | */ |
||
| 5961 | public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 5990 | |||
| 5991 | |||
| 5992 | /** |
||
| 5993 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer |
||
| 5994 | * |
||
| 5995 | * @return Array the airport list |
||
| 5996 | * |
||
| 5997 | */ |
||
| 5998 | public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 6024 | |||
| 6025 | |||
| 6026 | /** |
||
| 6027 | * Gets all departure airports of the airplanes that have flown over based on a date |
||
| 6028 | * |
||
| 6029 | * @return Array the airport list |
||
| 6030 | * |
||
| 6031 | */ |
||
| 6032 | public function countAllDepartureAirportsByDate($date,$filters = array()) |
||
| 6073 | |||
| 6074 | |||
| 6075 | |||
| 6076 | /** |
||
| 6077 | * Gets all departure airports by country of the airplanes that have flown over based on a date |
||
| 6078 | * |
||
| 6079 | * @return Array the airport list |
||
| 6080 | * |
||
| 6081 | */ |
||
| 6082 | public function countAllDepartureAirportCountriesByDate($date,$filters = array()) |
||
| 6120 | |||
| 6121 | |||
| 6122 | |||
| 6123 | /** |
||
| 6124 | * Gets all departure airports of the airplanes that have flown over based on a ident/callsign |
||
| 6125 | * |
||
| 6126 | * @return Array the airport list |
||
| 6127 | * |
||
| 6128 | */ |
||
| 6129 | public function countAllDepartureAirportsByIdent($ident,$filters = array()) |
||
| 6158 | |||
| 6159 | |||
| 6160 | |||
| 6161 | /** |
||
| 6162 | * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident |
||
| 6163 | * |
||
| 6164 | * @return Array the airport list |
||
| 6165 | * |
||
| 6166 | */ |
||
| 6167 | public function countAllDepartureAirportCountriesByIdent($ident,$filters = array()) |
||
| 6193 | |||
| 6194 | |||
| 6195 | |||
| 6196 | /** |
||
| 6197 | * Gets all departure airports of the airplanes that have flown over based on a country |
||
| 6198 | * |
||
| 6199 | * @return Array the airport list |
||
| 6200 | * |
||
| 6201 | */ |
||
| 6202 | public function countAllDepartureAirportsByCountry($country,$filters = array()) |
||
| 6232 | |||
| 6233 | |||
| 6234 | /** |
||
| 6235 | * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 6236 | * |
||
| 6237 | * @return Array the airport list |
||
| 6238 | * |
||
| 6239 | */ |
||
| 6240 | public function countAllDepartureAirportCountriesByCountry($country,$filters = array()) |
||
| 6266 | |||
| 6267 | |||
| 6268 | /** |
||
| 6269 | * Gets all arrival airports of the airplanes that have flown over |
||
| 6270 | * |
||
| 6271 | * @return Array the airport list |
||
| 6272 | * |
||
| 6273 | */ |
||
| 6274 | public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
||
| 6329 | |||
| 6330 | /** |
||
| 6331 | * Gets all arrival airports of the airplanes that have flown over |
||
| 6332 | * |
||
| 6333 | * @return Array the airport list |
||
| 6334 | * |
||
| 6335 | */ |
||
| 6336 | public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
||
| 6392 | |||
| 6393 | |||
| 6394 | /** |
||
| 6395 | * Gets all detected arrival airports of the airplanes that have flown over |
||
| 6396 | * |
||
| 6397 | * @return Array the airport list |
||
| 6398 | * |
||
| 6399 | */ |
||
| 6400 | public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
||
| 6454 | |||
| 6455 | /** |
||
| 6456 | * Gets all detected arrival airports of the airplanes that have flown over |
||
| 6457 | * |
||
| 6458 | * @return Array the airport list |
||
| 6459 | * |
||
| 6460 | */ |
||
| 6461 | public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
||
| 6517 | |||
| 6518 | /** |
||
| 6519 | * Gets all arrival airports of the airplanes that have flown over based on an airline icao |
||
| 6520 | * |
||
| 6521 | * @return Array the airport list |
||
| 6522 | * |
||
| 6523 | */ |
||
| 6524 | public function countAllArrivalAirportsByAirline($airline_icao, $filters = array()) |
||
| 6552 | |||
| 6553 | |||
| 6554 | /** |
||
| 6555 | * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao |
||
| 6556 | * |
||
| 6557 | * @return Array the airport list |
||
| 6558 | * |
||
| 6559 | */ |
||
| 6560 | public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array()) |
||
| 6587 | |||
| 6588 | |||
| 6589 | /** |
||
| 6590 | * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao |
||
| 6591 | * |
||
| 6592 | * @return Array the airport list |
||
| 6593 | * |
||
| 6594 | */ |
||
| 6595 | public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array()) |
||
| 6624 | |||
| 6625 | |||
| 6626 | |||
| 6627 | /** |
||
| 6628 | * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao |
||
| 6629 | * |
||
| 6630 | * @return Array the airport list |
||
| 6631 | * |
||
| 6632 | */ |
||
| 6633 | public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
||
| 6659 | |||
| 6660 | |||
| 6661 | /** |
||
| 6662 | * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration |
||
| 6663 | * |
||
| 6664 | * @return Array the airport list |
||
| 6665 | * |
||
| 6666 | */ |
||
| 6667 | public function countAllArrivalAirportsByRegistration($registration,$filters = array()) |
||
| 6697 | |||
| 6698 | |||
| 6699 | /** |
||
| 6700 | * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration |
||
| 6701 | * |
||
| 6702 | * @return Array the airport list |
||
| 6703 | * |
||
| 6704 | */ |
||
| 6705 | public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array()) |
||
| 6731 | |||
| 6732 | |||
| 6733 | |||
| 6734 | /** |
||
| 6735 | * Gets all arrival airports of the airplanes that have flown over based on an departure airport |
||
| 6736 | * |
||
| 6737 | * @return Array the airport list |
||
| 6738 | * |
||
| 6739 | */ |
||
| 6740 | public function countAllArrivalAirportsByAirport($airport_icao,$filters = array()) |
||
| 6769 | |||
| 6770 | |||
| 6771 | /** |
||
| 6772 | * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao |
||
| 6773 | * |
||
| 6774 | * @return Array the airport list |
||
| 6775 | * |
||
| 6776 | */ |
||
| 6777 | public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array()) |
||
| 6803 | |||
| 6804 | |||
| 6805 | /** |
||
| 6806 | * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer |
||
| 6807 | * |
||
| 6808 | * @return Array the airport list |
||
| 6809 | * |
||
| 6810 | */ |
||
| 6811 | public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 6840 | |||
| 6841 | |||
| 6842 | |||
| 6843 | /** |
||
| 6844 | * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer |
||
| 6845 | * |
||
| 6846 | * @return Array the airport list |
||
| 6847 | * |
||
| 6848 | */ |
||
| 6849 | public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
||
| 6875 | |||
| 6876 | |||
| 6877 | |||
| 6878 | /** |
||
| 6879 | * Gets all arrival airports of the airplanes that have flown over based on a date |
||
| 6880 | * |
||
| 6881 | * @return Array the airport list |
||
| 6882 | * |
||
| 6883 | */ |
||
| 6884 | public function countAllArrivalAirportsByDate($date,$filters = array()) |
||
| 6925 | |||
| 6926 | |||
| 6927 | |||
| 6928 | /** |
||
| 6929 | * Gets all arrival airports by country of the airplanes that have flown over based on a date |
||
| 6930 | * |
||
| 6931 | * @return Array the airport list |
||
| 6932 | * |
||
| 6933 | */ |
||
| 6934 | public function countAllArrivalAirportCountriesByDate($date, $filters = array()) |
||
| 6972 | |||
| 6973 | |||
| 6974 | |||
| 6975 | /** |
||
| 6976 | * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign |
||
| 6977 | * |
||
| 6978 | * @return Array the airport list |
||
| 6979 | * |
||
| 6980 | */ |
||
| 6981 | public function countAllArrivalAirportsByIdent($ident,$filters = array()) |
||
| 7010 | |||
| 7011 | |||
| 7012 | /** |
||
| 7013 | * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident |
||
| 7014 | * |
||
| 7015 | * @return Array the airport list |
||
| 7016 | * |
||
| 7017 | */ |
||
| 7018 | public function countAllArrivalAirportCountriesByIdent($ident, $filters = array()) |
||
| 7044 | |||
| 7045 | |||
| 7046 | |||
| 7047 | /** |
||
| 7048 | * Gets all arrival airports of the airplanes that have flown over based on a country |
||
| 7049 | * |
||
| 7050 | * @return Array the airport list |
||
| 7051 | * |
||
| 7052 | */ |
||
| 7053 | public function countAllArrivalAirportsByCountry($country,$filters = array()) |
||
| 7082 | |||
| 7083 | |||
| 7084 | /** |
||
| 7085 | * Gets all arrival airports by country of the airplanes that have flown over based on a country |
||
| 7086 | * |
||
| 7087 | * @return Array the airport list |
||
| 7088 | * |
||
| 7089 | */ |
||
| 7090 | public function countAllArrivalAirportCountriesByCountry($country,$filters = array()) |
||
| 7116 | |||
| 7117 | |||
| 7118 | |||
| 7119 | /** |
||
| 7120 | * Counts all airport departure countries |
||
| 7121 | * |
||
| 7122 | * @return Array the airport departure list |
||
| 7123 | * |
||
| 7124 | */ |
||
| 7125 | public function countAllDepartureCountries($filters = array()) |
||
| 7151 | |||
| 7152 | |||
| 7153 | /** |
||
| 7154 | * Counts all airport arrival countries |
||
| 7155 | * |
||
| 7156 | * @return Array the airport arrival list |
||
| 7157 | * |
||
| 7158 | */ |
||
| 7159 | public function countAllArrivalCountries($limit = true,$filters = array()) |
||
| 7185 | |||
| 7186 | |||
| 7187 | |||
| 7188 | |||
| 7189 | |||
| 7190 | /** |
||
| 7191 | * Gets all route combinations |
||
| 7192 | * |
||
| 7193 | * @return Array the route list |
||
| 7194 | * |
||
| 7195 | */ |
||
| 7196 | public function countAllRoutes($filters = array()) |
||
| 7229 | |||
| 7230 | |||
| 7231 | |||
| 7232 | |||
| 7233 | /** |
||
| 7234 | * Gets all route combinations based on an aircraft |
||
| 7235 | * |
||
| 7236 | * @return Array the route list |
||
| 7237 | * |
||
| 7238 | */ |
||
| 7239 | public function countAllRoutesByAircraft($aircraft_icao,$filters = array()) |
||
| 7271 | |||
| 7272 | |||
| 7273 | /** |
||
| 7274 | * Gets all route combinations based on an aircraft registration |
||
| 7275 | * |
||
| 7276 | * @return Array the route list |
||
| 7277 | * |
||
| 7278 | */ |
||
| 7279 | public function countAllRoutesByRegistration($registration, $filters = array()) |
||
| 7312 | |||
| 7313 | |||
| 7314 | |||
| 7315 | /** |
||
| 7316 | * Gets all route combinations based on an airline |
||
| 7317 | * |
||
| 7318 | * @return Array the route list |
||
| 7319 | * |
||
| 7320 | */ |
||
| 7321 | public function countAllRoutesByAirline($airline_icao, $filters = array()) |
||
| 7354 | |||
| 7355 | |||
| 7356 | |||
| 7357 | /** |
||
| 7358 | * Gets all route combinations based on an airport |
||
| 7359 | * |
||
| 7360 | * @return Array the route list |
||
| 7361 | * |
||
| 7362 | */ |
||
| 7363 | public function countAllRoutesByAirport($airport_icao, $filters = array()) |
||
| 7395 | |||
| 7396 | |||
| 7397 | |||
| 7398 | /** |
||
| 7399 | * Gets all route combinations based on an country |
||
| 7400 | * |
||
| 7401 | * @return Array the route list |
||
| 7402 | * |
||
| 7403 | */ |
||
| 7404 | public function countAllRoutesByCountry($country, $filters = array()) |
||
| 7436 | |||
| 7437 | |||
| 7438 | /** |
||
| 7439 | * Gets all route combinations based on an date |
||
| 7440 | * |
||
| 7441 | * @return Array the route list |
||
| 7442 | * |
||
| 7443 | */ |
||
| 7444 | public function countAllRoutesByDate($date, $filters = array()) |
||
| 7490 | |||
| 7491 | |||
| 7492 | /** |
||
| 7493 | * Gets all route combinations based on an ident/callsign |
||
| 7494 | * |
||
| 7495 | * @return Array the route list |
||
| 7496 | * |
||
| 7497 | */ |
||
| 7498 | public function countAllRoutesByIdent($ident, $filters = array()) |
||
| 7531 | |||
| 7532 | |||
| 7533 | /** |
||
| 7534 | * Gets all route combinations based on an manufacturer |
||
| 7535 | * |
||
| 7536 | * @return Array the route list |
||
| 7537 | * |
||
| 7538 | */ |
||
| 7539 | public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array()) |
||
| 7572 | |||
| 7573 | |||
| 7574 | |||
| 7575 | /** |
||
| 7576 | * Gets all route combinations with waypoints |
||
| 7577 | * |
||
| 7578 | * @return Array the route list |
||
| 7579 | * |
||
| 7580 | */ |
||
| 7581 | public function countAllRoutesWithWaypoints($filters = array()) |
||
| 7615 | |||
| 7616 | /** |
||
| 7617 | * Gets all callsigns that have flown over |
||
| 7618 | * |
||
| 7619 | * @return Array the callsign list |
||
| 7620 | * |
||
| 7621 | */ |
||
| 7622 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
||
| 7657 | |||
| 7658 | /** |
||
| 7659 | * Gets all callsigns that have flown over |
||
| 7660 | * |
||
| 7661 | * @return Array the callsign list |
||
| 7662 | * |
||
| 7663 | */ |
||
| 7664 | public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
||
| 7699 | |||
| 7700 | |||
| 7701 | |||
| 7702 | |||
| 7703 | /** |
||
| 7704 | * Counts all dates |
||
| 7705 | * |
||
| 7706 | * @return Array the date list |
||
| 7707 | * |
||
| 7708 | */ |
||
| 7709 | public function countAllDates($filters = array()) |
||
| 7751 | |||
| 7752 | /** |
||
| 7753 | * Counts all dates |
||
| 7754 | * |
||
| 7755 | * @return Array the date list |
||
| 7756 | * |
||
| 7757 | */ |
||
| 7758 | public function countAllDatesByAirlines($filters = array()) |
||
| 7800 | |||
| 7801 | /** |
||
| 7802 | * Counts all dates during the last 7 days |
||
| 7803 | * |
||
| 7804 | * @return Array the date list |
||
| 7805 | * |
||
| 7806 | */ |
||
| 7807 | public function countAllDatesLast7Days($filters = array()) |
||
| 7846 | |||
| 7847 | /** |
||
| 7848 | * Counts all dates during the last month |
||
| 7849 | * |
||
| 7850 | * @return Array the date list |
||
| 7851 | * |
||
| 7852 | */ |
||
| 7853 | public function countAllDatesLastMonth($filters = array()) |
||
| 7892 | |||
| 7893 | |||
| 7894 | /** |
||
| 7895 | * Counts all dates during the last month |
||
| 7896 | * |
||
| 7897 | * @return Array the date list |
||
| 7898 | * |
||
| 7899 | */ |
||
| 7900 | public function countAllDatesLastMonthByAirlines($filters = array()) |
||
| 7941 | |||
| 7942 | |||
| 7943 | /** |
||
| 7944 | * Counts all month |
||
| 7945 | * |
||
| 7946 | * @return Array the month list |
||
| 7947 | * |
||
| 7948 | */ |
||
| 7949 | public function countAllMonths($filters = array()) |
||
| 7988 | |||
| 7989 | /** |
||
| 7990 | * Counts all month |
||
| 7991 | * |
||
| 7992 | * @return Array the month list |
||
| 7993 | * |
||
| 7994 | */ |
||
| 7995 | public function countAllMonthsByAirlines($filters = array()) |
||
| 8037 | |||
| 8038 | /** |
||
| 8039 | * Counts all military month |
||
| 8040 | * |
||
| 8041 | * @return Array the month list |
||
| 8042 | * |
||
| 8043 | */ |
||
| 8044 | public function countAllMilitaryMonths($filters = array()) |
||
| 8082 | |||
| 8083 | /** |
||
| 8084 | * Counts all month owners |
||
| 8085 | * |
||
| 8086 | * @return Array the month list |
||
| 8087 | * |
||
| 8088 | */ |
||
| 8089 | public function countAllMonthsOwners($filters = array()) |
||
| 8128 | |||
| 8129 | /** |
||
| 8130 | * Counts all month owners |
||
| 8131 | * |
||
| 8132 | * @return Array the month list |
||
| 8133 | * |
||
| 8134 | */ |
||
| 8135 | public function countAllMonthsOwnersByAirlines($filters = array()) |
||
| 8175 | |||
| 8176 | /** |
||
| 8177 | * Counts all month pilot |
||
| 8178 | * |
||
| 8179 | * @return Array the month list |
||
| 8180 | * |
||
| 8181 | */ |
||
| 8182 | public function countAllMonthsPilots($filters = array()) |
||
| 8221 | |||
| 8222 | /** |
||
| 8223 | * Counts all month pilot |
||
| 8224 | * |
||
| 8225 | * @return Array the month list |
||
| 8226 | * |
||
| 8227 | */ |
||
| 8228 | public function countAllMonthsPilotsByAirlines($filters = array()) |
||
| 8268 | |||
| 8269 | /** |
||
| 8270 | * Counts all month airline |
||
| 8271 | * |
||
| 8272 | * @return Array the month list |
||
| 8273 | * |
||
| 8274 | */ |
||
| 8275 | public function countAllMonthsAirlines($filters = array()) |
||
| 8314 | |||
| 8315 | /** |
||
| 8316 | * Counts all month aircraft |
||
| 8317 | * |
||
| 8318 | * @return Array the month list |
||
| 8319 | * |
||
| 8320 | */ |
||
| 8321 | public function countAllMonthsAircrafts($filters = array()) |
||
| 8360 | |||
| 8361 | |||
| 8362 | /** |
||
| 8363 | * Counts all month aircraft |
||
| 8364 | * |
||
| 8365 | * @return Array the month list |
||
| 8366 | * |
||
| 8367 | */ |
||
| 8368 | public function countAllMonthsAircraftsByAirlines($filters = array()) |
||
| 8408 | |||
| 8409 | /** |
||
| 8410 | * Counts all month real arrival |
||
| 8411 | * |
||
| 8412 | * @return Array the month list |
||
| 8413 | * |
||
| 8414 | */ |
||
| 8415 | public function countAllMonthsRealArrivals($filters = array()) |
||
| 8454 | |||
| 8455 | |||
| 8456 | /** |
||
| 8457 | * Counts all month real arrival |
||
| 8458 | * |
||
| 8459 | * @return Array the month list |
||
| 8460 | * |
||
| 8461 | */ |
||
| 8462 | public function countAllMonthsRealArrivalsByAirlines($filters = array()) |
||
| 8502 | |||
| 8503 | |||
| 8504 | /** |
||
| 8505 | * Counts all dates during the last year |
||
| 8506 | * |
||
| 8507 | * @return Array the date list |
||
| 8508 | * |
||
| 8509 | */ |
||
| 8510 | public function countAllMonthsLastYear($filters) |
||
| 8550 | |||
| 8551 | |||
| 8552 | |||
| 8553 | /** |
||
| 8554 | * Counts all hours |
||
| 8555 | * |
||
| 8556 | * @return Array the hour list |
||
| 8557 | * |
||
| 8558 | */ |
||
| 8559 | public function countAllHours($orderby,$filters = array()) |
||
| 8617 | |||
| 8618 | /** |
||
| 8619 | * Counts all hours |
||
| 8620 | * |
||
| 8621 | * @return Array the hour list |
||
| 8622 | * |
||
| 8623 | */ |
||
| 8624 | public function countAllHoursByAirlines($orderby, $filters = array()) |
||
| 8682 | |||
| 8683 | |||
| 8684 | |||
| 8685 | /** |
||
| 8686 | * Counts all hours by airline |
||
| 8687 | * |
||
| 8688 | * @return Array the hour list |
||
| 8689 | * |
||
| 8690 | */ |
||
| 8691 | public function countAllHoursByAirline($airline_icao, $filters = array()) |
||
| 8731 | |||
| 8732 | |||
| 8733 | |||
| 8734 | |||
| 8735 | /** |
||
| 8736 | * Counts all hours by aircraft |
||
| 8737 | * |
||
| 8738 | * @return Array the hour list |
||
| 8739 | * |
||
| 8740 | */ |
||
| 8741 | public function countAllHoursByAircraft($aircraft_icao, $filters = array()) |
||
| 8780 | |||
| 8781 | |||
| 8782 | /** |
||
| 8783 | * Counts all hours by aircraft registration |
||
| 8784 | * |
||
| 8785 | * @return Array the hour list |
||
| 8786 | * |
||
| 8787 | */ |
||
| 8788 | public function countAllHoursByRegistration($registration, $filters = array()) |
||
| 8827 | |||
| 8828 | |||
| 8829 | /** |
||
| 8830 | * Counts all hours by airport |
||
| 8831 | * |
||
| 8832 | * @return Array the hour list |
||
| 8833 | * |
||
| 8834 | */ |
||
| 8835 | public function countAllHoursByAirport($airport_icao, $filters = array()) |
||
| 8874 | |||
| 8875 | |||
| 8876 | |||
| 8877 | /** |
||
| 8878 | * Counts all hours by manufacturer |
||
| 8879 | * |
||
| 8880 | * @return Array the hour list |
||
| 8881 | * |
||
| 8882 | */ |
||
| 8883 | public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array()) |
||
| 8922 | |||
| 8923 | |||
| 8924 | |||
| 8925 | /** |
||
| 8926 | * Counts all hours by date |
||
| 8927 | * |
||
| 8928 | * @return Array the hour list |
||
| 8929 | * |
||
| 8930 | */ |
||
| 8931 | public function countAllHoursByDate($date, $filters = array()) |
||
| 8970 | |||
| 8971 | |||
| 8972 | |||
| 8973 | /** |
||
| 8974 | * Counts all hours by a ident/callsign |
||
| 8975 | * |
||
| 8976 | * @return Array the hour list |
||
| 8977 | * |
||
| 8978 | */ |
||
| 8979 | public function countAllHoursByIdent($ident, $filters = array()) |
||
| 9019 | |||
| 9020 | |||
| 9021 | |||
| 9022 | /** |
||
| 9023 | * Counts all hours by route |
||
| 9024 | * |
||
| 9025 | * @return Array the hour list |
||
| 9026 | * |
||
| 9027 | */ |
||
| 9028 | public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array()) |
||
| 9068 | |||
| 9069 | |||
| 9070 | /** |
||
| 9071 | * Counts all hours by country |
||
| 9072 | * |
||
| 9073 | * @return Array the hour list |
||
| 9074 | * |
||
| 9075 | */ |
||
| 9076 | public function countAllHoursByCountry($country, $filters = array()) |
||
| 9115 | |||
| 9116 | |||
| 9117 | |||
| 9118 | |||
| 9119 | /** |
||
| 9120 | * Counts all aircraft that have flown over |
||
| 9121 | * |
||
| 9122 | * @return Integer the number of aircrafts |
||
| 9123 | * |
||
| 9124 | */ |
||
| 9125 | public function countOverallAircrafts($filters = array()) |
||
| 9134 | |||
| 9135 | /** |
||
| 9136 | * Counts all flight that really arrival |
||
| 9137 | * |
||
| 9138 | * @return Integer the number of aircrafts |
||
| 9139 | * |
||
| 9140 | */ |
||
| 9141 | public function countOverallArrival($filters = array()) |
||
| 9151 | |||
| 9152 | /** |
||
| 9153 | * Counts all pilots that have flown over |
||
| 9154 | * |
||
| 9155 | * @return Integer the number of pilots |
||
| 9156 | * |
||
| 9157 | */ |
||
| 9158 | public function countOverallPilots($filters = array()) |
||
| 9167 | |||
| 9168 | /** |
||
| 9169 | * Counts all owners that have flown over |
||
| 9170 | * |
||
| 9171 | * @return Integer the number of owners |
||
| 9172 | * |
||
| 9173 | */ |
||
| 9174 | public function countOverallOwners($filters = array()) |
||
| 9183 | |||
| 9184 | |||
| 9185 | /** |
||
| 9186 | * Counts all flights that have flown over |
||
| 9187 | * |
||
| 9188 | * @return Integer the number of flights |
||
| 9189 | * |
||
| 9190 | */ |
||
| 9191 | public function countOverallFlights($filters = array()) |
||
| 9201 | |||
| 9202 | /** |
||
| 9203 | * Counts all military flights that have flown over |
||
| 9204 | * |
||
| 9205 | * @return Integer the number of flights |
||
| 9206 | * |
||
| 9207 | */ |
||
| 9208 | public function countOverallMilitaryFlights($filters = array()) |
||
| 9218 | |||
| 9219 | |||
| 9220 | |||
| 9221 | /** |
||
| 9222 | * Counts all airlines that have flown over |
||
| 9223 | * |
||
| 9224 | * @return Integer the number of airlines |
||
| 9225 | * |
||
| 9226 | */ |
||
| 9227 | public function countOverallAirlines($filters = array()) |
||
| 9237 | |||
| 9238 | |||
| 9239 | /** |
||
| 9240 | * Counts all hours of today |
||
| 9241 | * |
||
| 9242 | * @return Array the hour list |
||
| 9243 | * |
||
| 9244 | */ |
||
| 9245 | public function countAllHoursFromToday($filters = array()) |
||
| 9282 | |||
| 9283 | /** |
||
| 9284 | * Gets all the spotter information based on calculated upcoming flights |
||
| 9285 | * |
||
| 9286 | * @return Array the spotter information |
||
| 9287 | * |
||
| 9288 | */ |
||
| 9289 | public function getUpcomingFlights($limit = '', $sort = '', $filters = array()) |
||
| 9361 | |||
| 9362 | |||
| 9363 | /** |
||
| 9364 | * Gets the Barrie Spotter ID based on the FlightAware ID |
||
| 9365 | * |
||
| 9366 | * @return Integer the Barrie Spotter ID |
||
| 9367 | q * |
||
| 9368 | */ |
||
| 9369 | public function getSpotterIDBasedOnFlightAwareID($flightaware_id) |
||
| 9386 | |||
| 9387 | |||
| 9388 | /** |
||
| 9389 | * Parses a date string |
||
| 9390 | * |
||
| 9391 | * @param String $dateString the date string |
||
| 9392 | * @param String $timezone the timezone of a user |
||
| 9393 | * @return Array the time information |
||
| 9394 | * |
||
| 9395 | */ |
||
| 9396 | public function parseDateString($dateString, $timezone = '') |
||
| 9426 | |||
| 9427 | |||
| 9428 | |||
| 9429 | |||
| 9430 | /** |
||
| 9431 | * Parses the direction degrees to working |
||
| 9432 | * |
||
| 9433 | * @param Float $direction the direction in degrees |
||
| 9434 | * @return Array the direction information |
||
| 9435 | * |
||
| 9436 | */ |
||
| 9437 | public function parseDirection($direction = 0) |
||
| 9512 | |||
| 9513 | |||
| 9514 | /** |
||
| 9515 | * Gets the aircraft registration |
||
| 9516 | * |
||
| 9517 | * @param String $flightaware_id the flight aware id |
||
| 9518 | * @return String the aircraft registration |
||
| 9519 | * |
||
| 9520 | */ |
||
| 9521 | |||
| 9522 | public function getAircraftRegistration($flightaware_id) |
||
| 9546 | |||
| 9547 | |||
| 9548 | /** |
||
| 9549 | * Gets the aircraft registration from ModeS |
||
| 9550 | * |
||
| 9551 | * @param String $aircraft_modes the flight ModeS in hex |
||
| 9552 | * @return String the aircraft registration |
||
| 9553 | * |
||
| 9554 | */ |
||
| 9555 | public function getAircraftRegistrationBymodeS($aircraft_modes) |
||
| 9572 | |||
| 9573 | /** |
||
| 9574 | * Gets the aircraft type from ModeS |
||
| 9575 | * |
||
| 9576 | * @param String $aircraft_modes the flight ModeS in hex |
||
| 9577 | * @return String the aircraft type |
||
| 9578 | * |
||
| 9579 | */ |
||
| 9580 | public function getAircraftTypeBymodeS($aircraft_modes) |
||
| 9597 | |||
| 9598 | /** |
||
| 9599 | * Gets Countrie from latitude/longitude |
||
| 9600 | * |
||
| 9601 | * @param Float $latitude latitute of the flight |
||
| 9602 | * @param Float $longitude longitute of the flight |
||
| 9603 | * @return String the countrie |
||
| 9604 | */ |
||
| 9605 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
||
| 9639 | |||
| 9640 | /** |
||
| 9641 | * converts the registration code using the country prefix |
||
| 9642 | * |
||
| 9643 | * @param String $registration the aircraft registration |
||
| 9644 | * @return String the aircraft registration |
||
| 9645 | * |
||
| 9646 | */ |
||
| 9647 | public function convertAircraftRegistration($registration) |
||
| 9696 | |||
| 9697 | /** |
||
| 9698 | * Country from the registration code |
||
| 9699 | * |
||
| 9700 | * @param String $registration the aircraft registration |
||
| 9701 | * @return String the country |
||
| 9702 | * |
||
| 9703 | */ |
||
| 9704 | public function countryFromAircraftRegistration($registration) |
||
| 9757 | |||
| 9758 | /** |
||
| 9759 | * Set a new highlight value for a flight |
||
| 9760 | * |
||
| 9761 | * @param String $flightaware_id flightaware_id from spotter_output table |
||
| 9762 | * @param String $highlight New highlight value |
||
| 9763 | */ |
||
| 9764 | public function setHighlightFlight($flightaware_id,$highlight) { |
||
| 9770 | |||
| 9771 | /** |
||
| 9772 | * Gets the short url from bit.ly |
||
| 9773 | * |
||
| 9774 | * @param String $url the full url |
||
| 9775 | * @return String the bit.ly url |
||
| 9776 | * |
||
| 9777 | */ |
||
| 9778 | public function getBitlyURL($url) |
||
| 9801 | |||
| 9802 | |||
| 9803 | public function getOrderBy() |
||
| 9810 | |||
| 9811 | /* |
||
| 9812 | public function importFromFlightAware() |
||
| 9813 | { |
||
| 9814 | global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore; |
||
| 9815 | $Spotter = new Spotter($this->db); |
||
| 9816 | $SpotterLive = new SpotterLive($this->db); |
||
| 9817 | $options = array( |
||
| 9818 | 'trace' => true, |
||
| 9819 | 'exceptions' => 0, |
||
| 9820 | 'login' => $globalFlightAwareUsername, |
||
| 9821 | 'password' => $globalFlightAwarePassword, |
||
| 9822 | ); |
||
| 9823 | $client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); |
||
| 9824 | $params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0'); |
||
| 9825 | $result = $client->SearchBirdseyeInFlight($params); |
||
| 9826 | $dataFound = false; |
||
| 9827 | $ignoreImport = false; |
||
| 9828 | if (isset($result->SearchBirdseyeInFlightResult)) |
||
| 9829 | { |
||
| 9830 | if (is_array($result->SearchBirdseyeInFlightResult->aircraft)) |
||
| 9831 | { |
||
| 9832 | foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft) |
||
| 9833 | { |
||
| 9834 | if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L ')) |
||
| 9835 | { |
||
| 9836 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 9837 | { |
||
| 9838 | if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
||
| 9839 | { |
||
| 9840 | $ignoreImport = true; |
||
| 9841 | } |
||
| 9842 | } |
||
| 9843 | if ($ignoreImport == false) |
||
| 9844 | { |
||
| 9845 | $flightaware_id = $aircraft->faFlightID; |
||
| 9846 | $ident = $aircraft->ident; |
||
| 9847 | $aircraft_type = $aircraft->type; |
||
| 9848 | $departure_airport = $aircraft->origin; |
||
| 9849 | $arrival_airport = $aircraft->destination; |
||
| 9850 | $latitude = $aircraft->latitude; |
||
| 9851 | $longitude = $aircraft->longitude; |
||
| 9852 | $waypoints = $aircraft->waypoints; |
||
| 9853 | $altitude = $aircraft->altitude; |
||
| 9854 | $heading = $aircraft->heading; |
||
| 9855 | $groundspeed = $aircraft->groundspeed; |
||
| 9856 | $dataFound = true; |
||
| 9857 | //gets the callsign from the last hour |
||
| 9858 | $last_hour_ident = $this->getIdentFromLastHour($ident); |
||
| 9859 | //change the departure/arrival airport to NA if its not available |
||
| 9860 | if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
||
| 9861 | if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
||
| 9862 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
||
| 9863 | if($last_hour_ident == "") |
||
| 9864 | { |
||
| 9865 | //adds the spotter data for the archive |
||
| 9866 | $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9867 | } |
||
| 9868 | |||
| 9869 | //adds the spotter LIVE data |
||
| 9870 | $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9871 | } |
||
| 9872 | } |
||
| 9873 | $ignoreImport = false; |
||
| 9874 | } |
||
| 9875 | } else { |
||
| 9876 | if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L ')) |
||
| 9877 | { |
||
| 9878 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 9879 | { |
||
| 9880 | foreach($globalAirportIgnore as $airportIgnore) |
||
| 9881 | { |
||
| 9882 | if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) |
||
| 9883 | { |
||
| 9884 | $ignoreImport = true; |
||
| 9885 | } |
||
| 9886 | } |
||
| 9887 | if ($ignoreImport == false) |
||
| 9888 | { |
||
| 9889 | $flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID; |
||
| 9890 | $ident = $result->SearchBirdseyeInFlightResult->aircraft->ident; |
||
| 9891 | $aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type; |
||
| 9892 | $departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin; |
||
| 9893 | $arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination; |
||
| 9894 | $latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude; |
||
| 9895 | $longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude; |
||
| 9896 | $waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints; |
||
| 9897 | $altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude; |
||
| 9898 | $heading = $result->SearchBirdseyeInFlightResult->aircraft->heading; |
||
| 9899 | $groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed; |
||
| 9900 | $dataFound = true; |
||
| 9901 | //gets the callsign from the last hour |
||
| 9902 | $last_hour_ident = $this->getIdentFromLastHour($ident); |
||
| 9903 | //change the departure/arrival airport to NA if its not available |
||
| 9904 | if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } |
||
| 9905 | if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } |
||
| 9906 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
||
| 9907 | if($last_hour_ident == "") |
||
| 9908 | { |
||
| 9909 | //adds the spotter data for the archive |
||
| 9910 | $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9911 | } |
||
| 9912 | //adds the spotter LIVE data |
||
| 9913 | $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
||
| 9914 | } |
||
| 9915 | $ignoreImport = false; |
||
| 9916 | } |
||
| 9917 | } |
||
| 9918 | } |
||
| 9919 | } |
||
| 9920 | } |
||
| 9921 | */ |
||
| 9922 | |||
| 9923 | // Update flights data when new data in DB |
||
| 9924 | public function updateFieldsFromOtherTables() |
||
| 10010 | |||
| 10011 | // Update arrival airports for data already in DB |
||
| 10012 | public function updateArrivalAirports() |
||
| 10053 | |||
| 10054 | public function closestAirports($origLat,$origLon,$dist = 10) { |
||
| 10075 | } |
||
| 10076 | /* |
||
| 10088 | ?> |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.