@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Gets all the spotter information based on the latest data entry |
|
| 91 | - * |
|
| 92 | - * @return Array the spotter information |
|
| 93 | - * |
|
| 94 | - */ |
|
| 90 | + * Gets all the spotter information based on the latest data entry |
|
| 91 | + * |
|
| 92 | + * @return Array the spotter information |
|
| 93 | + * |
|
| 94 | + */ |
|
| 95 | 95 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
| 96 | 96 | { |
| 97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * Gets Minimal Live Spotter data |
|
| 137 | - * |
|
| 138 | - * @return Array the spotter information |
|
| 139 | - * |
|
| 140 | - */ |
|
| 136 | + * Gets Minimal Live Spotter data |
|
| 137 | + * |
|
| 138 | + * @return Array the spotter information |
|
| 139 | + * |
|
| 140 | + */ |
|
| 141 | 141 | public function getMinLiveTrackerData($filter = array()) |
| 142 | 142 | { |
| 143 | 143 | global $globalDBdriver, $globalLiveInterval; |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 175 | - * |
|
| 176 | - * @return Array the spotter information |
|
| 177 | - * |
|
| 178 | - */ |
|
| 174 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 175 | + * |
|
| 176 | + * @return Array the spotter information |
|
| 177 | + * |
|
| 178 | + */ |
|
| 179 | 179 | public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
| 180 | 180 | { |
| 181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * Gets number of latest data entry |
|
| 253 | - * |
|
| 254 | - * @return String number of entry |
|
| 255 | - * |
|
| 256 | - */ |
|
| 252 | + * Gets number of latest data entry |
|
| 253 | + * |
|
| 254 | + * @return String number of entry |
|
| 255 | + * |
|
| 256 | + */ |
|
| 257 | 257 | public function getLiveTrackerCount($filter = array()) |
| 258 | 258 | { |
| 259 | 259 | global $globalDBdriver, $globalLiveInterval; |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 282 | - * |
|
| 283 | - * @return Array the spotter information |
|
| 284 | - * |
|
| 285 | - */ |
|
| 281 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 282 | + * |
|
| 283 | + * @return Array the spotter information |
|
| 284 | + * |
|
| 285 | + */ |
|
| 286 | 286 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
| 287 | 287 | { |
| 288 | 288 | global $globalDBdriver, $globalLiveInterval; |
@@ -306,11 +306,11 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 310 | - * |
|
| 311 | - * @return Array the spotter information |
|
| 312 | - * |
|
| 313 | - */ |
|
| 309 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 310 | + * |
|
| 311 | + * @return Array the spotter information |
|
| 312 | + * |
|
| 313 | + */ |
|
| 314 | 314 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
| 315 | 315 | { |
| 316 | 316 | global $globalDBdriver, $globalLiveInterval; |
@@ -378,11 +378,11 @@ discard block |
||
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
| 381 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 382 | - * |
|
| 383 | - * @return Array the spotter information |
|
| 384 | - * |
|
| 385 | - */ |
|
| 381 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 382 | + * |
|
| 383 | + * @return Array the spotter information |
|
| 384 | + * |
|
| 385 | + */ |
|
| 386 | 386 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
| 387 | 387 | { |
| 388 | 388 | $Tracker = new Tracker($this->db); |
@@ -395,142 +395,142 @@ discard block |
||
| 395 | 395 | if ($lng != '') |
| 396 | 396 | { |
| 397 | 397 | if (!is_numeric($lng)) |
| 398 | - { |
|
| 399 | - return false; |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - if ($radius != '') |
|
| 404 | - { |
|
| 405 | - if (!is_numeric($radius)) |
|
| 406 | - { |
|
| 407 | - return false; |
|
| 408 | - } |
|
| 409 | - } |
|
| 398 | + { |
|
| 399 | + return false; |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + if ($radius != '') |
|
| 404 | + { |
|
| 405 | + if (!is_numeric($radius)) |
|
| 406 | + { |
|
| 407 | + return false; |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | 410 | $additional_query = ''; |
| 411 | 411 | if ($interval != '') |
| 412 | - { |
|
| 413 | - if (!is_string($interval)) |
|
| 414 | - { |
|
| 415 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 416 | - return false; |
|
| 417 | - } else { |
|
| 418 | - if ($interval == '1m') |
|
| 419 | - { |
|
| 420 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 421 | - } else if ($interval == '15m'){ |
|
| 422 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 423 | - } |
|
| 424 | - } |
|
| 425 | - } else { |
|
| 426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 412 | + { |
|
| 413 | + if (!is_string($interval)) |
|
| 414 | + { |
|
| 415 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 416 | + return false; |
|
| 417 | + } else { |
|
| 418 | + if ($interval == '1m') |
|
| 419 | + { |
|
| 420 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 421 | + } else if ($interval == '15m'){ |
|
| 422 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + } else { |
|
| 426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 430 | 430 | WHERE tracker_live.latitude <> '' |
| 431 | 431 | AND tracker_live.longitude <> '' |
| 432 | 432 | ".$additional_query." |
| 433 | 433 | HAVING distance < :radius |
| 434 | 434 | ORDER BY distance"; |
| 435 | 435 | |
| 436 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 436 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 437 | 437 | |
| 438 | - return $spotter_array; |
|
| 439 | - } |
|
| 438 | + return $spotter_array; |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Gets all the spotter information based on a particular callsign |
|
| 444 | - * |
|
| 445 | - * @return Array the spotter information |
|
| 446 | - * |
|
| 447 | - */ |
|
| 442 | + /** |
|
| 443 | + * Gets all the spotter information based on a particular callsign |
|
| 444 | + * |
|
| 445 | + * @return Array the spotter information |
|
| 446 | + * |
|
| 447 | + */ |
|
| 448 | 448 | public function getLastLiveTrackerDataByIdent($ident) |
| 449 | 449 | { |
| 450 | 450 | $Tracker = new Tracker($this->db); |
| 451 | 451 | date_default_timezone_set('UTC'); |
| 452 | 452 | |
| 453 | 453 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 454 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 454 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 455 | 455 | |
| 456 | 456 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 457 | 457 | |
| 458 | 458 | return $spotter_array; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - /** |
|
| 462 | - * Gets all the spotter information based on a particular callsign |
|
| 463 | - * |
|
| 464 | - * @return Array the spotter information |
|
| 465 | - * |
|
| 466 | - */ |
|
| 461 | + /** |
|
| 462 | + * Gets all the spotter information based on a particular callsign |
|
| 463 | + * |
|
| 464 | + * @return Array the spotter information |
|
| 465 | + * |
|
| 466 | + */ |
|
| 467 | 467 | public function getDateLiveTrackerDataByIdent($ident,$date) |
| 468 | 468 | { |
| 469 | 469 | $Tracker = new Tracker($this->db); |
| 470 | 470 | date_default_timezone_set('UTC'); |
| 471 | 471 | |
| 472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 473 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 473 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 474 | 474 | |
| 475 | - $date = date('c',$date); |
|
| 475 | + $date = date('c',$date); |
|
| 476 | 476 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 477 | 477 | |
| 478 | 478 | return $spotter_array; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - /** |
|
| 482 | - * Gets last spotter information based on a particular callsign |
|
| 483 | - * |
|
| 484 | - * @return Array the spotter information |
|
| 485 | - * |
|
| 486 | - */ |
|
| 481 | + /** |
|
| 482 | + * Gets last spotter information based on a particular callsign |
|
| 483 | + * |
|
| 484 | + * @return Array the spotter information |
|
| 485 | + * |
|
| 486 | + */ |
|
| 487 | 487 | public function getLastLiveTrackerDataById($id) |
| 488 | 488 | { |
| 489 | 489 | $Tracker = new Tracker($this->db); |
| 490 | 490 | date_default_timezone_set('UTC'); |
| 491 | 491 | |
| 492 | 492 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 493 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 493 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 494 | 494 | |
| 495 | 495 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
| 496 | 496 | |
| 497 | 497 | return $spotter_array; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - /** |
|
| 501 | - * Gets last spotter information based on a particular callsign |
|
| 502 | - * |
|
| 503 | - * @return Array the spotter information |
|
| 504 | - * |
|
| 505 | - */ |
|
| 500 | + /** |
|
| 501 | + * Gets last spotter information based on a particular callsign |
|
| 502 | + * |
|
| 503 | + * @return Array the spotter information |
|
| 504 | + * |
|
| 505 | + */ |
|
| 506 | 506 | public function getDateLiveTrackerDataById($id,$date) |
| 507 | 507 | { |
| 508 | 508 | $Tracker = new Tracker($this->db); |
| 509 | 509 | date_default_timezone_set('UTC'); |
| 510 | 510 | |
| 511 | 511 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 512 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 513 | - $date = date('c',$date); |
|
| 512 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 513 | + $date = date('c',$date); |
|
| 514 | 514 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 515 | 515 | |
| 516 | 516 | return $spotter_array; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - /** |
|
| 520 | - * Gets altitude information based on a particular callsign |
|
| 521 | - * |
|
| 522 | - * @return Array the spotter information |
|
| 523 | - * |
|
| 524 | - */ |
|
| 519 | + /** |
|
| 520 | + * Gets altitude information based on a particular callsign |
|
| 521 | + * |
|
| 522 | + * @return Array the spotter information |
|
| 523 | + * |
|
| 524 | + */ |
|
| 525 | 525 | public function getAltitudeLiveTrackerDataByIdent($ident) |
| 526 | 526 | { |
| 527 | 527 | |
| 528 | 528 | date_default_timezone_set('UTC'); |
| 529 | 529 | |
| 530 | 530 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 531 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 531 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 532 | 532 | |
| 533 | - try { |
|
| 533 | + try { |
|
| 534 | 534 | |
| 535 | 535 | $sth = $this->db->prepare($query); |
| 536 | 536 | $sth->execute(array(':ident' => $ident)); |
@@ -543,12 +543,12 @@ discard block |
||
| 543 | 543 | return $spotter_array; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - /** |
|
| 547 | - * Gets all the spotter information based on a particular id |
|
| 548 | - * |
|
| 549 | - * @return Array the spotter information |
|
| 550 | - * |
|
| 551 | - */ |
|
| 546 | + /** |
|
| 547 | + * Gets all the spotter information based on a particular id |
|
| 548 | + * |
|
| 549 | + * @return Array the spotter information |
|
| 550 | + * |
|
| 551 | + */ |
|
| 552 | 552 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
| 553 | 553 | { |
| 554 | 554 | global $globalDBdriver, $globalLiveInterval; |
@@ -576,18 +576,18 @@ discard block |
||
| 576 | 576 | return $spotter_array; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - /** |
|
| 580 | - * Gets all the spotter information based on a particular ident |
|
| 581 | - * |
|
| 582 | - * @return Array the spotter information |
|
| 583 | - * |
|
| 584 | - */ |
|
| 579 | + /** |
|
| 580 | + * Gets all the spotter information based on a particular ident |
|
| 581 | + * |
|
| 582 | + * @return Array the spotter information |
|
| 583 | + * |
|
| 584 | + */ |
|
| 585 | 585 | public function getAllLiveTrackerDataByIdent($ident) |
| 586 | 586 | { |
| 587 | 587 | date_default_timezone_set('UTC'); |
| 588 | 588 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 589 | 589 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
| 590 | - try { |
|
| 590 | + try { |
|
| 591 | 591 | |
| 592 | 592 | $sth = $this->db->prepare($query); |
| 593 | 593 | $sth->execute(array(':ident' => $ident)); |
@@ -601,23 +601,23 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | - * Deletes all info in the table |
|
| 605 | - * |
|
| 606 | - * @return String success or false |
|
| 607 | - * |
|
| 608 | - */ |
|
| 604 | + * Deletes all info in the table |
|
| 605 | + * |
|
| 606 | + * @return String success or false |
|
| 607 | + * |
|
| 608 | + */ |
|
| 609 | 609 | public function deleteLiveTrackerData() |
| 610 | 610 | { |
| 611 | 611 | global $globalDBdriver; |
| 612 | 612 | if ($globalDBdriver == 'mysql') { |
| 613 | 613 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
| 614 | 614 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
| 615 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 615 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 616 | 616 | } else { |
| 617 | 617 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - try { |
|
| 620 | + try { |
|
| 621 | 621 | |
| 622 | 622 | $sth = $this->db->prepare($query); |
| 623 | 623 | $sth->execute(); |
@@ -629,18 +629,18 @@ discard block |
||
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 633 | - * |
|
| 634 | - * @return String success or false |
|
| 635 | - * |
|
| 636 | - */ |
|
| 632 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 633 | + * |
|
| 634 | + * @return String success or false |
|
| 635 | + * |
|
| 636 | + */ |
|
| 637 | 637 | public function deleteLiveTrackerDataNotUpdated() |
| 638 | 638 | { |
| 639 | 639 | global $globalDBdriver, $globalDebug; |
| 640 | 640 | if ($globalDBdriver == 'mysql') { |
| 641 | 641 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
| 642 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 643 | - try { |
|
| 642 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 643 | + try { |
|
| 644 | 644 | |
| 645 | 645 | $sth = $this->db->prepare($query); |
| 646 | 646 | $sth->execute(); |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | return "error"; |
| 649 | 649 | } |
| 650 | 650 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 651 | - $i = 0; |
|
| 652 | - $j =0; |
|
| 651 | + $i = 0; |
|
| 652 | + $j =0; |
|
| 653 | 653 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 654 | 654 | foreach($all as $row) |
| 655 | 655 | { |
@@ -657,20 +657,20 @@ discard block |
||
| 657 | 657 | $j++; |
| 658 | 658 | if ($j == 30) { |
| 659 | 659 | if ($globalDebug) echo "."; |
| 660 | - try { |
|
| 660 | + try { |
|
| 661 | 661 | |
| 662 | 662 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 663 | 663 | $sth->execute(); |
| 664 | 664 | } catch(PDOException $e) { |
| 665 | 665 | return "error"; |
| 666 | 666 | } |
| 667 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 668 | - $j = 0; |
|
| 667 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 668 | + $j = 0; |
|
| 669 | 669 | } |
| 670 | 670 | $query_delete .= "'".$row['famtrackid']."',"; |
| 671 | 671 | } |
| 672 | 672 | if ($i > 0) { |
| 673 | - try { |
|
| 673 | + try { |
|
| 674 | 674 | |
| 675 | 675 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 676 | 676 | $sth->execute(); |
@@ -681,9 +681,9 @@ discard block |
||
| 681 | 681 | return "success"; |
| 682 | 682 | } elseif ($globalDBdriver == 'pgsql') { |
| 683 | 683 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
| 684 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 685 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 686 | - try { |
|
| 684 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 685 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 686 | + try { |
|
| 687 | 687 | |
| 688 | 688 | $sth = $this->db->prepare($query); |
| 689 | 689 | $sth->execute(); |
@@ -727,17 +727,17 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
| 730 | - * Deletes all info in the table for an ident |
|
| 731 | - * |
|
| 732 | - * @return String success or false |
|
| 733 | - * |
|
| 734 | - */ |
|
| 730 | + * Deletes all info in the table for an ident |
|
| 731 | + * |
|
| 732 | + * @return String success or false |
|
| 733 | + * |
|
| 734 | + */ |
|
| 735 | 735 | public function deleteLiveTrackerDataByIdent($ident) |
| 736 | 736 | { |
| 737 | 737 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 738 | 738 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
| 739 | 739 | |
| 740 | - try { |
|
| 740 | + try { |
|
| 741 | 741 | |
| 742 | 742 | $sth = $this->db->prepare($query); |
| 743 | 743 | $sth->execute(array(':ident' => $ident)); |
@@ -749,17 +749,17 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | - * Deletes all info in the table for an id |
|
| 753 | - * |
|
| 754 | - * @return String success or false |
|
| 755 | - * |
|
| 756 | - */ |
|
| 752 | + * Deletes all info in the table for an id |
|
| 753 | + * |
|
| 754 | + * @return String success or false |
|
| 755 | + * |
|
| 756 | + */ |
|
| 757 | 757 | public function deleteLiveTrackerDataById($id) |
| 758 | 758 | { |
| 759 | 759 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 760 | 760 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
| 761 | 761 | |
| 762 | - try { |
|
| 762 | + try { |
|
| 763 | 763 | |
| 764 | 764 | $sth = $this->db->prepare($query); |
| 765 | 765 | $sth->execute(array(':id' => $id)); |
@@ -772,11 +772,11 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | |
| 774 | 774 | /** |
| 775 | - * Gets the aircraft ident within the last hour |
|
| 776 | - * |
|
| 777 | - * @return String the ident |
|
| 778 | - * |
|
| 779 | - */ |
|
| 775 | + * Gets the aircraft ident within the last hour |
|
| 776 | + * |
|
| 777 | + * @return String the ident |
|
| 778 | + * |
|
| 779 | + */ |
|
| 780 | 780 | public function getIdentFromLastHour($ident) |
| 781 | 781 | { |
| 782 | 782 | global $globalDBdriver, $globalTimezone; |
@@ -802,14 +802,14 @@ discard block |
||
| 802 | 802 | $ident_result = $row['ident']; |
| 803 | 803 | } |
| 804 | 804 | return $ident_result; |
| 805 | - } |
|
| 805 | + } |
|
| 806 | 806 | |
| 807 | 807 | /** |
| 808 | - * Check recent aircraft |
|
| 809 | - * |
|
| 810 | - * @return String the ident |
|
| 811 | - * |
|
| 812 | - */ |
|
| 808 | + * Check recent aircraft |
|
| 809 | + * |
|
| 810 | + * @return String the ident |
|
| 811 | + * |
|
| 812 | + */ |
|
| 813 | 813 | public function checkIdentRecent($ident) |
| 814 | 814 | { |
| 815 | 815 | global $globalDBdriver, $globalTimezone; |
@@ -835,14 +835,14 @@ discard block |
||
| 835 | 835 | $ident_result = $row['famtrackid']; |
| 836 | 836 | } |
| 837 | 837 | return $ident_result; |
| 838 | - } |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | 840 | /** |
| 841 | - * Check recent aircraft by id |
|
| 842 | - * |
|
| 843 | - * @return String the ident |
|
| 844 | - * |
|
| 845 | - */ |
|
| 841 | + * Check recent aircraft by id |
|
| 842 | + * |
|
| 843 | + * @return String the ident |
|
| 844 | + * |
|
| 845 | + */ |
|
| 846 | 846 | public function checkIdRecent($id) |
| 847 | 847 | { |
| 848 | 848 | global $globalDBdriver, $globalTimezone; |
@@ -868,19 +868,19 @@ discard block |
||
| 868 | 868 | $ident_result = $row['famtrackid']; |
| 869 | 869 | } |
| 870 | 870 | return $ident_result; |
| 871 | - } |
|
| 871 | + } |
|
| 872 | 872 | |
| 873 | 873 | /** |
| 874 | - * Adds a new spotter data |
|
| 875 | - * |
|
| 876 | - * @param String $famtrackid the ID from flightaware |
|
| 877 | - * @param String $ident the flight ident |
|
| 878 | - * @param String $aircraft_icao the aircraft type |
|
| 879 | - * @param String $departure_airport_icao the departure airport |
|
| 880 | - * @param String $arrival_airport_icao the arrival airport |
|
| 881 | - * @return String success or false |
|
| 882 | - * |
|
| 883 | - */ |
|
| 874 | + * Adds a new spotter data |
|
| 875 | + * |
|
| 876 | + * @param String $famtrackid the ID from flightaware |
|
| 877 | + * @param String $ident the flight ident |
|
| 878 | + * @param String $aircraft_icao the aircraft type |
|
| 879 | + * @param String $departure_airport_icao the departure airport |
|
| 880 | + * @param String $arrival_airport_icao the arrival airport |
|
| 881 | + * @return String success or false |
|
| 882 | + * |
|
| 883 | + */ |
|
| 884 | 884 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 885 | 885 | { |
| 886 | 886 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 954 | 954 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 955 | 955 | |
| 956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 958 | 958 | |
| 959 | 959 | $query = ''; |
| 960 | 960 | if ($globalArchive) { |
@@ -972,15 +972,15 @@ discard block |
||
| 972 | 972 | } catch(PDOException $e) { |
| 973 | 973 | return "error : ".$e->getMessage(); |
| 974 | 974 | } |
| 975 | - /* |
|
| 975 | + /* |
|
| 976 | 976 | echo 'putinarchive : '.$putinarchive."\n"; |
| 977 | 977 | echo 'noarchive : '.$noarchive."\n"; |
| 978 | 978 | */ |
| 979 | 979 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 980 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 981 | - $TrackerArchive = new TrackerArchive($this->db); |
|
| 982 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 983 | - if ($globalDebug) echo $result.')'; |
|
| 980 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 981 | + $TrackerArchive = new TrackerArchive($this->db); |
|
| 982 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 983 | + if ($globalDebug) echo $result.')'; |
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | return "success"; |