@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | $this->db = $Connection->db; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Get SQL query part for filter used |
|
| 13 | - * @param Array $filter the filter |
|
| 14 | - * @return Array the SQL part |
|
| 15 | - */ |
|
| 16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 11 | + /** |
|
| 12 | + * Get SQL query part for filter used |
|
| 13 | + * @param Array $filter the filter |
|
| 14 | + * @return Array the SQL part |
|
| 15 | + */ |
|
| 16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 18 | 18 | $filters = array(); |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -27,53 +27,53 @@ discard block |
||
| 27 | 27 | $filter_query_join = ''; |
| 28 | 28 | $filter_query_where = ''; |
| 29 | 29 | foreach($filters as $flt) { |
| 30 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 30 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 31 | 31 | if ($flt['airlines'][0] != '') { |
| 32 | - if (isset($flt['source'])) { |
|
| 32 | + if (isset($flt['source'])) { |
|
| 33 | 33 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
| 34 | - } else { |
|
| 34 | + } else { |
|
| 35 | 35 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | - } |
|
| 39 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 38 | + } |
|
| 39 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 40 | 40 | if (isset($flt['source'])) { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 42 | 42 | } else { |
| 43 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 43 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 44 | + } |
|
| 44 | 45 | } |
| 45 | - } |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 48 | - if ($filter['airlines'][0] != '') { |
|
| 48 | + if ($filter['airlines'][0] != '') { |
|
| 49 | 49 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 55 | 55 | } |
| 56 | 56 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 58 | 58 | } |
| 59 | 59 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 60 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 60 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 61 | 61 | } |
| 62 | 62 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 63 | - $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
| 63 | + $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
| 64 | 64 | } |
| 65 | 65 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 66 | - if ($filter_query_where == '') { |
|
| 66 | + if ($filter_query_where == '') { |
|
| 67 | 67 | $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 68 | - } else { |
|
| 68 | + } else { |
|
| 69 | 69 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | } |
| 72 | 72 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 73 | 73 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 74 | 74 | $filter_query = $filter_query_join.$filter_query_where; |
| 75 | 75 | return $filter_query; |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | // Spotter_archive |
| 79 | 79 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -104,44 +104,44 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Gets all the spotter information based on a particular callsign |
|
| 109 | - * |
|
| 110 | - * @return Array the spotter information |
|
| 111 | - * |
|
| 112 | - */ |
|
| 113 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 114 | - { |
|
| 107 | + /** |
|
| 108 | + * Gets all the spotter information based on a particular callsign |
|
| 109 | + * |
|
| 110 | + * @return Array the spotter information |
|
| 111 | + * |
|
| 112 | + */ |
|
| 113 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 114 | + { |
|
| 115 | 115 | $Spotter = new Spotter($this->db); |
| 116 | - date_default_timezone_set('UTC'); |
|
| 116 | + date_default_timezone_set('UTC'); |
|
| 117 | 117 | |
| 118 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 119 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 120 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 118 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 119 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 120 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 121 | 121 | |
| 122 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 122 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 123 | 123 | |
| 124 | - return $spotter_array; |
|
| 125 | - } |
|
| 124 | + return $spotter_array; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Gets last the spotter information based on a particular id |
|
| 130 | - * |
|
| 131 | - * @return Array the spotter information |
|
| 132 | - * |
|
| 133 | - */ |
|
| 134 | - public function getLastArchiveSpotterDataById($id) |
|
| 135 | - { |
|
| 136 | - $Spotter = new Spotter($this->db); |
|
| 137 | - date_default_timezone_set('UTC'); |
|
| 138 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 139 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 140 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 141 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 128 | + /** |
|
| 129 | + * Gets last the spotter information based on a particular id |
|
| 130 | + * |
|
| 131 | + * @return Array the spotter information |
|
| 132 | + * |
|
| 133 | + */ |
|
| 134 | + public function getLastArchiveSpotterDataById($id) |
|
| 135 | + { |
|
| 136 | + $Spotter = new Spotter($this->db); |
|
| 137 | + date_default_timezone_set('UTC'); |
|
| 138 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 139 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 140 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 141 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 142 | 142 | |
| 143 | 143 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 144 | - /* |
|
| 144 | + /* |
|
| 145 | 145 | try { |
| 146 | 146 | $Connection = new Connection(); |
| 147 | 147 | $sth = Connection->$db->prepare($query); |
@@ -151,232 +151,232 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 153 | 153 | */ |
| 154 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 155 | - |
|
| 156 | - return $spotter_array; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Gets all the spotter information based on a particular id |
|
| 161 | - * |
|
| 162 | - * @return Array the spotter information |
|
| 163 | - * |
|
| 164 | - */ |
|
| 165 | - public function getAllArchiveSpotterDataById($id) |
|
| 166 | - { |
|
| 167 | - date_default_timezone_set('UTC'); |
|
| 168 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 169 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 154 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 155 | + |
|
| 156 | + return $spotter_array; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Gets all the spotter information based on a particular id |
|
| 161 | + * |
|
| 162 | + * @return Array the spotter information |
|
| 163 | + * |
|
| 164 | + */ |
|
| 165 | + public function getAllArchiveSpotterDataById($id) |
|
| 166 | + { |
|
| 167 | + date_default_timezone_set('UTC'); |
|
| 168 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 169 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 170 | 170 | |
| 171 | 171 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 172 | 172 | |
| 173 | - try { |
|
| 174 | - $sth = $this->db->prepare($query); |
|
| 175 | - $sth->execute(array(':id' => $id)); |
|
| 176 | - } catch(PDOException $e) { |
|
| 177 | - echo $e->getMessage(); |
|
| 178 | - die; |
|
| 179 | - } |
|
| 180 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 181 | - |
|
| 182 | - return $spotter_array; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Gets coordinate & time spotter information based on a particular id |
|
| 187 | - * |
|
| 188 | - * @return Array the spotter information |
|
| 189 | - * |
|
| 190 | - */ |
|
| 191 | - public function getCoordArchiveSpotterDataById($id) |
|
| 192 | - { |
|
| 193 | - date_default_timezone_set('UTC'); |
|
| 194 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 195 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 173 | + try { |
|
| 174 | + $sth = $this->db->prepare($query); |
|
| 175 | + $sth->execute(array(':id' => $id)); |
|
| 176 | + } catch(PDOException $e) { |
|
| 177 | + echo $e->getMessage(); |
|
| 178 | + die; |
|
| 179 | + } |
|
| 180 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 181 | + |
|
| 182 | + return $spotter_array; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Gets coordinate & time spotter information based on a particular id |
|
| 187 | + * |
|
| 188 | + * @return Array the spotter information |
|
| 189 | + * |
|
| 190 | + */ |
|
| 191 | + public function getCoordArchiveSpotterDataById($id) |
|
| 192 | + { |
|
| 193 | + date_default_timezone_set('UTC'); |
|
| 194 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 195 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 196 | 196 | |
| 197 | 197 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 198 | 198 | |
| 199 | - try { |
|
| 200 | - $sth = $this->db->prepare($query); |
|
| 201 | - $sth->execute(array(':id' => $id)); |
|
| 202 | - } catch(PDOException $e) { |
|
| 203 | - echo $e->getMessage(); |
|
| 204 | - die; |
|
| 205 | - } |
|
| 206 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 199 | + try { |
|
| 200 | + $sth = $this->db->prepare($query); |
|
| 201 | + $sth->execute(array(':id' => $id)); |
|
| 202 | + } catch(PDOException $e) { |
|
| 203 | + echo $e->getMessage(); |
|
| 204 | + die; |
|
| 205 | + } |
|
| 206 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 207 | 207 | |
| 208 | - return $spotter_array; |
|
| 209 | - } |
|
| 208 | + return $spotter_array; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * Gets altitude information based on a particular callsign |
|
| 214 | - * |
|
| 215 | - * @return Array the spotter information |
|
| 216 | - * |
|
| 217 | - */ |
|
| 218 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 219 | - { |
|
| 212 | + /** |
|
| 213 | + * Gets altitude information based on a particular callsign |
|
| 214 | + * |
|
| 215 | + * @return Array the spotter information |
|
| 216 | + * |
|
| 217 | + */ |
|
| 218 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 219 | + { |
|
| 220 | 220 | |
| 221 | - date_default_timezone_set('UTC'); |
|
| 221 | + date_default_timezone_set('UTC'); |
|
| 222 | 222 | |
| 223 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 224 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 223 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 224 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 225 | 225 | |
| 226 | - try { |
|
| 227 | - $sth = $this->db->prepare($query); |
|
| 228 | - $sth->execute(array(':ident' => $ident)); |
|
| 229 | - } catch(PDOException $e) { |
|
| 230 | - echo $e->getMessage(); |
|
| 231 | - die; |
|
| 232 | - } |
|
| 233 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 226 | + try { |
|
| 227 | + $sth = $this->db->prepare($query); |
|
| 228 | + $sth->execute(array(':ident' => $ident)); |
|
| 229 | + } catch(PDOException $e) { |
|
| 230 | + echo $e->getMessage(); |
|
| 231 | + die; |
|
| 232 | + } |
|
| 233 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 234 | 234 | |
| 235 | - return $spotter_array; |
|
| 236 | - } |
|
| 235 | + return $spotter_array; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Gets altitude information based on a particular id |
|
| 240 | - * |
|
| 241 | - * @return Array the spotter information |
|
| 242 | - * |
|
| 243 | - */ |
|
| 244 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 245 | - { |
|
| 238 | + /** |
|
| 239 | + * Gets altitude information based on a particular id |
|
| 240 | + * |
|
| 241 | + * @return Array the spotter information |
|
| 242 | + * |
|
| 243 | + */ |
|
| 244 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 245 | + { |
|
| 246 | 246 | |
| 247 | - date_default_timezone_set('UTC'); |
|
| 247 | + date_default_timezone_set('UTC'); |
|
| 248 | 248 | |
| 249 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 250 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 249 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 250 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 251 | 251 | |
| 252 | - try { |
|
| 253 | - $sth = $this->db->prepare($query); |
|
| 254 | - $sth->execute(array(':id' => $id)); |
|
| 255 | - } catch(PDOException $e) { |
|
| 256 | - echo $e->getMessage(); |
|
| 257 | - die; |
|
| 258 | - } |
|
| 259 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 252 | + try { |
|
| 253 | + $sth = $this->db->prepare($query); |
|
| 254 | + $sth->execute(array(':id' => $id)); |
|
| 255 | + } catch(PDOException $e) { |
|
| 256 | + echo $e->getMessage(); |
|
| 257 | + die; |
|
| 258 | + } |
|
| 259 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 260 | 260 | |
| 261 | - return $spotter_array; |
|
| 262 | - } |
|
| 261 | + return $spotter_array; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * Gets altitude & speed information based on a particular id |
|
| 266 | - * |
|
| 267 | - * @return Array the spotter information |
|
| 268 | - * |
|
| 269 | - */ |
|
| 270 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 271 | - { |
|
| 264 | + /** |
|
| 265 | + * Gets altitude & speed information based on a particular id |
|
| 266 | + * |
|
| 267 | + * @return Array the spotter information |
|
| 268 | + * |
|
| 269 | + */ |
|
| 270 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 271 | + { |
|
| 272 | 272 | |
| 273 | - date_default_timezone_set('UTC'); |
|
| 273 | + date_default_timezone_set('UTC'); |
|
| 274 | 274 | |
| 275 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 276 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 275 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 276 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 277 | 277 | |
| 278 | - try { |
|
| 279 | - $sth = $this->db->prepare($query); |
|
| 280 | - $sth->execute(array(':id' => $id)); |
|
| 281 | - } catch(PDOException $e) { |
|
| 282 | - echo $e->getMessage(); |
|
| 283 | - die; |
|
| 284 | - } |
|
| 285 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 278 | + try { |
|
| 279 | + $sth = $this->db->prepare($query); |
|
| 280 | + $sth->execute(array(':id' => $id)); |
|
| 281 | + } catch(PDOException $e) { |
|
| 282 | + echo $e->getMessage(); |
|
| 283 | + die; |
|
| 284 | + } |
|
| 285 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 286 | 286 | |
| 287 | - return $spotter_array; |
|
| 288 | - } |
|
| 287 | + return $spotter_array; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * Gets altitude information based on a particular callsign |
|
| 293 | - * |
|
| 294 | - * @return Array the spotter information |
|
| 295 | - * |
|
| 296 | - */ |
|
| 297 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 298 | - { |
|
| 291 | + /** |
|
| 292 | + * Gets altitude information based on a particular callsign |
|
| 293 | + * |
|
| 294 | + * @return Array the spotter information |
|
| 295 | + * |
|
| 296 | + */ |
|
| 297 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 298 | + { |
|
| 299 | 299 | |
| 300 | - date_default_timezone_set('UTC'); |
|
| 300 | + date_default_timezone_set('UTC'); |
|
| 301 | 301 | |
| 302 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 303 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 302 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 303 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 304 | 304 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 305 | 305 | |
| 306 | - try { |
|
| 307 | - $sth = $this->db->prepare($query); |
|
| 308 | - $sth->execute(array(':ident' => $ident)); |
|
| 309 | - } catch(PDOException $e) { |
|
| 310 | - echo $e->getMessage(); |
|
| 311 | - die; |
|
| 312 | - } |
|
| 313 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 306 | + try { |
|
| 307 | + $sth = $this->db->prepare($query); |
|
| 308 | + $sth->execute(array(':ident' => $ident)); |
|
| 309 | + } catch(PDOException $e) { |
|
| 310 | + echo $e->getMessage(); |
|
| 311 | + die; |
|
| 312 | + } |
|
| 313 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 314 | 314 | |
| 315 | - return $spotter_array; |
|
| 316 | - } |
|
| 315 | + return $spotter_array; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | |
| 320 | - /** |
|
| 321 | - * Gets all the archive spotter information |
|
| 322 | - * |
|
| 323 | - * @return Array the spotter information |
|
| 324 | - * |
|
| 325 | - */ |
|
| 326 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 327 | - { |
|
| 328 | - $Spotter = new Spotter($this->db); |
|
| 329 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 330 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 320 | + /** |
|
| 321 | + * Gets all the archive spotter information |
|
| 322 | + * |
|
| 323 | + * @return Array the spotter information |
|
| 324 | + * |
|
| 325 | + */ |
|
| 326 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 327 | + { |
|
| 328 | + $Spotter = new Spotter($this->db); |
|
| 329 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 330 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 331 | 331 | |
| 332 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 332 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 333 | 333 | |
| 334 | - return $spotter_array; |
|
| 335 | - } |
|
| 334 | + return $spotter_array; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - public function deleteSpotterArchiveTrackData() |
|
| 338 | - { |
|
| 337 | + public function deleteSpotterArchiveTrackData() |
|
| 338 | + { |
|
| 339 | 339 | global $globalArchiveKeepTrackMonths; |
| 340 | - date_default_timezone_set('UTC'); |
|
| 340 | + date_default_timezone_set('UTC'); |
|
| 341 | 341 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 342 | - try { |
|
| 343 | - $sth = $this->db->prepare($query); |
|
| 344 | - $sth->execute(); |
|
| 345 | - } catch(PDOException $e) { |
|
| 346 | - echo $e->getMessage(); |
|
| 347 | - die; |
|
| 348 | - } |
|
| 342 | + try { |
|
| 343 | + $sth = $this->db->prepare($query); |
|
| 344 | + $sth->execute(); |
|
| 345 | + } catch(PDOException $e) { |
|
| 346 | + echo $e->getMessage(); |
|
| 347 | + die; |
|
| 348 | + } |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | - * Gets Minimal Live Spotter data |
|
| 353 | - * |
|
| 354 | - * @return Array the spotter information |
|
| 355 | - * |
|
| 356 | - */ |
|
| 357 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 358 | - { |
|
| 359 | - global $globalDBdriver, $globalLiveInterval; |
|
| 360 | - date_default_timezone_set('UTC'); |
|
| 361 | - |
|
| 362 | - $filter_query = ''; |
|
| 363 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 364 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 365 | - } |
|
| 366 | - // Use spotter_output also ? |
|
| 367 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 368 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 369 | - } |
|
| 370 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 371 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 372 | - } |
|
| 373 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 374 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 378 | - if ($globalDBdriver == 'mysql') { |
|
| 379 | - /* |
|
| 352 | + * Gets Minimal Live Spotter data |
|
| 353 | + * |
|
| 354 | + * @return Array the spotter information |
|
| 355 | + * |
|
| 356 | + */ |
|
| 357 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 358 | + { |
|
| 359 | + global $globalDBdriver, $globalLiveInterval; |
|
| 360 | + date_default_timezone_set('UTC'); |
|
| 361 | + |
|
| 362 | + $filter_query = ''; |
|
| 363 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 364 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 365 | + } |
|
| 366 | + // Use spotter_output also ? |
|
| 367 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 368 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 369 | + } |
|
| 370 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 371 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 372 | + } |
|
| 373 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 374 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 378 | + if ($globalDBdriver == 'mysql') { |
|
| 379 | + /* |
|
| 380 | 380 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 381 | 381 | FROM spotter_archive |
| 382 | 382 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -395,56 +395,56 @@ discard block |
||
| 395 | 395 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 396 | 396 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 397 | 397 | '.$filter_query.' ORDER BY flightaware_id'; |
| 398 | - } else { |
|
| 399 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 400 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 398 | + } else { |
|
| 399 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 400 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 401 | 401 | FROM spotter_archive |
| 402 | 402 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 403 | 403 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 404 | 404 | '.$filter_query.' ORDER BY flightaware_id'; |
| 405 | - } |
|
| 406 | - //echo $query; |
|
| 407 | - try { |
|
| 408 | - $sth = $this->db->prepare($query); |
|
| 409 | - $sth->execute(); |
|
| 410 | - } catch(PDOException $e) { |
|
| 411 | - echo $e->getMessage(); |
|
| 412 | - die; |
|
| 413 | - } |
|
| 414 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 415 | - |
|
| 416 | - return $spotter_array; |
|
| 417 | - } |
|
| 405 | + } |
|
| 406 | + //echo $query; |
|
| 407 | + try { |
|
| 408 | + $sth = $this->db->prepare($query); |
|
| 409 | + $sth->execute(); |
|
| 410 | + } catch(PDOException $e) { |
|
| 411 | + echo $e->getMessage(); |
|
| 412 | + die; |
|
| 413 | + } |
|
| 414 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 415 | + |
|
| 416 | + return $spotter_array; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | - * Gets Minimal Live Spotter data |
|
| 421 | - * |
|
| 422 | - * @return Array the spotter information |
|
| 423 | - * |
|
| 424 | - */ |
|
| 425 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 426 | - { |
|
| 427 | - global $globalDBdriver, $globalLiveInterval; |
|
| 428 | - date_default_timezone_set('UTC'); |
|
| 429 | - |
|
| 430 | - $filter_query = ''; |
|
| 431 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 432 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 433 | - } |
|
| 434 | - // Should use spotter_output also ? |
|
| 435 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 436 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 437 | - } |
|
| 438 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 439 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 440 | - } |
|
| 441 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 442 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 446 | - if ($globalDBdriver == 'mysql') { |
|
| 447 | - /* |
|
| 420 | + * Gets Minimal Live Spotter data |
|
| 421 | + * |
|
| 422 | + * @return Array the spotter information |
|
| 423 | + * |
|
| 424 | + */ |
|
| 425 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 426 | + { |
|
| 427 | + global $globalDBdriver, $globalLiveInterval; |
|
| 428 | + date_default_timezone_set('UTC'); |
|
| 429 | + |
|
| 430 | + $filter_query = ''; |
|
| 431 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 432 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 433 | + } |
|
| 434 | + // Should use spotter_output also ? |
|
| 435 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 436 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 437 | + } |
|
| 438 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 439 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 440 | + } |
|
| 441 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 442 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 446 | + if ($globalDBdriver == 'mysql') { |
|
| 447 | + /* |
|
| 448 | 448 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 449 | 449 | FROM spotter_archive |
| 450 | 450 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -455,95 +455,95 @@ discard block |
||
| 455 | 455 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 456 | 456 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 457 | 457 | |
| 458 | - } else { |
|
| 459 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 460 | - /* |
|
| 458 | + } else { |
|
| 459 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 460 | + /* |
|
| 461 | 461 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
| 462 | 462 | FROM spotter_archive_output |
| 463 | 463 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 464 | 464 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 465 | 465 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 466 | 466 | */ |
| 467 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 467 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 468 | 468 | FROM spotter_archive_output |
| 469 | 469 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 470 | 470 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 471 | 471 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 472 | 472 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 473 | 473 | |
| 474 | - } |
|
| 475 | - //echo $query; |
|
| 476 | - try { |
|
| 477 | - $sth = $this->db->prepare($query); |
|
| 478 | - $sth->execute(); |
|
| 479 | - } catch(PDOException $e) { |
|
| 480 | - echo $e->getMessage(); |
|
| 481 | - die; |
|
| 482 | - } |
|
| 483 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 484 | - |
|
| 485 | - return $spotter_array; |
|
| 486 | - } |
|
| 474 | + } |
|
| 475 | + //echo $query; |
|
| 476 | + try { |
|
| 477 | + $sth = $this->db->prepare($query); |
|
| 478 | + $sth->execute(); |
|
| 479 | + } catch(PDOException $e) { |
|
| 480 | + echo $e->getMessage(); |
|
| 481 | + die; |
|
| 482 | + } |
|
| 483 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 484 | + |
|
| 485 | + return $spotter_array; |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | 488 | /** |
| 489 | - * Gets count Live Spotter data |
|
| 490 | - * |
|
| 491 | - * @return Array the spotter information |
|
| 492 | - * |
|
| 493 | - */ |
|
| 494 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 495 | - { |
|
| 496 | - global $globalDBdriver, $globalLiveInterval; |
|
| 497 | - date_default_timezone_set('UTC'); |
|
| 498 | - |
|
| 499 | - $filter_query = ''; |
|
| 500 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 501 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 502 | - } |
|
| 503 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 504 | - $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_archive.flightaware_id "; |
|
| 505 | - } |
|
| 506 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 507 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 508 | - } |
|
| 509 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 510 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 514 | - if ($globalDBdriver == 'mysql') { |
|
| 489 | + * Gets count Live Spotter data |
|
| 490 | + * |
|
| 491 | + * @return Array the spotter information |
|
| 492 | + * |
|
| 493 | + */ |
|
| 494 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 495 | + { |
|
| 496 | + global $globalDBdriver, $globalLiveInterval; |
|
| 497 | + date_default_timezone_set('UTC'); |
|
| 498 | + |
|
| 499 | + $filter_query = ''; |
|
| 500 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 501 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 502 | + } |
|
| 503 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 504 | + $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_archive.flightaware_id "; |
|
| 505 | + } |
|
| 506 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 507 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 508 | + } |
|
| 509 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 510 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 514 | + if ($globalDBdriver == 'mysql') { |
|
| 515 | 515 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 516 | 516 | FROM spotter_archive l |
| 517 | 517 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 518 | - } else { |
|
| 518 | + } else { |
|
| 519 | 519 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 520 | - } |
|
| 521 | - //echo $query; |
|
| 522 | - try { |
|
| 523 | - $sth = $this->db->prepare($query); |
|
| 524 | - $sth->execute(); |
|
| 525 | - } catch(PDOException $e) { |
|
| 526 | - echo $e->getMessage(); |
|
| 527 | - die; |
|
| 528 | - } |
|
| 520 | + } |
|
| 521 | + //echo $query; |
|
| 522 | + try { |
|
| 523 | + $sth = $this->db->prepare($query); |
|
| 524 | + $sth->execute(); |
|
| 525 | + } catch(PDOException $e) { |
|
| 526 | + echo $e->getMessage(); |
|
| 527 | + die; |
|
| 528 | + } |
|
| 529 | 529 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 530 | 530 | $sth->closeCursor(); |
| 531 | - return $result['nb']; |
|
| 531 | + return $result['nb']; |
|
| 532 | 532 | |
| 533 | - } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | |
| 536 | 536 | |
| 537 | 537 | // Spotter_Archive_output |
| 538 | 538 | |
| 539 | - /** |
|
| 540 | - * Gets all the spotter information |
|
| 541 | - * |
|
| 542 | - * @return Array the spotter information |
|
| 543 | - * |
|
| 544 | - */ |
|
| 545 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 546 | - { |
|
| 539 | + /** |
|
| 540 | + * Gets all the spotter information |
|
| 541 | + * |
|
| 542 | + * @return Array the spotter information |
|
| 543 | + * |
|
| 544 | + */ |
|
| 545 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 546 | + { |
|
| 547 | 547 | global $globalTimezone, $globalDBdriver; |
| 548 | 548 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 549 | 549 | $Translation = new Translation(); |
@@ -557,159 +557,159 @@ discard block |
||
| 557 | 557 | $filter_query = $this->getFilter($filters); |
| 558 | 558 | if ($q != "") |
| 559 | 559 | { |
| 560 | - if (!is_string($q)) |
|
| 561 | - { |
|
| 560 | + if (!is_string($q)) |
|
| 561 | + { |
|
| 562 | 562 | return false; |
| 563 | - } else { |
|
| 563 | + } else { |
|
| 564 | 564 | |
| 565 | 565 | $q_array = explode(" ", $q); |
| 566 | 566 | |
| 567 | 567 | foreach ($q_array as $q_item){ |
| 568 | - $additional_query .= " AND ("; |
|
| 569 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 570 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 571 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 572 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 573 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 574 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 575 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 576 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 577 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 578 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 579 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 580 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 581 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 582 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 583 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 584 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 585 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 586 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 587 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 588 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 589 | - $translate = $Translation->ident2icao($q_item); |
|
| 590 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 591 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 592 | - $additional_query .= ")"; |
|
| 568 | + $additional_query .= " AND ("; |
|
| 569 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 570 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 571 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 572 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 573 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 574 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 575 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 576 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 577 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 578 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 579 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 580 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 581 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 582 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 583 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 584 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 585 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 586 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 587 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 588 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 589 | + $translate = $Translation->ident2icao($q_item); |
|
| 590 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 591 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 592 | + $additional_query .= ")"; |
|
| 593 | + } |
|
| 593 | 594 | } |
| 594 | - } |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | if ($registration != "") |
| 598 | 598 | { |
| 599 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 600 | - if (!is_string($registration)) |
|
| 601 | - { |
|
| 599 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 600 | + if (!is_string($registration)) |
|
| 601 | + { |
|
| 602 | 602 | return false; |
| 603 | - } else { |
|
| 603 | + } else { |
|
| 604 | 604 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 605 | - } |
|
| 605 | + } |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | if ($aircraft_icao != "") |
| 609 | 609 | { |
| 610 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 611 | - if (!is_string($aircraft_icao)) |
|
| 612 | - { |
|
| 610 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 611 | + if (!is_string($aircraft_icao)) |
|
| 612 | + { |
|
| 613 | 613 | return false; |
| 614 | - } else { |
|
| 614 | + } else { |
|
| 615 | 615 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 616 | - } |
|
| 616 | + } |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | if ($aircraft_manufacturer != "") |
| 620 | 620 | { |
| 621 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 622 | - if (!is_string($aircraft_manufacturer)) |
|
| 623 | - { |
|
| 621 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 622 | + if (!is_string($aircraft_manufacturer)) |
|
| 623 | + { |
|
| 624 | 624 | return false; |
| 625 | - } else { |
|
| 625 | + } else { |
|
| 626 | 626 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 627 | - } |
|
| 627 | + } |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | if ($highlights == "true") |
| 631 | 631 | { |
| 632 | - if (!is_string($highlights)) |
|
| 633 | - { |
|
| 632 | + if (!is_string($highlights)) |
|
| 633 | + { |
|
| 634 | 634 | return false; |
| 635 | - } else { |
|
| 635 | + } else { |
|
| 636 | 636 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 637 | - } |
|
| 637 | + } |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | if ($airline_icao != "") |
| 641 | 641 | { |
| 642 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 643 | - if (!is_string($airline_icao)) |
|
| 644 | - { |
|
| 642 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 643 | + if (!is_string($airline_icao)) |
|
| 644 | + { |
|
| 645 | 645 | return false; |
| 646 | - } else { |
|
| 646 | + } else { |
|
| 647 | 647 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 648 | - } |
|
| 648 | + } |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | if ($airline_country != "") |
| 652 | 652 | { |
| 653 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 654 | - if (!is_string($airline_country)) |
|
| 655 | - { |
|
| 653 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 654 | + if (!is_string($airline_country)) |
|
| 655 | + { |
|
| 656 | 656 | return false; |
| 657 | - } else { |
|
| 657 | + } else { |
|
| 658 | 658 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 659 | - } |
|
| 659 | + } |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | if ($airline_type != "") |
| 663 | 663 | { |
| 664 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 665 | - if (!is_string($airline_type)) |
|
| 666 | - { |
|
| 664 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 665 | + if (!is_string($airline_type)) |
|
| 666 | + { |
|
| 667 | 667 | return false; |
| 668 | - } else { |
|
| 668 | + } else { |
|
| 669 | 669 | if ($airline_type == "passenger") |
| 670 | 670 | { |
| 671 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 671 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 672 | 672 | } |
| 673 | 673 | if ($airline_type == "cargo") |
| 674 | 674 | { |
| 675 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 675 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 676 | 676 | } |
| 677 | 677 | if ($airline_type == "military") |
| 678 | 678 | { |
| 679 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 679 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 680 | + } |
|
| 680 | 681 | } |
| 681 | - } |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | if ($airport != "") |
| 685 | 685 | { |
| 686 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 687 | - if (!is_string($airport)) |
|
| 688 | - { |
|
| 686 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 687 | + if (!is_string($airport)) |
|
| 688 | + { |
|
| 689 | 689 | return false; |
| 690 | - } else { |
|
| 690 | + } else { |
|
| 691 | 691 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 692 | - } |
|
| 692 | + } |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | if ($airport_country != "") |
| 696 | 696 | { |
| 697 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 698 | - if (!is_string($airport_country)) |
|
| 699 | - { |
|
| 697 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 698 | + if (!is_string($airport_country)) |
|
| 699 | + { |
|
| 700 | 700 | return false; |
| 701 | - } else { |
|
| 701 | + } else { |
|
| 702 | 702 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 703 | - } |
|
| 703 | + } |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | if ($callsign != "") |
| 707 | 707 | { |
| 708 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 709 | - if (!is_string($callsign)) |
|
| 710 | - { |
|
| 708 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 709 | + if (!is_string($callsign)) |
|
| 710 | + { |
|
| 711 | 711 | return false; |
| 712 | - } else { |
|
| 712 | + } else { |
|
| 713 | 713 | $translate = $Translation->ident2icao($callsign); |
| 714 | 714 | if ($translate != $callsign) { |
| 715 | 715 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -717,99 +717,99 @@ discard block |
||
| 717 | 717 | } else { |
| 718 | 718 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 719 | 719 | } |
| 720 | - } |
|
| 720 | + } |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | if ($owner != "") |
| 724 | 724 | { |
| 725 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 726 | - if (!is_string($owner)) |
|
| 727 | - { |
|
| 725 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 726 | + if (!is_string($owner)) |
|
| 727 | + { |
|
| 728 | 728 | return false; |
| 729 | - } else { |
|
| 729 | + } else { |
|
| 730 | 730 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 731 | - } |
|
| 731 | + } |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | if ($pilot_name != "") |
| 735 | 735 | { |
| 736 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 737 | - if (!is_string($pilot_name)) |
|
| 738 | - { |
|
| 736 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 737 | + if (!is_string($pilot_name)) |
|
| 738 | + { |
|
| 739 | 739 | return false; |
| 740 | - } else { |
|
| 740 | + } else { |
|
| 741 | 741 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 742 | - } |
|
| 742 | + } |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if ($pilot_id != "") |
| 746 | 746 | { |
| 747 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 748 | - if (!is_string($pilot_id)) |
|
| 749 | - { |
|
| 747 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 748 | + if (!is_string($pilot_id)) |
|
| 749 | + { |
|
| 750 | 750 | return false; |
| 751 | - } else { |
|
| 751 | + } else { |
|
| 752 | 752 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 753 | - } |
|
| 753 | + } |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | if ($departure_airport_route != "") |
| 757 | 757 | { |
| 758 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 759 | - if (!is_string($departure_airport_route)) |
|
| 760 | - { |
|
| 758 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 759 | + if (!is_string($departure_airport_route)) |
|
| 760 | + { |
|
| 761 | 761 | return false; |
| 762 | - } else { |
|
| 762 | + } else { |
|
| 763 | 763 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 764 | - } |
|
| 764 | + } |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | if ($arrival_airport_route != "") |
| 768 | 768 | { |
| 769 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 770 | - if (!is_string($arrival_airport_route)) |
|
| 771 | - { |
|
| 769 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 770 | + if (!is_string($arrival_airport_route)) |
|
| 771 | + { |
|
| 772 | 772 | return false; |
| 773 | - } else { |
|
| 773 | + } else { |
|
| 774 | 774 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 775 | - } |
|
| 775 | + } |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | if ($altitude != "") |
| 779 | 779 | { |
| 780 | - $altitude_array = explode(",", $altitude); |
|
| 780 | + $altitude_array = explode(",", $altitude); |
|
| 781 | 781 | |
| 782 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 783 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 782 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 783 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 784 | 784 | |
| 785 | 785 | |
| 786 | - if ($altitude_array[1] != "") |
|
| 787 | - { |
|
| 786 | + if ($altitude_array[1] != "") |
|
| 787 | + { |
|
| 788 | 788 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 789 | 789 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 790 | 790 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 791 | - } else { |
|
| 791 | + } else { |
|
| 792 | 792 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 793 | 793 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 794 | - } |
|
| 794 | + } |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | if ($date_posted != "") |
| 798 | 798 | { |
| 799 | - $date_array = explode(",", $date_posted); |
|
| 799 | + $date_array = explode(",", $date_posted); |
|
| 800 | 800 | |
| 801 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 802 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 801 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 802 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 803 | 803 | |
| 804 | - if ($globalTimezone != '') { |
|
| 804 | + if ($globalTimezone != '') { |
|
| 805 | 805 | date_default_timezone_set($globalTimezone); |
| 806 | 806 | $datetime = new DateTime(); |
| 807 | 807 | $offset = $datetime->format('P'); |
| 808 | - } else $offset = '+00:00'; |
|
| 808 | + } else $offset = '+00:00'; |
|
| 809 | 809 | |
| 810 | 810 | |
| 811 | - if ($date_array[1] != "") |
|
| 812 | - { |
|
| 811 | + if ($date_array[1] != "") |
|
| 812 | + { |
|
| 813 | 813 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 814 | 814 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 815 | 815 | if ($globalDBdriver == 'mysql') { |
@@ -817,28 +817,28 @@ discard block |
||
| 817 | 817 | } else { |
| 818 | 818 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 819 | 819 | } |
| 820 | - } else { |
|
| 820 | + } else { |
|
| 821 | 821 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 822 | - if ($globalDBdriver == 'mysql') { |
|
| 822 | + if ($globalDBdriver == 'mysql') { |
|
| 823 | 823 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 824 | 824 | } else { |
| 825 | 825 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 826 | 826 | } |
| 827 | - } |
|
| 827 | + } |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | if ($limit != "") |
| 831 | 831 | { |
| 832 | - $limit_array = explode(",", $limit); |
|
| 832 | + $limit_array = explode(",", $limit); |
|
| 833 | 833 | |
| 834 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 835 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 834 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 835 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | 836 | |
| 837 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 838 | - { |
|
| 837 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 838 | + { |
|
| 839 | 839 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 840 | 840 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 841 | - } |
|
| 841 | + } |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | |
@@ -869,33 +869,33 @@ discard block |
||
| 869 | 869 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 870 | 870 | |
| 871 | 871 | return $spotter_array; |
| 872 | - } |
|
| 872 | + } |
|
| 873 | 873 | |
| 874 | - public function deleteSpotterArchiveData() |
|
| 875 | - { |
|
| 874 | + public function deleteSpotterArchiveData() |
|
| 875 | + { |
|
| 876 | 876 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 877 | - date_default_timezone_set('UTC'); |
|
| 878 | - if ($globalDBdriver == 'mysql') { |
|
| 877 | + date_default_timezone_set('UTC'); |
|
| 878 | + if ($globalDBdriver == 'mysql') { |
|
| 879 | 879 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 880 | 880 | } else { |
| 881 | 881 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 882 | 882 | } |
| 883 | - try { |
|
| 884 | - $sth = $this->db->prepare($query); |
|
| 885 | - $sth->execute(); |
|
| 886 | - } catch(PDOException $e) { |
|
| 887 | - return "error"; |
|
| 888 | - } |
|
| 883 | + try { |
|
| 884 | + $sth = $this->db->prepare($query); |
|
| 885 | + $sth->execute(); |
|
| 886 | + } catch(PDOException $e) { |
|
| 887 | + return "error"; |
|
| 888 | + } |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - /** |
|
| 892 | - * Gets all the spotter information based on the callsign |
|
| 893 | - * |
|
| 894 | - * @return Array the spotter information |
|
| 895 | - * |
|
| 896 | - */ |
|
| 897 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 898 | - { |
|
| 891 | + /** |
|
| 892 | + * Gets all the spotter information based on the callsign |
|
| 893 | + * |
|
| 894 | + * @return Array the spotter information |
|
| 895 | + * |
|
| 896 | + */ |
|
| 897 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 898 | + { |
|
| 899 | 899 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 900 | 900 | |
| 901 | 901 | date_default_timezone_set('UTC'); |
@@ -907,35 +907,35 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | if ($ident != "") |
| 909 | 909 | { |
| 910 | - if (!is_string($ident)) |
|
| 911 | - { |
|
| 910 | + if (!is_string($ident)) |
|
| 911 | + { |
|
| 912 | 912 | return false; |
| 913 | - } else { |
|
| 913 | + } else { |
|
| 914 | 914 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 915 | 915 | $query_values = array(':ident' => $ident); |
| 916 | - } |
|
| 916 | + } |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | if ($limit != "") |
| 920 | 920 | { |
| 921 | - $limit_array = explode(",", $limit); |
|
| 921 | + $limit_array = explode(",", $limit); |
|
| 922 | 922 | |
| 923 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 924 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 923 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 924 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 925 | 925 | |
| 926 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 927 | - { |
|
| 926 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 927 | + { |
|
| 928 | 928 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 929 | 929 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 930 | - } |
|
| 930 | + } |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | if ($sort != "") |
| 934 | 934 | { |
| 935 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 936 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 935 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 936 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 937 | 937 | } else { |
| 938 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 938 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -943,16 +943,16 @@ discard block |
||
| 943 | 943 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 944 | 944 | |
| 945 | 945 | return $spotter_array; |
| 946 | - } |
|
| 947 | - |
|
| 948 | - /** |
|
| 949 | - * Gets all number of flight over countries |
|
| 950 | - * |
|
| 951 | - * @return Array the airline country list |
|
| 952 | - * |
|
| 953 | - */ |
|
| 954 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 955 | - { |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + /** |
|
| 949 | + * Gets all number of flight over countries |
|
| 950 | + * |
|
| 951 | + * @return Array the airline country list |
|
| 952 | + * |
|
| 953 | + */ |
|
| 954 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 955 | + { |
|
| 956 | 956 | global $globalDBdriver; |
| 957 | 957 | /* |
| 958 | 958 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -962,14 +962,14 @@ discard block |
||
| 962 | 962 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 963 | 963 | FROM countries c, spotter_archive s |
| 964 | 964 | WHERE c.iso2 = s.over_country "; |
| 965 | - if ($olderthanmonths > 0) { |
|
| 966 | - if ($globalDBdriver == 'mysql') { |
|
| 965 | + if ($olderthanmonths > 0) { |
|
| 966 | + if ($globalDBdriver == 'mysql') { |
|
| 967 | 967 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 968 | 968 | } else { |
| 969 | 969 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 970 | 970 | } |
| 971 | 971 | } |
| 972 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 972 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 973 | 973 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 974 | 974 | if ($limit) $query .= " LIMIT 0,10"; |
| 975 | 975 | |
@@ -982,23 +982,23 @@ discard block |
||
| 982 | 982 | |
| 983 | 983 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 984 | 984 | { |
| 985 | - $temp_array['flight_count'] = $row['nb']; |
|
| 986 | - $temp_array['flight_country'] = $row['name']; |
|
| 987 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 988 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 989 | - $flight_array[] = $temp_array; |
|
| 985 | + $temp_array['flight_count'] = $row['nb']; |
|
| 986 | + $temp_array['flight_country'] = $row['name']; |
|
| 987 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 988 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 989 | + $flight_array[] = $temp_array; |
|
| 990 | 990 | } |
| 991 | 991 | return $flight_array; |
| 992 | - } |
|
| 993 | - |
|
| 994 | - /** |
|
| 995 | - * Gets last spotter information based on a particular callsign |
|
| 996 | - * |
|
| 997 | - * @return Array the spotter information |
|
| 998 | - * |
|
| 999 | - */ |
|
| 1000 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1001 | - { |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + /** |
|
| 995 | + * Gets last spotter information based on a particular callsign |
|
| 996 | + * |
|
| 997 | + * @return Array the spotter information |
|
| 998 | + * |
|
| 999 | + */ |
|
| 1000 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1001 | + { |
|
| 1002 | 1002 | $Spotter = new Spotter($this->db); |
| 1003 | 1003 | date_default_timezone_set('UTC'); |
| 1004 | 1004 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1006,16 +1006,16 @@ discard block |
||
| 1006 | 1006 | $date = date('c',$date); |
| 1007 | 1007 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1008 | 1008 | return $spotter_array; |
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - /** |
|
| 1012 | - * Gets all the spotter information based on a particular callsign |
|
| 1013 | - * |
|
| 1014 | - * @return Array the spotter information |
|
| 1015 | - * |
|
| 1016 | - */ |
|
| 1017 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1018 | - { |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + /** |
|
| 1012 | + * Gets all the spotter information based on a particular callsign |
|
| 1013 | + * |
|
| 1014 | + * @return Array the spotter information |
|
| 1015 | + * |
|
| 1016 | + */ |
|
| 1017 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1018 | + { |
|
| 1019 | 1019 | $Spotter = new Spotter($this->db); |
| 1020 | 1020 | date_default_timezone_set('UTC'); |
| 1021 | 1021 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1023,16 +1023,16 @@ discard block |
||
| 1023 | 1023 | $date = date('c',$date); |
| 1024 | 1024 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1025 | 1025 | return $spotter_array; |
| 1026 | - } |
|
| 1027 | - |
|
| 1028 | - /** |
|
| 1029 | - * Gets all the spotter information based on the airport |
|
| 1030 | - * |
|
| 1031 | - * @return Array the spotter information |
|
| 1032 | - * |
|
| 1033 | - */ |
|
| 1034 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1035 | - { |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + /** |
|
| 1029 | + * Gets all the spotter information based on the airport |
|
| 1030 | + * |
|
| 1031 | + * @return Array the spotter information |
|
| 1032 | + * |
|
| 1033 | + */ |
|
| 1034 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1035 | + { |
|
| 1036 | 1036 | global $global_query; |
| 1037 | 1037 | $Spotter = new Spotter(); |
| 1038 | 1038 | date_default_timezone_set('UTC'); |
@@ -1043,35 +1043,35 @@ discard block |
||
| 1043 | 1043 | |
| 1044 | 1044 | if ($airport != "") |
| 1045 | 1045 | { |
| 1046 | - if (!is_string($airport)) |
|
| 1047 | - { |
|
| 1046 | + if (!is_string($airport)) |
|
| 1047 | + { |
|
| 1048 | 1048 | return false; |
| 1049 | - } else { |
|
| 1049 | + } else { |
|
| 1050 | 1050 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1051 | 1051 | $query_values = array(':airport' => $airport); |
| 1052 | - } |
|
| 1052 | + } |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | if ($limit != "") |
| 1056 | 1056 | { |
| 1057 | - $limit_array = explode(",", $limit); |
|
| 1057 | + $limit_array = explode(",", $limit); |
|
| 1058 | 1058 | |
| 1059 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1060 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1059 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1060 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1061 | 1061 | |
| 1062 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1063 | - { |
|
| 1062 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1063 | + { |
|
| 1064 | 1064 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1065 | 1065 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1066 | - } |
|
| 1066 | + } |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | if ($sort != "") |
| 1070 | 1070 | { |
| 1071 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1072 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1071 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1072 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1073 | 1073 | } else { |
| 1074 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1074 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1079,6 +1079,6 @@ discard block |
||
| 1079 | 1079 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1080 | 1080 | |
| 1081 | 1081 | return $spotter_array; |
| 1082 | - } |
|
| 1082 | + } |
|
| 1083 | 1083 | } |
| 1084 | 1084 | ?> |
| 1085 | 1085 | \ No newline at end of file |