@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | - * Gets all the spotter information based on the latest data entry |
|
| 115 | - * |
|
| 116 | - * @return Array the spotter information |
|
| 117 | - * |
|
| 118 | - */ |
|
| 114 | + * Gets all the spotter information based on the latest data entry |
|
| 115 | + * |
|
| 116 | + * @return Array the spotter information |
|
| 117 | + * |
|
| 118 | + */ |
|
| 119 | 119 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 120 | 120 | { |
| 121 | 121 | global $globalDBdriver, $globalLiveInterval; |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | - * Gets Minimal Live Spotter data |
|
| 161 | - * |
|
| 162 | - * @return Array the spotter information |
|
| 163 | - * |
|
| 164 | - */ |
|
| 160 | + * Gets Minimal Live Spotter data |
|
| 161 | + * |
|
| 162 | + * @return Array the spotter information |
|
| 163 | + * |
|
| 164 | + */ |
|
| 165 | 165 | public function getMinLiveSpotterData($filter = array()) |
| 166 | 166 | { |
| 167 | 167 | global $globalDBdriver, $globalLiveInterval; |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 218 | - * |
|
| 219 | - * @return Array the spotter information |
|
| 220 | - * |
|
| 221 | - */ |
|
| 217 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 218 | + * |
|
| 219 | + * @return Array the spotter information |
|
| 220 | + * |
|
| 221 | + */ |
|
| 222 | 222 | public function getMinLastLiveSpotterData($filter = array()) |
| 223 | 223 | { |
| 224 | 224 | global $globalDBdriver, $globalLiveInterval; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 237 | 237 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 238 | 238 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 239 | - } else { |
|
| 239 | + } else { |
|
| 240 | 240 | /* |
| 241 | 241 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 242 | 242 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | // echo $query; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - try { |
|
| 251 | + try { |
|
| 252 | 252 | $sth = $this->db->prepare($query); |
| 253 | 253 | $sth->execute(); |
| 254 | 254 | } catch(PDOException $e) { |
@@ -260,11 +260,11 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
| 263 | - * Gets number of latest data entry |
|
| 264 | - * |
|
| 265 | - * @return String number of entry |
|
| 266 | - * |
|
| 267 | - */ |
|
| 263 | + * Gets number of latest data entry |
|
| 264 | + * |
|
| 265 | + * @return String number of entry |
|
| 266 | + * |
|
| 267 | + */ |
|
| 268 | 268 | public function getLiveSpotterCount($filter = array()) |
| 269 | 269 | { |
| 270 | 270 | global $globalDBdriver, $globalLiveInterval; |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 295 | - * |
|
| 296 | - * @return Array the spotter information |
|
| 297 | - * |
|
| 298 | - */ |
|
| 294 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 295 | + * |
|
| 296 | + * @return Array the spotter information |
|
| 297 | + * |
|
| 298 | + */ |
|
| 299 | 299 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 300 | 300 | { |
| 301 | 301 | global $globalDBdriver, $globalLiveInterval; |
@@ -320,11 +320,11 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 324 | - * |
|
| 325 | - * @return Array the spotter information |
|
| 326 | - * |
|
| 327 | - */ |
|
| 323 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 324 | + * |
|
| 325 | + * @return Array the spotter information |
|
| 326 | + * |
|
| 327 | + */ |
|
| 328 | 328 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 329 | 329 | { |
| 330 | 330 | $Spotter = new Spotter($this->db); |
@@ -334,145 +334,145 @@ discard block |
||
| 334 | 334 | return false; |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | - if ($lng != '') |
|
| 338 | - { |
|
| 339 | - if (!is_numeric($lng)) |
|
| 340 | - { |
|
| 341 | - return false; |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - if ($radius != '') |
|
| 346 | - { |
|
| 347 | - if (!is_numeric($radius)) |
|
| 348 | - { |
|
| 349 | - return false; |
|
| 350 | - } |
|
| 351 | - } |
|
| 337 | + if ($lng != '') |
|
| 338 | + { |
|
| 339 | + if (!is_numeric($lng)) |
|
| 340 | + { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + if ($radius != '') |
|
| 346 | + { |
|
| 347 | + if (!is_numeric($radius)) |
|
| 348 | + { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | 352 | $additional_query = ''; |
| 353 | - if ($interval != '') |
|
| 354 | - { |
|
| 355 | - if (!is_string($interval)) |
|
| 356 | - { |
|
| 357 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 358 | - return false; |
|
| 359 | - } else { |
|
| 360 | - if ($interval == '1m') |
|
| 361 | - { |
|
| 362 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 363 | - } else if ($interval == '15m'){ |
|
| 364 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 365 | - } |
|
| 366 | - } |
|
| 367 | - } else { |
|
| 368 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 353 | + if ($interval != '') |
|
| 354 | + { |
|
| 355 | + if (!is_string($interval)) |
|
| 356 | + { |
|
| 357 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 358 | + return false; |
|
| 359 | + } else { |
|
| 360 | + if ($interval == '1m') |
|
| 361 | + { |
|
| 362 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 363 | + } else if ($interval == '15m'){ |
|
| 364 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + } else { |
|
| 368 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 372 | 372 | WHERE spotter_live.latitude <> '' |
| 373 | 373 | AND spotter_live.longitude <> '' |
| 374 | 374 | ".$additional_query." |
| 375 | 375 | HAVING distance < :radius |
| 376 | 376 | ORDER BY distance"; |
| 377 | 377 | |
| 378 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 378 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 379 | 379 | |
| 380 | - return $spotter_array; |
|
| 381 | - } |
|
| 380 | + return $spotter_array; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | 383 | |
| 384 | - /** |
|
| 385 | - * Gets all the spotter information based on a particular callsign |
|
| 386 | - * |
|
| 387 | - * @return Array the spotter information |
|
| 388 | - * |
|
| 389 | - */ |
|
| 384 | + /** |
|
| 385 | + * Gets all the spotter information based on a particular callsign |
|
| 386 | + * |
|
| 387 | + * @return Array the spotter information |
|
| 388 | + * |
|
| 389 | + */ |
|
| 390 | 390 | public function getLastLiveSpotterDataByIdent($ident) |
| 391 | 391 | { |
| 392 | 392 | $Spotter = new Spotter($this->db); |
| 393 | 393 | date_default_timezone_set('UTC'); |
| 394 | 394 | |
| 395 | 395 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 396 | - $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 396 | + $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 397 | 397 | |
| 398 | 398 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 399 | 399 | |
| 400 | 400 | return $spotter_array; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * Gets all the spotter information based on a particular callsign |
|
| 405 | - * |
|
| 406 | - * @return Array the spotter information |
|
| 407 | - * |
|
| 408 | - */ |
|
| 403 | + /** |
|
| 404 | + * Gets all the spotter information based on a particular callsign |
|
| 405 | + * |
|
| 406 | + * @return Array the spotter information |
|
| 407 | + * |
|
| 408 | + */ |
|
| 409 | 409 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 410 | 410 | { |
| 411 | 411 | $Spotter = new Spotter($this->db); |
| 412 | 412 | date_default_timezone_set('UTC'); |
| 413 | 413 | |
| 414 | 414 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 415 | - $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 415 | + $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 416 | 416 | |
| 417 | - $date = date('c',$date); |
|
| 417 | + $date = date('c',$date); |
|
| 418 | 418 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 419 | 419 | |
| 420 | 420 | return $spotter_array; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - /** |
|
| 424 | - * Gets last spotter information based on a particular callsign |
|
| 425 | - * |
|
| 426 | - * @return Array the spotter information |
|
| 427 | - * |
|
| 428 | - */ |
|
| 423 | + /** |
|
| 424 | + * Gets last spotter information based on a particular callsign |
|
| 425 | + * |
|
| 426 | + * @return Array the spotter information |
|
| 427 | + * |
|
| 428 | + */ |
|
| 429 | 429 | public function getLastLiveSpotterDataById($id) |
| 430 | 430 | { |
| 431 | 431 | $Spotter = new Spotter($this->db); |
| 432 | 432 | date_default_timezone_set('UTC'); |
| 433 | 433 | |
| 434 | 434 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 435 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 435 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 436 | 436 | |
| 437 | 437 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
| 438 | 438 | |
| 439 | 439 | return $spotter_array; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Gets last spotter information based on a particular callsign |
|
| 444 | - * |
|
| 445 | - * @return Array the spotter information |
|
| 446 | - * |
|
| 447 | - */ |
|
| 442 | + /** |
|
| 443 | + * Gets last spotter information based on a particular callsign |
|
| 444 | + * |
|
| 445 | + * @return Array the spotter information |
|
| 446 | + * |
|
| 447 | + */ |
|
| 448 | 448 | public function getDateLiveSpotterDataById($id,$date) |
| 449 | 449 | { |
| 450 | 450 | $Spotter = new Spotter($this->db); |
| 451 | 451 | date_default_timezone_set('UTC'); |
| 452 | 452 | |
| 453 | 453 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 454 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 455 | - $date = date('c',$date); |
|
| 454 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 455 | + $date = date('c',$date); |
|
| 456 | 456 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 457 | 457 | |
| 458 | 458 | return $spotter_array; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - /** |
|
| 462 | - * Gets altitude information based on a particular callsign |
|
| 463 | - * |
|
| 464 | - * @return Array the spotter information |
|
| 465 | - * |
|
| 466 | - */ |
|
| 461 | + /** |
|
| 462 | + * Gets altitude information based on a particular callsign |
|
| 463 | + * |
|
| 464 | + * @return Array the spotter information |
|
| 465 | + * |
|
| 466 | + */ |
|
| 467 | 467 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 468 | 468 | { |
| 469 | 469 | |
| 470 | 470 | date_default_timezone_set('UTC'); |
| 471 | 471 | |
| 472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 473 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 473 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 474 | 474 | |
| 475 | - try { |
|
| 475 | + try { |
|
| 476 | 476 | |
| 477 | 477 | $sth = $this->db->prepare($query); |
| 478 | 478 | $sth->execute(array(':ident' => $ident)); |
@@ -485,12 +485,12 @@ discard block |
||
| 485 | 485 | return $spotter_array; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - /** |
|
| 489 | - * Gets all the spotter information based on a particular id |
|
| 490 | - * |
|
| 491 | - * @return Array the spotter information |
|
| 492 | - * |
|
| 493 | - */ |
|
| 488 | + /** |
|
| 489 | + * Gets all the spotter information based on a particular id |
|
| 490 | + * |
|
| 491 | + * @return Array the spotter information |
|
| 492 | + * |
|
| 493 | + */ |
|
| 494 | 494 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 495 | 495 | { |
| 496 | 496 | global $globalDBdriver, $globalLiveInterval; |
@@ -518,18 +518,18 @@ discard block |
||
| 518 | 518 | return $spotter_array; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - /** |
|
| 522 | - * Gets all the spotter information based on a particular ident |
|
| 523 | - * |
|
| 524 | - * @return Array the spotter information |
|
| 525 | - * |
|
| 526 | - */ |
|
| 521 | + /** |
|
| 522 | + * Gets all the spotter information based on a particular ident |
|
| 523 | + * |
|
| 524 | + * @return Array the spotter information |
|
| 525 | + * |
|
| 526 | + */ |
|
| 527 | 527 | public function getAllLiveSpotterDataByIdent($ident) |
| 528 | 528 | { |
| 529 | 529 | date_default_timezone_set('UTC'); |
| 530 | 530 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 531 | 531 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 532 | - try { |
|
| 532 | + try { |
|
| 533 | 533 | |
| 534 | 534 | $sth = $this->db->prepare($query); |
| 535 | 535 | $sth->execute(array(':ident' => $ident)); |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | |
| 545 | 545 | /** |
| 546 | - * Deletes all info in the table |
|
| 547 | - * |
|
| 548 | - * @return String success or false |
|
| 549 | - * |
|
| 550 | - */ |
|
| 546 | + * Deletes all info in the table |
|
| 547 | + * |
|
| 548 | + * @return String success or false |
|
| 549 | + * |
|
| 550 | + */ |
|
| 551 | 551 | public function deleteLiveSpotterData() |
| 552 | 552 | { |
| 553 | 553 | global $globalDBdriver; |
| 554 | 554 | if ($globalDBdriver == 'mysql') { |
| 555 | 555 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 556 | 556 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 557 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 557 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 558 | 558 | } else { |
| 559 | 559 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - try { |
|
| 562 | + try { |
|
| 563 | 563 | |
| 564 | 564 | $sth = $this->db->prepare($query); |
| 565 | 565 | $sth->execute(); |
@@ -571,18 +571,18 @@ discard block |
||
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
| 574 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 575 | - * |
|
| 576 | - * @return String success or false |
|
| 577 | - * |
|
| 578 | - */ |
|
| 574 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 575 | + * |
|
| 576 | + * @return String success or false |
|
| 577 | + * |
|
| 578 | + */ |
|
| 579 | 579 | public function deleteLiveSpotterDataNotUpdated() |
| 580 | 580 | { |
| 581 | 581 | global $globalDBdriver, $globalDebug; |
| 582 | 582 | if ($globalDBdriver == 'mysql') { |
| 583 | 583 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 584 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 585 | - try { |
|
| 584 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 585 | + try { |
|
| 586 | 586 | |
| 587 | 587 | $sth = $this->db->prepare($query); |
| 588 | 588 | $sth->execute(); |
@@ -590,8 +590,8 @@ discard block |
||
| 590 | 590 | return "error"; |
| 591 | 591 | } |
| 592 | 592 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 593 | - $i = 0; |
|
| 594 | - $j =0; |
|
| 593 | + $i = 0; |
|
| 594 | + $j =0; |
|
| 595 | 595 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 596 | 596 | foreach($all as $row) |
| 597 | 597 | { |
@@ -599,20 +599,20 @@ discard block |
||
| 599 | 599 | $j++; |
| 600 | 600 | if ($j == 30) { |
| 601 | 601 | if ($globalDebug) echo "."; |
| 602 | - try { |
|
| 602 | + try { |
|
| 603 | 603 | |
| 604 | 604 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 605 | 605 | $sth->execute(); |
| 606 | 606 | } catch(PDOException $e) { |
| 607 | 607 | return "error"; |
| 608 | 608 | } |
| 609 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 610 | - $j = 0; |
|
| 609 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 610 | + $j = 0; |
|
| 611 | 611 | } |
| 612 | 612 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 613 | 613 | } |
| 614 | 614 | if ($i > 0) { |
| 615 | - try { |
|
| 615 | + try { |
|
| 616 | 616 | |
| 617 | 617 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 618 | 618 | $sth->execute(); |
@@ -623,9 +623,9 @@ discard block |
||
| 623 | 623 | return "success"; |
| 624 | 624 | } elseif ($globalDBdriver == 'pgsql') { |
| 625 | 625 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 626 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 627 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 628 | - try { |
|
| 626 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 627 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 628 | + try { |
|
| 629 | 629 | |
| 630 | 630 | $sth = $this->db->prepare($query); |
| 631 | 631 | $sth->execute(); |
@@ -669,17 +669,17 @@ discard block |
||
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | - * Deletes all info in the table for an ident |
|
| 673 | - * |
|
| 674 | - * @return String success or false |
|
| 675 | - * |
|
| 676 | - */ |
|
| 672 | + * Deletes all info in the table for an ident |
|
| 673 | + * |
|
| 674 | + * @return String success or false |
|
| 675 | + * |
|
| 676 | + */ |
|
| 677 | 677 | public function deleteLiveSpotterDataByIdent($ident) |
| 678 | 678 | { |
| 679 | 679 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 680 | 680 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 681 | 681 | |
| 682 | - try { |
|
| 682 | + try { |
|
| 683 | 683 | |
| 684 | 684 | $sth = $this->db->prepare($query); |
| 685 | 685 | $sth->execute(array(':ident' => $ident)); |
@@ -691,17 +691,17 @@ discard block |
||
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | - * Deletes all info in the table for an id |
|
| 695 | - * |
|
| 696 | - * @return String success or false |
|
| 697 | - * |
|
| 698 | - */ |
|
| 694 | + * Deletes all info in the table for an id |
|
| 695 | + * |
|
| 696 | + * @return String success or false |
|
| 697 | + * |
|
| 698 | + */ |
|
| 699 | 699 | public function deleteLiveSpotterDataById($id) |
| 700 | 700 | { |
| 701 | 701 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 702 | 702 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 703 | 703 | |
| 704 | - try { |
|
| 704 | + try { |
|
| 705 | 705 | |
| 706 | 706 | $sth = $this->db->prepare($query); |
| 707 | 707 | $sth->execute(array(':id' => $id)); |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | - * Gets the aircraft ident within the last hour |
|
| 718 | - * |
|
| 719 | - * @return String the ident |
|
| 720 | - * |
|
| 721 | - */ |
|
| 717 | + * Gets the aircraft ident within the last hour |
|
| 718 | + * |
|
| 719 | + * @return String the ident |
|
| 720 | + * |
|
| 721 | + */ |
|
| 722 | 722 | public function getIdentFromLastHour($ident) |
| 723 | 723 | { |
| 724 | 724 | global $globalDBdriver, $globalTimezone; |
@@ -744,14 +744,14 @@ discard block |
||
| 744 | 744 | $ident_result = $row['ident']; |
| 745 | 745 | } |
| 746 | 746 | return $ident_result; |
| 747 | - } |
|
| 747 | + } |
|
| 748 | 748 | |
| 749 | 749 | /** |
| 750 | - * Check recent aircraft |
|
| 751 | - * |
|
| 752 | - * @return String the ident |
|
| 753 | - * |
|
| 754 | - */ |
|
| 750 | + * Check recent aircraft |
|
| 751 | + * |
|
| 752 | + * @return String the ident |
|
| 753 | + * |
|
| 754 | + */ |
|
| 755 | 755 | public function checkIdentRecent($ident) |
| 756 | 756 | { |
| 757 | 757 | global $globalDBdriver, $globalTimezone; |
@@ -777,14 +777,14 @@ discard block |
||
| 777 | 777 | $ident_result = $row['flightaware_id']; |
| 778 | 778 | } |
| 779 | 779 | return $ident_result; |
| 780 | - } |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | - * Check recent aircraft by id |
|
| 784 | - * |
|
| 785 | - * @return String the ident |
|
| 786 | - * |
|
| 787 | - */ |
|
| 783 | + * Check recent aircraft by id |
|
| 784 | + * |
|
| 785 | + * @return String the ident |
|
| 786 | + * |
|
| 787 | + */ |
|
| 788 | 788 | public function checkIdRecent($id) |
| 789 | 789 | { |
| 790 | 790 | global $globalDBdriver, $globalTimezone; |
@@ -810,14 +810,14 @@ discard block |
||
| 810 | 810 | $ident_result = $row['flightaware_id']; |
| 811 | 811 | } |
| 812 | 812 | return $ident_result; |
| 813 | - } |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Check recent aircraft by ModeS |
|
| 817 | - * |
|
| 818 | - * @return String the ModeS |
|
| 819 | - * |
|
| 820 | - */ |
|
| 816 | + * Check recent aircraft by ModeS |
|
| 817 | + * |
|
| 818 | + * @return String the ModeS |
|
| 819 | + * |
|
| 820 | + */ |
|
| 821 | 821 | public function checkModeSRecent($modes) |
| 822 | 822 | { |
| 823 | 823 | global $globalDBdriver, $globalTimezone; |
@@ -844,19 +844,19 @@ discard block |
||
| 844 | 844 | $ident_result = $row['flightaware_id']; |
| 845 | 845 | } |
| 846 | 846 | return $ident_result; |
| 847 | - } |
|
| 847 | + } |
|
| 848 | 848 | |
| 849 | 849 | /** |
| 850 | - * Adds a new spotter data |
|
| 851 | - * |
|
| 852 | - * @param String $flightaware_id the ID from flightaware |
|
| 853 | - * @param String $ident the flight ident |
|
| 854 | - * @param String $aircraft_icao the aircraft type |
|
| 855 | - * @param String $departure_airport_icao the departure airport |
|
| 856 | - * @param String $arrival_airport_icao the arrival airport |
|
| 857 | - * @return String success or false |
|
| 858 | - * |
|
| 859 | - */ |
|
| 850 | + * Adds a new spotter data |
|
| 851 | + * |
|
| 852 | + * @param String $flightaware_id the ID from flightaware |
|
| 853 | + * @param String $ident the flight ident |
|
| 854 | + * @param String $aircraft_icao the aircraft type |
|
| 855 | + * @param String $departure_airport_icao the departure airport |
|
| 856 | + * @param String $arrival_airport_icao the arrival airport |
|
| 857 | + * @return String success or false |
|
| 858 | + * |
|
| 859 | + */ |
|
| 860 | 860 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 861 | 861 | { |
| 862 | 862 | global $globalURL, $globalArchive, $globalDebug; |
@@ -991,10 +991,10 @@ discard block |
||
| 991 | 991 | $arrival_airport_country = ''; |
| 992 | 992 | |
| 993 | 993 | |
| 994 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 995 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 996 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 997 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 994 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 995 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 996 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 997 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 998 | 998 | |
| 999 | 999 | $query = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 1000 | 1000 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1004,14 +1004,14 @@ discard block |
||
| 1004 | 1004 | |
| 1005 | 1005 | $sth = $this->db->prepare($query); |
| 1006 | 1006 | $sth->execute($query_values); |
| 1007 | - } catch(PDOException $e) { |
|
| 1008 | - return "error : ".$e->getMessage(); |
|
| 1009 | - } |
|
| 1007 | + } catch(PDOException $e) { |
|
| 1008 | + return "error : ".$e->getMessage(); |
|
| 1009 | + } |
|
| 1010 | 1010 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1011 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1012 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1013 | - $result = $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1014 | - if ($globalDebug) echo $result.')'; |
|
| 1011 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1012 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1013 | + $result = $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1014 | + if ($globalDebug) echo $result.')'; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | return "success"; |
| 1017 | 1017 | |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) { |
|
| 30 | + $filter = array_merge($filter,$globalFilter); |
|
| 31 | + } |
|
| 30 | 32 | $filter_query_join = ''; |
| 31 | 33 | $filter_query_where = ''; |
| 32 | 34 | foreach($filters as $flt) { |
@@ -101,8 +103,11 @@ discard block |
||
| 101 | 103 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 102 | 104 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 103 | 105 | } |
| 104 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 105 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 106 | + if ($filter_query_where == '' && $where) { |
|
| 107 | + $filter_query_where = ' WHERE'; |
|
| 108 | + } elseif ($filter_query_where != '' && $and) { |
|
| 109 | + $filter_query_where .= ' AND'; |
|
| 110 | + } |
|
| 106 | 111 | if ($filter_query_where != '') { |
| 107 | 112 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 108 | 113 | } |
@@ -144,7 +149,9 @@ discard block |
||
| 144 | 149 | } |
| 145 | 150 | } |
| 146 | 151 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 152 | + if (!isset($globalLiveInterval)) { |
|
| 153 | + $globalLiveInterval = '200'; |
|
| 154 | + } |
|
| 148 | 155 | if ($globalDBdriver == 'mysql') { |
| 149 | 156 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 150 | 157 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -169,7 +176,9 @@ discard block |
||
| 169 | 176 | |
| 170 | 177 | $filter_query = $this->getFilter($filter,true,true); |
| 171 | 178 | |
| 172 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 179 | + if (!isset($globalLiveInterval)) { |
|
| 180 | + $globalLiveInterval = '200'; |
|
| 181 | + } |
|
| 173 | 182 | if ($globalDBdriver == 'mysql') { |
| 174 | 183 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
| 175 | 184 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -226,7 +235,9 @@ discard block |
||
| 226 | 235 | |
| 227 | 236 | $filter_query = $this->getFilter($filter,true,true); |
| 228 | 237 | |
| 229 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 238 | + if (!isset($globalLiveInterval)) { |
|
| 239 | + $globalLiveInterval = '200'; |
|
| 240 | + } |
|
| 230 | 241 | if ($globalDBdriver == 'mysql') { |
| 231 | 242 | /* |
| 232 | 243 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -270,7 +281,9 @@ discard block |
||
| 270 | 281 | global $globalDBdriver, $globalLiveInterval; |
| 271 | 282 | $filter_query = $this->getFilter($filter,true,true); |
| 272 | 283 | |
| 273 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 284 | + if (!isset($globalLiveInterval)) { |
|
| 285 | + $globalLiveInterval = '200'; |
|
| 286 | + } |
|
| 274 | 287 | if ($globalDBdriver == 'mysql') { |
| 275 | 288 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 276 | 289 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -300,7 +313,9 @@ discard block |
||
| 300 | 313 | { |
| 301 | 314 | global $globalDBdriver, $globalLiveInterval; |
| 302 | 315 | $Spotter = new Spotter($this->db); |
| 303 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 316 | + if (!isset($globalLiveInterval)) { |
|
| 317 | + $globalLiveInterval = '200'; |
|
| 318 | + } |
|
| 304 | 319 | $filter_query = $this->getFilter($filter); |
| 305 | 320 | |
| 306 | 321 | if (is_array($coord)) { |
@@ -308,7 +323,9 @@ discard block |
||
| 308 | 323 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 309 | 324 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 310 | 325 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 311 | - } else return array(); |
|
| 326 | + } else { |
|
| 327 | + return array(); |
|
| 328 | + } |
|
| 312 | 329 | if ($globalDBdriver == 'mysql') { |
| 313 | 330 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
| 314 | 331 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -499,11 +516,15 @@ discard block |
||
| 499 | 516 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 500 | 517 | if ($globalDBdriver == 'mysql') { |
| 501 | 518 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 502 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 519 | + if ($liveinterval) { |
|
| 520 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 521 | + } |
|
| 503 | 522 | $query .= ' ORDER BY date'; |
| 504 | 523 | } else { |
| 505 | 524 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 506 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 525 | + if ($liveinterval) { |
|
| 526 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 527 | + } |
|
| 507 | 528 | $query .= ' ORDER BY date'; |
| 508 | 529 | } |
| 509 | 530 | |
@@ -598,7 +619,9 @@ discard block |
||
| 598 | 619 | $i++; |
| 599 | 620 | $j++; |
| 600 | 621 | if ($j == 30) { |
| 601 | - if ($globalDebug) echo "."; |
|
| 622 | + if ($globalDebug) { |
|
| 623 | + echo "."; |
|
| 624 | + } |
|
| 602 | 625 | try { |
| 603 | 626 | |
| 604 | 627 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -905,7 +928,9 @@ discard block |
||
| 905 | 928 | { |
| 906 | 929 | return false; |
| 907 | 930 | } |
| 908 | - } else return ''; |
|
| 931 | + } else { |
|
| 932 | + return ''; |
|
| 933 | + } |
|
| 909 | 934 | |
| 910 | 935 | if ($longitude != '') |
| 911 | 936 | { |
@@ -913,7 +938,9 @@ discard block |
||
| 913 | 938 | { |
| 914 | 939 | return false; |
| 915 | 940 | } |
| 916 | - } else return ''; |
|
| 941 | + } else { |
|
| 942 | + return ''; |
|
| 943 | + } |
|
| 917 | 944 | |
| 918 | 945 | if ($waypoints != '') |
| 919 | 946 | { |
@@ -929,7 +956,9 @@ discard block |
||
| 929 | 956 | { |
| 930 | 957 | return false; |
| 931 | 958 | } |
| 932 | - } else $altitude = 0; |
|
| 959 | + } else { |
|
| 960 | + $altitude = 0; |
|
| 961 | + } |
|
| 933 | 962 | |
| 934 | 963 | if ($heading != '') |
| 935 | 964 | { |
@@ -937,7 +966,9 @@ discard block |
||
| 937 | 966 | { |
| 938 | 967 | return false; |
| 939 | 968 | } |
| 940 | - } else $heading = 0; |
|
| 969 | + } else { |
|
| 970 | + $heading = 0; |
|
| 971 | + } |
|
| 941 | 972 | |
| 942 | 973 | if ($groundspeed != '') |
| 943 | 974 | { |
@@ -945,9 +976,13 @@ discard block |
||
| 945 | 976 | { |
| 946 | 977 | return false; |
| 947 | 978 | } |
| 948 | - } else $groundspeed = 0; |
|
| 979 | + } else { |
|
| 980 | + $groundspeed = 0; |
|
| 981 | + } |
|
| 949 | 982 | date_default_timezone_set('UTC'); |
| 950 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 983 | + if ($date == '') { |
|
| 984 | + $date = date("Y-m-d H:i:s", time()); |
|
| 985 | + } |
|
| 951 | 986 | |
| 952 | 987 | |
| 953 | 988 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -991,10 +1026,18 @@ discard block |
||
| 991 | 1026 | $arrival_airport_country = ''; |
| 992 | 1027 | |
| 993 | 1028 | |
| 994 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 995 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 996 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 997 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1029 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1030 | + $squawk = NULL; |
|
| 1031 | + } |
|
| 1032 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1033 | + $verticalrate = NULL; |
|
| 1034 | + } |
|
| 1035 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1036 | + $groundspeed = 0; |
|
| 1037 | + } |
|
| 1038 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1039 | + $heading = 0; |
|
| 1040 | + } |
|
| 998 | 1041 | |
| 999 | 1042 | $query = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 1000 | 1043 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1008,10 +1051,14 @@ discard block |
||
| 1008 | 1051 | return "error : ".$e->getMessage(); |
| 1009 | 1052 | } |
| 1010 | 1053 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1011 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1054 | + if ($globalDebug) { |
|
| 1055 | + echo '(Add to SBS archive : '; |
|
| 1056 | + } |
|
| 1012 | 1057 | $SpotterArchive = new SpotterArchive($this->db); |
| 1013 | 1058 | $result = $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1014 | - if ($globalDebug) echo $result.')'; |
|
| 1059 | + if ($globalDebug) { |
|
| 1060 | + echo $result.')'; |
|
| 1061 | + } |
|
| 1015 | 1062 | } |
| 1016 | 1063 | return "success"; |
| 1017 | 1064 | |
@@ -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,74 +27,74 @@ 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'])."')) saff ON saff.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'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 36 | - } |
|
| 36 | + } |
|
| 37 | + } |
|
| 37 | 38 | } |
| 38 | - } |
|
| 39 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 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'])."')) sp ON sp.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'])."')) sp ON sp.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'])."')) sp ON sp.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'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 44 | 44 | } |
| 45 | - } |
|
| 46 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
| 45 | + } |
|
| 46 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 49 | + } |
|
| 49 | 50 | } |
| 50 | - } |
|
| 51 | 51 | } |
| 52 | 52 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 53 | - if ($filter['airlines'][0] != '') { |
|
| 53 | + if ($filter['airlines'][0] != '') { |
|
| 54 | 54 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 59 | - $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 "; |
|
| 59 | + $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 "; |
|
| 60 | 60 | } |
| 61 | 61 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 63 | 63 | } |
| 64 | 64 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 65 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 65 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 66 | 66 | } |
| 67 | 67 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 68 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 68 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 71 | 71 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 72 | 72 | } |
| 73 | 73 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 74 | - $filter_query_date = ''; |
|
| 74 | + $filter_query_date = ''; |
|
| 75 | 75 | |
| 76 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
| 76 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
| 77 | 77 | if ($globalDBdriver == 'mysql') { |
| 78 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 78 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 79 | 79 | } else { |
| 80 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 80 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 81 | 81 | } |
| 82 | - } |
|
| 83 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
| 82 | + } |
|
| 83 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
| 84 | 84 | if ($globalDBdriver == 'mysql') { |
| 85 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 85 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 86 | 86 | } else { |
| 87 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 87 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 88 | + } |
|
| 88 | 89 | } |
| 89 | - } |
|
| 90 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
| 90 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
| 91 | 91 | if ($globalDBdriver == 'mysql') { |
| 92 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 92 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 93 | 93 | } else { |
| 94 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 94 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 95 | + } |
|
| 95 | 96 | } |
| 96 | - } |
|
| 97 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 97 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 98 | 98 | } |
| 99 | 99 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 100 | 100 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | $filter_query = $filter_query_join.$filter_query_where; |
| 105 | 105 | return $filter_query; |
| 106 | - } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | // Spotter_archive |
| 109 | 109 | 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 = '') { |
@@ -134,44 +134,44 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Gets all the spotter information based on a particular callsign |
|
| 139 | - * |
|
| 140 | - * @return Array the spotter information |
|
| 141 | - * |
|
| 142 | - */ |
|
| 143 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 144 | - { |
|
| 137 | + /** |
|
| 138 | + * Gets all the spotter information based on a particular callsign |
|
| 139 | + * |
|
| 140 | + * @return Array the spotter information |
|
| 141 | + * |
|
| 142 | + */ |
|
| 143 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 144 | + { |
|
| 145 | 145 | $Spotter = new Spotter($this->db); |
| 146 | - date_default_timezone_set('UTC'); |
|
| 146 | + date_default_timezone_set('UTC'); |
|
| 147 | 147 | |
| 148 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 149 | - //$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"; |
|
| 150 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 148 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 149 | + //$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"; |
|
| 150 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 151 | 151 | |
| 152 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 152 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 153 | 153 | |
| 154 | - return $spotter_array; |
|
| 155 | - } |
|
| 154 | + return $spotter_array; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Gets last the spotter information based on a particular id |
|
| 160 | - * |
|
| 161 | - * @return Array the spotter information |
|
| 162 | - * |
|
| 163 | - */ |
|
| 164 | - public function getLastArchiveSpotterDataById($id) |
|
| 165 | - { |
|
| 166 | - $Spotter = new Spotter($this->db); |
|
| 167 | - date_default_timezone_set('UTC'); |
|
| 168 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 169 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 170 | - //$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"; |
|
| 171 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 158 | + /** |
|
| 159 | + * Gets last the spotter information based on a particular id |
|
| 160 | + * |
|
| 161 | + * @return Array the spotter information |
|
| 162 | + * |
|
| 163 | + */ |
|
| 164 | + public function getLastArchiveSpotterDataById($id) |
|
| 165 | + { |
|
| 166 | + $Spotter = new Spotter($this->db); |
|
| 167 | + date_default_timezone_set('UTC'); |
|
| 168 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 169 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 170 | + //$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"; |
|
| 171 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 172 | 172 | |
| 173 | 173 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 174 | - /* |
|
| 174 | + /* |
|
| 175 | 175 | try { |
| 176 | 176 | $Connection = new Connection(); |
| 177 | 177 | $sth = Connection->$db->prepare($query); |
@@ -181,232 +181,232 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 183 | 183 | */ |
| 184 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 185 | - |
|
| 186 | - return $spotter_array; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Gets all the spotter information based on a particular id |
|
| 191 | - * |
|
| 192 | - * @return Array the spotter information |
|
| 193 | - * |
|
| 194 | - */ |
|
| 195 | - public function getAllArchiveSpotterDataById($id) |
|
| 196 | - { |
|
| 197 | - date_default_timezone_set('UTC'); |
|
| 198 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 199 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 184 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 185 | + |
|
| 186 | + return $spotter_array; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Gets all the spotter information based on a particular id |
|
| 191 | + * |
|
| 192 | + * @return Array the spotter information |
|
| 193 | + * |
|
| 194 | + */ |
|
| 195 | + public function getAllArchiveSpotterDataById($id) |
|
| 196 | + { |
|
| 197 | + date_default_timezone_set('UTC'); |
|
| 198 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 199 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 200 | 200 | |
| 201 | 201 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 202 | 202 | |
| 203 | - try { |
|
| 204 | - $sth = $this->db->prepare($query); |
|
| 205 | - $sth->execute(array(':id' => $id)); |
|
| 206 | - } catch(PDOException $e) { |
|
| 207 | - echo $e->getMessage(); |
|
| 208 | - die; |
|
| 209 | - } |
|
| 210 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 211 | - |
|
| 212 | - return $spotter_array; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Gets coordinate & time spotter information based on a particular id |
|
| 217 | - * |
|
| 218 | - * @return Array the spotter information |
|
| 219 | - * |
|
| 220 | - */ |
|
| 221 | - public function getCoordArchiveSpotterDataById($id) |
|
| 222 | - { |
|
| 223 | - date_default_timezone_set('UTC'); |
|
| 224 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 225 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 203 | + try { |
|
| 204 | + $sth = $this->db->prepare($query); |
|
| 205 | + $sth->execute(array(':id' => $id)); |
|
| 206 | + } catch(PDOException $e) { |
|
| 207 | + echo $e->getMessage(); |
|
| 208 | + die; |
|
| 209 | + } |
|
| 210 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 211 | + |
|
| 212 | + return $spotter_array; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Gets coordinate & time spotter information based on a particular id |
|
| 217 | + * |
|
| 218 | + * @return Array the spotter information |
|
| 219 | + * |
|
| 220 | + */ |
|
| 221 | + public function getCoordArchiveSpotterDataById($id) |
|
| 222 | + { |
|
| 223 | + date_default_timezone_set('UTC'); |
|
| 224 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 225 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 226 | 226 | |
| 227 | 227 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 228 | 228 | |
| 229 | - try { |
|
| 230 | - $sth = $this->db->prepare($query); |
|
| 231 | - $sth->execute(array(':id' => $id)); |
|
| 232 | - } catch(PDOException $e) { |
|
| 233 | - echo $e->getMessage(); |
|
| 234 | - die; |
|
| 235 | - } |
|
| 236 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 229 | + try { |
|
| 230 | + $sth = $this->db->prepare($query); |
|
| 231 | + $sth->execute(array(':id' => $id)); |
|
| 232 | + } catch(PDOException $e) { |
|
| 233 | + echo $e->getMessage(); |
|
| 234 | + die; |
|
| 235 | + } |
|
| 236 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 237 | 237 | |
| 238 | - return $spotter_array; |
|
| 239 | - } |
|
| 238 | + return $spotter_array; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Gets altitude information based on a particular callsign |
|
| 244 | - * |
|
| 245 | - * @return Array the spotter information |
|
| 246 | - * |
|
| 247 | - */ |
|
| 248 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 249 | - { |
|
| 242 | + /** |
|
| 243 | + * Gets altitude information based on a particular callsign |
|
| 244 | + * |
|
| 245 | + * @return Array the spotter information |
|
| 246 | + * |
|
| 247 | + */ |
|
| 248 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 249 | + { |
|
| 250 | 250 | |
| 251 | - date_default_timezone_set('UTC'); |
|
| 251 | + date_default_timezone_set('UTC'); |
|
| 252 | 252 | |
| 253 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 254 | - $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"; |
|
| 253 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 254 | + $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"; |
|
| 255 | 255 | |
| 256 | - try { |
|
| 257 | - $sth = $this->db->prepare($query); |
|
| 258 | - $sth->execute(array(':ident' => $ident)); |
|
| 259 | - } catch(PDOException $e) { |
|
| 260 | - echo $e->getMessage(); |
|
| 261 | - die; |
|
| 262 | - } |
|
| 263 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 256 | + try { |
|
| 257 | + $sth = $this->db->prepare($query); |
|
| 258 | + $sth->execute(array(':ident' => $ident)); |
|
| 259 | + } catch(PDOException $e) { |
|
| 260 | + echo $e->getMessage(); |
|
| 261 | + die; |
|
| 262 | + } |
|
| 263 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 264 | 264 | |
| 265 | - return $spotter_array; |
|
| 266 | - } |
|
| 265 | + return $spotter_array; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Gets altitude information based on a particular id |
|
| 270 | - * |
|
| 271 | - * @return Array the spotter information |
|
| 272 | - * |
|
| 273 | - */ |
|
| 274 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 275 | - { |
|
| 268 | + /** |
|
| 269 | + * Gets altitude information based on a particular id |
|
| 270 | + * |
|
| 271 | + * @return Array the spotter information |
|
| 272 | + * |
|
| 273 | + */ |
|
| 274 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 275 | + { |
|
| 276 | 276 | |
| 277 | - date_default_timezone_set('UTC'); |
|
| 277 | + date_default_timezone_set('UTC'); |
|
| 278 | 278 | |
| 279 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 280 | - $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"; |
|
| 279 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 280 | + $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"; |
|
| 281 | 281 | |
| 282 | - try { |
|
| 283 | - $sth = $this->db->prepare($query); |
|
| 284 | - $sth->execute(array(':id' => $id)); |
|
| 285 | - } catch(PDOException $e) { |
|
| 286 | - echo $e->getMessage(); |
|
| 287 | - die; |
|
| 288 | - } |
|
| 289 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 282 | + try { |
|
| 283 | + $sth = $this->db->prepare($query); |
|
| 284 | + $sth->execute(array(':id' => $id)); |
|
| 285 | + } catch(PDOException $e) { |
|
| 286 | + echo $e->getMessage(); |
|
| 287 | + die; |
|
| 288 | + } |
|
| 289 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 290 | 290 | |
| 291 | - return $spotter_array; |
|
| 292 | - } |
|
| 291 | + return $spotter_array; |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - /** |
|
| 295 | - * Gets altitude & speed information based on a particular id |
|
| 296 | - * |
|
| 297 | - * @return Array the spotter information |
|
| 298 | - * |
|
| 299 | - */ |
|
| 300 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 301 | - { |
|
| 294 | + /** |
|
| 295 | + * Gets altitude & speed information based on a particular id |
|
| 296 | + * |
|
| 297 | + * @return Array the spotter information |
|
| 298 | + * |
|
| 299 | + */ |
|
| 300 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 301 | + { |
|
| 302 | 302 | |
| 303 | - date_default_timezone_set('UTC'); |
|
| 303 | + date_default_timezone_set('UTC'); |
|
| 304 | 304 | |
| 305 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 306 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 305 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 306 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 307 | 307 | |
| 308 | - try { |
|
| 309 | - $sth = $this->db->prepare($query); |
|
| 310 | - $sth->execute(array(':id' => $id)); |
|
| 311 | - } catch(PDOException $e) { |
|
| 312 | - echo $e->getMessage(); |
|
| 313 | - die; |
|
| 314 | - } |
|
| 315 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 308 | + try { |
|
| 309 | + $sth = $this->db->prepare($query); |
|
| 310 | + $sth->execute(array(':id' => $id)); |
|
| 311 | + } catch(PDOException $e) { |
|
| 312 | + echo $e->getMessage(); |
|
| 313 | + die; |
|
| 314 | + } |
|
| 315 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 316 | 316 | |
| 317 | - return $spotter_array; |
|
| 318 | - } |
|
| 317 | + return $spotter_array; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | |
| 321 | - /** |
|
| 322 | - * Gets altitude information based on a particular callsign |
|
| 323 | - * |
|
| 324 | - * @return Array the spotter information |
|
| 325 | - * |
|
| 326 | - */ |
|
| 327 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 328 | - { |
|
| 321 | + /** |
|
| 322 | + * Gets altitude information based on a particular callsign |
|
| 323 | + * |
|
| 324 | + * @return Array the spotter information |
|
| 325 | + * |
|
| 326 | + */ |
|
| 327 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 328 | + { |
|
| 329 | 329 | |
| 330 | - date_default_timezone_set('UTC'); |
|
| 330 | + date_default_timezone_set('UTC'); |
|
| 331 | 331 | |
| 332 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 333 | - $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"; |
|
| 332 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 333 | + $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"; |
|
| 334 | 334 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 335 | 335 | |
| 336 | - try { |
|
| 337 | - $sth = $this->db->prepare($query); |
|
| 338 | - $sth->execute(array(':ident' => $ident)); |
|
| 339 | - } catch(PDOException $e) { |
|
| 340 | - echo $e->getMessage(); |
|
| 341 | - die; |
|
| 342 | - } |
|
| 343 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 336 | + try { |
|
| 337 | + $sth = $this->db->prepare($query); |
|
| 338 | + $sth->execute(array(':ident' => $ident)); |
|
| 339 | + } catch(PDOException $e) { |
|
| 340 | + echo $e->getMessage(); |
|
| 341 | + die; |
|
| 342 | + } |
|
| 343 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 344 | 344 | |
| 345 | - return $spotter_array; |
|
| 346 | - } |
|
| 345 | + return $spotter_array; |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | 348 | |
| 349 | 349 | |
| 350 | - /** |
|
| 351 | - * Gets all the archive spotter information |
|
| 352 | - * |
|
| 353 | - * @return Array the spotter information |
|
| 354 | - * |
|
| 355 | - */ |
|
| 356 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 357 | - { |
|
| 358 | - $Spotter = new Spotter($this->db); |
|
| 359 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 360 | - $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"; |
|
| 350 | + /** |
|
| 351 | + * Gets all the archive spotter information |
|
| 352 | + * |
|
| 353 | + * @return Array the spotter information |
|
| 354 | + * |
|
| 355 | + */ |
|
| 356 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 357 | + { |
|
| 358 | + $Spotter = new Spotter($this->db); |
|
| 359 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 360 | + $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"; |
|
| 361 | 361 | |
| 362 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 362 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 363 | 363 | |
| 364 | - return $spotter_array; |
|
| 365 | - } |
|
| 364 | + return $spotter_array; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - public function deleteSpotterArchiveTrackData() |
|
| 368 | - { |
|
| 367 | + public function deleteSpotterArchiveTrackData() |
|
| 368 | + { |
|
| 369 | 369 | global $globalArchiveKeepTrackMonths; |
| 370 | - date_default_timezone_set('UTC'); |
|
| 370 | + date_default_timezone_set('UTC'); |
|
| 371 | 371 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 372 | - try { |
|
| 373 | - $sth = $this->db->prepare($query); |
|
| 374 | - $sth->execute(); |
|
| 375 | - } catch(PDOException $e) { |
|
| 376 | - echo $e->getMessage(); |
|
| 377 | - die; |
|
| 378 | - } |
|
| 372 | + try { |
|
| 373 | + $sth = $this->db->prepare($query); |
|
| 374 | + $sth->execute(); |
|
| 375 | + } catch(PDOException $e) { |
|
| 376 | + echo $e->getMessage(); |
|
| 377 | + die; |
|
| 378 | + } |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | - * Gets Minimal Live Spotter data |
|
| 383 | - * |
|
| 384 | - * @return Array the spotter information |
|
| 385 | - * |
|
| 386 | - */ |
|
| 387 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 388 | - { |
|
| 389 | - global $globalDBdriver, $globalLiveInterval; |
|
| 390 | - date_default_timezone_set('UTC'); |
|
| 391 | - |
|
| 392 | - $filter_query = ''; |
|
| 393 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 394 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 395 | - } |
|
| 396 | - // Use spotter_output also ? |
|
| 397 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 398 | - $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 "; |
|
| 399 | - } |
|
| 400 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 401 | - $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 "; |
|
| 402 | - } |
|
| 403 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 404 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 408 | - if ($globalDBdriver == 'mysql') { |
|
| 409 | - /* |
|
| 382 | + * Gets Minimal Live Spotter data |
|
| 383 | + * |
|
| 384 | + * @return Array the spotter information |
|
| 385 | + * |
|
| 386 | + */ |
|
| 387 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 388 | + { |
|
| 389 | + global $globalDBdriver, $globalLiveInterval; |
|
| 390 | + date_default_timezone_set('UTC'); |
|
| 391 | + |
|
| 392 | + $filter_query = ''; |
|
| 393 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 394 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 395 | + } |
|
| 396 | + // Use spotter_output also ? |
|
| 397 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 398 | + $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 "; |
|
| 399 | + } |
|
| 400 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 401 | + $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 "; |
|
| 402 | + } |
|
| 403 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 404 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 408 | + if ($globalDBdriver == 'mysql') { |
|
| 409 | + /* |
|
| 410 | 410 | $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 |
| 411 | 411 | FROM spotter_archive |
| 412 | 412 | 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'; |
@@ -425,56 +425,56 @@ discard block |
||
| 425 | 425 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 426 | 426 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 427 | 427 | '.$filter_query.' ORDER BY flightaware_id'; |
| 428 | - } else { |
|
| 429 | - //$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'; |
|
| 430 | - $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 |
|
| 428 | + } else { |
|
| 429 | + //$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'; |
|
| 430 | + $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 |
|
| 431 | 431 | FROM spotter_archive |
| 432 | 432 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 433 | 433 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 434 | 434 | '.$filter_query.' ORDER BY flightaware_id'; |
| 435 | - } |
|
| 436 | - //echo $query; |
|
| 437 | - try { |
|
| 438 | - $sth = $this->db->prepare($query); |
|
| 439 | - $sth->execute(); |
|
| 440 | - } catch(PDOException $e) { |
|
| 441 | - echo $e->getMessage(); |
|
| 442 | - die; |
|
| 443 | - } |
|
| 444 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 445 | - |
|
| 446 | - return $spotter_array; |
|
| 447 | - } |
|
| 435 | + } |
|
| 436 | + //echo $query; |
|
| 437 | + try { |
|
| 438 | + $sth = $this->db->prepare($query); |
|
| 439 | + $sth->execute(); |
|
| 440 | + } catch(PDOException $e) { |
|
| 441 | + echo $e->getMessage(); |
|
| 442 | + die; |
|
| 443 | + } |
|
| 444 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 445 | + |
|
| 446 | + return $spotter_array; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | - * Gets Minimal Live Spotter data |
|
| 451 | - * |
|
| 452 | - * @return Array the spotter information |
|
| 453 | - * |
|
| 454 | - */ |
|
| 455 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 456 | - { |
|
| 457 | - global $globalDBdriver, $globalLiveInterval; |
|
| 458 | - date_default_timezone_set('UTC'); |
|
| 459 | - |
|
| 460 | - $filter_query = ''; |
|
| 461 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 462 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 463 | - } |
|
| 464 | - // Should use spotter_output also ? |
|
| 465 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 466 | - $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 "; |
|
| 467 | - } |
|
| 468 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 469 | - $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 "; |
|
| 470 | - } |
|
| 471 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 472 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 476 | - if ($globalDBdriver == 'mysql') { |
|
| 477 | - /* |
|
| 450 | + * Gets Minimal Live Spotter data |
|
| 451 | + * |
|
| 452 | + * @return Array the spotter information |
|
| 453 | + * |
|
| 454 | + */ |
|
| 455 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 456 | + { |
|
| 457 | + global $globalDBdriver, $globalLiveInterval; |
|
| 458 | + date_default_timezone_set('UTC'); |
|
| 459 | + |
|
| 460 | + $filter_query = ''; |
|
| 461 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 462 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 463 | + } |
|
| 464 | + // Should use spotter_output also ? |
|
| 465 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 466 | + $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 "; |
|
| 467 | + } |
|
| 468 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 469 | + $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 "; |
|
| 470 | + } |
|
| 471 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 472 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 476 | + if ($globalDBdriver == 'mysql') { |
|
| 477 | + /* |
|
| 478 | 478 | $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 |
| 479 | 479 | FROM spotter_archive |
| 480 | 480 | 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'; |
@@ -485,95 +485,95 @@ discard block |
||
| 485 | 485 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 486 | 486 | '.$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'; |
| 487 | 487 | |
| 488 | - } else { |
|
| 489 | - //$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'; |
|
| 490 | - /* |
|
| 488 | + } else { |
|
| 489 | + //$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'; |
|
| 490 | + /* |
|
| 491 | 491 | $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 |
| 492 | 492 | FROM spotter_archive_output |
| 493 | 493 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 494 | 494 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$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 | - $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 |
|
| 497 | + $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 |
|
| 498 | 498 | FROM spotter_archive_output |
| 499 | 499 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 500 | 500 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 501 | 501 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 502 | 502 | // .' 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'; |
| 503 | 503 | |
| 504 | - } |
|
| 505 | - //echo $query; |
|
| 506 | - try { |
|
| 507 | - $sth = $this->db->prepare($query); |
|
| 508 | - $sth->execute(); |
|
| 509 | - } catch(PDOException $e) { |
|
| 510 | - echo $e->getMessage(); |
|
| 511 | - die; |
|
| 512 | - } |
|
| 513 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 514 | - |
|
| 515 | - return $spotter_array; |
|
| 516 | - } |
|
| 504 | + } |
|
| 505 | + //echo $query; |
|
| 506 | + try { |
|
| 507 | + $sth = $this->db->prepare($query); |
|
| 508 | + $sth->execute(); |
|
| 509 | + } catch(PDOException $e) { |
|
| 510 | + echo $e->getMessage(); |
|
| 511 | + die; |
|
| 512 | + } |
|
| 513 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 514 | + |
|
| 515 | + return $spotter_array; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | - * Gets count Live Spotter data |
|
| 520 | - * |
|
| 521 | - * @return Array the spotter information |
|
| 522 | - * |
|
| 523 | - */ |
|
| 524 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 525 | - { |
|
| 526 | - global $globalDBdriver, $globalLiveInterval; |
|
| 527 | - date_default_timezone_set('UTC'); |
|
| 528 | - |
|
| 529 | - $filter_query = ''; |
|
| 530 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 531 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 532 | - } |
|
| 533 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 534 | - $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 "; |
|
| 535 | - } |
|
| 536 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 537 | - $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 "; |
|
| 538 | - } |
|
| 539 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 540 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 544 | - if ($globalDBdriver == 'mysql') { |
|
| 519 | + * Gets count Live Spotter data |
|
| 520 | + * |
|
| 521 | + * @return Array the spotter information |
|
| 522 | + * |
|
| 523 | + */ |
|
| 524 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 525 | + { |
|
| 526 | + global $globalDBdriver, $globalLiveInterval; |
|
| 527 | + date_default_timezone_set('UTC'); |
|
| 528 | + |
|
| 529 | + $filter_query = ''; |
|
| 530 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 531 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 532 | + } |
|
| 533 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 534 | + $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 "; |
|
| 535 | + } |
|
| 536 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 537 | + $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 "; |
|
| 538 | + } |
|
| 539 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 540 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 544 | + if ($globalDBdriver == 'mysql') { |
|
| 545 | 545 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 546 | 546 | FROM spotter_archive l |
| 547 | 547 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 548 | - } else { |
|
| 548 | + } else { |
|
| 549 | 549 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 550 | - } |
|
| 551 | - //echo $query; |
|
| 552 | - try { |
|
| 553 | - $sth = $this->db->prepare($query); |
|
| 554 | - $sth->execute(); |
|
| 555 | - } catch(PDOException $e) { |
|
| 556 | - echo $e->getMessage(); |
|
| 557 | - die; |
|
| 558 | - } |
|
| 550 | + } |
|
| 551 | + //echo $query; |
|
| 552 | + try { |
|
| 553 | + $sth = $this->db->prepare($query); |
|
| 554 | + $sth->execute(); |
|
| 555 | + } catch(PDOException $e) { |
|
| 556 | + echo $e->getMessage(); |
|
| 557 | + die; |
|
| 558 | + } |
|
| 559 | 559 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 560 | 560 | $sth->closeCursor(); |
| 561 | - return $result['nb']; |
|
| 561 | + return $result['nb']; |
|
| 562 | 562 | |
| 563 | - } |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | 565 | |
| 566 | 566 | |
| 567 | 567 | // Spotter_Archive_output |
| 568 | 568 | |
| 569 | - /** |
|
| 570 | - * Gets all the spotter information |
|
| 571 | - * |
|
| 572 | - * @return Array the spotter information |
|
| 573 | - * |
|
| 574 | - */ |
|
| 575 | - 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()) |
|
| 576 | - { |
|
| 569 | + /** |
|
| 570 | + * Gets all the spotter information |
|
| 571 | + * |
|
| 572 | + * @return Array the spotter information |
|
| 573 | + * |
|
| 574 | + */ |
|
| 575 | + 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()) |
|
| 576 | + { |
|
| 577 | 577 | global $globalTimezone, $globalDBdriver; |
| 578 | 578 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 579 | 579 | $Translation = new Translation(); |
@@ -587,159 +587,159 @@ discard block |
||
| 587 | 587 | $filter_query = $this->getFilter($filters); |
| 588 | 588 | if ($q != "") |
| 589 | 589 | { |
| 590 | - if (!is_string($q)) |
|
| 591 | - { |
|
| 590 | + if (!is_string($q)) |
|
| 591 | + { |
|
| 592 | 592 | return false; |
| 593 | - } else { |
|
| 593 | + } else { |
|
| 594 | 594 | |
| 595 | 595 | $q_array = explode(" ", $q); |
| 596 | 596 | |
| 597 | 597 | foreach ($q_array as $q_item){ |
| 598 | - $additional_query .= " AND ("; |
|
| 599 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 600 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 601 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 602 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 603 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 604 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 605 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 606 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 607 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 608 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 609 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 610 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 611 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 612 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 613 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 614 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 615 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 616 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 617 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 618 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 619 | - $translate = $Translation->ident2icao($q_item); |
|
| 620 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 621 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 622 | - $additional_query .= ")"; |
|
| 623 | - } |
|
| 624 | - } |
|
| 598 | + $additional_query .= " AND ("; |
|
| 599 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 600 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 601 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 602 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 603 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 604 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 605 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 606 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 607 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 608 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 609 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 610 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 611 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 612 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 613 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 614 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 615 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 616 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 617 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 618 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 619 | + $translate = $Translation->ident2icao($q_item); |
|
| 620 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 621 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 622 | + $additional_query .= ")"; |
|
| 623 | + } |
|
| 624 | + } |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | if ($registration != "") |
| 628 | 628 | { |
| 629 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 630 | - if (!is_string($registration)) |
|
| 631 | - { |
|
| 629 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 630 | + if (!is_string($registration)) |
|
| 631 | + { |
|
| 632 | 632 | return false; |
| 633 | - } else { |
|
| 633 | + } else { |
|
| 634 | 634 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 635 | - } |
|
| 635 | + } |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if ($aircraft_icao != "") |
| 639 | 639 | { |
| 640 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 641 | - if (!is_string($aircraft_icao)) |
|
| 642 | - { |
|
| 640 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 641 | + if (!is_string($aircraft_icao)) |
|
| 642 | + { |
|
| 643 | 643 | return false; |
| 644 | - } else { |
|
| 644 | + } else { |
|
| 645 | 645 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 646 | - } |
|
| 646 | + } |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | if ($aircraft_manufacturer != "") |
| 650 | 650 | { |
| 651 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 652 | - if (!is_string($aircraft_manufacturer)) |
|
| 653 | - { |
|
| 651 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 652 | + if (!is_string($aircraft_manufacturer)) |
|
| 653 | + { |
|
| 654 | 654 | return false; |
| 655 | - } else { |
|
| 655 | + } else { |
|
| 656 | 656 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 657 | - } |
|
| 657 | + } |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | if ($highlights == "true") |
| 661 | 661 | { |
| 662 | - if (!is_string($highlights)) |
|
| 663 | - { |
|
| 662 | + if (!is_string($highlights)) |
|
| 663 | + { |
|
| 664 | 664 | return false; |
| 665 | - } else { |
|
| 665 | + } else { |
|
| 666 | 666 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 667 | - } |
|
| 667 | + } |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | if ($airline_icao != "") |
| 671 | 671 | { |
| 672 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 673 | - if (!is_string($airline_icao)) |
|
| 674 | - { |
|
| 672 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 673 | + if (!is_string($airline_icao)) |
|
| 674 | + { |
|
| 675 | 675 | return false; |
| 676 | - } else { |
|
| 676 | + } else { |
|
| 677 | 677 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 678 | - } |
|
| 678 | + } |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | if ($airline_country != "") |
| 682 | 682 | { |
| 683 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 684 | - if (!is_string($airline_country)) |
|
| 685 | - { |
|
| 683 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 684 | + if (!is_string($airline_country)) |
|
| 685 | + { |
|
| 686 | 686 | return false; |
| 687 | - } else { |
|
| 687 | + } else { |
|
| 688 | 688 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 689 | - } |
|
| 689 | + } |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | if ($airline_type != "") |
| 693 | 693 | { |
| 694 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 695 | - if (!is_string($airline_type)) |
|
| 696 | - { |
|
| 694 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 695 | + if (!is_string($airline_type)) |
|
| 696 | + { |
|
| 697 | 697 | return false; |
| 698 | - } else { |
|
| 698 | + } else { |
|
| 699 | 699 | if ($airline_type == "passenger") |
| 700 | 700 | { |
| 701 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 701 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 702 | 702 | } |
| 703 | 703 | if ($airline_type == "cargo") |
| 704 | 704 | { |
| 705 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 705 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 706 | 706 | } |
| 707 | 707 | if ($airline_type == "military") |
| 708 | 708 | { |
| 709 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 709 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 710 | + } |
|
| 710 | 711 | } |
| 711 | - } |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | if ($airport != "") |
| 715 | 715 | { |
| 716 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 717 | - if (!is_string($airport)) |
|
| 718 | - { |
|
| 716 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 717 | + if (!is_string($airport)) |
|
| 718 | + { |
|
| 719 | 719 | return false; |
| 720 | - } else { |
|
| 720 | + } else { |
|
| 721 | 721 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 722 | - } |
|
| 722 | + } |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | if ($airport_country != "") |
| 726 | 726 | { |
| 727 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 728 | - if (!is_string($airport_country)) |
|
| 729 | - { |
|
| 727 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 728 | + if (!is_string($airport_country)) |
|
| 729 | + { |
|
| 730 | 730 | return false; |
| 731 | - } else { |
|
| 731 | + } else { |
|
| 732 | 732 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 733 | - } |
|
| 733 | + } |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | if ($callsign != "") |
| 737 | 737 | { |
| 738 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($callsign)) |
|
| 740 | - { |
|
| 738 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($callsign)) |
|
| 740 | + { |
|
| 741 | 741 | return false; |
| 742 | - } else { |
|
| 742 | + } else { |
|
| 743 | 743 | $translate = $Translation->ident2icao($callsign); |
| 744 | 744 | if ($translate != $callsign) { |
| 745 | 745 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -747,99 +747,99 @@ discard block |
||
| 747 | 747 | } else { |
| 748 | 748 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 749 | 749 | } |
| 750 | - } |
|
| 750 | + } |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | if ($owner != "") |
| 754 | 754 | { |
| 755 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 756 | - if (!is_string($owner)) |
|
| 757 | - { |
|
| 755 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 756 | + if (!is_string($owner)) |
|
| 757 | + { |
|
| 758 | 758 | return false; |
| 759 | - } else { |
|
| 759 | + } else { |
|
| 760 | 760 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 761 | - } |
|
| 761 | + } |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | if ($pilot_name != "") |
| 765 | 765 | { |
| 766 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 767 | - if (!is_string($pilot_name)) |
|
| 768 | - { |
|
| 766 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 767 | + if (!is_string($pilot_name)) |
|
| 768 | + { |
|
| 769 | 769 | return false; |
| 770 | - } else { |
|
| 770 | + } else { |
|
| 771 | 771 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 772 | - } |
|
| 772 | + } |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | if ($pilot_id != "") |
| 776 | 776 | { |
| 777 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 778 | - if (!is_string($pilot_id)) |
|
| 779 | - { |
|
| 777 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 778 | + if (!is_string($pilot_id)) |
|
| 779 | + { |
|
| 780 | 780 | return false; |
| 781 | - } else { |
|
| 781 | + } else { |
|
| 782 | 782 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 783 | - } |
|
| 783 | + } |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | if ($departure_airport_route != "") |
| 787 | 787 | { |
| 788 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 789 | - if (!is_string($departure_airport_route)) |
|
| 790 | - { |
|
| 788 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 789 | + if (!is_string($departure_airport_route)) |
|
| 790 | + { |
|
| 791 | 791 | return false; |
| 792 | - } else { |
|
| 792 | + } else { |
|
| 793 | 793 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 794 | - } |
|
| 794 | + } |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | if ($arrival_airport_route != "") |
| 798 | 798 | { |
| 799 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 800 | - if (!is_string($arrival_airport_route)) |
|
| 801 | - { |
|
| 799 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 800 | + if (!is_string($arrival_airport_route)) |
|
| 801 | + { |
|
| 802 | 802 | return false; |
| 803 | - } else { |
|
| 803 | + } else { |
|
| 804 | 804 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 805 | - } |
|
| 805 | + } |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | if ($altitude != "") |
| 809 | 809 | { |
| 810 | - $altitude_array = explode(",", $altitude); |
|
| 810 | + $altitude_array = explode(",", $altitude); |
|
| 811 | 811 | |
| 812 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 813 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 812 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 813 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 814 | 814 | |
| 815 | 815 | |
| 816 | - if ($altitude_array[1] != "") |
|
| 817 | - { |
|
| 816 | + if ($altitude_array[1] != "") |
|
| 817 | + { |
|
| 818 | 818 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 819 | 819 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 820 | 820 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 821 | - } else { |
|
| 821 | + } else { |
|
| 822 | 822 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 823 | 823 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 824 | - } |
|
| 824 | + } |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | if ($date_posted != "") |
| 828 | 828 | { |
| 829 | - $date_array = explode(",", $date_posted); |
|
| 829 | + $date_array = explode(",", $date_posted); |
|
| 830 | 830 | |
| 831 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 832 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 831 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 832 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 833 | 833 | |
| 834 | - if ($globalTimezone != '') { |
|
| 834 | + if ($globalTimezone != '') { |
|
| 835 | 835 | date_default_timezone_set($globalTimezone); |
| 836 | 836 | $datetime = new DateTime(); |
| 837 | 837 | $offset = $datetime->format('P'); |
| 838 | - } else $offset = '+00:00'; |
|
| 838 | + } else $offset = '+00:00'; |
|
| 839 | 839 | |
| 840 | 840 | |
| 841 | - if ($date_array[1] != "") |
|
| 842 | - { |
|
| 841 | + if ($date_array[1] != "") |
|
| 842 | + { |
|
| 843 | 843 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 844 | 844 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 845 | 845 | if ($globalDBdriver == 'mysql') { |
@@ -847,28 +847,28 @@ discard block |
||
| 847 | 847 | } else { |
| 848 | 848 | $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) "; |
| 849 | 849 | } |
| 850 | - } else { |
|
| 850 | + } else { |
|
| 851 | 851 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 852 | - if ($globalDBdriver == 'mysql') { |
|
| 852 | + if ($globalDBdriver == 'mysql') { |
|
| 853 | 853 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 854 | 854 | } else { |
| 855 | 855 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 856 | 856 | } |
| 857 | - } |
|
| 857 | + } |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | if ($limit != "") |
| 861 | 861 | { |
| 862 | - $limit_array = explode(",", $limit); |
|
| 862 | + $limit_array = explode(",", $limit); |
|
| 863 | 863 | |
| 864 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 865 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 865 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 866 | 866 | |
| 867 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 868 | - { |
|
| 867 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 868 | + { |
|
| 869 | 869 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 870 | 870 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 871 | - } |
|
| 871 | + } |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | |
@@ -899,33 +899,33 @@ discard block |
||
| 899 | 899 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 900 | 900 | |
| 901 | 901 | return $spotter_array; |
| 902 | - } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - public function deleteSpotterArchiveData() |
|
| 905 | - { |
|
| 904 | + public function deleteSpotterArchiveData() |
|
| 905 | + { |
|
| 906 | 906 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 907 | - date_default_timezone_set('UTC'); |
|
| 908 | - if ($globalDBdriver == 'mysql') { |
|
| 907 | + date_default_timezone_set('UTC'); |
|
| 908 | + if ($globalDBdriver == 'mysql') { |
|
| 909 | 909 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 910 | 910 | } else { |
| 911 | 911 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 912 | 912 | } |
| 913 | - try { |
|
| 914 | - $sth = $this->db->prepare($query); |
|
| 915 | - $sth->execute(); |
|
| 916 | - } catch(PDOException $e) { |
|
| 917 | - return "error"; |
|
| 918 | - } |
|
| 913 | + try { |
|
| 914 | + $sth = $this->db->prepare($query); |
|
| 915 | + $sth->execute(); |
|
| 916 | + } catch(PDOException $e) { |
|
| 917 | + return "error"; |
|
| 918 | + } |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | - /** |
|
| 922 | - * Gets all the spotter information based on the callsign |
|
| 923 | - * |
|
| 924 | - * @return Array the spotter information |
|
| 925 | - * |
|
| 926 | - */ |
|
| 927 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 928 | - { |
|
| 921 | + /** |
|
| 922 | + * Gets all the spotter information based on the callsign |
|
| 923 | + * |
|
| 924 | + * @return Array the spotter information |
|
| 925 | + * |
|
| 926 | + */ |
|
| 927 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 928 | + { |
|
| 929 | 929 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 930 | 930 | |
| 931 | 931 | date_default_timezone_set('UTC'); |
@@ -937,35 +937,35 @@ discard block |
||
| 937 | 937 | |
| 938 | 938 | if ($ident != "") |
| 939 | 939 | { |
| 940 | - if (!is_string($ident)) |
|
| 941 | - { |
|
| 940 | + if (!is_string($ident)) |
|
| 941 | + { |
|
| 942 | 942 | return false; |
| 943 | - } else { |
|
| 943 | + } else { |
|
| 944 | 944 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 945 | 945 | $query_values = array(':ident' => $ident); |
| 946 | - } |
|
| 946 | + } |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | if ($limit != "") |
| 950 | 950 | { |
| 951 | - $limit_array = explode(",", $limit); |
|
| 951 | + $limit_array = explode(",", $limit); |
|
| 952 | 952 | |
| 953 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 954 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 953 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 954 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 955 | 955 | |
| 956 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 957 | - { |
|
| 956 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 957 | + { |
|
| 958 | 958 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 959 | 959 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 960 | - } |
|
| 960 | + } |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | if ($sort != "") |
| 964 | 964 | { |
| 965 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 966 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 965 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 966 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 967 | 967 | } else { |
| 968 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 968 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -973,17 +973,17 @@ discard block |
||
| 973 | 973 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 974 | 974 | |
| 975 | 975 | return $spotter_array; |
| 976 | - } |
|
| 976 | + } |
|
| 977 | 977 | |
| 978 | 978 | |
| 979 | - /** |
|
| 980 | - * Gets all the spotter information based on the owner |
|
| 981 | - * |
|
| 982 | - * @return Array the spotter information |
|
| 983 | - * |
|
| 984 | - */ |
|
| 985 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 986 | - { |
|
| 979 | + /** |
|
| 980 | + * Gets all the spotter information based on the owner |
|
| 981 | + * |
|
| 982 | + * @return Array the spotter information |
|
| 983 | + * |
|
| 984 | + */ |
|
| 985 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 986 | + { |
|
| 987 | 987 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 988 | 988 | |
| 989 | 989 | date_default_timezone_set('UTC'); |
@@ -996,35 +996,35 @@ discard block |
||
| 996 | 996 | |
| 997 | 997 | if ($owner != "") |
| 998 | 998 | { |
| 999 | - if (!is_string($owner)) |
|
| 1000 | - { |
|
| 999 | + if (!is_string($owner)) |
|
| 1000 | + { |
|
| 1001 | 1001 | return false; |
| 1002 | - } else { |
|
| 1002 | + } else { |
|
| 1003 | 1003 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1004 | 1004 | $query_values = array(':owner' => $owner); |
| 1005 | - } |
|
| 1005 | + } |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | if ($limit != "") |
| 1009 | 1009 | { |
| 1010 | - $limit_array = explode(",", $limit); |
|
| 1010 | + $limit_array = explode(",", $limit); |
|
| 1011 | 1011 | |
| 1012 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1013 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1012 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1013 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1014 | 1014 | |
| 1015 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1016 | - { |
|
| 1015 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1016 | + { |
|
| 1017 | 1017 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1018 | 1018 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1019 | - } |
|
| 1019 | + } |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | if ($sort != "") |
| 1023 | 1023 | { |
| 1024 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1025 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1024 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1025 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1026 | 1026 | } else { |
| 1027 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1027 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1032,16 +1032,16 @@ discard block |
||
| 1032 | 1032 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1033 | 1033 | |
| 1034 | 1034 | return $spotter_array; |
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - /** |
|
| 1038 | - * Gets all the spotter information based on the pilot |
|
| 1039 | - * |
|
| 1040 | - * @return Array the spotter information |
|
| 1041 | - * |
|
| 1042 | - */ |
|
| 1043 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1044 | - { |
|
| 1035 | + } |
|
| 1036 | + |
|
| 1037 | + /** |
|
| 1038 | + * Gets all the spotter information based on the pilot |
|
| 1039 | + * |
|
| 1040 | + * @return Array the spotter information |
|
| 1041 | + * |
|
| 1042 | + */ |
|
| 1043 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1044 | + { |
|
| 1045 | 1045 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1046 | 1046 | |
| 1047 | 1047 | date_default_timezone_set('UTC'); |
@@ -1060,24 +1060,24 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | if ($limit != "") |
| 1062 | 1062 | { |
| 1063 | - $limit_array = explode(",", $limit); |
|
| 1063 | + $limit_array = explode(",", $limit); |
|
| 1064 | 1064 | |
| 1065 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1066 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1065 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1066 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1067 | 1067 | |
| 1068 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1069 | - { |
|
| 1068 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1069 | + { |
|
| 1070 | 1070 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1071 | 1071 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1072 | - } |
|
| 1072 | + } |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | if ($sort != "") |
| 1076 | 1076 | { |
| 1077 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1078 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1077 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1078 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1079 | 1079 | } else { |
| 1080 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1080 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1085,16 +1085,16 @@ discard block |
||
| 1085 | 1085 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1086 | 1086 | |
| 1087 | 1087 | return $spotter_array; |
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * Gets all number of flight over countries |
|
| 1092 | - * |
|
| 1093 | - * @return Array the airline country list |
|
| 1094 | - * |
|
| 1095 | - */ |
|
| 1096 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1097 | - { |
|
| 1088 | + } |
|
| 1089 | + |
|
| 1090 | + /** |
|
| 1091 | + * Gets all number of flight over countries |
|
| 1092 | + * |
|
| 1093 | + * @return Array the airline country list |
|
| 1094 | + * |
|
| 1095 | + */ |
|
| 1096 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1097 | + { |
|
| 1098 | 1098 | global $globalDBdriver; |
| 1099 | 1099 | /* |
| 1100 | 1100 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1104,14 +1104,14 @@ discard block |
||
| 1104 | 1104 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1105 | 1105 | FROM countries c, spotter_archive s |
| 1106 | 1106 | WHERE c.iso2 = s.over_country "; |
| 1107 | - if ($olderthanmonths > 0) { |
|
| 1108 | - if ($globalDBdriver == 'mysql') { |
|
| 1107 | + if ($olderthanmonths > 0) { |
|
| 1108 | + if ($globalDBdriver == 'mysql') { |
|
| 1109 | 1109 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1110 | 1110 | } else { |
| 1111 | 1111 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1112 | 1112 | } |
| 1113 | 1113 | } |
| 1114 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1114 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1115 | 1115 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1116 | 1116 | if ($limit) $query .= " LIMIT 0,10"; |
| 1117 | 1117 | |
@@ -1124,23 +1124,23 @@ discard block |
||
| 1124 | 1124 | |
| 1125 | 1125 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1126 | 1126 | { |
| 1127 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1128 | - $temp_array['flight_country'] = $row['name']; |
|
| 1129 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1130 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1131 | - $flight_array[] = $temp_array; |
|
| 1127 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1128 | + $temp_array['flight_country'] = $row['name']; |
|
| 1129 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1130 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1131 | + $flight_array[] = $temp_array; |
|
| 1132 | 1132 | } |
| 1133 | 1133 | return $flight_array; |
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - /** |
|
| 1137 | - * Gets all number of flight over countries |
|
| 1138 | - * |
|
| 1139 | - * @return Array the airline country list |
|
| 1140 | - * |
|
| 1141 | - */ |
|
| 1142 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1143 | - { |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + /** |
|
| 1137 | + * Gets all number of flight over countries |
|
| 1138 | + * |
|
| 1139 | + * @return Array the airline country list |
|
| 1140 | + * |
|
| 1141 | + */ |
|
| 1142 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1143 | + { |
|
| 1144 | 1144 | global $globalDBdriver; |
| 1145 | 1145 | /* |
| 1146 | 1146 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1150,14 +1150,14 @@ discard block |
||
| 1150 | 1150 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1151 | 1151 | FROM countries c, spotter_archive s, spotter_output o |
| 1152 | 1152 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1153 | - if ($olderthanmonths > 0) { |
|
| 1154 | - if ($globalDBdriver == 'mysql') { |
|
| 1153 | + if ($olderthanmonths > 0) { |
|
| 1154 | + if ($globalDBdriver == 'mysql') { |
|
| 1155 | 1155 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1156 | 1156 | } else { |
| 1157 | 1157 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1158 | 1158 | } |
| 1159 | 1159 | } |
| 1160 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1160 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1161 | 1161 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1162 | 1162 | if ($limit) $query .= " LIMIT 0,10"; |
| 1163 | 1163 | |
@@ -1170,24 +1170,24 @@ discard block |
||
| 1170 | 1170 | |
| 1171 | 1171 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1172 | 1172 | { |
| 1173 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1174 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1175 | - $temp_array['flight_country'] = $row['name']; |
|
| 1176 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1177 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1178 | - $flight_array[] = $temp_array; |
|
| 1173 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1174 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1175 | + $temp_array['flight_country'] = $row['name']; |
|
| 1176 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1177 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1178 | + $flight_array[] = $temp_array; |
|
| 1179 | 1179 | } |
| 1180 | 1180 | return $flight_array; |
| 1181 | - } |
|
| 1182 | - |
|
| 1183 | - /** |
|
| 1184 | - * Gets last spotter information based on a particular callsign |
|
| 1185 | - * |
|
| 1186 | - * @return Array the spotter information |
|
| 1187 | - * |
|
| 1188 | - */ |
|
| 1189 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1190 | - { |
|
| 1181 | + } |
|
| 1182 | + |
|
| 1183 | + /** |
|
| 1184 | + * Gets last spotter information based on a particular callsign |
|
| 1185 | + * |
|
| 1186 | + * @return Array the spotter information |
|
| 1187 | + * |
|
| 1188 | + */ |
|
| 1189 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1190 | + { |
|
| 1191 | 1191 | $Spotter = new Spotter($this->db); |
| 1192 | 1192 | date_default_timezone_set('UTC'); |
| 1193 | 1193 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1195,16 +1195,16 @@ discard block |
||
| 1195 | 1195 | $date = date('c',$date); |
| 1196 | 1196 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1197 | 1197 | return $spotter_array; |
| 1198 | - } |
|
| 1199 | - |
|
| 1200 | - /** |
|
| 1201 | - * Gets all the spotter information based on a particular callsign |
|
| 1202 | - * |
|
| 1203 | - * @return Array the spotter information |
|
| 1204 | - * |
|
| 1205 | - */ |
|
| 1206 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1207 | - { |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + /** |
|
| 1201 | + * Gets all the spotter information based on a particular callsign |
|
| 1202 | + * |
|
| 1203 | + * @return Array the spotter information |
|
| 1204 | + * |
|
| 1205 | + */ |
|
| 1206 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1207 | + { |
|
| 1208 | 1208 | $Spotter = new Spotter($this->db); |
| 1209 | 1209 | date_default_timezone_set('UTC'); |
| 1210 | 1210 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1212,16 +1212,16 @@ discard block |
||
| 1212 | 1212 | $date = date('c',$date); |
| 1213 | 1213 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1214 | 1214 | return $spotter_array; |
| 1215 | - } |
|
| 1216 | - |
|
| 1217 | - /** |
|
| 1218 | - * Gets all the spotter information based on the airport |
|
| 1219 | - * |
|
| 1220 | - * @return Array the spotter information |
|
| 1221 | - * |
|
| 1222 | - */ |
|
| 1223 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1224 | - { |
|
| 1215 | + } |
|
| 1216 | + |
|
| 1217 | + /** |
|
| 1218 | + * Gets all the spotter information based on the airport |
|
| 1219 | + * |
|
| 1220 | + * @return Array the spotter information |
|
| 1221 | + * |
|
| 1222 | + */ |
|
| 1223 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1224 | + { |
|
| 1225 | 1225 | global $global_query; |
| 1226 | 1226 | $Spotter = new Spotter(); |
| 1227 | 1227 | date_default_timezone_set('UTC'); |
@@ -1232,35 +1232,35 @@ discard block |
||
| 1232 | 1232 | |
| 1233 | 1233 | if ($airport != "") |
| 1234 | 1234 | { |
| 1235 | - if (!is_string($airport)) |
|
| 1236 | - { |
|
| 1235 | + if (!is_string($airport)) |
|
| 1236 | + { |
|
| 1237 | 1237 | return false; |
| 1238 | - } else { |
|
| 1238 | + } else { |
|
| 1239 | 1239 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1240 | 1240 | $query_values = array(':airport' => $airport); |
| 1241 | - } |
|
| 1241 | + } |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | if ($limit != "") |
| 1245 | 1245 | { |
| 1246 | - $limit_array = explode(",", $limit); |
|
| 1246 | + $limit_array = explode(",", $limit); |
|
| 1247 | 1247 | |
| 1248 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1249 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1248 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1249 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1250 | 1250 | |
| 1251 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1252 | - { |
|
| 1251 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1252 | + { |
|
| 1253 | 1253 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1254 | 1254 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1255 | - } |
|
| 1255 | + } |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | if ($sort != "") |
| 1259 | 1259 | { |
| 1260 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1261 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1260 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1261 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1262 | 1262 | } else { |
| 1263 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1263 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | $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; |
@@ -1268,6 +1268,6 @@ discard block |
||
| 1268 | 1268 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1269 | 1269 | |
| 1270 | 1270 | return $spotter_array; |
| 1271 | - } |
|
| 1271 | + } |
|
| 1272 | 1272 | } |
| 1273 | 1273 | ?> |
| 1274 | 1274 | \ No newline at end of file |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 26 | + if (is_array($globalFilter)) { |
|
| 27 | + $filter = array_merge($filter,$globalFilter); |
|
| 28 | + } |
|
| 27 | 29 | $filter_query_join = ''; |
| 28 | 30 | $filter_query_where = ''; |
| 29 | 31 | foreach($filters as $flt) { |
@@ -96,8 +98,11 @@ discard block |
||
| 96 | 98 | } |
| 97 | 99 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
| 98 | 100 | } |
| 99 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 100 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 101 | + if ($filter_query_where == '' && $where) { |
|
| 102 | + $filter_query_where = ' WHERE'; |
|
| 103 | + } elseif ($filter_query_where != '' && $and) { |
|
| 104 | + $filter_query_where .= ' AND'; |
|
| 105 | + } |
|
| 101 | 106 | if ($filter_query_where != '') { |
| 102 | 107 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 103 | 108 | } |
@@ -111,10 +116,17 @@ discard block |
||
| 111 | 116 | if ($over_country == '') { |
| 112 | 117 | $Spotter = new Spotter($this->db); |
| 113 | 118 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 114 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 115 | - else $country = ''; |
|
| 116 | - } else $country = $over_country; |
|
| 117 | - if ($airline_type === NULL) $airline_type =''; |
|
| 119 | + if (!empty($data_country)) { |
|
| 120 | + $country = $data_country['iso2']; |
|
| 121 | + } else { |
|
| 122 | + $country = ''; |
|
| 123 | + } |
|
| 124 | + } else { |
|
| 125 | + $country = $over_country; |
|
| 126 | + } |
|
| 127 | + if ($airline_type === NULL) { |
|
| 128 | + $airline_type =''; |
|
| 129 | + } |
|
| 118 | 130 | |
| 119 | 131 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 120 | 132 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -617,7 +629,9 @@ discard block |
||
| 617 | 629 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 618 | 630 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 619 | 631 | $translate = $Translation->ident2icao($q_item); |
| 620 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 632 | + if ($translate != $q_item) { |
|
| 633 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 634 | + } |
|
| 621 | 635 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 622 | 636 | $additional_query .= ")"; |
| 623 | 637 | } |
@@ -835,7 +849,9 @@ discard block |
||
| 835 | 849 | date_default_timezone_set($globalTimezone); |
| 836 | 850 | $datetime = new DateTime(); |
| 837 | 851 | $offset = $datetime->format('P'); |
| 838 | - } else $offset = '+00:00'; |
|
| 852 | + } else { |
|
| 853 | + $offset = '+00:00'; |
|
| 854 | + } |
|
| 839 | 855 | |
| 840 | 856 | |
| 841 | 857 | if ($date_array[1] != "") |
@@ -1111,9 +1127,13 @@ discard block |
||
| 1111 | 1127 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1112 | 1128 | } |
| 1113 | 1129 | } |
| 1114 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1130 | + if ($sincedate != '') { |
|
| 1131 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1132 | + } |
|
| 1115 | 1133 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1116 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1134 | + if ($limit) { |
|
| 1135 | + $query .= " LIMIT 0,10"; |
|
| 1136 | + } |
|
| 1117 | 1137 | |
| 1118 | 1138 | |
| 1119 | 1139 | $sth = $this->db->prepare($query); |
@@ -1157,9 +1177,13 @@ discard block |
||
| 1157 | 1177 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1158 | 1178 | } |
| 1159 | 1179 | } |
| 1160 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1180 | + if ($sincedate != '') { |
|
| 1181 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1182 | + } |
|
| 1161 | 1183 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1162 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1184 | + if ($limit) { |
|
| 1185 | + $query .= " LIMIT 0,10"; |
|
| 1186 | + } |
|
| 1163 | 1187 | |
| 1164 | 1188 | |
| 1165 | 1189 | $sth = $this->db->prepare($query); |