@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
@@ -151,44 +151,44 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Gets all the spotter information based on a particular callsign |
|
| 156 | - * |
|
| 157 | - * @return Array the spotter information |
|
| 158 | - * |
|
| 159 | - */ |
|
| 160 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 161 | - { |
|
| 154 | + /** |
|
| 155 | + * Gets all the spotter information based on a particular callsign |
|
| 156 | + * |
|
| 157 | + * @return Array the spotter information |
|
| 158 | + * |
|
| 159 | + */ |
|
| 160 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 161 | + { |
|
| 162 | 162 | $Spotter = new Spotter($this->db); |
| 163 | - date_default_timezone_set('UTC'); |
|
| 163 | + date_default_timezone_set('UTC'); |
|
| 164 | 164 | |
| 165 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 166 | - //$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"; |
|
| 167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 165 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 166 | + //$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"; |
|
| 167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 169 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 170 | 170 | |
| 171 | - return $spotter_array; |
|
| 172 | - } |
|
| 171 | + return $spotter_array; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Gets last the spotter information based on a particular id |
|
| 177 | - * |
|
| 178 | - * @return Array the spotter information |
|
| 179 | - * |
|
| 180 | - */ |
|
| 181 | - public function getLastArchiveSpotterDataById($id) |
|
| 182 | - { |
|
| 183 | - $Spotter = new Spotter($this->db); |
|
| 184 | - date_default_timezone_set('UTC'); |
|
| 185 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 186 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 187 | - //$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"; |
|
| 188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 175 | + /** |
|
| 176 | + * Gets last the spotter information based on a particular id |
|
| 177 | + * |
|
| 178 | + * @return Array the spotter information |
|
| 179 | + * |
|
| 180 | + */ |
|
| 181 | + public function getLastArchiveSpotterDataById($id) |
|
| 182 | + { |
|
| 183 | + $Spotter = new Spotter($this->db); |
|
| 184 | + date_default_timezone_set('UTC'); |
|
| 185 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 186 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 187 | + //$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"; |
|
| 188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 189 | 189 | |
| 190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 191 | - /* |
|
| 191 | + /* |
|
| 192 | 192 | try { |
| 193 | 193 | $Connection = new Connection(); |
| 194 | 194 | $sth = Connection->$db->prepare($query); |
@@ -198,122 +198,122 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 200 | 200 | */ |
| 201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | - |
|
| 203 | - return $spotter_array; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Gets all the spotter information based on a particular id |
|
| 208 | - * |
|
| 209 | - * @return Array the spotter information |
|
| 210 | - * |
|
| 211 | - */ |
|
| 212 | - public function getAllArchiveSpotterDataById($id) |
|
| 201 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | + |
|
| 203 | + return $spotter_array; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Gets all the spotter information based on a particular id |
|
| 208 | + * |
|
| 209 | + * @return Array the spotter information |
|
| 210 | + * |
|
| 211 | + */ |
|
| 212 | + public function getAllArchiveSpotterDataById($id) |
|
| 213 | 213 | { |
| 214 | - date_default_timezone_set('UTC'); |
|
| 215 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 214 | + date_default_timezone_set('UTC'); |
|
| 215 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 217 | 217 | |
| 218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 219 | 219 | |
| 220 | - try { |
|
| 221 | - $sth = $this->db->prepare($query); |
|
| 222 | - $sth->execute(array(':id' => $id)); |
|
| 223 | - } catch(PDOException $e) { |
|
| 224 | - echo $e->getMessage(); |
|
| 225 | - die; |
|
| 226 | - } |
|
| 227 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | - |
|
| 229 | - return $spotter_array; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * Gets coordinate & time spotter information based on a particular id |
|
| 234 | - * |
|
| 235 | - * @return Array the spotter information |
|
| 236 | - * |
|
| 237 | - */ |
|
| 238 | - public function getCoordArchiveSpotterDataById($id) |
|
| 239 | - { |
|
| 240 | - date_default_timezone_set('UTC'); |
|
| 241 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 220 | + try { |
|
| 221 | + $sth = $this->db->prepare($query); |
|
| 222 | + $sth->execute(array(':id' => $id)); |
|
| 223 | + } catch(PDOException $e) { |
|
| 224 | + echo $e->getMessage(); |
|
| 225 | + die; |
|
| 226 | + } |
|
| 227 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | + |
|
| 229 | + return $spotter_array; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * Gets coordinate & time spotter information based on a particular id |
|
| 234 | + * |
|
| 235 | + * @return Array the spotter information |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | + public function getCoordArchiveSpotterDataById($id) |
|
| 239 | + { |
|
| 240 | + date_default_timezone_set('UTC'); |
|
| 241 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 243 | 243 | |
| 244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 245 | 245 | |
| 246 | - try { |
|
| 247 | - $sth = $this->db->prepare($query); |
|
| 248 | - $sth->execute(array(':id' => $id)); |
|
| 249 | - } catch(PDOException $e) { |
|
| 250 | - echo $e->getMessage(); |
|
| 251 | - die; |
|
| 252 | - } |
|
| 253 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 246 | + try { |
|
| 247 | + $sth = $this->db->prepare($query); |
|
| 248 | + $sth->execute(array(':id' => $id)); |
|
| 249 | + } catch(PDOException $e) { |
|
| 250 | + echo $e->getMessage(); |
|
| 251 | + die; |
|
| 252 | + } |
|
| 253 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 254 | 254 | |
| 255 | - return $spotter_array; |
|
| 256 | - } |
|
| 255 | + return $spotter_array; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Gets altitude information based on a particular callsign |
|
| 261 | - * |
|
| 262 | - * @return Array the spotter information |
|
| 263 | - * |
|
| 264 | - */ |
|
| 265 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 266 | - { |
|
| 259 | + /** |
|
| 260 | + * Gets altitude information based on a particular callsign |
|
| 261 | + * |
|
| 262 | + * @return Array the spotter information |
|
| 263 | + * |
|
| 264 | + */ |
|
| 265 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 266 | + { |
|
| 267 | 267 | |
| 268 | - date_default_timezone_set('UTC'); |
|
| 268 | + date_default_timezone_set('UTC'); |
|
| 269 | 269 | |
| 270 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 271 | - $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"; |
|
| 270 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 271 | + $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"; |
|
| 272 | 272 | |
| 273 | - try { |
|
| 274 | - $sth = $this->db->prepare($query); |
|
| 275 | - $sth->execute(array(':ident' => $ident)); |
|
| 276 | - } catch(PDOException $e) { |
|
| 277 | - echo $e->getMessage(); |
|
| 278 | - die; |
|
| 279 | - } |
|
| 280 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 273 | + try { |
|
| 274 | + $sth = $this->db->prepare($query); |
|
| 275 | + $sth->execute(array(':ident' => $ident)); |
|
| 276 | + } catch(PDOException $e) { |
|
| 277 | + echo $e->getMessage(); |
|
| 278 | + die; |
|
| 279 | + } |
|
| 280 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 281 | 281 | |
| 282 | - return $spotter_array; |
|
| 283 | - } |
|
| 282 | + return $spotter_array; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Gets altitude information based on a particular id |
|
| 287 | - * |
|
| 288 | - * @return Array the spotter information |
|
| 289 | - * |
|
| 290 | - */ |
|
| 291 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 292 | - { |
|
| 285 | + /** |
|
| 286 | + * Gets altitude information based on a particular id |
|
| 287 | + * |
|
| 288 | + * @return Array the spotter information |
|
| 289 | + * |
|
| 290 | + */ |
|
| 291 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 292 | + { |
|
| 293 | 293 | |
| 294 | - date_default_timezone_set('UTC'); |
|
| 294 | + date_default_timezone_set('UTC'); |
|
| 295 | 295 | |
| 296 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 297 | - $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"; |
|
| 296 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 297 | + $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"; |
|
| 298 | 298 | |
| 299 | - try { |
|
| 300 | - $sth = $this->db->prepare($query); |
|
| 301 | - $sth->execute(array(':id' => $id)); |
|
| 302 | - } catch(PDOException $e) { |
|
| 303 | - echo $e->getMessage(); |
|
| 304 | - die; |
|
| 305 | - } |
|
| 306 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 299 | + try { |
|
| 300 | + $sth = $this->db->prepare($query); |
|
| 301 | + $sth->execute(array(':id' => $id)); |
|
| 302 | + } catch(PDOException $e) { |
|
| 303 | + echo $e->getMessage(); |
|
| 304 | + die; |
|
| 305 | + } |
|
| 306 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 307 | 307 | |
| 308 | - return $spotter_array; |
|
| 309 | - } |
|
| 308 | + return $spotter_array; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Gets altitude & speed information based on a particular id |
|
| 313 | - * |
|
| 314 | - * @return Array the spotter information |
|
| 315 | - * |
|
| 316 | - */ |
|
| 311 | + /** |
|
| 312 | + * Gets altitude & speed information based on a particular id |
|
| 313 | + * |
|
| 314 | + * @return Array the spotter information |
|
| 315 | + * |
|
| 316 | + */ |
|
| 317 | 317 | public function getAltitudeSpeedArchiveSpotterDataById($id) |
| 318 | 318 | { |
| 319 | 319 | date_default_timezone_set('UTC'); |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | return $spotter_array; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Gets altitude information based on a particular callsign |
|
| 335 | - * |
|
| 336 | - * @return Array the spotter information |
|
| 337 | - * |
|
| 338 | - */ |
|
| 333 | + /** |
|
| 334 | + * Gets altitude information based on a particular callsign |
|
| 335 | + * |
|
| 336 | + * @return Array the spotter information |
|
| 337 | + * |
|
| 338 | + */ |
|
| 339 | 339 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
| 340 | 340 | { |
| 341 | 341 | date_default_timezone_set('UTC'); |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | |
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * Gets all the archive spotter information |
|
| 360 | - * |
|
| 361 | - * @return Array the spotter information |
|
| 362 | - * |
|
| 363 | - */ |
|
| 358 | + /** |
|
| 359 | + * Gets all the archive spotter information |
|
| 360 | + * |
|
| 361 | + * @return Array the spotter information |
|
| 362 | + * |
|
| 363 | + */ |
|
| 364 | 364 | public function getSpotterArchiveData($ident,$flightaware_id,$date) |
| 365 | 365 | { |
| 366 | 366 | $Spotter = new Spotter($this->db); |
@@ -388,34 +388,34 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | - * Gets Minimal Live Spotter data |
|
| 392 | - * |
|
| 393 | - * @return Array the spotter information |
|
| 394 | - * |
|
| 395 | - */ |
|
| 396 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 397 | - { |
|
| 398 | - global $globalDBdriver, $globalLiveInterval; |
|
| 399 | - date_default_timezone_set('UTC'); |
|
| 400 | - |
|
| 401 | - $filter_query = ''; |
|
| 402 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 403 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 404 | - } |
|
| 405 | - // Use spotter_output also ? |
|
| 406 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 407 | - $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 "; |
|
| 408 | - } |
|
| 409 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 410 | - $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 "; |
|
| 411 | - } |
|
| 412 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 413 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 414 | - } |
|
| 391 | + * Gets Minimal Live Spotter data |
|
| 392 | + * |
|
| 393 | + * @return Array the spotter information |
|
| 394 | + * |
|
| 395 | + */ |
|
| 396 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 397 | + { |
|
| 398 | + global $globalDBdriver, $globalLiveInterval; |
|
| 399 | + date_default_timezone_set('UTC'); |
|
| 400 | + |
|
| 401 | + $filter_query = ''; |
|
| 402 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 403 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 404 | + } |
|
| 405 | + // Use spotter_output also ? |
|
| 406 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 407 | + $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 "; |
|
| 408 | + } |
|
| 409 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 410 | + $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 "; |
|
| 411 | + } |
|
| 412 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 413 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 417 | - if ($globalDBdriver == 'mysql') { |
|
| 418 | - /* |
|
| 416 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 417 | + if ($globalDBdriver == 'mysql') { |
|
| 418 | + /* |
|
| 419 | 419 | $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 |
| 420 | 420 | FROM spotter_archive |
| 421 | 421 | 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'; |
@@ -434,56 +434,56 @@ discard block |
||
| 434 | 434 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 435 | 435 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 436 | 436 | '.$filter_query.' ORDER BY flightaware_id'; |
| 437 | - } else { |
|
| 438 | - //$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'; |
|
| 439 | - $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 |
|
| 437 | + } else { |
|
| 438 | + //$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'; |
|
| 439 | + $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 |
|
| 440 | 440 | FROM spotter_archive |
| 441 | 441 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 442 | 442 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 443 | 443 | '.$filter_query.' ORDER BY flightaware_id'; |
| 444 | - } |
|
| 445 | - //echo $query; |
|
| 446 | - try { |
|
| 447 | - $sth = $this->db->prepare($query); |
|
| 448 | - $sth->execute(); |
|
| 449 | - } catch(PDOException $e) { |
|
| 450 | - echo $e->getMessage(); |
|
| 451 | - die; |
|
| 452 | - } |
|
| 453 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 444 | + } |
|
| 445 | + //echo $query; |
|
| 446 | + try { |
|
| 447 | + $sth = $this->db->prepare($query); |
|
| 448 | + $sth->execute(); |
|
| 449 | + } catch(PDOException $e) { |
|
| 450 | + echo $e->getMessage(); |
|
| 451 | + die; |
|
| 452 | + } |
|
| 453 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 454 | 454 | |
| 455 | - return $spotter_array; |
|
| 456 | - } |
|
| 455 | + return $spotter_array; |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | - * Gets Minimal Live Spotter data |
|
| 460 | - * |
|
| 461 | - * @return Array the spotter information |
|
| 462 | - * |
|
| 463 | - */ |
|
| 464 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 465 | - { |
|
| 466 | - global $globalDBdriver, $globalLiveInterval; |
|
| 467 | - date_default_timezone_set('UTC'); |
|
| 468 | - |
|
| 469 | - $filter_query = ''; |
|
| 470 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 471 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 472 | - } |
|
| 473 | - // Should use spotter_output also ? |
|
| 474 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 475 | - $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 "; |
|
| 476 | - } |
|
| 477 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 478 | - $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 "; |
|
| 479 | - } |
|
| 480 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 481 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 482 | - } |
|
| 459 | + * Gets Minimal Live Spotter data |
|
| 460 | + * |
|
| 461 | + * @return Array the spotter information |
|
| 462 | + * |
|
| 463 | + */ |
|
| 464 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 465 | + { |
|
| 466 | + global $globalDBdriver, $globalLiveInterval; |
|
| 467 | + date_default_timezone_set('UTC'); |
|
| 468 | + |
|
| 469 | + $filter_query = ''; |
|
| 470 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 471 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 472 | + } |
|
| 473 | + // Should use spotter_output also ? |
|
| 474 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 475 | + $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 "; |
|
| 476 | + } |
|
| 477 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 478 | + $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 "; |
|
| 479 | + } |
|
| 480 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 481 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 485 | - if ($globalDBdriver == 'mysql') { |
|
| 486 | - /* |
|
| 484 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 485 | + if ($globalDBdriver == 'mysql') { |
|
| 486 | + /* |
|
| 487 | 487 | $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 |
| 488 | 488 | FROM spotter_archive |
| 489 | 489 | 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'; |
@@ -494,95 +494,95 @@ discard block |
||
| 494 | 494 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 495 | 495 | '.$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'; |
| 496 | 496 | |
| 497 | - } else { |
|
| 498 | - //$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'; |
|
| 499 | - /* |
|
| 497 | + } else { |
|
| 498 | + //$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'; |
|
| 499 | + /* |
|
| 500 | 500 | $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 |
| 501 | 501 | FROM spotter_archive_output |
| 502 | 502 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 503 | 503 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 504 | 504 | '.$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'; |
| 505 | 505 | */ |
| 506 | - $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 |
|
| 506 | + $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 |
|
| 507 | 507 | FROM spotter_archive_output |
| 508 | 508 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 509 | 509 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 510 | 510 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 511 | 511 | // .' 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'; |
| 512 | 512 | |
| 513 | - } |
|
| 514 | - //echo $query; |
|
| 515 | - try { |
|
| 516 | - $sth = $this->db->prepare($query); |
|
| 517 | - $sth->execute(); |
|
| 518 | - } catch(PDOException $e) { |
|
| 519 | - echo $e->getMessage(); |
|
| 520 | - die; |
|
| 521 | - } |
|
| 522 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 513 | + } |
|
| 514 | + //echo $query; |
|
| 515 | + try { |
|
| 516 | + $sth = $this->db->prepare($query); |
|
| 517 | + $sth->execute(); |
|
| 518 | + } catch(PDOException $e) { |
|
| 519 | + echo $e->getMessage(); |
|
| 520 | + die; |
|
| 521 | + } |
|
| 522 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 523 | 523 | |
| 524 | - return $spotter_array; |
|
| 525 | - } |
|
| 524 | + return $spotter_array; |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | - * Gets count Live Spotter data |
|
| 529 | - * |
|
| 530 | - * @return Array the spotter information |
|
| 531 | - * |
|
| 532 | - */ |
|
| 533 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 534 | - { |
|
| 535 | - global $globalDBdriver, $globalLiveInterval; |
|
| 536 | - date_default_timezone_set('UTC'); |
|
| 537 | - |
|
| 538 | - $filter_query = ''; |
|
| 539 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 540 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 541 | - } |
|
| 542 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 543 | - $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 "; |
|
| 544 | - } |
|
| 545 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 546 | - $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 "; |
|
| 547 | - } |
|
| 548 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 549 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 550 | - } |
|
| 528 | + * Gets count Live Spotter data |
|
| 529 | + * |
|
| 530 | + * @return Array the spotter information |
|
| 531 | + * |
|
| 532 | + */ |
|
| 533 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 534 | + { |
|
| 535 | + global $globalDBdriver, $globalLiveInterval; |
|
| 536 | + date_default_timezone_set('UTC'); |
|
| 551 | 537 | |
| 552 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 553 | - if ($globalDBdriver == 'mysql') { |
|
| 538 | + $filter_query = ''; |
|
| 539 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 540 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 541 | + } |
|
| 542 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 543 | + $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 "; |
|
| 544 | + } |
|
| 545 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 546 | + $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 "; |
|
| 547 | + } |
|
| 548 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 549 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 553 | + if ($globalDBdriver == 'mysql') { |
|
| 554 | 554 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 555 | 555 | FROM spotter_archive l |
| 556 | 556 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 557 | - } else { |
|
| 557 | + } else { |
|
| 558 | 558 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 559 | - } |
|
| 560 | - //echo $query; |
|
| 561 | - try { |
|
| 562 | - $sth = $this->db->prepare($query); |
|
| 563 | - $sth->execute(); |
|
| 564 | - } catch(PDOException $e) { |
|
| 565 | - echo $e->getMessage(); |
|
| 566 | - die; |
|
| 567 | - } |
|
| 559 | + } |
|
| 560 | + //echo $query; |
|
| 561 | + try { |
|
| 562 | + $sth = $this->db->prepare($query); |
|
| 563 | + $sth->execute(); |
|
| 564 | + } catch(PDOException $e) { |
|
| 565 | + echo $e->getMessage(); |
|
| 566 | + die; |
|
| 567 | + } |
|
| 568 | 568 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 569 | 569 | $sth->closeCursor(); |
| 570 | - return $result['nb']; |
|
| 570 | + return $result['nb']; |
|
| 571 | 571 | |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | 574 | |
| 575 | 575 | |
| 576 | 576 | // Spotter_Archive_output |
| 577 | 577 | |
| 578 | - /** |
|
| 579 | - * Gets all the spotter information |
|
| 580 | - * |
|
| 581 | - * @return Array the spotter information |
|
| 582 | - * |
|
| 583 | - */ |
|
| 584 | - 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()) |
|
| 585 | - { |
|
| 578 | + /** |
|
| 579 | + * Gets all the spotter information |
|
| 580 | + * |
|
| 581 | + * @return Array the spotter information |
|
| 582 | + * |
|
| 583 | + */ |
|
| 584 | + 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()) |
|
| 585 | + { |
|
| 586 | 586 | global $globalTimezone, $globalDBdriver; |
| 587 | 587 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 588 | 588 | $Translation = new Translation($this->db); |
@@ -596,159 +596,159 @@ discard block |
||
| 596 | 596 | $filter_query = $this->getFilter($filters); |
| 597 | 597 | if ($q != "") |
| 598 | 598 | { |
| 599 | - if (!is_string($q)) |
|
| 600 | - { |
|
| 599 | + if (!is_string($q)) |
|
| 600 | + { |
|
| 601 | 601 | return false; |
| 602 | - } else { |
|
| 602 | + } else { |
|
| 603 | 603 | |
| 604 | 604 | $q_array = explode(" ", $q); |
| 605 | 605 | |
| 606 | 606 | foreach ($q_array as $q_item){ |
| 607 | - $additional_query .= " AND ("; |
|
| 608 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 609 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 610 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 611 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 612 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 613 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 614 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 615 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 616 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 617 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 618 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 619 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 620 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 621 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 622 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 623 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 624 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 625 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 626 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 627 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 628 | - $translate = $Translation->ident2icao($q_item); |
|
| 629 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 630 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 631 | - $additional_query .= ")"; |
|
| 607 | + $additional_query .= " AND ("; |
|
| 608 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 609 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 610 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 611 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 612 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 613 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 614 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 615 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 616 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 617 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 618 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 619 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 620 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 621 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 622 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 623 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 624 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 625 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 626 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 627 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 628 | + $translate = $Translation->ident2icao($q_item); |
|
| 629 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 630 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 631 | + $additional_query .= ")"; |
|
| 632 | + } |
|
| 632 | 633 | } |
| 633 | - } |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | if ($registration != "") |
| 637 | 637 | { |
| 638 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 639 | - if (!is_string($registration)) |
|
| 640 | - { |
|
| 638 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 639 | + if (!is_string($registration)) |
|
| 640 | + { |
|
| 641 | 641 | return false; |
| 642 | - } else { |
|
| 642 | + } else { |
|
| 643 | 643 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 644 | - } |
|
| 644 | + } |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | if ($aircraft_icao != "") |
| 648 | 648 | { |
| 649 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 650 | - if (!is_string($aircraft_icao)) |
|
| 651 | - { |
|
| 649 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 650 | + if (!is_string($aircraft_icao)) |
|
| 651 | + { |
|
| 652 | 652 | return false; |
| 653 | - } else { |
|
| 653 | + } else { |
|
| 654 | 654 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 655 | - } |
|
| 655 | + } |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | if ($aircraft_manufacturer != "") |
| 659 | 659 | { |
| 660 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 661 | - if (!is_string($aircraft_manufacturer)) |
|
| 662 | - { |
|
| 660 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 661 | + if (!is_string($aircraft_manufacturer)) |
|
| 662 | + { |
|
| 663 | 663 | return false; |
| 664 | - } else { |
|
| 664 | + } else { |
|
| 665 | 665 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 666 | - } |
|
| 666 | + } |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | if ($highlights == "true") |
| 670 | 670 | { |
| 671 | - if (!is_string($highlights)) |
|
| 672 | - { |
|
| 671 | + if (!is_string($highlights)) |
|
| 672 | + { |
|
| 673 | 673 | return false; |
| 674 | - } else { |
|
| 674 | + } else { |
|
| 675 | 675 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 676 | - } |
|
| 676 | + } |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | if ($airline_icao != "") |
| 680 | 680 | { |
| 681 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 682 | - if (!is_string($airline_icao)) |
|
| 683 | - { |
|
| 681 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 682 | + if (!is_string($airline_icao)) |
|
| 683 | + { |
|
| 684 | 684 | return false; |
| 685 | - } else { |
|
| 685 | + } else { |
|
| 686 | 686 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | if ($airline_country != "") |
| 691 | 691 | { |
| 692 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 693 | - if (!is_string($airline_country)) |
|
| 694 | - { |
|
| 692 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 693 | + if (!is_string($airline_country)) |
|
| 694 | + { |
|
| 695 | 695 | return false; |
| 696 | - } else { |
|
| 696 | + } else { |
|
| 697 | 697 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 698 | - } |
|
| 698 | + } |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | if ($airline_type != "") |
| 702 | 702 | { |
| 703 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 704 | - if (!is_string($airline_type)) |
|
| 705 | - { |
|
| 703 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 704 | + if (!is_string($airline_type)) |
|
| 705 | + { |
|
| 706 | 706 | return false; |
| 707 | - } else { |
|
| 707 | + } else { |
|
| 708 | 708 | if ($airline_type == "passenger") |
| 709 | 709 | { |
| 710 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 710 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 711 | 711 | } |
| 712 | 712 | if ($airline_type == "cargo") |
| 713 | 713 | { |
| 714 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 714 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 715 | 715 | } |
| 716 | 716 | if ($airline_type == "military") |
| 717 | 717 | { |
| 718 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 718 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 719 | + } |
|
| 719 | 720 | } |
| 720 | - } |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | if ($airport != "") |
| 724 | 724 | { |
| 725 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 726 | - if (!is_string($airport)) |
|
| 727 | - { |
|
| 725 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 726 | + if (!is_string($airport)) |
|
| 727 | + { |
|
| 728 | 728 | return false; |
| 729 | - } else { |
|
| 729 | + } else { |
|
| 730 | 730 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 731 | - } |
|
| 731 | + } |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | if ($airport_country != "") |
| 735 | 735 | { |
| 736 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 737 | - if (!is_string($airport_country)) |
|
| 738 | - { |
|
| 736 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 737 | + if (!is_string($airport_country)) |
|
| 738 | + { |
|
| 739 | 739 | return false; |
| 740 | - } else { |
|
| 740 | + } else { |
|
| 741 | 741 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 742 | - } |
|
| 742 | + } |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if ($callsign != "") |
| 746 | 746 | { |
| 747 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 748 | - if (!is_string($callsign)) |
|
| 749 | - { |
|
| 747 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 748 | + if (!is_string($callsign)) |
|
| 749 | + { |
|
| 750 | 750 | return false; |
| 751 | - } else { |
|
| 751 | + } else { |
|
| 752 | 752 | $translate = $Translation->ident2icao($callsign); |
| 753 | 753 | if ($translate != $callsign) { |
| 754 | 754 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -756,81 +756,81 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 758 | 758 | } |
| 759 | - } |
|
| 759 | + } |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | if ($owner != "") |
| 763 | 763 | { |
| 764 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 765 | - if (!is_string($owner)) |
|
| 766 | - { |
|
| 764 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 765 | + if (!is_string($owner)) |
|
| 766 | + { |
|
| 767 | 767 | return false; |
| 768 | - } else { |
|
| 768 | + } else { |
|
| 769 | 769 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 770 | - } |
|
| 770 | + } |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | if ($pilot_name != "") |
| 774 | 774 | { |
| 775 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 776 | - if (!is_string($pilot_name)) |
|
| 777 | - { |
|
| 775 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 776 | + if (!is_string($pilot_name)) |
|
| 777 | + { |
|
| 778 | 778 | return false; |
| 779 | - } else { |
|
| 779 | + } else { |
|
| 780 | 780 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 781 | - } |
|
| 781 | + } |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | if ($pilot_id != "") |
| 785 | 785 | { |
| 786 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 787 | - if (!is_string($pilot_id)) |
|
| 788 | - { |
|
| 786 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 787 | + if (!is_string($pilot_id)) |
|
| 788 | + { |
|
| 789 | 789 | return false; |
| 790 | - } else { |
|
| 790 | + } else { |
|
| 791 | 791 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 792 | - } |
|
| 792 | + } |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | if ($departure_airport_route != "") |
| 796 | 796 | { |
| 797 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 798 | - if (!is_string($departure_airport_route)) |
|
| 799 | - { |
|
| 797 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 798 | + if (!is_string($departure_airport_route)) |
|
| 799 | + { |
|
| 800 | 800 | return false; |
| 801 | - } else { |
|
| 801 | + } else { |
|
| 802 | 802 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 803 | - } |
|
| 803 | + } |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | if ($arrival_airport_route != "") |
| 807 | 807 | { |
| 808 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 809 | - if (!is_string($arrival_airport_route)) |
|
| 810 | - { |
|
| 808 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 809 | + if (!is_string($arrival_airport_route)) |
|
| 810 | + { |
|
| 811 | 811 | return false; |
| 812 | - } else { |
|
| 812 | + } else { |
|
| 813 | 813 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 814 | - } |
|
| 814 | + } |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | if ($altitude != "") |
| 818 | 818 | { |
| 819 | - $altitude_array = explode(",", $altitude); |
|
| 819 | + $altitude_array = explode(",", $altitude); |
|
| 820 | 820 | |
| 821 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 822 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 821 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 822 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 823 | 823 | |
| 824 | 824 | |
| 825 | - if ($altitude_array[1] != "") |
|
| 826 | - { |
|
| 825 | + if ($altitude_array[1] != "") |
|
| 826 | + { |
|
| 827 | 827 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 828 | 828 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 829 | 829 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 830 | - } else { |
|
| 830 | + } else { |
|
| 831 | 831 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 832 | 832 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 833 | - } |
|
| 833 | + } |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | if ($date_posted != "") |
@@ -915,14 +915,14 @@ discard block |
||
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - /** |
|
| 919 | - * Gets all the spotter information based on the callsign |
|
| 920 | - * |
|
| 921 | - * @return Array the spotter information |
|
| 922 | - * |
|
| 923 | - */ |
|
| 924 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 925 | - { |
|
| 918 | + /** |
|
| 919 | + * Gets all the spotter information based on the callsign |
|
| 920 | + * |
|
| 921 | + * @return Array the spotter information |
|
| 922 | + * |
|
| 923 | + */ |
|
| 924 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 925 | + { |
|
| 926 | 926 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 927 | 927 | |
| 928 | 928 | date_default_timezone_set('UTC'); |
@@ -934,35 +934,35 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | if ($ident != "") |
| 936 | 936 | { |
| 937 | - if (!is_string($ident)) |
|
| 938 | - { |
|
| 937 | + if (!is_string($ident)) |
|
| 938 | + { |
|
| 939 | 939 | return false; |
| 940 | - } else { |
|
| 940 | + } else { |
|
| 941 | 941 | $additional_query = " AND spotter_archive_output.ident = :ident"; |
| 942 | 942 | $query_values = array(':ident' => $ident); |
| 943 | - } |
|
| 943 | + } |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | if ($limit != "") |
| 947 | 947 | { |
| 948 | - $limit_array = explode(",", $limit); |
|
| 948 | + $limit_array = explode(",", $limit); |
|
| 949 | 949 | |
| 950 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 950 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 952 | 952 | |
| 953 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 954 | - { |
|
| 953 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 954 | + { |
|
| 955 | 955 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 956 | 956 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 957 | - } |
|
| 957 | + } |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | if ($sort != "") |
| 961 | 961 | { |
| 962 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 963 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 962 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 963 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 964 | 964 | } else { |
| 965 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 965 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -970,17 +970,17 @@ discard block |
||
| 970 | 970 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 971 | 971 | |
| 972 | 972 | return $spotter_array; |
| 973 | - } |
|
| 973 | + } |
|
| 974 | 974 | |
| 975 | 975 | |
| 976 | - /** |
|
| 977 | - * Gets all the spotter information based on the owner |
|
| 978 | - * |
|
| 979 | - * @return Array the spotter information |
|
| 980 | - * |
|
| 981 | - */ |
|
| 982 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 983 | - { |
|
| 976 | + /** |
|
| 977 | + * Gets all the spotter information based on the owner |
|
| 978 | + * |
|
| 979 | + * @return Array the spotter information |
|
| 980 | + * |
|
| 981 | + */ |
|
| 982 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 983 | + { |
|
| 984 | 984 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 985 | 985 | |
| 986 | 986 | date_default_timezone_set('UTC'); |
@@ -993,35 +993,35 @@ discard block |
||
| 993 | 993 | |
| 994 | 994 | if ($owner != "") |
| 995 | 995 | { |
| 996 | - if (!is_string($owner)) |
|
| 997 | - { |
|
| 996 | + if (!is_string($owner)) |
|
| 997 | + { |
|
| 998 | 998 | return false; |
| 999 | - } else { |
|
| 999 | + } else { |
|
| 1000 | 1000 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1001 | 1001 | $query_values = array(':owner' => $owner); |
| 1002 | - } |
|
| 1002 | + } |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | if ($limit != "") |
| 1006 | 1006 | { |
| 1007 | - $limit_array = explode(",", $limit); |
|
| 1007 | + $limit_array = explode(",", $limit); |
|
| 1008 | 1008 | |
| 1009 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1010 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1009 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1010 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1011 | 1011 | |
| 1012 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1013 | - { |
|
| 1012 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1013 | + { |
|
| 1014 | 1014 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1015 | 1015 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1016 | - } |
|
| 1016 | + } |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | if ($sort != "") |
| 1020 | 1020 | { |
| 1021 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1022 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1021 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1022 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1023 | 1023 | } else { |
| 1024 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1024 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1029,16 +1029,16 @@ discard block |
||
| 1029 | 1029 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1030 | 1030 | |
| 1031 | 1031 | return $spotter_array; |
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - /** |
|
| 1035 | - * Gets all the spotter information based on the pilot |
|
| 1036 | - * |
|
| 1037 | - * @return Array the spotter information |
|
| 1038 | - * |
|
| 1039 | - */ |
|
| 1040 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1041 | - { |
|
| 1032 | + } |
|
| 1033 | + |
|
| 1034 | + /** |
|
| 1035 | + * Gets all the spotter information based on the pilot |
|
| 1036 | + * |
|
| 1037 | + * @return Array the spotter information |
|
| 1038 | + * |
|
| 1039 | + */ |
|
| 1040 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1041 | + { |
|
| 1042 | 1042 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1043 | 1043 | |
| 1044 | 1044 | date_default_timezone_set('UTC'); |
@@ -1057,24 +1057,24 @@ discard block |
||
| 1057 | 1057 | |
| 1058 | 1058 | if ($limit != "") |
| 1059 | 1059 | { |
| 1060 | - $limit_array = explode(",", $limit); |
|
| 1060 | + $limit_array = explode(",", $limit); |
|
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | - { |
|
| 1065 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | + { |
|
| 1067 | 1067 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1068 | 1068 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1069 | - } |
|
| 1069 | + } |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | if ($sort != "") |
| 1073 | 1073 | { |
| 1074 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1075 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1074 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1075 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1076 | 1076 | } else { |
| 1077 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1077 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1082,16 +1082,16 @@ discard block |
||
| 1082 | 1082 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1083 | 1083 | |
| 1084 | 1084 | return $spotter_array; |
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - /** |
|
| 1088 | - * Gets all number of flight over countries |
|
| 1089 | - * |
|
| 1090 | - * @return Array the airline country list |
|
| 1091 | - * |
|
| 1092 | - */ |
|
| 1093 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1094 | - { |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + /** |
|
| 1088 | + * Gets all number of flight over countries |
|
| 1089 | + * |
|
| 1090 | + * @return Array the airline country list |
|
| 1091 | + * |
|
| 1092 | + */ |
|
| 1093 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1094 | + { |
|
| 1095 | 1095 | global $globalDBdriver; |
| 1096 | 1096 | /* |
| 1097 | 1097 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1101,14 +1101,14 @@ discard block |
||
| 1101 | 1101 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1102 | 1102 | FROM countries c, spotter_archive s |
| 1103 | 1103 | WHERE c.iso2 = s.over_country "; |
| 1104 | - if ($olderthanmonths > 0) { |
|
| 1105 | - if ($globalDBdriver == 'mysql') { |
|
| 1104 | + if ($olderthanmonths > 0) { |
|
| 1105 | + if ($globalDBdriver == 'mysql') { |
|
| 1106 | 1106 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1107 | 1107 | } else { |
| 1108 | 1108 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1109 | 1109 | } |
| 1110 | 1110 | } |
| 1111 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1111 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1112 | 1112 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1113 | 1113 | if ($limit) $query .= " LIMIT 0,10"; |
| 1114 | 1114 | |
@@ -1121,23 +1121,23 @@ discard block |
||
| 1121 | 1121 | |
| 1122 | 1122 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1123 | 1123 | { |
| 1124 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1125 | - $temp_array['flight_country'] = $row['name']; |
|
| 1126 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1127 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1128 | - $flight_array[] = $temp_array; |
|
| 1124 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1125 | + $temp_array['flight_country'] = $row['name']; |
|
| 1126 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1127 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1128 | + $flight_array[] = $temp_array; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | return $flight_array; |
| 1131 | - } |
|
| 1132 | - |
|
| 1133 | - /** |
|
| 1134 | - * Gets all number of flight over countries |
|
| 1135 | - * |
|
| 1136 | - * @return Array the airline country list |
|
| 1137 | - * |
|
| 1138 | - */ |
|
| 1139 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1140 | - { |
|
| 1131 | + } |
|
| 1132 | + |
|
| 1133 | + /** |
|
| 1134 | + * Gets all number of flight over countries |
|
| 1135 | + * |
|
| 1136 | + * @return Array the airline country list |
|
| 1137 | + * |
|
| 1138 | + */ |
|
| 1139 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1140 | + { |
|
| 1141 | 1141 | global $globalDBdriver; |
| 1142 | 1142 | /* |
| 1143 | 1143 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1147,14 +1147,14 @@ discard block |
||
| 1147 | 1147 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1148 | 1148 | FROM countries c, spotter_archive s, spotter_output o |
| 1149 | 1149 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1150 | - if ($olderthanmonths > 0) { |
|
| 1151 | - if ($globalDBdriver == 'mysql') { |
|
| 1150 | + if ($olderthanmonths > 0) { |
|
| 1151 | + if ($globalDBdriver == 'mysql') { |
|
| 1152 | 1152 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1153 | 1153 | } else { |
| 1154 | 1154 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1155 | 1155 | } |
| 1156 | 1156 | } |
| 1157 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1157 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1158 | 1158 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1159 | 1159 | if ($limit) $query .= " LIMIT 0,10"; |
| 1160 | 1160 | |
@@ -1167,24 +1167,24 @@ discard block |
||
| 1167 | 1167 | |
| 1168 | 1168 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1169 | 1169 | { |
| 1170 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1171 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1172 | - $temp_array['flight_country'] = $row['name']; |
|
| 1173 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1174 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1175 | - $flight_array[] = $temp_array; |
|
| 1170 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1171 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1172 | + $temp_array['flight_country'] = $row['name']; |
|
| 1173 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1174 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1175 | + $flight_array[] = $temp_array; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | return $flight_array; |
| 1178 | - } |
|
| 1179 | - |
|
| 1180 | - /** |
|
| 1181 | - * Gets last spotter information based on a particular callsign |
|
| 1182 | - * |
|
| 1183 | - * @return Array the spotter information |
|
| 1184 | - * |
|
| 1185 | - */ |
|
| 1186 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1187 | - { |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1180 | + /** |
|
| 1181 | + * Gets last spotter information based on a particular callsign |
|
| 1182 | + * |
|
| 1183 | + * @return Array the spotter information |
|
| 1184 | + * |
|
| 1185 | + */ |
|
| 1186 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1187 | + { |
|
| 1188 | 1188 | $Spotter = new Spotter($this->db); |
| 1189 | 1189 | date_default_timezone_set('UTC'); |
| 1190 | 1190 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1192,16 +1192,16 @@ discard block |
||
| 1192 | 1192 | $date = date('c',$date); |
| 1193 | 1193 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1194 | 1194 | return $spotter_array; |
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - /** |
|
| 1198 | - * Gets all the spotter information based on a particular callsign |
|
| 1199 | - * |
|
| 1200 | - * @return Array the spotter information |
|
| 1201 | - * |
|
| 1202 | - */ |
|
| 1203 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1204 | - { |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + /** |
|
| 1198 | + * Gets all the spotter information based on a particular callsign |
|
| 1199 | + * |
|
| 1200 | + * @return Array the spotter information |
|
| 1201 | + * |
|
| 1202 | + */ |
|
| 1203 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1204 | + { |
|
| 1205 | 1205 | $Spotter = new Spotter($this->db); |
| 1206 | 1206 | date_default_timezone_set('UTC'); |
| 1207 | 1207 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1209,16 +1209,16 @@ discard block |
||
| 1209 | 1209 | $date = date('c',$date); |
| 1210 | 1210 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1211 | 1211 | return $spotter_array; |
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - /** |
|
| 1215 | - * Gets all the spotter information based on the airport |
|
| 1216 | - * |
|
| 1217 | - * @return Array the spotter information |
|
| 1218 | - * |
|
| 1219 | - */ |
|
| 1220 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1221 | - { |
|
| 1212 | + } |
|
| 1213 | + |
|
| 1214 | + /** |
|
| 1215 | + * Gets all the spotter information based on the airport |
|
| 1216 | + * |
|
| 1217 | + * @return Array the spotter information |
|
| 1218 | + * |
|
| 1219 | + */ |
|
| 1220 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1221 | + { |
|
| 1222 | 1222 | global $global_query; |
| 1223 | 1223 | $Spotter = new Spotter($this->db); |
| 1224 | 1224 | date_default_timezone_set('UTC'); |
@@ -1229,35 +1229,35 @@ discard block |
||
| 1229 | 1229 | |
| 1230 | 1230 | if ($airport != "") |
| 1231 | 1231 | { |
| 1232 | - if (!is_string($airport)) |
|
| 1233 | - { |
|
| 1232 | + if (!is_string($airport)) |
|
| 1233 | + { |
|
| 1234 | 1234 | return false; |
| 1235 | - } else { |
|
| 1235 | + } else { |
|
| 1236 | 1236 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1237 | 1237 | $query_values = array(':airport' => $airport); |
| 1238 | - } |
|
| 1238 | + } |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | if ($limit != "") |
| 1242 | 1242 | { |
| 1243 | - $limit_array = explode(",", $limit); |
|
| 1243 | + $limit_array = explode(",", $limit); |
|
| 1244 | 1244 | |
| 1245 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1246 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1245 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1246 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1247 | 1247 | |
| 1248 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1249 | - { |
|
| 1248 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1249 | + { |
|
| 1250 | 1250 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1251 | 1251 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1252 | - } |
|
| 1252 | + } |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | if ($sort != "") |
| 1256 | 1256 | { |
| 1257 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1258 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1257 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1258 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1259 | 1259 | } else { |
| 1260 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1260 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | $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; |
@@ -1265,6 +1265,6 @@ discard block |
||
| 1265 | 1265 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1266 | 1266 | |
| 1267 | 1267 | return $spotter_array; |
| 1268 | - } |
|
| 1268 | + } |
|
| 1269 | 1269 | } |
| 1270 | 1270 | ?> |
| 1271 | 1271 | \ No newline at end of file |