@@ -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(); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * Gets all the spotter information based on the latest data entry |
|
| 132 | - * |
|
| 133 | - * @return Array the spotter information |
|
| 134 | - * |
|
| 135 | - */ |
|
| 131 | + * Gets all the spotter information based on the latest data entry |
|
| 132 | + * |
|
| 133 | + * @return Array the spotter information |
|
| 134 | + * |
|
| 135 | + */ |
|
| 136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 137 | 137 | { |
| 138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Gets Minimal Live Spotter data |
|
| 178 | - * |
|
| 179 | - * @return Array the spotter information |
|
| 180 | - * |
|
| 181 | - */ |
|
| 177 | + * Gets Minimal Live Spotter data |
|
| 178 | + * |
|
| 179 | + * @return Array the spotter information |
|
| 180 | + * |
|
| 181 | + */ |
|
| 182 | 182 | public function getMinLiveSpotterData($filter = array()) |
| 183 | 183 | { |
| 184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 219 | - * |
|
| 220 | - * @return Array the spotter information |
|
| 221 | - * |
|
| 222 | - */ |
|
| 218 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 219 | + * |
|
| 220 | + * @return Array the spotter information |
|
| 221 | + * |
|
| 222 | + */ |
|
| 223 | 223 | public function getMinLastLiveSpotterData($filter = array()) |
| 224 | 224 | { |
| 225 | 225 | global $globalDBdriver, $globalLiveInterval; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $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 |
| 238 | 238 | 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' |
| 239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 240 | - } else { |
|
| 240 | + } else { |
|
| 241 | 241 | /* |
| 242 | 242 | $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 |
| 243 | 243 | 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' |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | // echo $query; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - try { |
|
| 252 | + try { |
|
| 253 | 253 | $sth = $this->db->prepare($query); |
| 254 | 254 | $sth->execute(); |
| 255 | 255 | } catch(PDOException $e) { |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * Gets number of latest data entry |
|
| 265 | - * |
|
| 266 | - * @return String number of entry |
|
| 267 | - * |
|
| 268 | - */ |
|
| 264 | + * Gets number of latest data entry |
|
| 265 | + * |
|
| 266 | + * @return String number of entry |
|
| 267 | + * |
|
| 268 | + */ |
|
| 269 | 269 | public function getLiveSpotterCount($filter = array()) |
| 270 | 270 | { |
| 271 | 271 | global $globalDBdriver, $globalLiveInterval; |
@@ -292,11 +292,11 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 296 | - * |
|
| 297 | - * @return Array the spotter information |
|
| 298 | - * |
|
| 299 | - */ |
|
| 295 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 296 | + * |
|
| 297 | + * @return Array the spotter information |
|
| 298 | + * |
|
| 299 | + */ |
|
| 300 | 300 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 301 | 301 | { |
| 302 | 302 | global $globalDBdriver, $globalLiveInterval; |
@@ -321,11 +321,11 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 325 | - * |
|
| 326 | - * @return Array the spotter information |
|
| 327 | - * |
|
| 328 | - */ |
|
| 324 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 325 | + * |
|
| 326 | + * @return Array the spotter information |
|
| 327 | + * |
|
| 328 | + */ |
|
| 329 | 329 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 330 | 330 | { |
| 331 | 331 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 394 | - * |
|
| 395 | - * @return Array the spotter information |
|
| 396 | - * |
|
| 397 | - */ |
|
| 393 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 394 | + * |
|
| 395 | + * @return Array the spotter information |
|
| 396 | + * |
|
| 397 | + */ |
|
| 398 | 398 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 399 | 399 | { |
| 400 | 400 | $Spotter = new Spotter($this->db); |
@@ -404,145 +404,145 @@ discard block |
||
| 404 | 404 | return false; |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | - if ($lng != '') |
|
| 408 | - { |
|
| 409 | - if (!is_numeric($lng)) |
|
| 410 | - { |
|
| 411 | - return false; |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - if ($radius != '') |
|
| 416 | - { |
|
| 417 | - if (!is_numeric($radius)) |
|
| 418 | - { |
|
| 419 | - return false; |
|
| 420 | - } |
|
| 421 | - } |
|
| 407 | + if ($lng != '') |
|
| 408 | + { |
|
| 409 | + if (!is_numeric($lng)) |
|
| 410 | + { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + if ($radius != '') |
|
| 416 | + { |
|
| 417 | + if (!is_numeric($radius)) |
|
| 418 | + { |
|
| 419 | + return false; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | 422 | $additional_query = ''; |
| 423 | - if ($interval != '') |
|
| 424 | - { |
|
| 425 | - if (!is_string($interval)) |
|
| 426 | - { |
|
| 427 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 428 | - return false; |
|
| 429 | - } else { |
|
| 430 | - if ($interval == '1m') |
|
| 431 | - { |
|
| 432 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 433 | - } else if ($interval == '15m'){ |
|
| 434 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - } else { |
|
| 438 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - $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 |
|
| 423 | + if ($interval != '') |
|
| 424 | + { |
|
| 425 | + if (!is_string($interval)) |
|
| 426 | + { |
|
| 427 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 428 | + return false; |
|
| 429 | + } else { |
|
| 430 | + if ($interval == '1m') |
|
| 431 | + { |
|
| 432 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 433 | + } else if ($interval == '15m'){ |
|
| 434 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + } else { |
|
| 438 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + $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 |
|
| 442 | 442 | WHERE spotter_live.latitude <> '' |
| 443 | 443 | AND spotter_live.longitude <> '' |
| 444 | 444 | ".$additional_query." |
| 445 | 445 | HAVING distance < :radius |
| 446 | 446 | ORDER BY distance"; |
| 447 | 447 | |
| 448 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 448 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 449 | 449 | |
| 450 | - return $spotter_array; |
|
| 451 | - } |
|
| 450 | + return $spotter_array; |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | 453 | |
| 454 | - /** |
|
| 455 | - * Gets all the spotter information based on a particular callsign |
|
| 456 | - * |
|
| 457 | - * @return Array the spotter information |
|
| 458 | - * |
|
| 459 | - */ |
|
| 454 | + /** |
|
| 455 | + * Gets all the spotter information based on a particular callsign |
|
| 456 | + * |
|
| 457 | + * @return Array the spotter information |
|
| 458 | + * |
|
| 459 | + */ |
|
| 460 | 460 | public function getLastLiveSpotterDataByIdent($ident) |
| 461 | 461 | { |
| 462 | 462 | $Spotter = new Spotter($this->db); |
| 463 | 463 | date_default_timezone_set('UTC'); |
| 464 | 464 | |
| 465 | 465 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 466 | - $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'; |
|
| 466 | + $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'; |
|
| 467 | 467 | |
| 468 | 468 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 469 | 469 | |
| 470 | 470 | return $spotter_array; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - /** |
|
| 474 | - * Gets all the spotter information based on a particular callsign |
|
| 475 | - * |
|
| 476 | - * @return Array the spotter information |
|
| 477 | - * |
|
| 478 | - */ |
|
| 473 | + /** |
|
| 474 | + * Gets all the spotter information based on a particular callsign |
|
| 475 | + * |
|
| 476 | + * @return Array the spotter information |
|
| 477 | + * |
|
| 478 | + */ |
|
| 479 | 479 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 480 | 480 | { |
| 481 | 481 | $Spotter = new Spotter($this->db); |
| 482 | 482 | date_default_timezone_set('UTC'); |
| 483 | 483 | |
| 484 | 484 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 485 | - $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'; |
|
| 485 | + $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'; |
|
| 486 | 486 | |
| 487 | - $date = date('c',$date); |
|
| 487 | + $date = date('c',$date); |
|
| 488 | 488 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 489 | 489 | |
| 490 | 490 | return $spotter_array; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - /** |
|
| 494 | - * Gets last spotter information based on a particular callsign |
|
| 495 | - * |
|
| 496 | - * @return Array the spotter information |
|
| 497 | - * |
|
| 498 | - */ |
|
| 493 | + /** |
|
| 494 | + * Gets last spotter information based on a particular callsign |
|
| 495 | + * |
|
| 496 | + * @return Array the spotter information |
|
| 497 | + * |
|
| 498 | + */ |
|
| 499 | 499 | public function getLastLiveSpotterDataById($id) |
| 500 | 500 | { |
| 501 | 501 | $Spotter = new Spotter($this->db); |
| 502 | 502 | date_default_timezone_set('UTC'); |
| 503 | 503 | |
| 504 | 504 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 505 | - $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'; |
|
| 505 | + $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'; |
|
| 506 | 506 | |
| 507 | 507 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
| 508 | 508 | |
| 509 | 509 | return $spotter_array; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - /** |
|
| 513 | - * Gets last spotter information based on a particular callsign |
|
| 514 | - * |
|
| 515 | - * @return Array the spotter information |
|
| 516 | - * |
|
| 517 | - */ |
|
| 512 | + /** |
|
| 513 | + * Gets last spotter information based on a particular callsign |
|
| 514 | + * |
|
| 515 | + * @return Array the spotter information |
|
| 516 | + * |
|
| 517 | + */ |
|
| 518 | 518 | public function getDateLiveSpotterDataById($id,$date) |
| 519 | 519 | { |
| 520 | 520 | $Spotter = new Spotter($this->db); |
| 521 | 521 | date_default_timezone_set('UTC'); |
| 522 | 522 | |
| 523 | 523 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 524 | - $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'; |
|
| 525 | - $date = date('c',$date); |
|
| 524 | + $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'; |
|
| 525 | + $date = date('c',$date); |
|
| 526 | 526 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 527 | 527 | |
| 528 | 528 | return $spotter_array; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Gets altitude information based on a particular callsign |
|
| 533 | - * |
|
| 534 | - * @return Array the spotter information |
|
| 535 | - * |
|
| 536 | - */ |
|
| 531 | + /** |
|
| 532 | + * Gets altitude information based on a particular callsign |
|
| 533 | + * |
|
| 534 | + * @return Array the spotter information |
|
| 535 | + * |
|
| 536 | + */ |
|
| 537 | 537 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 538 | 538 | { |
| 539 | 539 | |
| 540 | 540 | date_default_timezone_set('UTC'); |
| 541 | 541 | |
| 542 | 542 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 543 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 543 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 544 | 544 | |
| 545 | - try { |
|
| 545 | + try { |
|
| 546 | 546 | |
| 547 | 547 | $sth = $this->db->prepare($query); |
| 548 | 548 | $sth->execute(array(':ident' => $ident)); |
@@ -555,12 +555,12 @@ discard block |
||
| 555 | 555 | return $spotter_array; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - /** |
|
| 559 | - * Gets all the spotter information based on a particular id |
|
| 560 | - * |
|
| 561 | - * @return Array the spotter information |
|
| 562 | - * |
|
| 563 | - */ |
|
| 558 | + /** |
|
| 559 | + * Gets all the spotter information based on a particular id |
|
| 560 | + * |
|
| 561 | + * @return Array the spotter information |
|
| 562 | + * |
|
| 563 | + */ |
|
| 564 | 564 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 565 | 565 | { |
| 566 | 566 | global $globalDBdriver, $globalLiveInterval; |
@@ -588,18 +588,18 @@ discard block |
||
| 588 | 588 | return $spotter_array; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - /** |
|
| 592 | - * Gets all the spotter information based on a particular ident |
|
| 593 | - * |
|
| 594 | - * @return Array the spotter information |
|
| 595 | - * |
|
| 596 | - */ |
|
| 591 | + /** |
|
| 592 | + * Gets all the spotter information based on a particular ident |
|
| 593 | + * |
|
| 594 | + * @return Array the spotter information |
|
| 595 | + * |
|
| 596 | + */ |
|
| 597 | 597 | public function getAllLiveSpotterDataByIdent($ident) |
| 598 | 598 | { |
| 599 | 599 | date_default_timezone_set('UTC'); |
| 600 | 600 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 601 | 601 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 602 | - try { |
|
| 602 | + try { |
|
| 603 | 603 | |
| 604 | 604 | $sth = $this->db->prepare($query); |
| 605 | 605 | $sth->execute(array(':ident' => $ident)); |
@@ -613,23 +613,23 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | - * Deletes all info in the table |
|
| 617 | - * |
|
| 618 | - * @return String success or false |
|
| 619 | - * |
|
| 620 | - */ |
|
| 616 | + * Deletes all info in the table |
|
| 617 | + * |
|
| 618 | + * @return String success or false |
|
| 619 | + * |
|
| 620 | + */ |
|
| 621 | 621 | public function deleteLiveSpotterData() |
| 622 | 622 | { |
| 623 | 623 | global $globalDBdriver; |
| 624 | 624 | if ($globalDBdriver == 'mysql') { |
| 625 | 625 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 626 | 626 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 627 | - //$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)"; |
|
| 627 | + //$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)"; |
|
| 628 | 628 | } else { |
| 629 | 629 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - try { |
|
| 632 | + try { |
|
| 633 | 633 | |
| 634 | 634 | $sth = $this->db->prepare($query); |
| 635 | 635 | $sth->execute(); |
@@ -641,18 +641,18 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 645 | - * |
|
| 646 | - * @return String success or false |
|
| 647 | - * |
|
| 648 | - */ |
|
| 644 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 645 | + * |
|
| 646 | + * @return String success or false |
|
| 647 | + * |
|
| 648 | + */ |
|
| 649 | 649 | public function deleteLiveSpotterDataNotUpdated() |
| 650 | 650 | { |
| 651 | 651 | global $globalDBdriver, $globalDebug; |
| 652 | 652 | if ($globalDBdriver == 'mysql') { |
| 653 | 653 | //$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'; |
| 654 | - $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 2000 OFFSET 0"; |
|
| 655 | - try { |
|
| 654 | + $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 2000 OFFSET 0"; |
|
| 655 | + try { |
|
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(); |
@@ -660,8 +660,8 @@ discard block |
||
| 660 | 660 | return "error"; |
| 661 | 661 | } |
| 662 | 662 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 663 | - $i = 0; |
|
| 664 | - $j =0; |
|
| 663 | + $i = 0; |
|
| 664 | + $j =0; |
|
| 665 | 665 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 666 | 666 | foreach($all as $row) |
| 667 | 667 | { |
@@ -669,20 +669,20 @@ discard block |
||
| 669 | 669 | $j++; |
| 670 | 670 | if ($j == 30) { |
| 671 | 671 | if ($globalDebug) echo "."; |
| 672 | - try { |
|
| 672 | + try { |
|
| 673 | 673 | |
| 674 | 674 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 675 | 675 | $sth->execute(); |
| 676 | 676 | } catch(PDOException $e) { |
| 677 | 677 | return "error"; |
| 678 | 678 | } |
| 679 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 680 | - $j = 0; |
|
| 679 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 680 | + $j = 0; |
|
| 681 | 681 | } |
| 682 | 682 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 683 | 683 | } |
| 684 | 684 | if ($i > 0) { |
| 685 | - try { |
|
| 685 | + try { |
|
| 686 | 686 | |
| 687 | 687 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 688 | 688 | $sth->execute(); |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | return "success"; |
| 694 | 694 | } elseif ($globalDBdriver == 'pgsql') { |
| 695 | 695 | //$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"; |
| 696 | - //$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"; |
|
| 697 | - $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 2000 OFFSET 0)"; |
|
| 698 | - try { |
|
| 696 | + //$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"; |
|
| 697 | + $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 2000 OFFSET 0)"; |
|
| 698 | + try { |
|
| 699 | 699 | |
| 700 | 700 | $sth = $this->db->prepare($query); |
| 701 | 701 | $sth->execute(); |
@@ -739,17 +739,17 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | - * Deletes all info in the table for an ident |
|
| 743 | - * |
|
| 744 | - * @return String success or false |
|
| 745 | - * |
|
| 746 | - */ |
|
| 742 | + * Deletes all info in the table for an ident |
|
| 743 | + * |
|
| 744 | + * @return String success or false |
|
| 745 | + * |
|
| 746 | + */ |
|
| 747 | 747 | public function deleteLiveSpotterDataByIdent($ident) |
| 748 | 748 | { |
| 749 | 749 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 750 | 750 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 751 | 751 | |
| 752 | - try { |
|
| 752 | + try { |
|
| 753 | 753 | |
| 754 | 754 | $sth = $this->db->prepare($query); |
| 755 | 755 | $sth->execute(array(':ident' => $ident)); |
@@ -761,17 +761,17 @@ discard block |
||
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
| 764 | - * Deletes all info in the table for an id |
|
| 765 | - * |
|
| 766 | - * @return String success or false |
|
| 767 | - * |
|
| 768 | - */ |
|
| 764 | + * Deletes all info in the table for an id |
|
| 765 | + * |
|
| 766 | + * @return String success or false |
|
| 767 | + * |
|
| 768 | + */ |
|
| 769 | 769 | public function deleteLiveSpotterDataById($id) |
| 770 | 770 | { |
| 771 | 771 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 772 | 772 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 773 | 773 | |
| 774 | - try { |
|
| 774 | + try { |
|
| 775 | 775 | |
| 776 | 776 | $sth = $this->db->prepare($query); |
| 777 | 777 | $sth->execute(array(':id' => $id)); |
@@ -784,11 +784,11 @@ discard block |
||
| 784 | 784 | |
| 785 | 785 | |
| 786 | 786 | /** |
| 787 | - * Gets the aircraft ident within the last hour |
|
| 788 | - * |
|
| 789 | - * @return String the ident |
|
| 790 | - * |
|
| 791 | - */ |
|
| 787 | + * Gets the aircraft ident within the last hour |
|
| 788 | + * |
|
| 789 | + * @return String the ident |
|
| 790 | + * |
|
| 791 | + */ |
|
| 792 | 792 | public function getIdentFromLastHour($ident) |
| 793 | 793 | { |
| 794 | 794 | global $globalDBdriver, $globalTimezone; |
@@ -814,14 +814,14 @@ discard block |
||
| 814 | 814 | $ident_result = $row['ident']; |
| 815 | 815 | } |
| 816 | 816 | return $ident_result; |
| 817 | - } |
|
| 817 | + } |
|
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | - * Check recent aircraft |
|
| 821 | - * |
|
| 822 | - * @return String the ident |
|
| 823 | - * |
|
| 824 | - */ |
|
| 820 | + * Check recent aircraft |
|
| 821 | + * |
|
| 822 | + * @return String the ident |
|
| 823 | + * |
|
| 824 | + */ |
|
| 825 | 825 | public function checkIdentRecent($ident) |
| 826 | 826 | { |
| 827 | 827 | global $globalDBdriver, $globalTimezone; |
@@ -847,14 +847,14 @@ discard block |
||
| 847 | 847 | $ident_result = $row['flightaware_id']; |
| 848 | 848 | } |
| 849 | 849 | return $ident_result; |
| 850 | - } |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | 852 | /** |
| 853 | - * Check recent aircraft by id |
|
| 854 | - * |
|
| 855 | - * @return String the ident |
|
| 856 | - * |
|
| 857 | - */ |
|
| 853 | + * Check recent aircraft by id |
|
| 854 | + * |
|
| 855 | + * @return String the ident |
|
| 856 | + * |
|
| 857 | + */ |
|
| 858 | 858 | public function checkIdRecent($id) |
| 859 | 859 | { |
| 860 | 860 | global $globalDBdriver, $globalTimezone; |
@@ -880,14 +880,14 @@ discard block |
||
| 880 | 880 | $ident_result = $row['flightaware_id']; |
| 881 | 881 | } |
| 882 | 882 | return $ident_result; |
| 883 | - } |
|
| 883 | + } |
|
| 884 | 884 | |
| 885 | 885 | /** |
| 886 | - * Check recent aircraft by ModeS |
|
| 887 | - * |
|
| 888 | - * @return String the ModeS |
|
| 889 | - * |
|
| 890 | - */ |
|
| 886 | + * Check recent aircraft by ModeS |
|
| 887 | + * |
|
| 888 | + * @return String the ModeS |
|
| 889 | + * |
|
| 890 | + */ |
|
| 891 | 891 | public function checkModeSRecent($modes) |
| 892 | 892 | { |
| 893 | 893 | global $globalDBdriver, $globalTimezone; |
@@ -914,19 +914,19 @@ discard block |
||
| 914 | 914 | $ident_result = $row['flightaware_id']; |
| 915 | 915 | } |
| 916 | 916 | return $ident_result; |
| 917 | - } |
|
| 917 | + } |
|
| 918 | 918 | |
| 919 | 919 | /** |
| 920 | - * Adds a new spotter data |
|
| 921 | - * |
|
| 922 | - * @param String $flightaware_id the ID from flightaware |
|
| 923 | - * @param String $ident the flight ident |
|
| 924 | - * @param String $aircraft_icao the aircraft type |
|
| 925 | - * @param String $departure_airport_icao the departure airport |
|
| 926 | - * @param String $arrival_airport_icao the arrival airport |
|
| 927 | - * @return String success or false |
|
| 928 | - * |
|
| 929 | - */ |
|
| 920 | + * Adds a new spotter data |
|
| 921 | + * |
|
| 922 | + * @param String $flightaware_id the ID from flightaware |
|
| 923 | + * @param String $ident the flight ident |
|
| 924 | + * @param String $aircraft_icao the aircraft type |
|
| 925 | + * @param String $departure_airport_icao the departure airport |
|
| 926 | + * @param String $arrival_airport_icao the arrival airport |
|
| 927 | + * @return String success or false |
|
| 928 | + * |
|
| 929 | + */ |
|
| 930 | 930 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 931 | 931 | { |
| 932 | 932 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1061,10 +1061,10 @@ discard block |
||
| 1061 | 1061 | $arrival_airport_country = ''; |
| 1062 | 1062 | |
| 1063 | 1063 | |
| 1064 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1065 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1066 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1067 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1064 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1065 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1066 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1067 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1068 | 1068 | |
| 1069 | 1069 | $query = ''; |
| 1070 | 1070 | if ($globalArchive) { |
@@ -1085,10 +1085,10 @@ discard block |
||
| 1085 | 1085 | return "error : ".$e->getMessage(); |
| 1086 | 1086 | } |
| 1087 | 1087 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1088 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1089 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1090 | - $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); |
|
| 1091 | - if ($globalDebug) echo $result.')'; |
|
| 1088 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1089 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1090 | + $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); |
|
| 1091 | + if ($globalDebug) echo $result.')'; |
|
| 1092 | 1092 | } |
| 1093 | 1093 | return "success"; |
| 1094 | 1094 | |
@@ -16,62 +16,62 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 37 | 37 | if ($flt['airlines'][0] != '') { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 53 | 53 | if (isset($flt['source'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | 55 | } else { |
| 56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 60 | 60 | if (isset($flt['source'])) { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | 62 | } else { |
| 63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 67 | 67 | if (isset($flt['source'])) { |
| 68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 73 | 73 | if ($filter['airlines'][0] != '') { |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 82 | 82 | } |
| 83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | 85 | } |
| 86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 88 | 88 | } |
| 89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 117 | 117 | } |
| 118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 120 | 120 | } |
| 121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 123 | 123 | if ($filter_query_where != '') { |
| 124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 125 | 125 | } |
| 126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
| 127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | if ($limit != '') |
| 145 | 145 | { |
| 146 | 146 | $limit_array = explode(',', $limit); |
| 147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 150 | 150 | { |
| 151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | } else { |
| 169 | 169 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= 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; |
| 170 | 170 | } |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 172 | 172 | |
| 173 | 173 | return $spotter_array; |
| 174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 185 | 185 | date_default_timezone_set('UTC'); |
| 186 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 186 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 187 | 187 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 188 | 188 | if ($globalDBdriver == 'mysql') { |
| 189 | 189 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | try { |
| 207 | 207 | $sth = $this->db->prepare($query); |
| 208 | 208 | $sth->execute(); |
| 209 | - } catch(PDOException $e) { |
|
| 209 | + } catch (PDOException $e) { |
|
| 210 | 210 | echo $e->getMessage(); |
| 211 | 211 | die; |
| 212 | 212 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | global $globalDBdriver, $globalLiveInterval; |
| 226 | 226 | date_default_timezone_set('UTC'); |
| 227 | 227 | |
| 228 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 228 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 229 | 229 | |
| 230 | 230 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 231 | 231 | if ($globalDBdriver == 'mysql') { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | 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.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 235 | 235 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 236 | 236 | */ |
| 237 | - $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 | + $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 |
|
| 238 | 238 | 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' |
| 239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 240 | 240 | } else { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | 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' |
| 244 | 244 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 245 | 245 | */ |
| 246 | - $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 |
|
| 246 | + $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 |
|
| 247 | 247 | FROM spotter_live".$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 | 248 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 249 | 249 | // echo $query; |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | try { |
| 253 | 253 | $sth = $this->db->prepare($query); |
| 254 | 254 | $sth->execute(); |
| 255 | - } catch(PDOException $e) { |
|
| 255 | + } catch (PDOException $e) { |
|
| 256 | 256 | echo $e->getMessage(); |
| 257 | 257 | die; |
| 258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | public function getLiveSpotterCount($filter = array()) |
| 270 | 270 | { |
| 271 | 271 | global $globalDBdriver, $globalLiveInterval; |
| 272 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 272 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 273 | 273 | |
| 274 | 274 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 275 | 275 | if ($globalDBdriver == 'mysql') { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | try { |
| 283 | 283 | $sth = $this->db->prepare($query); |
| 284 | 284 | $sth->execute(); |
| 285 | - } catch(PDOException $e) { |
|
| 285 | + } catch (PDOException $e) { |
|
| 286 | 286 | echo $e->getMessage(); |
| 287 | 287 | die; |
| 288 | 288 | } |
@@ -305,10 +305,10 @@ discard block |
||
| 305 | 305 | $filter_query = $this->getFilter($filter); |
| 306 | 306 | |
| 307 | 307 | if (is_array($coord)) { |
| 308 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 309 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 310 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 311 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 308 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 309 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 310 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 311 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 312 | 312 | } else return array(); |
| 313 | 313 | if ($globalDBdriver == 'mysql') { |
| 314 | 314 | $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; |
@@ -331,23 +331,23 @@ discard block |
||
| 331 | 331 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 332 | 332 | $Spotter = new Spotter($this->db); |
| 333 | 333 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 334 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 334 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 335 | 335 | |
| 336 | 336 | if (is_array($coord)) { |
| 337 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 338 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 339 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 340 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 337 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 338 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 339 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 340 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 341 | 341 | } else return array(); |
| 342 | 342 | if ($globalDBdriver == 'mysql') { |
| 343 | 343 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 344 | - $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 |
|
| 344 | + $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 |
|
| 345 | 345 | FROM spotter_live |
| 346 | 346 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 347 | 347 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 348 | 348 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
| 349 | 349 | } else { |
| 350 | - $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 |
|
| 350 | + $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 |
|
| 351 | 351 | FROM spotter_live |
| 352 | 352 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 353 | 353 | FROM spotter_live l |
@@ -359,14 +359,14 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | } else { |
| 361 | 361 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 362 | - $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 |
|
| 362 | + $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 |
|
| 363 | 363 | FROM spotter_live |
| 364 | 364 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 365 | 365 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 366 | 366 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 367 | 367 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 368 | 368 | } else { |
| 369 | - $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 |
|
| 369 | + $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 |
|
| 370 | 370 | FROM spotter_live |
| 371 | 371 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 372 | 372 | FROM spotter_live l |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | try { |
| 382 | 382 | $sth = $this->db->prepare($query); |
| 383 | 383 | $sth->execute(); |
| 384 | - } catch(PDOException $e) { |
|
| 384 | + } catch (PDOException $e) { |
|
| 385 | 385 | echo $e->getMessage(); |
| 386 | 386 | die; |
| 387 | 387 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | if ($interval == '1m') |
| 431 | 431 | { |
| 432 | 432 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 433 | - } else if ($interval == '15m'){ |
|
| 433 | + } else if ($interval == '15m') { |
|
| 434 | 434 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 435 | 435 | } |
| 436 | 436 | } |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - $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 |
|
| 441 | + $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 |
|
| 442 | 442 | WHERE spotter_live.latitude <> '' |
| 443 | 443 | AND spotter_live.longitude <> '' |
| 444 | 444 | ".$additional_query." |
| 445 | 445 | HAVING distance < :radius |
| 446 | 446 | ORDER BY distance"; |
| 447 | 447 | |
| 448 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 448 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 449 | 449 | |
| 450 | 450 | return $spotter_array; |
| 451 | 451 | } |
@@ -463,9 +463,9 @@ discard block |
||
| 463 | 463 | date_default_timezone_set('UTC'); |
| 464 | 464 | |
| 465 | 465 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 466 | - $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'; |
|
| 466 | + $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'; |
|
| 467 | 467 | |
| 468 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 468 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 469 | 469 | |
| 470 | 470 | return $spotter_array; |
| 471 | 471 | } |
@@ -476,16 +476,16 @@ discard block |
||
| 476 | 476 | * @return Array the spotter information |
| 477 | 477 | * |
| 478 | 478 | */ |
| 479 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 479 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 480 | 480 | { |
| 481 | 481 | $Spotter = new Spotter($this->db); |
| 482 | 482 | date_default_timezone_set('UTC'); |
| 483 | 483 | |
| 484 | 484 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 485 | - $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'; |
|
| 485 | + $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'; |
|
| 486 | 486 | |
| 487 | - $date = date('c',$date); |
|
| 488 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 487 | + $date = date('c', $date); |
|
| 488 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 489 | 489 | |
| 490 | 490 | return $spotter_array; |
| 491 | 491 | } |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | date_default_timezone_set('UTC'); |
| 503 | 503 | |
| 504 | 504 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 505 | - $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'; |
|
| 505 | + $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'; |
|
| 506 | 506 | |
| 507 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 507 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 508 | 508 | |
| 509 | 509 | return $spotter_array; |
| 510 | 510 | } |
@@ -515,15 +515,15 @@ discard block |
||
| 515 | 515 | * @return Array the spotter information |
| 516 | 516 | * |
| 517 | 517 | */ |
| 518 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 518 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 519 | 519 | { |
| 520 | 520 | $Spotter = new Spotter($this->db); |
| 521 | 521 | date_default_timezone_set('UTC'); |
| 522 | 522 | |
| 523 | 523 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 524 | - $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'; |
|
| 525 | - $date = date('c',$date); |
|
| 526 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 524 | + $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'; |
|
| 525 | + $date = date('c', $date); |
|
| 526 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 527 | 527 | |
| 528 | 528 | return $spotter_array; |
| 529 | 529 | } |
@@ -540,13 +540,13 @@ discard block |
||
| 540 | 540 | date_default_timezone_set('UTC'); |
| 541 | 541 | |
| 542 | 542 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 543 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 543 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 544 | 544 | |
| 545 | 545 | try { |
| 546 | 546 | |
| 547 | 547 | $sth = $this->db->prepare($query); |
| 548 | 548 | $sth->execute(array(':ident' => $ident)); |
| 549 | - } catch(PDOException $e) { |
|
| 549 | + } catch (PDOException $e) { |
|
| 550 | 550 | echo $e->getMessage(); |
| 551 | 551 | die; |
| 552 | 552 | } |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * @return Array the spotter information |
| 562 | 562 | * |
| 563 | 563 | */ |
| 564 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 564 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 565 | 565 | { |
| 566 | 566 | global $globalDBdriver, $globalLiveInterval; |
| 567 | 567 | date_default_timezone_set('UTC'); |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | try { |
| 581 | 581 | $sth = $this->db->prepare($query); |
| 582 | 582 | $sth->execute(array(':id' => $id)); |
| 583 | - } catch(PDOException $e) { |
|
| 583 | + } catch (PDOException $e) { |
|
| 584 | 584 | echo $e->getMessage(); |
| 585 | 585 | die; |
| 586 | 586 | } |
@@ -598,12 +598,12 @@ discard block |
||
| 598 | 598 | { |
| 599 | 599 | date_default_timezone_set('UTC'); |
| 600 | 600 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 601 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 601 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 602 | 602 | try { |
| 603 | 603 | |
| 604 | 604 | $sth = $this->db->prepare($query); |
| 605 | 605 | $sth->execute(array(':ident' => $ident)); |
| 606 | - } catch(PDOException $e) { |
|
| 606 | + } catch (PDOException $e) { |
|
| 607 | 607 | echo $e->getMessage(); |
| 608 | 608 | die; |
| 609 | 609 | } |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | $sth = $this->db->prepare($query); |
| 635 | 635 | $sth->execute(); |
| 636 | - } catch(PDOException $e) { |
|
| 636 | + } catch (PDOException $e) { |
|
| 637 | 637 | return "error"; |
| 638 | 638 | } |
| 639 | 639 | |
@@ -656,14 +656,14 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(); |
| 659 | - } catch(PDOException $e) { |
|
| 659 | + } catch (PDOException $e) { |
|
| 660 | 660 | return "error"; |
| 661 | 661 | } |
| 662 | 662 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 663 | 663 | $i = 0; |
| 664 | - $j =0; |
|
| 664 | + $j = 0; |
|
| 665 | 665 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 666 | - foreach($all as $row) |
|
| 666 | + foreach ($all as $row) |
|
| 667 | 667 | { |
| 668 | 668 | $i++; |
| 669 | 669 | $j++; |
@@ -671,9 +671,9 @@ discard block |
||
| 671 | 671 | if ($globalDebug) echo "."; |
| 672 | 672 | try { |
| 673 | 673 | |
| 674 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 674 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 675 | 675 | $sth->execute(); |
| 676 | - } catch(PDOException $e) { |
|
| 676 | + } catch (PDOException $e) { |
|
| 677 | 677 | return "error"; |
| 678 | 678 | } |
| 679 | 679 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -684,9 +684,9 @@ discard block |
||
| 684 | 684 | if ($i > 0) { |
| 685 | 685 | try { |
| 686 | 686 | |
| 687 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 687 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 688 | 688 | $sth->execute(); |
| 689 | - } catch(PDOException $e) { |
|
| 689 | + } catch (PDOException $e) { |
|
| 690 | 690 | return "error"; |
| 691 | 691 | } |
| 692 | 692 | } |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | |
| 700 | 700 | $sth = $this->db->prepare($query); |
| 701 | 701 | $sth->execute(); |
| 702 | - } catch(PDOException $e) { |
|
| 702 | + } catch (PDOException $e) { |
|
| 703 | 703 | return "error"; |
| 704 | 704 | } |
| 705 | 705 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -747,13 +747,13 @@ discard block |
||
| 747 | 747 | public function deleteLiveSpotterDataByIdent($ident) |
| 748 | 748 | { |
| 749 | 749 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 750 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 750 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 751 | 751 | |
| 752 | 752 | try { |
| 753 | 753 | |
| 754 | 754 | $sth = $this->db->prepare($query); |
| 755 | 755 | $sth->execute(array(':ident' => $ident)); |
| 756 | - } catch(PDOException $e) { |
|
| 756 | + } catch (PDOException $e) { |
|
| 757 | 757 | return "error"; |
| 758 | 758 | } |
| 759 | 759 | |
@@ -769,13 +769,13 @@ discard block |
||
| 769 | 769 | public function deleteLiveSpotterDataById($id) |
| 770 | 770 | { |
| 771 | 771 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 772 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 772 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 773 | 773 | |
| 774 | 774 | try { |
| 775 | 775 | |
| 776 | 776 | $sth = $this->db->prepare($query); |
| 777 | 777 | $sth->execute(array(':id' => $id)); |
| 778 | - } catch(PDOException $e) { |
|
| 778 | + } catch (PDOException $e) { |
|
| 779 | 779 | return "error"; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -793,13 +793,13 @@ discard block |
||
| 793 | 793 | { |
| 794 | 794 | global $globalDBdriver, $globalTimezone; |
| 795 | 795 | if ($globalDBdriver == 'mysql') { |
| 796 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 796 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 797 | 797 | WHERE spotter_live.ident = :ident |
| 798 | 798 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 799 | 799 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 800 | 800 | $query_data = array(':ident' => $ident); |
| 801 | 801 | } else { |
| 802 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 802 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 803 | 803 | WHERE spotter_live.ident = :ident |
| 804 | 804 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 805 | 805 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -808,8 +808,8 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | $sth = $this->db->prepare($query); |
| 810 | 810 | $sth->execute($query_data); |
| 811 | - $ident_result=''; |
|
| 812 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 811 | + $ident_result = ''; |
|
| 812 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 813 | 813 | { |
| 814 | 814 | $ident_result = $row['ident']; |
| 815 | 815 | } |
@@ -826,13 +826,13 @@ discard block |
||
| 826 | 826 | { |
| 827 | 827 | global $globalDBdriver, $globalTimezone; |
| 828 | 828 | if ($globalDBdriver == 'mysql') { |
| 829 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 829 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 830 | 830 | WHERE spotter_live.ident = :ident |
| 831 | 831 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 832 | 832 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 833 | 833 | $query_data = array(':ident' => $ident); |
| 834 | 834 | } else { |
| 835 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 835 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 836 | 836 | WHERE spotter_live.ident = :ident |
| 837 | 837 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 838 | 838 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | $sth = $this->db->prepare($query); |
| 843 | 843 | $sth->execute($query_data); |
| 844 | - $ident_result=''; |
|
| 845 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 844 | + $ident_result = ''; |
|
| 845 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 846 | 846 | { |
| 847 | 847 | $ident_result = $row['flightaware_id']; |
| 848 | 848 | } |
@@ -859,13 +859,13 @@ discard block |
||
| 859 | 859 | { |
| 860 | 860 | global $globalDBdriver, $globalTimezone; |
| 861 | 861 | if ($globalDBdriver == 'mysql') { |
| 862 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 862 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 863 | 863 | WHERE spotter_live.flightaware_id = :id |
| 864 | 864 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 865 | 865 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 866 | 866 | $query_data = array(':id' => $id); |
| 867 | 867 | } else { |
| 868 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 868 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 869 | 869 | WHERE spotter_live.flightaware_id = :id |
| 870 | 870 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 871 | 871 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -874,8 +874,8 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | $sth = $this->db->prepare($query); |
| 876 | 876 | $sth->execute($query_data); |
| 877 | - $ident_result=''; |
|
| 878 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 877 | + $ident_result = ''; |
|
| 878 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 879 | 879 | { |
| 880 | 880 | $ident_result = $row['flightaware_id']; |
| 881 | 881 | } |
@@ -892,13 +892,13 @@ discard block |
||
| 892 | 892 | { |
| 893 | 893 | global $globalDBdriver, $globalTimezone; |
| 894 | 894 | if ($globalDBdriver == 'mysql') { |
| 895 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 895 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 896 | 896 | WHERE spotter_live.ModeS = :modes |
| 897 | 897 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 898 | 898 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 899 | 899 | $query_data = array(':modes' => $modes); |
| 900 | 900 | } else { |
| 901 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 901 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 902 | 902 | WHERE spotter_live.ModeS = :modes |
| 903 | 903 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 904 | 904 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -907,8 +907,8 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | $sth = $this->db->prepare($query); |
| 909 | 909 | $sth->execute($query_data); |
| 910 | - $ident_result=''; |
|
| 911 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 910 | + $ident_result = ''; |
|
| 911 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 912 | 912 | { |
| 913 | 913 | //$ident_result = $row['spotter_live_id']; |
| 914 | 914 | $ident_result = $row['flightaware_id']; |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | * @return String success or false |
| 928 | 928 | * |
| 929 | 929 | */ |
| 930 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 930 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 931 | 931 | { |
| 932 | 932 | global $globalURL, $globalArchive, $globalDebug; |
| 933 | 933 | $Common = new Common(); |
@@ -1020,26 +1020,26 @@ discard block |
||
| 1020 | 1020 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1021 | 1021 | |
| 1022 | 1022 | |
| 1023 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1024 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1025 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1026 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1027 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1028 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1029 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1030 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1031 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1032 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1033 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1034 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1036 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1037 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1038 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1039 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1040 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1041 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1042 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1023 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1024 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1025 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1026 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1027 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1028 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1029 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1030 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1031 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1032 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1033 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1034 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1036 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1037 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1038 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1039 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1040 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1041 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1042 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1043 | 1043 | |
| 1044 | 1044 | $airline_name = ''; |
| 1045 | 1045 | $airline_icao = ''; |
@@ -1061,10 +1061,10 @@ discard block |
||
| 1061 | 1061 | $arrival_airport_country = ''; |
| 1062 | 1062 | |
| 1063 | 1063 | |
| 1064 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1065 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1066 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1067 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1064 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1065 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1066 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1067 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1068 | 1068 | |
| 1069 | 1069 | $query = ''; |
| 1070 | 1070 | if ($globalArchive) { |
@@ -1075,19 +1075,19 @@ discard block |
||
| 1075 | 1075 | $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) |
| 1076 | 1076 | 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)'; |
| 1077 | 1077 | |
| 1078 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 1078 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 1079 | 1079 | try { |
| 1080 | 1080 | |
| 1081 | 1081 | $sth = $this->db->prepare($query); |
| 1082 | 1082 | $sth->execute($query_values); |
| 1083 | 1083 | $sth->closeCursor(); |
| 1084 | - } catch(PDOException $e) { |
|
| 1084 | + } catch (PDOException $e) { |
|
| 1085 | 1085 | return "error : ".$e->getMessage(); |
| 1086 | 1086 | } |
| 1087 | 1087 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1088 | 1088 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1089 | 1089 | $SpotterArchive = new SpotterArchive($this->db); |
| 1090 | - $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); |
|
| 1090 | + $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); |
|
| 1091 | 1091 | if ($globalDebug) echo $result.')'; |
| 1092 | 1092 | } |
| 1093 | 1093 | return "success"; |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | |
| 1097 | 1097 | public function getOrderBy() |
| 1098 | 1098 | { |
| 1099 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1099 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1100 | 1100 | return $orderby; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -118,8 +120,11 @@ discard block |
||
| 118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 120 | 122 | } |
| 121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 123 | + if ($filter_query_where == '' && $where) { |
|
| 124 | + $filter_query_where = ' WHERE'; |
|
| 125 | + } elseif ($filter_query_where != '' && $and) { |
|
| 126 | + $filter_query_where .= ' AND'; |
|
| 127 | + } |
|
| 123 | 128 | if ($filter_query_where != '') { |
| 124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 125 | 130 | } |
@@ -161,7 +166,9 @@ discard block |
||
| 161 | 166 | } |
| 162 | 167 | } |
| 163 | 168 | |
| 164 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 169 | + if (!isset($globalLiveInterval)) { |
|
| 170 | + $globalLiveInterval = '200'; |
|
| 171 | + } |
|
| 165 | 172 | if ($globalDBdriver == 'mysql') { |
| 166 | 173 | //$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"; |
| 167 | 174 | $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; |
@@ -184,7 +191,9 @@ discard block |
||
| 184 | 191 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 185 | 192 | date_default_timezone_set('UTC'); |
| 186 | 193 | $filter_query = $this->getFilter($filter,true,true); |
| 187 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 194 | + if (!isset($globalLiveInterval)) { |
|
| 195 | + $globalLiveInterval = '200'; |
|
| 196 | + } |
|
| 188 | 197 | if ($globalDBdriver == 'mysql') { |
| 189 | 198 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 190 | 199 | $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 |
@@ -227,7 +236,9 @@ discard block |
||
| 227 | 236 | |
| 228 | 237 | $filter_query = $this->getFilter($filter,true,true); |
| 229 | 238 | |
| 230 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 239 | + if (!isset($globalLiveInterval)) { |
|
| 240 | + $globalLiveInterval = '200'; |
|
| 241 | + } |
|
| 231 | 242 | if ($globalDBdriver == 'mysql') { |
| 232 | 243 | /* |
| 233 | 244 | $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 |
@@ -271,7 +282,9 @@ discard block |
||
| 271 | 282 | global $globalDBdriver, $globalLiveInterval; |
| 272 | 283 | $filter_query = $this->getFilter($filter,true,true); |
| 273 | 284 | |
| 274 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 285 | + if (!isset($globalLiveInterval)) { |
|
| 286 | + $globalLiveInterval = '200'; |
|
| 287 | + } |
|
| 275 | 288 | if ($globalDBdriver == 'mysql') { |
| 276 | 289 | //$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; |
| 277 | 290 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -301,7 +314,9 @@ discard block |
||
| 301 | 314 | { |
| 302 | 315 | global $globalDBdriver, $globalLiveInterval; |
| 303 | 316 | $Spotter = new Spotter($this->db); |
| 304 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 317 | + if (!isset($globalLiveInterval)) { |
|
| 318 | + $globalLiveInterval = '200'; |
|
| 319 | + } |
|
| 305 | 320 | $filter_query = $this->getFilter($filter); |
| 306 | 321 | |
| 307 | 322 | if (is_array($coord)) { |
@@ -309,7 +324,9 @@ discard block |
||
| 309 | 324 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 310 | 325 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 311 | 326 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 312 | - } else return array(); |
|
| 327 | + } else { |
|
| 328 | + return array(); |
|
| 329 | + } |
|
| 313 | 330 | if ($globalDBdriver == 'mysql') { |
| 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; |
| 315 | 332 | } else { |
@@ -330,7 +347,9 @@ discard block |
||
| 330 | 347 | { |
| 331 | 348 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 332 | 349 | $Spotter = new Spotter($this->db); |
| 333 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 350 | + if (!isset($globalLiveInterval)) { |
|
| 351 | + $globalLiveInterval = '200'; |
|
| 352 | + } |
|
| 334 | 353 | $filter_query = $this->getFilter($filter,true,true); |
| 335 | 354 | |
| 336 | 355 | if (is_array($coord)) { |
@@ -338,7 +357,9 @@ discard block |
||
| 338 | 357 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 339 | 358 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 340 | 359 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 341 | - } else return array(); |
|
| 360 | + } else { |
|
| 361 | + return array(); |
|
| 362 | + } |
|
| 342 | 363 | if ($globalDBdriver == 'mysql') { |
| 343 | 364 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 344 | 365 | $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 |
@@ -569,11 +590,15 @@ discard block |
||
| 569 | 590 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 570 | 591 | if ($globalDBdriver == 'mysql') { |
| 571 | 592 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 572 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 593 | + if ($liveinterval) { |
|
| 594 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 595 | + } |
|
| 573 | 596 | $query .= ' ORDER BY date'; |
| 574 | 597 | } else { |
| 575 | 598 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 576 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 599 | + if ($liveinterval) { |
|
| 600 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 601 | + } |
|
| 577 | 602 | $query .= ' ORDER BY date'; |
| 578 | 603 | } |
| 579 | 604 | |
@@ -668,7 +693,9 @@ discard block |
||
| 668 | 693 | $i++; |
| 669 | 694 | $j++; |
| 670 | 695 | if ($j == 30) { |
| 671 | - if ($globalDebug) echo "."; |
|
| 696 | + if ($globalDebug) { |
|
| 697 | + echo "."; |
|
| 698 | + } |
|
| 672 | 699 | try { |
| 673 | 700 | |
| 674 | 701 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -975,7 +1002,9 @@ discard block |
||
| 975 | 1002 | { |
| 976 | 1003 | return false; |
| 977 | 1004 | } |
| 978 | - } else return ''; |
|
| 1005 | + } else { |
|
| 1006 | + return ''; |
|
| 1007 | + } |
|
| 979 | 1008 | |
| 980 | 1009 | if ($longitude != '') |
| 981 | 1010 | { |
@@ -983,7 +1012,9 @@ discard block |
||
| 983 | 1012 | { |
| 984 | 1013 | return false; |
| 985 | 1014 | } |
| 986 | - } else return ''; |
|
| 1015 | + } else { |
|
| 1016 | + return ''; |
|
| 1017 | + } |
|
| 987 | 1018 | |
| 988 | 1019 | if ($waypoints != '') |
| 989 | 1020 | { |
@@ -999,7 +1030,9 @@ discard block |
||
| 999 | 1030 | { |
| 1000 | 1031 | return false; |
| 1001 | 1032 | } |
| 1002 | - } else $altitude = 0; |
|
| 1033 | + } else { |
|
| 1034 | + $altitude = 0; |
|
| 1035 | + } |
|
| 1003 | 1036 | |
| 1004 | 1037 | if ($heading != '') |
| 1005 | 1038 | { |
@@ -1007,7 +1040,9 @@ discard block |
||
| 1007 | 1040 | { |
| 1008 | 1041 | return false; |
| 1009 | 1042 | } |
| 1010 | - } else $heading = 0; |
|
| 1043 | + } else { |
|
| 1044 | + $heading = 0; |
|
| 1045 | + } |
|
| 1011 | 1046 | |
| 1012 | 1047 | if ($groundspeed != '') |
| 1013 | 1048 | { |
@@ -1015,9 +1050,13 @@ discard block |
||
| 1015 | 1050 | { |
| 1016 | 1051 | return false; |
| 1017 | 1052 | } |
| 1018 | - } else $groundspeed = 0; |
|
| 1053 | + } else { |
|
| 1054 | + $groundspeed = 0; |
|
| 1055 | + } |
|
| 1019 | 1056 | date_default_timezone_set('UTC'); |
| 1020 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1057 | + if ($date == '') { |
|
| 1058 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1059 | + } |
|
| 1021 | 1060 | |
| 1022 | 1061 | |
| 1023 | 1062 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1061,14 +1100,24 @@ discard block |
||
| 1061 | 1100 | $arrival_airport_country = ''; |
| 1062 | 1101 | |
| 1063 | 1102 | |
| 1064 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1065 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1066 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1067 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1103 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1104 | + $squawk = NULL; |
|
| 1105 | + } |
|
| 1106 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1107 | + $verticalrate = NULL; |
|
| 1108 | + } |
|
| 1109 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1110 | + $groundspeed = 0; |
|
| 1111 | + } |
|
| 1112 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1113 | + $heading = 0; |
|
| 1114 | + } |
|
| 1068 | 1115 | |
| 1069 | 1116 | $query = ''; |
| 1070 | 1117 | if ($globalArchive) { |
| 1071 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1118 | + if ($globalDebug) { |
|
| 1119 | + echo '-- Delete previous data -- '; |
|
| 1120 | + } |
|
| 1072 | 1121 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1073 | 1122 | } |
| 1074 | 1123 | |
@@ -1085,10 +1134,14 @@ discard block |
||
| 1085 | 1134 | return "error : ".$e->getMessage(); |
| 1086 | 1135 | } |
| 1087 | 1136 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1088 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1137 | + if ($globalDebug) { |
|
| 1138 | + echo '(Add to SBS archive : '; |
|
| 1139 | + } |
|
| 1089 | 1140 | $SpotterArchive = new SpotterArchive($this->db); |
| 1090 | 1141 | $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); |
| 1091 | - if ($globalDebug) echo $result.')'; |
|
| 1142 | + if ($globalDebug) { |
|
| 1143 | + echo $result.')'; |
|
| 1144 | + } |
|
| 1092 | 1145 | } |
| 1093 | 1146 | return "success"; |
| 1094 | 1147 | |