@@ -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, $globalArchive; |
@@ -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"; |
@@ -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 getLiveMarineData($limit = '', $sort = '', $filter = array()) |
| 96 | 96 | { |
| 97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | - * Gets Minimal Live Spotter data |
|
| 138 | - * |
|
| 139 | - * @return Array the spotter information |
|
| 140 | - * |
|
| 141 | - */ |
|
| 137 | + * Gets Minimal Live Spotter data |
|
| 138 | + * |
|
| 139 | + * @return Array the spotter information |
|
| 140 | + * |
|
| 141 | + */ |
|
| 142 | 142 | public function getMinLiveMarineData($filter = array()) |
| 143 | 143 | { |
| 144 | 144 | global $globalDBdriver, $globalLiveInterval; |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 172 | - * |
|
| 173 | - * @return Array the spotter information |
|
| 174 | - * |
|
| 175 | - */ |
|
| 171 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 172 | + * |
|
| 173 | + * @return Array the spotter information |
|
| 174 | + * |
|
| 175 | + */ |
|
| 176 | 176 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
| 177 | 177 | { |
| 178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | - * Gets number of latest data entry |
|
| 247 | - * |
|
| 248 | - * @return String number of entry |
|
| 249 | - * |
|
| 250 | - */ |
|
| 246 | + * Gets number of latest data entry |
|
| 247 | + * |
|
| 248 | + * @return String number of entry |
|
| 249 | + * |
|
| 250 | + */ |
|
| 251 | 251 | public function getLiveMarineCount($filter = array()) |
| 252 | 252 | { |
| 253 | 253 | global $globalDBdriver, $globalLiveInterval; |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
| 275 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 276 | - * |
|
| 277 | - * @return Array the spotter information |
|
| 278 | - * |
|
| 279 | - */ |
|
| 275 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 276 | + * |
|
| 277 | + * @return Array the spotter information |
|
| 278 | + * |
|
| 279 | + */ |
|
| 280 | 280 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
| 281 | 281 | { |
| 282 | 282 | global $globalDBdriver, $globalLiveInterval; |
@@ -300,11 +300,11 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 304 | - * |
|
| 305 | - * @return Array the spotter information |
|
| 306 | - * |
|
| 307 | - */ |
|
| 303 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 304 | + * |
|
| 305 | + * @return Array the spotter information |
|
| 306 | + * |
|
| 307 | + */ |
|
| 308 | 308 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
| 309 | 309 | { |
| 310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -373,11 +373,11 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 377 | - * |
|
| 378 | - * @return Array the spotter information |
|
| 379 | - * |
|
| 380 | - */ |
|
| 376 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 377 | + * |
|
| 378 | + * @return Array the spotter information |
|
| 379 | + * |
|
| 380 | + */ |
|
| 381 | 381 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
| 382 | 382 | { |
| 383 | 383 | $Marine = new Marine($this->db); |
@@ -390,134 +390,134 @@ discard block |
||
| 390 | 390 | if ($lng != '') |
| 391 | 391 | { |
| 392 | 392 | if (!is_numeric($lng)) |
| 393 | - { |
|
| 394 | - return false; |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - if ($radius != '') |
|
| 399 | - { |
|
| 400 | - if (!is_numeric($radius)) |
|
| 401 | - { |
|
| 402 | - return false; |
|
| 403 | - } |
|
| 404 | - } |
|
| 393 | + { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + if ($radius != '') |
|
| 399 | + { |
|
| 400 | + if (!is_numeric($radius)) |
|
| 401 | + { |
|
| 402 | + return false; |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | 405 | $additional_query = ''; |
| 406 | 406 | if ($interval != '') |
| 407 | - { |
|
| 408 | - if (!is_string($interval)) |
|
| 409 | - { |
|
| 410 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 411 | - return false; |
|
| 412 | - } else { |
|
| 413 | - if ($interval == '1m') |
|
| 414 | - { |
|
| 415 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 416 | - } else if ($interval == '15m'){ |
|
| 417 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 407 | + { |
|
| 408 | + if (!is_string($interval)) |
|
| 409 | + { |
|
| 410 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 411 | + return false; |
|
| 412 | + } else { |
|
| 413 | + if ($interval == '1m') |
|
| 414 | + { |
|
| 415 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 416 | + } else if ($interval == '15m'){ |
|
| 417 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 425 | 425 | WHERE marine_live.latitude <> '' |
| 426 | 426 | AND marine_live.longitude <> '' |
| 427 | 427 | ".$additional_query." |
| 428 | 428 | HAVING distance < :radius |
| 429 | 429 | ORDER BY distance"; |
| 430 | 430 | |
| 431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 432 | 432 | |
| 433 | - return $spotter_array; |
|
| 434 | - } |
|
| 433 | + return $spotter_array; |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | 436 | |
| 437 | - /** |
|
| 438 | - * Gets all the spotter information based on a particular callsign |
|
| 439 | - * |
|
| 440 | - * @return Array the spotter information |
|
| 441 | - * |
|
| 442 | - */ |
|
| 437 | + /** |
|
| 438 | + * Gets all the spotter information based on a particular callsign |
|
| 439 | + * |
|
| 440 | + * @return Array the spotter information |
|
| 441 | + * |
|
| 442 | + */ |
|
| 443 | 443 | public function getLastLiveMarineDataByIdent($ident) |
| 444 | 444 | { |
| 445 | 445 | $Marine = new Marine($this->db); |
| 446 | 446 | date_default_timezone_set('UTC'); |
| 447 | 447 | |
| 448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 450 | 450 | |
| 451 | 451 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 452 | 452 | |
| 453 | 453 | return $spotter_array; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - /** |
|
| 457 | - * Gets all the spotter information based on a particular callsign |
|
| 458 | - * |
|
| 459 | - * @return Array the spotter information |
|
| 460 | - * |
|
| 461 | - */ |
|
| 456 | + /** |
|
| 457 | + * Gets all the spotter information based on a particular callsign |
|
| 458 | + * |
|
| 459 | + * @return Array the spotter information |
|
| 460 | + * |
|
| 461 | + */ |
|
| 462 | 462 | public function getDateLiveMarineDataByIdent($ident,$date) |
| 463 | 463 | { |
| 464 | 464 | $Marine = new Marine($this->db); |
| 465 | 465 | date_default_timezone_set('UTC'); |
| 466 | 466 | |
| 467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 469 | 469 | |
| 470 | - $date = date('c',$date); |
|
| 470 | + $date = date('c',$date); |
|
| 471 | 471 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 472 | 472 | |
| 473 | 473 | return $spotter_array; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Gets last spotter information based on a particular callsign |
|
| 478 | - * |
|
| 479 | - * @return Array the spotter information |
|
| 480 | - * |
|
| 481 | - */ |
|
| 476 | + /** |
|
| 477 | + * Gets last spotter information based on a particular callsign |
|
| 478 | + * |
|
| 479 | + * @return Array the spotter information |
|
| 480 | + * |
|
| 481 | + */ |
|
| 482 | 482 | public function getLastLiveMarineDataById($id) |
| 483 | 483 | { |
| 484 | 484 | $Marine = new Marine($this->db); |
| 485 | 485 | date_default_timezone_set('UTC'); |
| 486 | 486 | |
| 487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 489 | 489 | |
| 490 | 490 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
| 491 | 491 | |
| 492 | 492 | return $spotter_array; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - /** |
|
| 496 | - * Gets last spotter information based on a particular callsign |
|
| 497 | - * |
|
| 498 | - * @return Array the spotter information |
|
| 499 | - * |
|
| 500 | - */ |
|
| 495 | + /** |
|
| 496 | + * Gets last spotter information based on a particular callsign |
|
| 497 | + * |
|
| 498 | + * @return Array the spotter information |
|
| 499 | + * |
|
| 500 | + */ |
|
| 501 | 501 | public function getDateLiveMarineDataById($id,$date) |
| 502 | 502 | { |
| 503 | 503 | $Marine = new Marine($this->db); |
| 504 | 504 | date_default_timezone_set('UTC'); |
| 505 | 505 | |
| 506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 508 | - $date = date('c',$date); |
|
| 507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 508 | + $date = date('c',$date); |
|
| 509 | 509 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 510 | 510 | |
| 511 | 511 | return $spotter_array; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | |
| 515 | - /** |
|
| 516 | - * Gets all the spotter information based on a particular id |
|
| 517 | - * |
|
| 518 | - * @return Array the spotter information |
|
| 519 | - * |
|
| 520 | - */ |
|
| 515 | + /** |
|
| 516 | + * Gets all the spotter information based on a particular id |
|
| 517 | + * |
|
| 518 | + * @return Array the spotter information |
|
| 519 | + * |
|
| 520 | + */ |
|
| 521 | 521 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
| 522 | 522 | { |
| 523 | 523 | global $globalDBdriver, $globalLiveInterval; |
@@ -545,18 +545,18 @@ discard block |
||
| 545 | 545 | return $spotter_array; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - /** |
|
| 549 | - * Gets all the spotter information based on a particular ident |
|
| 550 | - * |
|
| 551 | - * @return Array the spotter information |
|
| 552 | - * |
|
| 553 | - */ |
|
| 548 | + /** |
|
| 549 | + * Gets all the spotter information based on a particular ident |
|
| 550 | + * |
|
| 551 | + * @return Array the spotter information |
|
| 552 | + * |
|
| 553 | + */ |
|
| 554 | 554 | public function getAllLiveMarineDataByIdent($ident) |
| 555 | 555 | { |
| 556 | 556 | date_default_timezone_set('UTC'); |
| 557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 558 | 558 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
| 559 | - try { |
|
| 559 | + try { |
|
| 560 | 560 | |
| 561 | 561 | $sth = $this->db->prepare($query); |
| 562 | 562 | $sth->execute(array(':ident' => $ident)); |
@@ -570,23 +570,23 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | |
| 572 | 572 | /** |
| 573 | - * Deletes all info in the table |
|
| 574 | - * |
|
| 575 | - * @return String success or false |
|
| 576 | - * |
|
| 577 | - */ |
|
| 573 | + * Deletes all info in the table |
|
| 574 | + * |
|
| 575 | + * @return String success or false |
|
| 576 | + * |
|
| 577 | + */ |
|
| 578 | 578 | public function deleteLiveMarineData() |
| 579 | 579 | { |
| 580 | 580 | global $globalDBdriver; |
| 581 | 581 | if ($globalDBdriver == 'mysql') { |
| 582 | 582 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
| 583 | 583 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
| 584 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 584 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 585 | 585 | } else { |
| 586 | 586 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - try { |
|
| 589 | + try { |
|
| 590 | 590 | |
| 591 | 591 | $sth = $this->db->prepare($query); |
| 592 | 592 | $sth->execute(); |
@@ -598,18 +598,18 @@ discard block |
||
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
| 601 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 602 | - * |
|
| 603 | - * @return String success or false |
|
| 604 | - * |
|
| 605 | - */ |
|
| 601 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 602 | + * |
|
| 603 | + * @return String success or false |
|
| 604 | + * |
|
| 605 | + */ |
|
| 606 | 606 | public function deleteLiveMarineDataNotUpdated() |
| 607 | 607 | { |
| 608 | 608 | global $globalDBdriver, $globalDebug; |
| 609 | 609 | if ($globalDBdriver == 'mysql') { |
| 610 | 610 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
| 611 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 612 | - try { |
|
| 611 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 612 | + try { |
|
| 613 | 613 | |
| 614 | 614 | $sth = $this->db->prepare($query); |
| 615 | 615 | $sth->execute(); |
@@ -617,8 +617,8 @@ discard block |
||
| 617 | 617 | return "error"; |
| 618 | 618 | } |
| 619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 620 | - $i = 0; |
|
| 621 | - $j =0; |
|
| 620 | + $i = 0; |
|
| 621 | + $j =0; |
|
| 622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 623 | 623 | foreach($all as $row) |
| 624 | 624 | { |
@@ -626,20 +626,20 @@ discard block |
||
| 626 | 626 | $j++; |
| 627 | 627 | if ($j == 30) { |
| 628 | 628 | if ($globalDebug) echo "."; |
| 629 | - try { |
|
| 629 | + try { |
|
| 630 | 630 | |
| 631 | 631 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 632 | 632 | $sth->execute(); |
| 633 | 633 | } catch(PDOException $e) { |
| 634 | 634 | return "error"; |
| 635 | 635 | } |
| 636 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 637 | - $j = 0; |
|
| 636 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 637 | + $j = 0; |
|
| 638 | 638 | } |
| 639 | 639 | $query_delete .= "'".$row['fammarine_id']."',"; |
| 640 | 640 | } |
| 641 | 641 | if ($i > 0) { |
| 642 | - try { |
|
| 642 | + try { |
|
| 643 | 643 | |
| 644 | 644 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 645 | 645 | $sth->execute(); |
@@ -650,9 +650,9 @@ discard block |
||
| 650 | 650 | return "success"; |
| 651 | 651 | } elseif ($globalDBdriver == 'pgsql') { |
| 652 | 652 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
| 653 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 654 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 655 | - try { |
|
| 653 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 654 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 655 | + try { |
|
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(); |
@@ -696,17 +696,17 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
| 699 | - * Deletes all info in the table for an ident |
|
| 700 | - * |
|
| 701 | - * @return String success or false |
|
| 702 | - * |
|
| 703 | - */ |
|
| 699 | + * Deletes all info in the table for an ident |
|
| 700 | + * |
|
| 701 | + * @return String success or false |
|
| 702 | + * |
|
| 703 | + */ |
|
| 704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
| 705 | 705 | { |
| 706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 707 | 707 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
| 708 | 708 | |
| 709 | - try { |
|
| 709 | + try { |
|
| 710 | 710 | |
| 711 | 711 | $sth = $this->db->prepare($query); |
| 712 | 712 | $sth->execute(array(':ident' => $ident)); |
@@ -718,17 +718,17 @@ discard block |
||
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
| 721 | - * Deletes all info in the table for an id |
|
| 722 | - * |
|
| 723 | - * @return String success or false |
|
| 724 | - * |
|
| 725 | - */ |
|
| 721 | + * Deletes all info in the table for an id |
|
| 722 | + * |
|
| 723 | + * @return String success or false |
|
| 724 | + * |
|
| 725 | + */ |
|
| 726 | 726 | public function deleteLiveMarineDataById($id) |
| 727 | 727 | { |
| 728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 729 | 729 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
| 730 | 730 | |
| 731 | - try { |
|
| 731 | + try { |
|
| 732 | 732 | |
| 733 | 733 | $sth = $this->db->prepare($query); |
| 734 | 734 | $sth->execute(array(':id' => $id)); |
@@ -741,11 +741,11 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | |
| 743 | 743 | /** |
| 744 | - * Gets the aircraft ident within the last hour |
|
| 745 | - * |
|
| 746 | - * @return String the ident |
|
| 747 | - * |
|
| 748 | - */ |
|
| 744 | + * Gets the aircraft ident within the last hour |
|
| 745 | + * |
|
| 746 | + * @return String the ident |
|
| 747 | + * |
|
| 748 | + */ |
|
| 749 | 749 | public function getIdentFromLastHour($ident) |
| 750 | 750 | { |
| 751 | 751 | global $globalDBdriver, $globalTimezone; |
@@ -771,14 +771,14 @@ discard block |
||
| 771 | 771 | $ident_result = $row['ident']; |
| 772 | 772 | } |
| 773 | 773 | return $ident_result; |
| 774 | - } |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | 776 | /** |
| 777 | - * Check recent aircraft |
|
| 778 | - * |
|
| 779 | - * @return String the ident |
|
| 780 | - * |
|
| 781 | - */ |
|
| 777 | + * Check recent aircraft |
|
| 778 | + * |
|
| 779 | + * @return String the ident |
|
| 780 | + * |
|
| 781 | + */ |
|
| 782 | 782 | public function checkIdentRecent($ident) |
| 783 | 783 | { |
| 784 | 784 | global $globalDBdriver, $globalTimezone; |
@@ -804,14 +804,14 @@ discard block |
||
| 804 | 804 | $ident_result = $row['fammarine_id']; |
| 805 | 805 | } |
| 806 | 806 | return $ident_result; |
| 807 | - } |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | 809 | /** |
| 810 | - * Check recent aircraft by id |
|
| 811 | - * |
|
| 812 | - * @return String the ident |
|
| 813 | - * |
|
| 814 | - */ |
|
| 810 | + * Check recent aircraft by id |
|
| 811 | + * |
|
| 812 | + * @return String the ident |
|
| 813 | + * |
|
| 814 | + */ |
|
| 815 | 815 | public function checkIdRecent($id) |
| 816 | 816 | { |
| 817 | 817 | global $globalDBdriver, $globalTimezone; |
@@ -837,14 +837,14 @@ discard block |
||
| 837 | 837 | $ident_result = $row['fammarine_id']; |
| 838 | 838 | } |
| 839 | 839 | return $ident_result; |
| 840 | - } |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | 842 | /** |
| 843 | - * Check recent aircraft by mmsi |
|
| 844 | - * |
|
| 845 | - * @return String the ident |
|
| 846 | - * |
|
| 847 | - */ |
|
| 843 | + * Check recent aircraft by mmsi |
|
| 844 | + * |
|
| 845 | + * @return String the ident |
|
| 846 | + * |
|
| 847 | + */ |
|
| 848 | 848 | public function checkMMSIRecent($mmsi) |
| 849 | 849 | { |
| 850 | 850 | global $globalDBdriver, $globalTimezone; |
@@ -870,19 +870,19 @@ discard block |
||
| 870 | 870 | $ident_result = $row['fammarine_id']; |
| 871 | 871 | } |
| 872 | 872 | return $ident_result; |
| 873 | - } |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | 875 | /** |
| 876 | - * Adds a new spotter data |
|
| 877 | - * |
|
| 878 | - * @param String $fammarine_id the ID from flightaware |
|
| 879 | - * @param String $ident the flight ident |
|
| 880 | - * @param String $aircraft_icao the aircraft type |
|
| 881 | - * @param String $departure_airport_icao the departure airport |
|
| 882 | - * @param String $arrival_airport_icao the arrival airport |
|
| 883 | - * @return String success or false |
|
| 884 | - * |
|
| 885 | - */ |
|
| 876 | + * Adds a new spotter data |
|
| 877 | + * |
|
| 878 | + * @param String $fammarine_id the ID from flightaware |
|
| 879 | + * @param String $ident the flight ident |
|
| 880 | + * @param String $aircraft_icao the aircraft type |
|
| 881 | + * @param String $departure_airport_icao the departure airport |
|
| 882 | + * @param String $arrival_airport_icao the arrival airport |
|
| 883 | + * @return String success or false |
|
| 884 | + * |
|
| 885 | + */ |
|
| 886 | 886 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 887 | 887 | { |
| 888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,10 +953,10 @@ discard block |
||
| 953 | 953 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 954 | 954 | |
| 955 | 955 | |
| 956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 959 | - $query = ''; |
|
| 956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 958 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 959 | + $query = ''; |
|
| 960 | 960 | if ($globalArchive) { |
| 961 | 961 | if ($globalDebug) echo '-- Delete previous data -- '; |
| 962 | 962 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |