@@ -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; |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * Gets Minimal Live Spotter data |
|
| 179 | - * |
|
| 180 | - * @return Array the spotter information |
|
| 181 | - * |
|
| 182 | - */ |
|
| 178 | + * Gets Minimal Live Spotter data |
|
| 179 | + * |
|
| 180 | + * @return Array the spotter information |
|
| 181 | + * |
|
| 182 | + */ |
|
| 183 | 183 | public function getMinLiveSpotterData($filter = array()) |
| 184 | 184 | { |
| 185 | 185 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 220 | - * |
|
| 221 | - * @return Array the spotter information |
|
| 222 | - * |
|
| 223 | - */ |
|
| 219 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 220 | + * |
|
| 221 | + * @return Array the spotter information |
|
| 222 | + * |
|
| 223 | + */ |
|
| 224 | 224 | public function getMinLastLiveSpotterData($filter = array()) |
| 225 | 225 | { |
| 226 | 226 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 252 | 252 | } |
| 253 | - } else { |
|
| 253 | + } else { |
|
| 254 | 254 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 255 | 255 | /* |
| 256 | 256 | $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | - try { |
|
| 277 | + try { |
|
| 278 | 278 | $sth = $this->db->prepare($query); |
| 279 | 279 | $sth->execute(); |
| 280 | 280 | } catch(PDOException $e) { |
@@ -286,11 +286,11 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | - * Gets number of latest data entry |
|
| 290 | - * |
|
| 291 | - * @return String number of entry |
|
| 292 | - * |
|
| 293 | - */ |
|
| 289 | + * Gets number of latest data entry |
|
| 290 | + * |
|
| 291 | + * @return String number of entry |
|
| 292 | + * |
|
| 293 | + */ |
|
| 294 | 294 | public function getLiveSpotterCount($filter = array()) |
| 295 | 295 | { |
| 296 | 296 | global $globalDBdriver, $globalLiveInterval; |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 321 | - * |
|
| 322 | - * @return Array the spotter information |
|
| 323 | - * |
|
| 324 | - */ |
|
| 320 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 321 | + * |
|
| 322 | + * @return Array the spotter information |
|
| 323 | + * |
|
| 324 | + */ |
|
| 325 | 325 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 326 | 326 | { |
| 327 | 327 | global $globalDBdriver, $globalLiveInterval; |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 350 | - * |
|
| 351 | - * @return Array the spotter information |
|
| 352 | - * |
|
| 353 | - */ |
|
| 349 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 350 | + * |
|
| 351 | + * @return Array the spotter information |
|
| 352 | + * |
|
| 353 | + */ |
|
| 354 | 354 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 355 | 355 | { |
| 356 | 356 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
| 418 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 419 | - * |
|
| 420 | - * @return Array the spotter information |
|
| 421 | - * |
|
| 422 | - */ |
|
| 418 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 419 | + * |
|
| 420 | + * @return Array the spotter information |
|
| 421 | + * |
|
| 422 | + */ |
|
| 423 | 423 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 424 | 424 | { |
| 425 | 425 | $Spotter = new Spotter($this->db); |
@@ -429,117 +429,117 @@ discard block |
||
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | - if ($lng != '') |
|
| 433 | - { |
|
| 434 | - if (!is_numeric($lng)) |
|
| 435 | - { |
|
| 436 | - return false; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - if ($radius != '') |
|
| 441 | - { |
|
| 442 | - if (!is_numeric($radius)) |
|
| 443 | - { |
|
| 444 | - return false; |
|
| 445 | - } |
|
| 446 | - } |
|
| 432 | + if ($lng != '') |
|
| 433 | + { |
|
| 434 | + if (!is_numeric($lng)) |
|
| 435 | + { |
|
| 436 | + return false; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + if ($radius != '') |
|
| 441 | + { |
|
| 442 | + if (!is_numeric($radius)) |
|
| 443 | + { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 446 | + } |
|
| 447 | 447 | $additional_query = ''; |
| 448 | - if ($interval != '') |
|
| 449 | - { |
|
| 450 | - if (!is_string($interval)) |
|
| 451 | - { |
|
| 452 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 453 | - return false; |
|
| 454 | - } else { |
|
| 455 | - if ($interval == '1m') |
|
| 456 | - { |
|
| 457 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 458 | - } else if ($interval == '15m'){ |
|
| 459 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - } else { |
|
| 463 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - $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 |
|
| 448 | + if ($interval != '') |
|
| 449 | + { |
|
| 450 | + if (!is_string($interval)) |
|
| 451 | + { |
|
| 452 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 453 | + return false; |
|
| 454 | + } else { |
|
| 455 | + if ($interval == '1m') |
|
| 456 | + { |
|
| 457 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 458 | + } else if ($interval == '15m'){ |
|
| 459 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + } else { |
|
| 463 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + $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 |
|
| 467 | 467 | WHERE spotter_live.latitude <> '' |
| 468 | 468 | AND spotter_live.longitude <> '' |
| 469 | 469 | ".$additional_query." |
| 470 | 470 | HAVING distance < :radius |
| 471 | 471 | ORDER BY distance"; |
| 472 | 472 | |
| 473 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 473 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 474 | 474 | |
| 475 | - return $spotter_array; |
|
| 476 | - } |
|
| 475 | + return $spotter_array; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | 478 | |
| 479 | - /** |
|
| 480 | - * Gets all the spotter information based on a particular callsign |
|
| 481 | - * |
|
| 482 | - * @return Array the spotter information |
|
| 483 | - * |
|
| 484 | - */ |
|
| 479 | + /** |
|
| 480 | + * Gets all the spotter information based on a particular callsign |
|
| 481 | + * |
|
| 482 | + * @return Array the spotter information |
|
| 483 | + * |
|
| 484 | + */ |
|
| 485 | 485 | public function getLastLiveSpotterDataByIdent($ident) |
| 486 | 486 | { |
| 487 | 487 | $Spotter = new Spotter($this->db); |
| 488 | 488 | date_default_timezone_set('UTC'); |
| 489 | 489 | |
| 490 | 490 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 491 | - $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'; |
|
| 491 | + $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'; |
|
| 492 | 492 | |
| 493 | 493 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 494 | 494 | |
| 495 | 495 | return $spotter_array; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - /** |
|
| 499 | - * Gets all the spotter information based on a particular callsign |
|
| 500 | - * |
|
| 501 | - * @return Array the spotter information |
|
| 502 | - * |
|
| 503 | - */ |
|
| 498 | + /** |
|
| 499 | + * Gets all the spotter information based on a particular callsign |
|
| 500 | + * |
|
| 501 | + * @return Array the spotter information |
|
| 502 | + * |
|
| 503 | + */ |
|
| 504 | 504 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 505 | 505 | { |
| 506 | 506 | $Spotter = new Spotter($this->db); |
| 507 | 507 | date_default_timezone_set('UTC'); |
| 508 | 508 | |
| 509 | 509 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 510 | - $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'; |
|
| 510 | + $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'; |
|
| 511 | 511 | |
| 512 | - $date = date('c',$date); |
|
| 512 | + $date = date('c',$date); |
|
| 513 | 513 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 514 | 514 | |
| 515 | 515 | return $spotter_array; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - /** |
|
| 519 | - * Gets last spotter information based on a particular callsign |
|
| 520 | - * |
|
| 521 | - * @return Array the spotter information |
|
| 522 | - * |
|
| 523 | - */ |
|
| 518 | + /** |
|
| 519 | + * Gets last spotter information based on a particular callsign |
|
| 520 | + * |
|
| 521 | + * @return Array the spotter information |
|
| 522 | + * |
|
| 523 | + */ |
|
| 524 | 524 | public function getLastLiveSpotterDataById($id) |
| 525 | 525 | { |
| 526 | 526 | $Spotter = new Spotter($this->db); |
| 527 | 527 | date_default_timezone_set('UTC'); |
| 528 | 528 | |
| 529 | 529 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 530 | - $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'; |
|
| 530 | + $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'; |
|
| 531 | 531 | |
| 532 | 532 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
| 533 | 533 | |
| 534 | 534 | return $spotter_array; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - /** |
|
| 538 | - * Gets last spotter information based on a particular callsign |
|
| 539 | - * |
|
| 540 | - * @return Array the spotter information |
|
| 541 | - * |
|
| 542 | - */ |
|
| 537 | + /** |
|
| 538 | + * Gets last spotter information based on a particular callsign |
|
| 539 | + * |
|
| 540 | + * @return Array the spotter information |
|
| 541 | + * |
|
| 542 | + */ |
|
| 543 | 543 | public function getDateLiveSpotterDataById($id,$date) |
| 544 | 544 | { |
| 545 | 545 | $Spotter = new Spotter($this->db); |
@@ -552,21 +552,21 @@ discard block |
||
| 552 | 552 | return $spotter_array; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - /** |
|
| 556 | - * Gets altitude information based on a particular callsign |
|
| 557 | - * |
|
| 558 | - * @return Array the spotter information |
|
| 559 | - * |
|
| 560 | - */ |
|
| 555 | + /** |
|
| 556 | + * Gets altitude information based on a particular callsign |
|
| 557 | + * |
|
| 558 | + * @return Array the spotter information |
|
| 559 | + * |
|
| 560 | + */ |
|
| 561 | 561 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 562 | 562 | { |
| 563 | 563 | |
| 564 | 564 | date_default_timezone_set('UTC'); |
| 565 | 565 | |
| 566 | 566 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 567 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 567 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 568 | 568 | |
| 569 | - try { |
|
| 569 | + try { |
|
| 570 | 570 | |
| 571 | 571 | $sth = $this->db->prepare($query); |
| 572 | 572 | $sth->execute(array(':ident' => $ident)); |
@@ -579,12 +579,12 @@ discard block |
||
| 579 | 579 | return $spotter_array; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - /** |
|
| 583 | - * Gets all the spotter information based on a particular id |
|
| 584 | - * |
|
| 585 | - * @return Array the spotter information |
|
| 586 | - * |
|
| 587 | - */ |
|
| 582 | + /** |
|
| 583 | + * Gets all the spotter information based on a particular id |
|
| 584 | + * |
|
| 585 | + * @return Array the spotter information |
|
| 586 | + * |
|
| 587 | + */ |
|
| 588 | 588 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 589 | 589 | { |
| 590 | 590 | global $globalDBdriver, $globalLiveInterval; |
@@ -612,18 +612,18 @@ discard block |
||
| 612 | 612 | return $spotter_array; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - /** |
|
| 616 | - * Gets all the spotter information based on a particular ident |
|
| 617 | - * |
|
| 618 | - * @return Array the spotter information |
|
| 619 | - * |
|
| 620 | - */ |
|
| 615 | + /** |
|
| 616 | + * Gets all the spotter information based on a particular ident |
|
| 617 | + * |
|
| 618 | + * @return Array the spotter information |
|
| 619 | + * |
|
| 620 | + */ |
|
| 621 | 621 | public function getAllLiveSpotterDataByIdent($ident) |
| 622 | 622 | { |
| 623 | 623 | date_default_timezone_set('UTC'); |
| 624 | 624 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 625 | 625 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 626 | - try { |
|
| 626 | + try { |
|
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query); |
| 629 | 629 | $sth->execute(array(':ident' => $ident)); |
@@ -637,23 +637,23 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | |
| 639 | 639 | /** |
| 640 | - * Deletes all info in the table |
|
| 641 | - * |
|
| 642 | - * @return String success or false |
|
| 643 | - * |
|
| 644 | - */ |
|
| 640 | + * Deletes all info in the table |
|
| 641 | + * |
|
| 642 | + * @return String success or false |
|
| 643 | + * |
|
| 644 | + */ |
|
| 645 | 645 | public function deleteLiveSpotterData() |
| 646 | 646 | { |
| 647 | 647 | global $globalDBdriver; |
| 648 | 648 | if ($globalDBdriver == 'mysql') { |
| 649 | 649 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 650 | 650 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 651 | - //$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)"; |
|
| 651 | + //$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)"; |
|
| 652 | 652 | } else { |
| 653 | 653 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - try { |
|
| 656 | + try { |
|
| 657 | 657 | |
| 658 | 658 | $sth = $this->db->prepare($query); |
| 659 | 659 | $sth->execute(); |
@@ -665,18 +665,18 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
| 668 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 669 | - * |
|
| 670 | - * @return String success or false |
|
| 671 | - * |
|
| 672 | - */ |
|
| 668 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 669 | + * |
|
| 670 | + * @return String success or false |
|
| 671 | + * |
|
| 672 | + */ |
|
| 673 | 673 | public function deleteLiveSpotterDataNotUpdated() |
| 674 | 674 | { |
| 675 | 675 | global $globalDBdriver, $globalDebug; |
| 676 | 676 | if ($globalDBdriver == 'mysql') { |
| 677 | 677 | //$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'; |
| 678 | - $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"; |
|
| 679 | - try { |
|
| 678 | + $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"; |
|
| 679 | + try { |
|
| 680 | 680 | |
| 681 | 681 | $sth = $this->db->prepare($query); |
| 682 | 682 | $sth->execute(); |
@@ -684,8 +684,8 @@ discard block |
||
| 684 | 684 | return "error"; |
| 685 | 685 | } |
| 686 | 686 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 687 | - $i = 0; |
|
| 688 | - $j =0; |
|
| 687 | + $i = 0; |
|
| 688 | + $j =0; |
|
| 689 | 689 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 690 | 690 | foreach($all as $row) |
| 691 | 691 | { |
@@ -693,20 +693,20 @@ discard block |
||
| 693 | 693 | $j++; |
| 694 | 694 | if ($j == 30) { |
| 695 | 695 | if ($globalDebug) echo "."; |
| 696 | - try { |
|
| 696 | + try { |
|
| 697 | 697 | |
| 698 | 698 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 699 | 699 | $sth->execute(); |
| 700 | 700 | } catch(PDOException $e) { |
| 701 | 701 | return "error"; |
| 702 | 702 | } |
| 703 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 704 | - $j = 0; |
|
| 703 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 704 | + $j = 0; |
|
| 705 | 705 | } |
| 706 | 706 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 707 | 707 | } |
| 708 | 708 | if ($i > 0) { |
| 709 | - try { |
|
| 709 | + try { |
|
| 710 | 710 | |
| 711 | 711 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 712 | 712 | $sth->execute(); |
@@ -717,9 +717,9 @@ discard block |
||
| 717 | 717 | return "success"; |
| 718 | 718 | } elseif ($globalDBdriver == 'pgsql') { |
| 719 | 719 | //$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"; |
| 720 | - //$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"; |
|
| 721 | - $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)"; |
|
| 722 | - try { |
|
| 720 | + //$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"; |
|
| 721 | + $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)"; |
|
| 722 | + try { |
|
| 723 | 723 | |
| 724 | 724 | $sth = $this->db->prepare($query); |
| 725 | 725 | $sth->execute(); |
@@ -763,17 +763,17 @@ discard block |
||
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | /** |
| 766 | - * Deletes all info in the table for an ident |
|
| 767 | - * |
|
| 768 | - * @return String success or false |
|
| 769 | - * |
|
| 770 | - */ |
|
| 766 | + * Deletes all info in the table for an ident |
|
| 767 | + * |
|
| 768 | + * @return String success or false |
|
| 769 | + * |
|
| 770 | + */ |
|
| 771 | 771 | public function deleteLiveSpotterDataByIdent($ident) |
| 772 | 772 | { |
| 773 | 773 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 774 | 774 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 775 | 775 | |
| 776 | - try { |
|
| 776 | + try { |
|
| 777 | 777 | |
| 778 | 778 | $sth = $this->db->prepare($query); |
| 779 | 779 | $sth->execute(array(':ident' => $ident)); |
@@ -785,17 +785,17 @@ discard block |
||
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | /** |
| 788 | - * Deletes all info in the table for an id |
|
| 789 | - * |
|
| 790 | - * @return String success or false |
|
| 791 | - * |
|
| 792 | - */ |
|
| 788 | + * Deletes all info in the table for an id |
|
| 789 | + * |
|
| 790 | + * @return String success or false |
|
| 791 | + * |
|
| 792 | + */ |
|
| 793 | 793 | public function deleteLiveSpotterDataById($id) |
| 794 | 794 | { |
| 795 | 795 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 796 | 796 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 797 | 797 | |
| 798 | - try { |
|
| 798 | + try { |
|
| 799 | 799 | |
| 800 | 800 | $sth = $this->db->prepare($query); |
| 801 | 801 | $sth->execute(array(':id' => $id)); |
@@ -808,11 +808,11 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | - * Gets the aircraft ident within the last hour |
|
| 812 | - * |
|
| 813 | - * @return String the ident |
|
| 814 | - * |
|
| 815 | - */ |
|
| 811 | + * Gets the aircraft ident within the last hour |
|
| 812 | + * |
|
| 813 | + * @return String the ident |
|
| 814 | + * |
|
| 815 | + */ |
|
| 816 | 816 | public function getIdentFromLastHour($ident) |
| 817 | 817 | { |
| 818 | 818 | global $globalDBdriver, $globalTimezone; |
@@ -838,14 +838,14 @@ discard block |
||
| 838 | 838 | $ident_result = $row['ident']; |
| 839 | 839 | } |
| 840 | 840 | return $ident_result; |
| 841 | - } |
|
| 841 | + } |
|
| 842 | 842 | |
| 843 | 843 | /** |
| 844 | - * Check recent aircraft |
|
| 845 | - * |
|
| 846 | - * @return String the ident |
|
| 847 | - * |
|
| 848 | - */ |
|
| 844 | + * Check recent aircraft |
|
| 845 | + * |
|
| 846 | + * @return String the ident |
|
| 847 | + * |
|
| 848 | + */ |
|
| 849 | 849 | public function checkIdentRecent($ident) |
| 850 | 850 | { |
| 851 | 851 | global $globalDBdriver, $globalTimezone; |
@@ -871,14 +871,14 @@ discard block |
||
| 871 | 871 | $ident_result = $row['flightaware_id']; |
| 872 | 872 | } |
| 873 | 873 | return $ident_result; |
| 874 | - } |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | 876 | /** |
| 877 | - * Check recent aircraft by id |
|
| 878 | - * |
|
| 879 | - * @return String the ident |
|
| 880 | - * |
|
| 881 | - */ |
|
| 877 | + * Check recent aircraft by id |
|
| 878 | + * |
|
| 879 | + * @return String the ident |
|
| 880 | + * |
|
| 881 | + */ |
|
| 882 | 882 | public function checkIdRecent($id) |
| 883 | 883 | { |
| 884 | 884 | global $globalDBdriver, $globalTimezone; |
@@ -904,14 +904,14 @@ discard block |
||
| 904 | 904 | $ident_result = $row['flightaware_id']; |
| 905 | 905 | } |
| 906 | 906 | return $ident_result; |
| 907 | - } |
|
| 907 | + } |
|
| 908 | 908 | |
| 909 | 909 | /** |
| 910 | - * Check recent aircraft by ModeS |
|
| 911 | - * |
|
| 912 | - * @return String the ModeS |
|
| 913 | - * |
|
| 914 | - */ |
|
| 910 | + * Check recent aircraft by ModeS |
|
| 911 | + * |
|
| 912 | + * @return String the ModeS |
|
| 913 | + * |
|
| 914 | + */ |
|
| 915 | 915 | public function checkModeSRecent($modes) |
| 916 | 916 | { |
| 917 | 917 | global $globalDBdriver, $globalTimezone; |
@@ -938,19 +938,19 @@ discard block |
||
| 938 | 938 | $ident_result = $row['flightaware_id']; |
| 939 | 939 | } |
| 940 | 940 | return $ident_result; |
| 941 | - } |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | 943 | /** |
| 944 | - * Adds a new spotter data |
|
| 945 | - * |
|
| 946 | - * @param String $flightaware_id the ID from flightaware |
|
| 947 | - * @param String $ident the flight ident |
|
| 948 | - * @param String $aircraft_icao the aircraft type |
|
| 949 | - * @param String $departure_airport_icao the departure airport |
|
| 950 | - * @param String $arrival_airport_icao the arrival airport |
|
| 951 | - * @return String success or false |
|
| 952 | - * |
|
| 953 | - */ |
|
| 944 | + * Adds a new spotter data |
|
| 945 | + * |
|
| 946 | + * @param String $flightaware_id the ID from flightaware |
|
| 947 | + * @param String $ident the flight ident |
|
| 948 | + * @param String $aircraft_icao the aircraft type |
|
| 949 | + * @param String $departure_airport_icao the departure airport |
|
| 950 | + * @param String $arrival_airport_icao the arrival airport |
|
| 951 | + * @return String success or false |
|
| 952 | + * |
|
| 953 | + */ |
|
| 954 | 954 | 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 = '') |
| 955 | 955 | { |
| 956 | 956 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1093,10 +1093,10 @@ discard block |
||
| 1093 | 1093 | $arrival_airport_country = ''; |
| 1094 | 1094 | |
| 1095 | 1095 | |
| 1096 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1097 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1098 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1099 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1096 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1097 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1098 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1099 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1100 | 1100 | |
| 1101 | 1101 | $query = ''; |
| 1102 | 1102 | if ($globalArchive) { |
@@ -1117,10 +1117,10 @@ discard block |
||
| 1117 | 1117 | return "error : ".$e->getMessage(); |
| 1118 | 1118 | } |
| 1119 | 1119 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1120 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1121 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1122 | - $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1123 | - if ($globalDebug) echo $result.')'; |
|
| 1120 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1121 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1122 | + $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1123 | + if ($globalDebug) echo $result.')'; |
|
| 1124 | 1124 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1125 | 1125 | echo '(Not adding to archive)'; |
| 1126 | 1126 | } elseif ($globalDebug && $noarchive === true) { |
@@ -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]; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } else { |
| 170 | 170 | $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; |
| 171 | 171 | } |
| 172 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 172 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 173 | 173 | |
| 174 | 174 | return $spotter_array; |
| 175 | 175 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 186 | 186 | date_default_timezone_set('UTC'); |
| 187 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 187 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 188 | 188 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 189 | 189 | if ($globalDBdriver == 'mysql') { |
| 190 | 190 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | try { |
| 208 | 208 | $sth = $this->db->prepare($query); |
| 209 | 209 | $sth->execute(); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | echo $e->getMessage(); |
| 212 | 212 | die; |
| 213 | 213 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 227 | 227 | date_default_timezone_set('UTC'); |
| 228 | 228 | |
| 229 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 229 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 230 | 230 | |
| 231 | 231 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 232 | 232 | if ($globalDBdriver == 'mysql') { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
| 238 | 238 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
| 239 | 239 | */ |
| 240 | - $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 240 | + $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 241 | 241 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id |
| 242 | 242 | UNION |
| 243 | 243 | 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 |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | WHERE latitude <> '0' AND longitude <> '0' |
| 246 | 246 | ORDER BY flightaware_id, date"; |
| 247 | 247 | } else { |
| 248 | - $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 |
|
| 248 | + $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 |
|
| 249 | 249 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date |
| 250 | 250 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
| 259 | 259 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
| 260 | 260 | */ |
| 261 | - $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 261 | + $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 262 | 262 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id |
| 263 | 263 | UNION |
| 264 | 264 | 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 |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | ORDER BY flightaware_id, date"; |
| 269 | 269 | //AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".round($globalLiveInterval*1000)." SECONDS' <= spotter_archive.date |
| 270 | 270 | } else { |
| 271 | - $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 |
|
| 271 | + $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 |
|
| 272 | 272 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 273 | 273 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 274 | 274 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | try { |
| 278 | 278 | $sth = $this->db->prepare($query); |
| 279 | 279 | $sth->execute(); |
| 280 | - } catch(PDOException $e) { |
|
| 280 | + } catch (PDOException $e) { |
|
| 281 | 281 | echo $e->getMessage(); |
| 282 | 282 | die; |
| 283 | 283 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | public function getLiveSpotterCount($filter = array()) |
| 295 | 295 | { |
| 296 | 296 | global $globalDBdriver, $globalLiveInterval; |
| 297 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 297 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 298 | 298 | |
| 299 | 299 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 300 | 300 | if ($globalDBdriver == 'mysql') { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | try { |
| 308 | 308 | $sth = $this->db->prepare($query); |
| 309 | 309 | $sth->execute(); |
| 310 | - } catch(PDOException $e) { |
|
| 310 | + } catch (PDOException $e) { |
|
| 311 | 311 | echo $e->getMessage(); |
| 312 | 312 | die; |
| 313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | $filter_query = $this->getFilter($filter); |
| 331 | 331 | |
| 332 | 332 | if (is_array($coord)) { |
| 333 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 334 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 335 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 336 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 333 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 334 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 335 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 336 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 337 | 337 | } else return array(); |
| 338 | 338 | if ($globalDBdriver == 'mysql') { |
| 339 | 339 | $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; |
@@ -356,23 +356,23 @@ discard block |
||
| 356 | 356 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 357 | 357 | $Spotter = new Spotter($this->db); |
| 358 | 358 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 359 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 359 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 360 | 360 | |
| 361 | 361 | if (is_array($coord)) { |
| 362 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 363 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 364 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 365 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 362 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 363 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 364 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 365 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 366 | 366 | } else return array(); |
| 367 | 367 | if ($globalDBdriver == 'mysql') { |
| 368 | 368 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 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 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 372 | 372 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 373 | 373 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
| 374 | 374 | } else { |
| 375 | - $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 |
|
| 375 | + $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 |
|
| 376 | 376 | FROM spotter_live |
| 377 | 377 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 378 | 378 | FROM spotter_live l |
@@ -384,14 +384,14 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | } else { |
| 386 | 386 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 387 | - $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 |
|
| 387 | + $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 |
|
| 388 | 388 | FROM spotter_live |
| 389 | 389 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 390 | 390 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 391 | 391 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 392 | 392 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 393 | 393 | } else { |
| 394 | - $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 |
|
| 394 | + $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 |
|
| 395 | 395 | FROM spotter_live |
| 396 | 396 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 397 | 397 | FROM spotter_live l |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | try { |
| 407 | 407 | $sth = $this->db->prepare($query); |
| 408 | 408 | $sth->execute(); |
| 409 | - } catch(PDOException $e) { |
|
| 409 | + } catch (PDOException $e) { |
|
| 410 | 410 | echo $e->getMessage(); |
| 411 | 411 | die; |
| 412 | 412 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | if ($interval == '1m') |
| 456 | 456 | { |
| 457 | 457 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 458 | - } else if ($interval == '15m'){ |
|
| 458 | + } else if ($interval == '15m') { |
|
| 459 | 459 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -463,14 +463,14 @@ discard block |
||
| 463 | 463 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - $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 |
|
| 466 | + $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 |
|
| 467 | 467 | WHERE spotter_live.latitude <> '' |
| 468 | 468 | AND spotter_live.longitude <> '' |
| 469 | 469 | ".$additional_query." |
| 470 | 470 | HAVING distance < :radius |
| 471 | 471 | ORDER BY distance"; |
| 472 | 472 | |
| 473 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 473 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 474 | 474 | |
| 475 | 475 | return $spotter_array; |
| 476 | 476 | } |
@@ -488,9 +488,9 @@ discard block |
||
| 488 | 488 | date_default_timezone_set('UTC'); |
| 489 | 489 | |
| 490 | 490 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 491 | - $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'; |
|
| 491 | + $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'; |
|
| 492 | 492 | |
| 493 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 493 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 494 | 494 | |
| 495 | 495 | return $spotter_array; |
| 496 | 496 | } |
@@ -501,16 +501,16 @@ discard block |
||
| 501 | 501 | * @return Array the spotter information |
| 502 | 502 | * |
| 503 | 503 | */ |
| 504 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 504 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 505 | 505 | { |
| 506 | 506 | $Spotter = new Spotter($this->db); |
| 507 | 507 | date_default_timezone_set('UTC'); |
| 508 | 508 | |
| 509 | 509 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 510 | - $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'; |
|
| 510 | + $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'; |
|
| 511 | 511 | |
| 512 | - $date = date('c',$date); |
|
| 513 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 512 | + $date = date('c', $date); |
|
| 513 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 514 | 514 | |
| 515 | 515 | return $spotter_array; |
| 516 | 516 | } |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | date_default_timezone_set('UTC'); |
| 528 | 528 | |
| 529 | 529 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 530 | - $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'; |
|
| 530 | + $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'; |
|
| 531 | 531 | |
| 532 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 532 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 533 | 533 | |
| 534 | 534 | return $spotter_array; |
| 535 | 535 | } |
@@ -540,15 +540,15 @@ discard block |
||
| 540 | 540 | * @return Array the spotter information |
| 541 | 541 | * |
| 542 | 542 | */ |
| 543 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 543 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 544 | 544 | { |
| 545 | 545 | $Spotter = new Spotter($this->db); |
| 546 | 546 | date_default_timezone_set('UTC'); |
| 547 | 547 | |
| 548 | 548 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 549 | - $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'; |
|
| 550 | - $date = date('c',$date); |
|
| 551 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 549 | + $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'; |
|
| 550 | + $date = date('c', $date); |
|
| 551 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 552 | 552 | return $spotter_array; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | date_default_timezone_set('UTC'); |
| 565 | 565 | |
| 566 | 566 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 567 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 567 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 568 | 568 | |
| 569 | 569 | try { |
| 570 | 570 | |
| 571 | 571 | $sth = $this->db->prepare($query); |
| 572 | 572 | $sth->execute(array(':ident' => $ident)); |
| 573 | - } catch(PDOException $e) { |
|
| 573 | + } catch (PDOException $e) { |
|
| 574 | 574 | echo $e->getMessage(); |
| 575 | 575 | die; |
| 576 | 576 | } |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * @return Array the spotter information |
| 586 | 586 | * |
| 587 | 587 | */ |
| 588 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 588 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 589 | 589 | { |
| 590 | 590 | global $globalDBdriver, $globalLiveInterval; |
| 591 | 591 | date_default_timezone_set('UTC'); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | try { |
| 605 | 605 | $sth = $this->db->prepare($query); |
| 606 | 606 | $sth->execute(array(':id' => $id)); |
| 607 | - } catch(PDOException $e) { |
|
| 607 | + } catch (PDOException $e) { |
|
| 608 | 608 | echo $e->getMessage(); |
| 609 | 609 | die; |
| 610 | 610 | } |
@@ -622,12 +622,12 @@ discard block |
||
| 622 | 622 | { |
| 623 | 623 | date_default_timezone_set('UTC'); |
| 624 | 624 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 625 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 625 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 626 | 626 | try { |
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query); |
| 629 | 629 | $sth->execute(array(':ident' => $ident)); |
| 630 | - } catch(PDOException $e) { |
|
| 630 | + } catch (PDOException $e) { |
|
| 631 | 631 | echo $e->getMessage(); |
| 632 | 632 | die; |
| 633 | 633 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | $sth = $this->db->prepare($query); |
| 659 | 659 | $sth->execute(); |
| 660 | - } catch(PDOException $e) { |
|
| 660 | + } catch (PDOException $e) { |
|
| 661 | 661 | return "error"; |
| 662 | 662 | } |
| 663 | 663 | |
@@ -680,14 +680,14 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | $sth = $this->db->prepare($query); |
| 682 | 682 | $sth->execute(); |
| 683 | - } catch(PDOException $e) { |
|
| 683 | + } catch (PDOException $e) { |
|
| 684 | 684 | return "error"; |
| 685 | 685 | } |
| 686 | 686 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 687 | 687 | $i = 0; |
| 688 | - $j =0; |
|
| 688 | + $j = 0; |
|
| 689 | 689 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 690 | - foreach($all as $row) |
|
| 690 | + foreach ($all as $row) |
|
| 691 | 691 | { |
| 692 | 692 | $i++; |
| 693 | 693 | $j++; |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | if ($globalDebug) echo "."; |
| 696 | 696 | try { |
| 697 | 697 | |
| 698 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 698 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 699 | 699 | $sth->execute(); |
| 700 | - } catch(PDOException $e) { |
|
| 700 | + } catch (PDOException $e) { |
|
| 701 | 701 | return "error"; |
| 702 | 702 | } |
| 703 | 703 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -708,9 +708,9 @@ discard block |
||
| 708 | 708 | if ($i > 0) { |
| 709 | 709 | try { |
| 710 | 710 | |
| 711 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 711 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 712 | 712 | $sth->execute(); |
| 713 | - } catch(PDOException $e) { |
|
| 713 | + } catch (PDOException $e) { |
|
| 714 | 714 | return "error"; |
| 715 | 715 | } |
| 716 | 716 | } |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | |
| 724 | 724 | $sth = $this->db->prepare($query); |
| 725 | 725 | $sth->execute(); |
| 726 | - } catch(PDOException $e) { |
|
| 726 | + } catch (PDOException $e) { |
|
| 727 | 727 | return "error"; |
| 728 | 728 | } |
| 729 | 729 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -771,13 +771,13 @@ discard block |
||
| 771 | 771 | public function deleteLiveSpotterDataByIdent($ident) |
| 772 | 772 | { |
| 773 | 773 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 774 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 774 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 775 | 775 | |
| 776 | 776 | try { |
| 777 | 777 | |
| 778 | 778 | $sth = $this->db->prepare($query); |
| 779 | 779 | $sth->execute(array(':ident' => $ident)); |
| 780 | - } catch(PDOException $e) { |
|
| 780 | + } catch (PDOException $e) { |
|
| 781 | 781 | return "error"; |
| 782 | 782 | } |
| 783 | 783 | |
@@ -793,13 +793,13 @@ discard block |
||
| 793 | 793 | public function deleteLiveSpotterDataById($id) |
| 794 | 794 | { |
| 795 | 795 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 796 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 796 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 797 | 797 | |
| 798 | 798 | try { |
| 799 | 799 | |
| 800 | 800 | $sth = $this->db->prepare($query); |
| 801 | 801 | $sth->execute(array(':id' => $id)); |
| 802 | - } catch(PDOException $e) { |
|
| 802 | + } catch (PDOException $e) { |
|
| 803 | 803 | return "error"; |
| 804 | 804 | } |
| 805 | 805 | |
@@ -817,13 +817,13 @@ discard block |
||
| 817 | 817 | { |
| 818 | 818 | global $globalDBdriver, $globalTimezone; |
| 819 | 819 | if ($globalDBdriver == 'mysql') { |
| 820 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 820 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 821 | 821 | WHERE spotter_live.ident = :ident |
| 822 | 822 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 823 | 823 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 824 | 824 | $query_data = array(':ident' => $ident); |
| 825 | 825 | } else { |
| 826 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 826 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 827 | 827 | WHERE spotter_live.ident = :ident |
| 828 | 828 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 829 | 829 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -832,8 +832,8 @@ discard block |
||
| 832 | 832 | |
| 833 | 833 | $sth = $this->db->prepare($query); |
| 834 | 834 | $sth->execute($query_data); |
| 835 | - $ident_result=''; |
|
| 836 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 835 | + $ident_result = ''; |
|
| 836 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 837 | 837 | { |
| 838 | 838 | $ident_result = $row['ident']; |
| 839 | 839 | } |
@@ -850,13 +850,13 @@ discard block |
||
| 850 | 850 | { |
| 851 | 851 | global $globalDBdriver, $globalTimezone; |
| 852 | 852 | if ($globalDBdriver == 'mysql') { |
| 853 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 853 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 854 | 854 | WHERE spotter_live.ident = :ident |
| 855 | 855 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 856 | 856 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 857 | 857 | $query_data = array(':ident' => $ident); |
| 858 | 858 | } else { |
| 859 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 859 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 860 | 860 | WHERE spotter_live.ident = :ident |
| 861 | 861 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 862 | 862 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -865,8 +865,8 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | $sth = $this->db->prepare($query); |
| 867 | 867 | $sth->execute($query_data); |
| 868 | - $ident_result=''; |
|
| 869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 868 | + $ident_result = ''; |
|
| 869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 870 | 870 | { |
| 871 | 871 | $ident_result = $row['flightaware_id']; |
| 872 | 872 | } |
@@ -883,13 +883,13 @@ discard block |
||
| 883 | 883 | { |
| 884 | 884 | global $globalDBdriver, $globalTimezone; |
| 885 | 885 | if ($globalDBdriver == 'mysql') { |
| 886 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 886 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 887 | 887 | WHERE spotter_live.flightaware_id = :id |
| 888 | 888 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 889 | 889 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 890 | 890 | $query_data = array(':id' => $id); |
| 891 | 891 | } else { |
| 892 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 892 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 893 | 893 | WHERE spotter_live.flightaware_id = :id |
| 894 | 894 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 895 | 895 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -898,8 +898,8 @@ discard block |
||
| 898 | 898 | |
| 899 | 899 | $sth = $this->db->prepare($query); |
| 900 | 900 | $sth->execute($query_data); |
| 901 | - $ident_result=''; |
|
| 902 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 901 | + $ident_result = ''; |
|
| 902 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 903 | 903 | { |
| 904 | 904 | $ident_result = $row['flightaware_id']; |
| 905 | 905 | } |
@@ -916,13 +916,13 @@ discard block |
||
| 916 | 916 | { |
| 917 | 917 | global $globalDBdriver, $globalTimezone; |
| 918 | 918 | if ($globalDBdriver == 'mysql') { |
| 919 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 919 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 920 | 920 | WHERE spotter_live.ModeS = :modes |
| 921 | 921 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 922 | 922 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 923 | 923 | $query_data = array(':modes' => $modes); |
| 924 | 924 | } else { |
| 925 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 925 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 926 | 926 | WHERE spotter_live.ModeS = :modes |
| 927 | 927 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 928 | 928 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -931,8 +931,8 @@ discard block |
||
| 931 | 931 | |
| 932 | 932 | $sth = $this->db->prepare($query); |
| 933 | 933 | $sth->execute($query_data); |
| 934 | - $ident_result=''; |
|
| 935 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 934 | + $ident_result = ''; |
|
| 935 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 936 | 936 | { |
| 937 | 937 | //$ident_result = $row['spotter_live_id']; |
| 938 | 938 | $ident_result = $row['flightaware_id']; |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | * @return String success or false |
| 952 | 952 | * |
| 953 | 953 | */ |
| 954 | - 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 = '') |
|
| 954 | + 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 = '') |
|
| 955 | 955 | { |
| 956 | 956 | global $globalURL, $globalArchive, $globalDebug; |
| 957 | 957 | $Common = new Common(); |
@@ -1051,27 +1051,27 @@ discard block |
||
| 1051 | 1051 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1052 | 1052 | |
| 1053 | 1053 | |
| 1054 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1055 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1056 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1057 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1058 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1059 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1060 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1062 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1064 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1065 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1066 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1067 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1068 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1069 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1070 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1071 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1072 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1073 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1074 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1054 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1055 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1056 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1057 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1058 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1059 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1060 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1062 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1064 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1065 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1066 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1067 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1068 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1069 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1070 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1071 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1072 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1073 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1074 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1075 | 1075 | |
| 1076 | 1076 | $airline_name = ''; |
| 1077 | 1077 | $airline_icao = ''; |
@@ -1093,10 +1093,10 @@ discard block |
||
| 1093 | 1093 | $arrival_airport_country = ''; |
| 1094 | 1094 | |
| 1095 | 1095 | |
| 1096 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1097 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1098 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1099 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1096 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1097 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1098 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1099 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1100 | 1100 | |
| 1101 | 1101 | $query = ''; |
| 1102 | 1102 | if ($globalArchive) { |
@@ -1107,19 +1107,19 @@ discard block |
||
| 1107 | 1107 | $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, real_altitude) |
| 1108 | 1108 | 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, :real_altitude)'; |
| 1109 | 1109 | |
| 1110 | - $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,':real_altitude' => $altitude_real); |
|
| 1110 | + $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, ':real_altitude' => $altitude_real); |
|
| 1111 | 1111 | try { |
| 1112 | 1112 | |
| 1113 | 1113 | $sth = $this->db->prepare($query); |
| 1114 | 1114 | $sth->execute($query_values); |
| 1115 | 1115 | $sth->closeCursor(); |
| 1116 | - } catch(PDOException $e) { |
|
| 1116 | + } catch (PDOException $e) { |
|
| 1117 | 1117 | return "error : ".$e->getMessage(); |
| 1118 | 1118 | } |
| 1119 | 1119 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1120 | 1120 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1121 | 1121 | $SpotterArchive = new SpotterArchive($this->db); |
| 1122 | - $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1122 | + $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, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1123 | 1123 | if ($globalDebug) echo $result.')'; |
| 1124 | 1124 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1125 | 1125 | echo '(Not adding to archive)'; |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | |
| 1133 | 1133 | public function getOrderBy() |
| 1134 | 1134 | { |
| 1135 | - $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")); |
|
| 1135 | + $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")); |
|
| 1136 | 1136 | return $orderby; |
| 1137 | 1137 | } |
| 1138 | 1138 | |
@@ -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 | } |
@@ -160,9 +165,13 @@ discard block |
||
| 160 | 165 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 161 | 166 | } |
| 162 | 167 | } |
| 163 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 168 | + if ($orderby_query == '') { |
|
| 169 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 172 | + if (!isset($globalLiveInterval)) { |
|
| 173 | + $globalLiveInterval = '200'; |
|
| 174 | + } |
|
| 166 | 175 | if ($globalDBdriver == 'mysql') { |
| 167 | 176 | //$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"; |
| 168 | 177 | $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; |
@@ -185,7 +194,9 @@ discard block |
||
| 185 | 194 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 186 | 195 | date_default_timezone_set('UTC'); |
| 187 | 196 | $filter_query = $this->getFilter($filter,true,true); |
| 188 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 197 | + if (!isset($globalLiveInterval)) { |
|
| 198 | + $globalLiveInterval = '200'; |
|
| 199 | + } |
|
| 189 | 200 | if ($globalDBdriver == 'mysql') { |
| 190 | 201 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 191 | 202 | $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 |
@@ -228,7 +239,9 @@ discard block |
||
| 228 | 239 | |
| 229 | 240 | $filter_query = $this->getFilter($filter,true,true); |
| 230 | 241 | |
| 231 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 242 | + if (!isset($globalLiveInterval)) { |
|
| 243 | + $globalLiveInterval = '200'; |
|
| 244 | + } |
|
| 232 | 245 | if ($globalDBdriver == 'mysql') { |
| 233 | 246 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 234 | 247 | /* |
@@ -296,7 +309,9 @@ discard block |
||
| 296 | 309 | global $globalDBdriver, $globalLiveInterval; |
| 297 | 310 | $filter_query = $this->getFilter($filter,true,true); |
| 298 | 311 | |
| 299 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 312 | + if (!isset($globalLiveInterval)) { |
|
| 313 | + $globalLiveInterval = '200'; |
|
| 314 | + } |
|
| 300 | 315 | if ($globalDBdriver == 'mysql') { |
| 301 | 316 | //$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; |
| 302 | 317 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -326,7 +341,9 @@ discard block |
||
| 326 | 341 | { |
| 327 | 342 | global $globalDBdriver, $globalLiveInterval; |
| 328 | 343 | $Spotter = new Spotter($this->db); |
| 329 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 344 | + if (!isset($globalLiveInterval)) { |
|
| 345 | + $globalLiveInterval = '200'; |
|
| 346 | + } |
|
| 330 | 347 | $filter_query = $this->getFilter($filter); |
| 331 | 348 | |
| 332 | 349 | if (is_array($coord)) { |
@@ -334,7 +351,9 @@ discard block |
||
| 334 | 351 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 335 | 352 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 336 | 353 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 337 | - } else return array(); |
|
| 354 | + } else { |
|
| 355 | + return array(); |
|
| 356 | + } |
|
| 338 | 357 | if ($globalDBdriver == 'mysql') { |
| 339 | 358 | $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; |
| 340 | 359 | } else { |
@@ -355,7 +374,9 @@ discard block |
||
| 355 | 374 | { |
| 356 | 375 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 357 | 376 | $Spotter = new Spotter($this->db); |
| 358 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 377 | + if (!isset($globalLiveInterval)) { |
|
| 378 | + $globalLiveInterval = '200'; |
|
| 379 | + } |
|
| 359 | 380 | $filter_query = $this->getFilter($filter,true,true); |
| 360 | 381 | |
| 361 | 382 | if (is_array($coord)) { |
@@ -363,7 +384,9 @@ discard block |
||
| 363 | 384 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 364 | 385 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 365 | 386 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 366 | - } else return array(); |
|
| 387 | + } else { |
|
| 388 | + return array(); |
|
| 389 | + } |
|
| 367 | 390 | if ($globalDBdriver == 'mysql') { |
| 368 | 391 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 369 | 392 | $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 |
@@ -593,11 +616,15 @@ discard block |
||
| 593 | 616 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 594 | 617 | if ($globalDBdriver == 'mysql') { |
| 595 | 618 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 596 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 619 | + if ($liveinterval) { |
|
| 620 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 621 | + } |
|
| 597 | 622 | $query .= ' ORDER BY date'; |
| 598 | 623 | } else { |
| 599 | 624 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 600 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 625 | + if ($liveinterval) { |
|
| 626 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 627 | + } |
|
| 601 | 628 | $query .= ' ORDER BY date'; |
| 602 | 629 | } |
| 603 | 630 | |
@@ -692,7 +719,9 @@ discard block |
||
| 692 | 719 | $i++; |
| 693 | 720 | $j++; |
| 694 | 721 | if ($j == 30) { |
| 695 | - if ($globalDebug) echo "."; |
|
| 722 | + if ($globalDebug) { |
|
| 723 | + echo "."; |
|
| 724 | + } |
|
| 696 | 725 | try { |
| 697 | 726 | |
| 698 | 727 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -999,7 +1028,9 @@ discard block |
||
| 999 | 1028 | { |
| 1000 | 1029 | return false; |
| 1001 | 1030 | } |
| 1002 | - } else return ''; |
|
| 1031 | + } else { |
|
| 1032 | + return ''; |
|
| 1033 | + } |
|
| 1003 | 1034 | |
| 1004 | 1035 | if ($longitude != '') |
| 1005 | 1036 | { |
@@ -1007,7 +1038,9 @@ discard block |
||
| 1007 | 1038 | { |
| 1008 | 1039 | return false; |
| 1009 | 1040 | } |
| 1010 | - } else return ''; |
|
| 1041 | + } else { |
|
| 1042 | + return ''; |
|
| 1043 | + } |
|
| 1011 | 1044 | |
| 1012 | 1045 | if ($waypoints != '') |
| 1013 | 1046 | { |
@@ -1023,14 +1056,18 @@ discard block |
||
| 1023 | 1056 | { |
| 1024 | 1057 | return false; |
| 1025 | 1058 | } |
| 1026 | - } else $altitude = 0; |
|
| 1059 | + } else { |
|
| 1060 | + $altitude = 0; |
|
| 1061 | + } |
|
| 1027 | 1062 | if ($altitude_real != '') |
| 1028 | 1063 | { |
| 1029 | 1064 | if (!is_numeric($altitude_real)) |
| 1030 | 1065 | { |
| 1031 | 1066 | return false; |
| 1032 | 1067 | } |
| 1033 | - } else $altitude_real = 0; |
|
| 1068 | + } else { |
|
| 1069 | + $altitude_real = 0; |
|
| 1070 | + } |
|
| 1034 | 1071 | |
| 1035 | 1072 | if ($heading != '') |
| 1036 | 1073 | { |
@@ -1038,7 +1075,9 @@ discard block |
||
| 1038 | 1075 | { |
| 1039 | 1076 | return false; |
| 1040 | 1077 | } |
| 1041 | - } else $heading = 0; |
|
| 1078 | + } else { |
|
| 1079 | + $heading = 0; |
|
| 1080 | + } |
|
| 1042 | 1081 | |
| 1043 | 1082 | if ($groundspeed != '') |
| 1044 | 1083 | { |
@@ -1046,9 +1085,13 @@ discard block |
||
| 1046 | 1085 | { |
| 1047 | 1086 | return false; |
| 1048 | 1087 | } |
| 1049 | - } else $groundspeed = 0; |
|
| 1088 | + } else { |
|
| 1089 | + $groundspeed = 0; |
|
| 1090 | + } |
|
| 1050 | 1091 | date_default_timezone_set('UTC'); |
| 1051 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1092 | + if ($date == '') { |
|
| 1093 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1094 | + } |
|
| 1052 | 1095 | |
| 1053 | 1096 | |
| 1054 | 1097 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1093,14 +1136,24 @@ discard block |
||
| 1093 | 1136 | $arrival_airport_country = ''; |
| 1094 | 1137 | |
| 1095 | 1138 | |
| 1096 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1097 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1098 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1099 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1139 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1140 | + $squawk = NULL; |
|
| 1141 | + } |
|
| 1142 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1143 | + $verticalrate = NULL; |
|
| 1144 | + } |
|
| 1145 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1146 | + $groundspeed = 0; |
|
| 1147 | + } |
|
| 1148 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1149 | + $heading = 0; |
|
| 1150 | + } |
|
| 1100 | 1151 | |
| 1101 | 1152 | $query = ''; |
| 1102 | 1153 | if ($globalArchive) { |
| 1103 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1154 | + if ($globalDebug) { |
|
| 1155 | + echo '-- Delete previous data -- '; |
|
| 1156 | + } |
|
| 1104 | 1157 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1105 | 1158 | } |
| 1106 | 1159 | |
@@ -1117,10 +1170,14 @@ discard block |
||
| 1117 | 1170 | return "error : ".$e->getMessage(); |
| 1118 | 1171 | } |
| 1119 | 1172 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1120 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1173 | + if ($globalDebug) { |
|
| 1174 | + echo '(Add to SBS archive : '; |
|
| 1175 | + } |
|
| 1121 | 1176 | $SpotterArchive = new SpotterArchive($this->db); |
| 1122 | 1177 | $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1123 | - if ($globalDebug) echo $result.')'; |
|
| 1178 | + if ($globalDebug) { |
|
| 1179 | + echo $result.')'; |
|
| 1180 | + } |
|
| 1124 | 1181 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1125 | 1182 | echo '(Not adding to archive)'; |
| 1126 | 1183 | } elseif ($globalDebug && $noarchive === true) { |
@@ -8,20 +8,20 @@ discard block |
||
| 8 | 8 | require_once(dirname(__FILE__).'/class.Stats.php'); |
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 11 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 11 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class SpotterImport { |
| 15 | - private $all_flights = array(); |
|
| 16 | - private $last_delete_hourly = 0; |
|
| 17 | - private $last_delete = 0; |
|
| 18 | - private $stats = array(); |
|
| 19 | - private $tmd = 0; |
|
| 20 | - private $source_location = array(); |
|
| 21 | - public $db = null; |
|
| 22 | - public $nb = 0; |
|
| 15 | + private $all_flights = array(); |
|
| 16 | + private $last_delete_hourly = 0; |
|
| 17 | + private $last_delete = 0; |
|
| 18 | + private $stats = array(); |
|
| 19 | + private $tmd = 0; |
|
| 20 | + private $source_location = array(); |
|
| 21 | + public $db = null; |
|
| 22 | + public $nb = 0; |
|
| 23 | 23 | |
| 24 | - public function __construct($dbc = null) { |
|
| 24 | + public function __construct($dbc = null) { |
|
| 25 | 25 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB; |
| 26 | 26 | if (!(isset($globalNoDB) && $globalNoDB)) { |
| 27 | 27 | $Connection = new Connection($dbc); |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | $currentdate = date('Y-m-d'); |
| 34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 35 | 35 | if (!empty($sourcestat)) { |
| 36 | - foreach($sourcestat as $srcst) { |
|
| 37 | - $type = $srcst['stats_type']; |
|
| 36 | + foreach($sourcestat as $srcst) { |
|
| 37 | + $type = $srcst['stats_type']; |
|
| 38 | 38 | if ($type == 'polar' || $type == 'hist') { |
| 39 | - $source = $srcst['source_name']; |
|
| 40 | - $data = $srcst['source_data']; |
|
| 41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 42 | - } |
|
| 43 | - } |
|
| 39 | + $source = $srcst['source_name']; |
|
| 40 | + $data = $srcst['source_data']; |
|
| 41 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | //$APRSSpotter->connect(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function get_Schedule($id,$ident) { |
|
| 53 | + public function get_Schedule($id,$ident) { |
|
| 54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 55 | 55 | // Get schedule here, so it's done only one time |
| 56 | 56 | |
@@ -70,42 +70,42 @@ discard block |
||
| 70 | 70 | $operator = $Spotter->getOperator($ident); |
| 71 | 71 | $scheduleexist = false; |
| 72 | 72 | if ($Schedule->checkSchedule($operator) == 0) { |
| 73 | - $operator = $Translation->checkTranslation($ident); |
|
| 74 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 73 | + $operator = $Translation->checkTranslation($ident); |
|
| 74 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
| 76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 80 | - // Should also check if route schedule = route from DB |
|
| 81 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 77 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 80 | + // Should also check if route schedule = route from DB |
|
| 81 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 83 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 84 | - if (trim($airport_icao) != '') { |
|
| 83 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 84 | + if (trim($airport_icao) != '') { |
|
| 85 | 85 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 86 | 86 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 87 | - } |
|
| 87 | + } |
|
| 88 | + } |
|
| 88 | 89 | } |
| 89 | - } |
|
| 90 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 90 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 91 | 91 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 92 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 93 | - if (trim($airport_icao) != '') { |
|
| 92 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 93 | + if (trim($airport_icao) != '') { |
|
| 94 | 94 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 95 | 95 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | - } |
|
| 99 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 98 | + } |
|
| 99 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 100 | 100 | } |
| 101 | - } else $scheduleexist = true; |
|
| 101 | + } else $scheduleexist = true; |
|
| 102 | 102 | } else $scheduleexist = true; |
| 103 | 103 | // close connection, at least one way will work ? |
| 104 | - if ($scheduleexist) { |
|
| 104 | + if ($scheduleexist) { |
|
| 105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 106 | - $sch = $Schedule->getSchedule($operator); |
|
| 106 | + $sch = $Schedule->getSchedule($operator); |
|
| 107 | 107 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | $Spotter->db = null; |
| 110 | 110 | $Schedule->db = null; |
| 111 | 111 | $Translation->db = null; |
@@ -120,78 +120,78 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | */ |
| 122 | 122 | } |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public function checkAll() { |
|
| 125 | + public function checkAll() { |
|
| 126 | 126 | global $globalDebug, $globalNoImport; |
| 127 | 127 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 128 | 128 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 129 | - foreach ($this->all_flights as $key => $flight) { |
|
| 129 | + foreach ($this->all_flights as $key => $flight) { |
|
| 130 | 130 | if (isset($this->all_flights[$key]['id'])) { |
| 131 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 132 | - $Spotter = new Spotter($this->db); |
|
| 133 | - $real_arrival = $this->arrival($key); |
|
| 134 | - if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 135 | - } |
|
| 136 | - } |
|
| 131 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 132 | + $Spotter = new Spotter($this->db); |
|
| 133 | + $real_arrival = $this->arrival($key); |
|
| 134 | + if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + } |
|
| 137 | 138 | } |
| 138 | - } |
|
| 139 | 139 | |
| 140 | - public function arrival($key) { |
|
| 140 | + public function arrival($key) { |
|
| 141 | 141 | global $globalClosestMinDist, $globalDebug; |
| 142 | 142 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 143 | 143 | $Spotter = new Spotter($this->db); |
| 144 | - $airport_icao = ''; |
|
| 145 | - $airport_time = ''; |
|
| 146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 144 | + $airport_icao = ''; |
|
| 145 | + $airport_time = ''; |
|
| 146 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 149 | - if (isset($closestAirports[0])) { |
|
| 150 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 151 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 152 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 154 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 155 | - foreach ($closestAirports as $airport) { |
|
| 156 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 157 | - $airport_icao = $airport['icao']; |
|
| 158 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 160 | - break; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 164 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 165 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 166 | - } else { |
|
| 167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 168 | - } |
|
| 169 | - } else { |
|
| 170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 171 | - } |
|
| 148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 149 | + if (isset($closestAirports[0])) { |
|
| 150 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 151 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 152 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 153 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 154 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 155 | + foreach ($closestAirports as $airport) { |
|
| 156 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 157 | + $airport_icao = $airport['icao']; |
|
| 158 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 159 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 160 | + break; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 164 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 165 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 166 | + } else { |
|
| 167 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 168 | + } |
|
| 169 | + } else { |
|
| 170 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - } else { |
|
| 174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 175 | - } |
|
| 176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 177 | - } |
|
| 173 | + } else { |
|
| 174 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 175 | + } |
|
| 176 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - public function del() { |
|
| 181 | + public function del() { |
|
| 182 | 182 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 183 | 183 | // Delete old infos |
| 184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 185 | 185 | foreach ($this->all_flights as $key => $flight) { |
| 186 | - if (isset($flight['lastupdate'])) { |
|
| 186 | + if (isset($flight['lastupdate'])) { |
|
| 187 | 187 | if ($flight['lastupdate'] < (time()-5900)) { |
| 188 | - $this->delKey($key); |
|
| 188 | + $this->delKey($key); |
|
| 189 | 189 | } |
| 190 | - } |
|
| 190 | + } |
|
| 191 | + } |
|
| 191 | 192 | } |
| 192 | - } |
|
| 193 | 193 | |
| 194 | - public function delKey($key) { |
|
| 194 | + public function delKey($key) { |
|
| 195 | 195 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 196 | 196 | // Delete old infos |
| 197 | 197 | if (isset($this->all_flights[$key]['id'])) { |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | unset($this->all_flights[$key]); |
| 209 | - } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - public function add($line) { |
|
| 211 | + public function add($line) { |
|
| 212 | 212 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval; |
| 213 | 213 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 214 | 214 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -234,20 +234,20 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | // SBS format is CSV format |
| 236 | 236 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 237 | - //print_r($line); |
|
| 238 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 239 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 237 | + //print_r($line); |
|
| 238 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 239 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 240 | 240 | |
| 241 | 241 | // Increment message number |
| 242 | 242 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 243 | - $current_date = date('Y-m-d'); |
|
| 244 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 245 | - else $source = ''; |
|
| 246 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 247 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 248 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 249 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 250 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 243 | + $current_date = date('Y-m-d'); |
|
| 244 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 245 | + else $source = ''; |
|
| 246 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 247 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 248 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 249 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 250 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /* |
@@ -263,54 +263,54 @@ discard block |
||
| 263 | 263 | //$this->db = $dbc; |
| 264 | 264 | |
| 265 | 265 | //$hex = trim($line['hex']); |
| 266 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 267 | - else $id = trim($line['id']); |
|
| 266 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 267 | + else $id = trim($line['id']); |
|
| 268 | 268 | |
| 269 | 269 | if (!isset($this->all_flights[$id])) { |
| 270 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 271 | - $this->all_flights[$id] = array(); |
|
| 272 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 273 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 274 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 275 | - if (!isset($line['id'])) { |
|
| 270 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
| 271 | + $this->all_flights[$id] = array(); |
|
| 272 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 273 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 274 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 275 | + if (!isset($line['id'])) { |
|
| 276 | 276 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 277 | 277 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 278 | 278 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 279 | 279 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 280 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 281 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 282 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 280 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 281 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 282 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 283 | 283 | } |
| 284 | 284 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 285 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 285 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | //print_r($this->all_flights); |
| 289 | 289 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 290 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 291 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 290 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 291 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 292 | 292 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 293 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 294 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 293 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 294 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 295 | 295 | $timeelapsed = microtime(true); |
| 296 | 296 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 297 | - $Spotter = new Spotter($this->db); |
|
| 298 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
| 297 | + $Spotter = new Spotter($this->db); |
|
| 298 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
| 299 | 299 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
| 300 | - } else { |
|
| 300 | + } else { |
|
| 301 | 301 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 302 | - } |
|
| 303 | - $Spotter->db = null; |
|
| 304 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 305 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 302 | + } |
|
| 303 | + $Spotter->db = null; |
|
| 304 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 305 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 306 | 306 | } |
| 307 | - } |
|
| 308 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 309 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 307 | + } |
|
| 308 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 309 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 310 | 310 | } |
| 311 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
| 312 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 313 | - } |
|
| 311 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
| 312 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 313 | + } |
|
| 314 | 314 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 315 | 315 | $icao = $line['aircraft_icao']; |
| 316 | 316 | $Spotter = new Spotter($this->db); |
@@ -339,9 +339,9 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 341 | 341 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 342 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 342 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 343 | 343 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 344 | - } else { |
|
| 344 | + } else { |
|
| 345 | 345 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 346 | 346 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 347 | 347 | /* |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | print_r($line); |
| 351 | 351 | */ |
| 352 | 352 | return ''; |
| 353 | - } |
|
| 353 | + } |
|
| 354 | 354 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 355 | 355 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
| 356 | 356 | return ''; |
@@ -367,21 +367,21 @@ discard block |
||
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 371 | 371 | } |
| 372 | 372 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 373 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 373 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 374 | 374 | } |
| 375 | 375 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 376 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 377 | 377 | } |
| 378 | 378 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 383 | 383 | |
| 384 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 384 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 385 | 385 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 386 | 386 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 387 | 387 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -390,23 +390,23 @@ discard block |
||
| 390 | 390 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 391 | 391 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 392 | 392 | } else { |
| 393 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 394 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 393 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 394 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 395 | 395 | $timeelapsed = microtime(true); |
| 396 | - $Spotter = new Spotter($this->db); |
|
| 397 | - $fromsource = NULL; |
|
| 398 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 399 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 396 | + $Spotter = new Spotter($this->db); |
|
| 397 | + $fromsource = NULL; |
|
| 398 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 399 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 400 | 400 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 401 | 401 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 402 | 402 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 403 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 403 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 404 | 404 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 405 | 405 | $Spotter->db = null; |
| 406 | 406 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 407 | - } |
|
| 407 | + } |
|
| 408 | 408 | } |
| 409 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 409 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 410 | 410 | |
| 411 | 411 | /* |
| 412 | 412 | if (!isset($line['id'])) { |
@@ -416,109 +416,109 @@ discard block |
||
| 416 | 416 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 417 | 417 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 418 | 418 | */ |
| 419 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 419 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 420 | 420 | |
| 421 | - //$putinarchive = true; |
|
| 422 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 421 | + //$putinarchive = true; |
|
| 422 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 423 | 423 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 424 | - } |
|
| 425 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 424 | + } |
|
| 425 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 426 | 426 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 427 | - } |
|
| 428 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 429 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 430 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 427 | + } |
|
| 428 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 429 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 430 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 431 | 431 | $timeelapsed = microtime(true); |
| 432 | 432 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 433 | 433 | $Spotter = new Spotter($this->db); |
| 434 | 434 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 435 | 435 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 437 | 437 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 438 | - } |
|
| 439 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 438 | + } |
|
| 439 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 440 | 440 | $timeelapsed = microtime(true); |
| 441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 442 | - $Spotter = new Spotter($this->db); |
|
| 443 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 444 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 442 | + $Spotter = new Spotter($this->db); |
|
| 443 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 444 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 445 | 445 | $Translation = new Translation($this->db); |
| 446 | 446 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
| 447 | 447 | $route = $Spotter->getRouteInfo($ident); |
| 448 | 448 | $Translation->db = null; |
| 449 | - } |
|
| 450 | - $Spotter->db = null; |
|
| 451 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 452 | - } |
|
| 449 | + } |
|
| 450 | + $Spotter->db = null; |
|
| 451 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 452 | + } |
|
| 453 | 453 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 454 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 455 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 454 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 455 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 456 | 456 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 457 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 458 | - } |
|
| 457 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 458 | + } |
|
| 459 | 459 | } |
| 460 | 460 | if (!isset($globalFork)) $globalFork = TRUE; |
| 461 | 461 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 462 | 462 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 463 | 463 | } |
| 464 | - } |
|
| 464 | + } |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | if (isset($line['speed']) && $line['speed'] != '') { |
| 468 | 468 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 469 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 470 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 471 | - //$dataFound = true; |
|
| 469 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 470 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 471 | + //$dataFound = true; |
|
| 472 | 472 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 473 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 474 | - if ($distance > 1000 && $distance < 10000) { |
|
| 475 | - // use datetime |
|
| 473 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 474 | + if ($distance > 1000 && $distance < 10000) { |
|
| 475 | + // use datetime |
|
| 476 | 476 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 477 | 477 | $speed = $speed*3.6; |
| 478 | 478 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 479 | 479 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 480 | - } |
|
| 480 | + } |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | |
| 484 | 484 | |
| 485 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 486 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 487 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 488 | - return false; |
|
| 489 | - } |
|
| 490 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 491 | - else unset($timediff); |
|
| 492 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 493 | - else unset($timediff_archive); |
|
| 494 | - if ($this->tmd > 5 |
|
| 495 | - || (isset($line['format_source']) |
|
| 496 | - && $line['format_source'] == 'airwhere' |
|
| 497 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
| 498 | - || !isset($this->all_flights[$id]['longitude'])) |
|
| 499 | - || (isset($this->all_flights[$id]['latitude']) |
|
| 500 | - && isset($this->all_flights[$id]['longitude']) |
|
| 501 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 502 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 503 | - ) |
|
| 504 | - ) |
|
| 505 | - ) |
|
| 506 | - || (isset($globalVA) && $globalVA) |
|
| 507 | - || (isset($globalIVAO) && $globalIVAO) |
|
| 508 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
| 509 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
| 510 | - || (isset($globalVAM) && $globalVAM) |
|
| 511 | - || !isset($timediff) |
|
| 512 | - || $timediff > $globalLiveInterval |
|
| 513 | - || ($timediff > 30 |
|
| 514 | - && isset($this->all_flights[$id]['latitude']) |
|
| 515 | - && isset($this->all_flights[$id]['longitude']) |
|
| 516 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 517 | - ) |
|
| 518 | - ) { |
|
| 485 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 486 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 487 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 488 | + return false; |
|
| 489 | + } |
|
| 490 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 491 | + else unset($timediff); |
|
| 492 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 493 | + else unset($timediff_archive); |
|
| 494 | + if ($this->tmd > 5 |
|
| 495 | + || (isset($line['format_source']) |
|
| 496 | + && $line['format_source'] == 'airwhere' |
|
| 497 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
| 498 | + || !isset($this->all_flights[$id]['longitude'])) |
|
| 499 | + || (isset($this->all_flights[$id]['latitude']) |
|
| 500 | + && isset($this->all_flights[$id]['longitude']) |
|
| 501 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 502 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 503 | + ) |
|
| 504 | + ) |
|
| 505 | + ) |
|
| 506 | + || (isset($globalVA) && $globalVA) |
|
| 507 | + || (isset($globalIVAO) && $globalIVAO) |
|
| 508 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
| 509 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
| 510 | + || (isset($globalVAM) && $globalVAM) |
|
| 511 | + || !isset($timediff) |
|
| 512 | + || $timediff > $globalLiveInterval |
|
| 513 | + || ($timediff > 30 |
|
| 514 | + && isset($this->all_flights[$id]['latitude']) |
|
| 515 | + && isset($this->all_flights[$id]['longitude']) |
|
| 516 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 517 | + ) |
|
| 518 | + ) { |
|
| 519 | 519 | |
| 520 | 520 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 521 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 521 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 522 | 522 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 523 | 523 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
| 524 | 524 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -526,9 +526,9 @@ discard block |
||
| 526 | 526 | $this->all_flights[$id]['putinarchive'] = true; |
| 527 | 527 | $this->tmd = 0; |
| 528 | 528 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 529 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 530 | - $timeelapsed = microtime(true); |
|
| 531 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 529 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 530 | + $timeelapsed = microtime(true); |
|
| 531 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 532 | 532 | $Spotter = new Spotter($this->db); |
| 533 | 533 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 534 | 534 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -536,11 +536,11 @@ discard block |
||
| 536 | 536 | $Spotter->db = null; |
| 537 | 537 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 538 | 538 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 539 | - } |
|
| 539 | + } |
|
| 540 | 540 | } |
| 541 | 541 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
| 542 | - } |
|
| 543 | - /* |
|
| 542 | + } |
|
| 543 | + /* |
|
| 544 | 544 | else { |
| 545 | 545 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
| 546 | 546 | else { |
@@ -554,16 +554,16 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 557 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 557 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 558 | 558 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
| 559 | 559 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 560 | 560 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 561 | 561 | } |
| 562 | 562 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 563 | 563 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 564 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 565 | - $dataFound = true; |
|
| 566 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 564 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 565 | + $dataFound = true; |
|
| 566 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 567 | 567 | } |
| 568 | 568 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 569 | 569 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -574,24 +574,24 @@ discard block |
||
| 574 | 574 | //$putinarchive = true; |
| 575 | 575 | } |
| 576 | 576 | */ |
| 577 | - /* |
|
| 577 | + /* |
|
| 578 | 578 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 579 | 579 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
| 580 | 580 | } |
| 581 | 581 | */ |
| 582 | 582 | } |
| 583 | 583 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 584 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 585 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 584 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 585 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 586 | 586 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 587 | 587 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 588 | 588 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 589 | 589 | } |
| 590 | 590 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 591 | 591 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 592 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 593 | - $dataFound = true; |
|
| 594 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 592 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 593 | + $dataFound = true; |
|
| 594 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 595 | 595 | } |
| 596 | 596 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 597 | 597 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -609,77 +609,77 @@ discard block |
||
| 609 | 609 | */ |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - } else if ($globalDebug && $timediff > 30) { |
|
| 612 | + } else if ($globalDebug && $timediff > 30) { |
|
| 613 | 613 | $this->tmd = $this->tmd + 1; |
| 614 | 614 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 615 | 615 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 616 | 616 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 617 | 617 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 618 | - } |
|
| 618 | + } |
|
| 619 | 619 | } |
| 620 | 620 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 621 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 622 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 621 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 622 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 623 | 623 | } |
| 624 | 624 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 625 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 626 | - //$dataFound = true; |
|
| 625 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 626 | + //$dataFound = true; |
|
| 627 | 627 | } |
| 628 | 628 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 629 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 629 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 630 | 630 | } |
| 631 | 631 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 632 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 632 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 633 | 633 | } |
| 634 | 634 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 636 | - //$dataFound = true; |
|
| 635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 636 | + //$dataFound = true; |
|
| 637 | 637 | } |
| 638 | 638 | if (isset($line['ground']) && $line['ground'] != '') { |
| 639 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 639 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 640 | 640 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 641 | 641 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 642 | 642 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 643 | 643 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 644 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 644 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 645 | 645 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 646 | - } |
|
| 647 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 649 | - //$dataFound = true; |
|
| 646 | + } |
|
| 647 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 649 | + //$dataFound = true; |
|
| 650 | 650 | } |
| 651 | 651 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 652 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 653 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 654 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 655 | - $highlight = ''; |
|
| 656 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 657 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 658 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 659 | - if ($highlight != '') { |
|
| 652 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 653 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 654 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 655 | + $highlight = ''; |
|
| 656 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 657 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 658 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 659 | + if ($highlight != '') { |
|
| 660 | 660 | $timeelapsed = microtime(true); |
| 661 | 661 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 662 | - $Spotter = new Spotter($this->db); |
|
| 663 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 664 | - $Spotter->db = null; |
|
| 665 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 662 | + $Spotter = new Spotter($this->db); |
|
| 663 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 664 | + $Spotter->db = null; |
|
| 665 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 666 | 666 | } |
| 667 | 667 | //$putinarchive = true; |
| 668 | 668 | //$highlight = ''; |
| 669 | - } |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 672 | - //$dataFound = true; |
|
| 671 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 672 | + //$dataFound = true; |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 676 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 676 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 677 | 677 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
| 678 | 678 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 679 | 679 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 680 | 680 | //$dataFound = true; |
| 681 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 682 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 681 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 682 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 683 | 683 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 684 | 684 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 685 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -688,27 +688,27 @@ discard block |
||
| 688 | 688 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 689 | 689 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 690 | 690 | } |
| 691 | - } |
|
| 692 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 691 | + } |
|
| 692 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | if (isset($line['heading']) && $line['heading'] != '') { |
| 700 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 701 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 702 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 703 | - //$dataFound = true; |
|
| 700 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 701 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 702 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 703 | + //$dataFound = true; |
|
| 704 | 704 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 705 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 707 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 708 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 705 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 707 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 708 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 709 | 709 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 710 | - // If not enough messages and ACARS set heading to 0 |
|
| 711 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 710 | + // If not enough messages and ACARS set heading to 0 |
|
| 711 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 712 | 712 | } |
| 713 | 713 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 714 | 714 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -721,125 +721,125 @@ discard block |
||
| 721 | 721 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 722 | 722 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 723 | 723 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 724 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 725 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 726 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 727 | - //print_r($this->all_flights); |
|
| 728 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 729 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 730 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 724 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 725 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 726 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 727 | + //print_r($this->all_flights); |
|
| 728 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 729 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 730 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 731 | 731 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 732 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 733 | - $timeelapsed = microtime(true); |
|
| 734 | - $SpotterLive = new SpotterLive($this->db); |
|
| 735 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 732 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 733 | + $timeelapsed = microtime(true); |
|
| 734 | + $SpotterLive = new SpotterLive($this->db); |
|
| 735 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 736 | 736 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 737 | 737 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 738 | - } elseif (isset($line['id'])) { |
|
| 738 | + } elseif (isset($line['id'])) { |
|
| 739 | 739 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 740 | 740 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 741 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 741 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 742 | 742 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 743 | 743 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 744 | - } else $recent_ident = ''; |
|
| 745 | - $SpotterLive->db=null; |
|
| 746 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 747 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 744 | + } else $recent_ident = ''; |
|
| 745 | + $SpotterLive->db=null; |
|
| 746 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 747 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 748 | 748 | } else $recent_ident = ''; |
| 749 | - } else { |
|
| 749 | + } else { |
|
| 750 | 750 | $recent_ident = ''; |
| 751 | 751 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 752 | - } |
|
| 753 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 754 | - if($recent_ident == "") |
|
| 755 | - { |
|
| 752 | + } |
|
| 753 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 754 | + if($recent_ident == "") |
|
| 755 | + { |
|
| 756 | 756 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 757 | 757 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 758 | 758 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 759 | 759 | //adds the spotter data for the archive |
| 760 | 760 | $ignoreImport = false; |
| 761 | 761 | foreach($globalAirportIgnore as $airportIgnore) { |
| 762 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 762 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 763 | 763 | $ignoreImport = true; |
| 764 | - } |
|
| 764 | + } |
|
| 765 | 765 | } |
| 766 | 766 | if (count($globalAirportAccept) > 0) { |
| 767 | - $ignoreImport = true; |
|
| 768 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 767 | + $ignoreImport = true; |
|
| 768 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 769 | 769 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 770 | - $ignoreImport = false; |
|
| 770 | + $ignoreImport = false; |
|
| 771 | + } |
|
| 771 | 772 | } |
| 772 | - } |
|
| 773 | 773 | } |
| 774 | 774 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 775 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 775 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 776 | 776 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
| 777 | - $ignoreImport = true; |
|
| 777 | + $ignoreImport = true; |
|
| 778 | + } |
|
| 778 | 779 | } |
| 779 | - } |
|
| 780 | 780 | } |
| 781 | 781 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 782 | - $ignoreImport = true; |
|
| 783 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 782 | + $ignoreImport = true; |
|
| 783 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 784 | 784 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
| 785 | - $ignoreImport = false; |
|
| 785 | + $ignoreImport = false; |
|
| 786 | + } |
|
| 786 | 787 | } |
| 787 | - } |
|
| 788 | 788 | } |
| 789 | 789 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 790 | - $ignoreImport = true; |
|
| 791 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 790 | + $ignoreImport = true; |
|
| 791 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 792 | 792 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 793 | - $ignoreImport = false; |
|
| 793 | + $ignoreImport = false; |
|
| 794 | + } |
|
| 794 | 795 | } |
| 795 | - } |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | if (!$ignoreImport) { |
| 799 | - $highlight = ''; |
|
| 800 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 801 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 802 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 803 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 804 | - $timeelapsed = microtime(true); |
|
| 805 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 799 | + $highlight = ''; |
|
| 800 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 801 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 802 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 803 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 804 | + $timeelapsed = microtime(true); |
|
| 805 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 806 | 806 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 807 | - $Spotter = new Spotter($this->db); |
|
| 808 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 809 | - $Spotter->db = null; |
|
| 810 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 807 | + $Spotter = new Spotter($this->db); |
|
| 808 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 809 | + $Spotter->db = null; |
|
| 810 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 811 | 811 | } |
| 812 | - } |
|
| 813 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 814 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 812 | + } |
|
| 813 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 814 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 815 | 815 | |
| 816 | - // Add source stat in DB |
|
| 817 | - $Stats = new Stats($this->db); |
|
| 818 | - if (!empty($this->stats)) { |
|
| 816 | + // Add source stat in DB |
|
| 817 | + $Stats = new Stats($this->db); |
|
| 818 | + if (!empty($this->stats)) { |
|
| 819 | 819 | if ($globalDebug) echo 'Add source stats : '; |
| 820 | - foreach($this->stats as $date => $data) { |
|
| 821 | - foreach($data as $source => $sourced) { |
|
| 822 | - //print_r($sourced); |
|
| 823 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 824 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 825 | - if (isset($sourced['msg'])) { |
|
| 826 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 827 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 828 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 829 | - unset($this->stats[$date][$source]['msg']); |
|
| 830 | - } |
|
| 831 | - } |
|
| 832 | - } |
|
| 833 | - if ($date != date('Y-m-d')) { |
|
| 834 | - unset($this->stats[$date]); |
|
| 835 | - } |
|
| 836 | - } |
|
| 837 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 820 | + foreach($this->stats as $date => $data) { |
|
| 821 | + foreach($data as $source => $sourced) { |
|
| 822 | + //print_r($sourced); |
|
| 823 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 824 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 825 | + if (isset($sourced['msg'])) { |
|
| 826 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 827 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 828 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 829 | + unset($this->stats[$date][$source]['msg']); |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | + } |
|
| 833 | + if ($date != date('Y-m-d')) { |
|
| 834 | + unset($this->stats[$date]); |
|
| 835 | + } |
|
| 836 | + } |
|
| 837 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 838 | 838 | |
| 839 | - } |
|
| 840 | - $Stats->db = null; |
|
| 841 | - } |
|
| 842 | - $this->del(); |
|
| 839 | + } |
|
| 840 | + $Stats->db = null; |
|
| 841 | + } |
|
| 842 | + $this->del(); |
|
| 843 | 843 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 844 | 844 | //$ignoreImport = false; |
| 845 | 845 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -857,41 +857,41 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 859 | 859 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 860 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 861 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 862 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 860 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 861 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 862 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 863 | 863 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 864 | - $SpotterLive = new SpotterLive($this->db); |
|
| 865 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 866 | - $SpotterLive->db=null; |
|
| 864 | + $SpotterLive = new SpotterLive($this->db); |
|
| 865 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 866 | + $SpotterLive->db=null; |
|
| 867 | 867 | } |
| 868 | - } |
|
| 869 | - if ($globalDebug) echo " Done\n"; |
|
| 870 | - $this->last_delete = time(); |
|
| 868 | + } |
|
| 869 | + if ($globalDebug) echo " Done\n"; |
|
| 870 | + $this->last_delete = time(); |
|
| 871 | 871 | } |
| 872 | - } else { |
|
| 872 | + } else { |
|
| 873 | 873 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
| 874 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 875 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 874 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 875 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 876 | 876 | } |
| 877 | 877 | if (isset($globalDaemon) && !$globalDaemon) { |
| 878 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 878 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 879 | 879 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 880 | - $Spotter = new Spotter($this->db); |
|
| 881 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 882 | - $Spotter->db = null; |
|
| 880 | + $Spotter = new Spotter($this->db); |
|
| 881 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 882 | + $Spotter->db = null; |
|
| 883 | + } |
|
| 883 | 884 | } |
| 884 | - } |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - } |
|
| 887 | + } |
|
| 888 | 888 | } |
| 889 | - } |
|
| 890 | - //adds the spotter LIVE data |
|
| 891 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 892 | - //echo "\nAdd in Live !! \n"; |
|
| 893 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 894 | - if ($globalDebug) { |
|
| 889 | + } |
|
| 890 | + //adds the spotter LIVE data |
|
| 891 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 892 | + //echo "\nAdd in Live !! \n"; |
|
| 893 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 894 | + if ($globalDebug) { |
|
| 895 | 895 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 896 | 896 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
| 897 | 897 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -899,60 +899,60 @@ discard block |
||
| 899 | 899 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
| 900 | 900 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
| 901 | 901 | } |
| 902 | - } |
|
| 903 | - $ignoreImport = false; |
|
| 904 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 905 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 902 | + } |
|
| 903 | + $ignoreImport = false; |
|
| 904 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 905 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 906 | 906 | |
| 907 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 908 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 909 | - $ignoreImport = true; |
|
| 907 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 908 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 909 | + $ignoreImport = true; |
|
| 910 | + } |
|
| 910 | 911 | } |
| 911 | - } |
|
| 912 | - if (count($globalAirportAccept) > 0) { |
|
| 913 | - $ignoreImport = true; |
|
| 914 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 915 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 912 | + if (count($globalAirportAccept) > 0) { |
|
| 913 | + $ignoreImport = true; |
|
| 914 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 915 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 916 | 916 | $ignoreImport = false; |
| 917 | - } |
|
| 917 | + } |
|
| 918 | 918 | } |
| 919 | - } |
|
| 920 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 919 | + } |
|
| 920 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 921 | 921 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 922 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 922 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 923 | 923 | $ignoreImport = true; |
| 924 | - } |
|
| 924 | + } |
|
| 925 | 925 | } |
| 926 | - } |
|
| 927 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 926 | + } |
|
| 927 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 928 | 928 | $ignoreImport = true; |
| 929 | 929 | foreach($globalAirlineAccept as $airlineAccept) { |
| 930 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 930 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 931 | 931 | $ignoreImport = false; |
| 932 | - } |
|
| 932 | + } |
|
| 933 | + } |
|
| 933 | 934 | } |
| 934 | - } |
|
| 935 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 935 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 936 | 936 | $ignoreImport = true; |
| 937 | 937 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 938 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 939 | - $ignoreImport = false; |
|
| 940 | - } |
|
| 938 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 939 | + $ignoreImport = false; |
|
| 940 | + } |
|
| 941 | + } |
|
| 941 | 942 | } |
| 942 | - } |
|
| 943 | 943 | |
| 944 | - if (!$ignoreImport) { |
|
| 944 | + if (!$ignoreImport) { |
|
| 945 | 945 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 946 | 946 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 947 | 947 | $timeelapsed = microtime(true); |
| 948 | 948 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 949 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 949 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 950 | 950 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 951 | 951 | $SpotterLive = new SpotterLive($this->db); |
| 952 | 952 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 953 | 953 | $SpotterLive->db = null; |
| 954 | 954 | if ($globalDebug) echo $result."\n"; |
| 955 | - } |
|
| 955 | + } |
|
| 956 | 956 | } |
| 957 | 957 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 958 | 958 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | //if ($line['format_source'] != 'aprs') { |
| 965 | 965 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 966 | 966 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 967 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 967 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 968 | 968 | $source = $this->all_flights[$id]['source_name']; |
| 969 | 969 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
| 970 | 970 | if (!isset($this->source_location[$source])) { |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | if ($stats_heading == 16) $stats_heading = 0; |
| 991 | 991 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 992 | 992 | for ($i=0;$i<=15;$i++) { |
| 993 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 993 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 994 | 994 | } |
| 995 | 995 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 996 | 996 | } else { |
@@ -1003,17 +1003,17 @@ discard block |
||
| 1003 | 1003 | //var_dump($this->stats); |
| 1004 | 1004 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1005 | 1005 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1006 | - end($this->stats[$current_date][$source]['hist']); |
|
| 1007 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1006 | + end($this->stats[$current_date][$source]['hist']); |
|
| 1007 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1008 | 1008 | } else $mini = 0; |
| 1009 | 1009 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1010 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1010 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1011 | 1011 | } |
| 1012 | 1012 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 1013 | 1013 | } else { |
| 1014 | 1014 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
| 1015 | 1015 | } |
| 1016 | - } |
|
| 1016 | + } |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | //$this->del(); |
| 1024 | 1024 | |
| 1025 | 1025 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1026 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1026 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1027 | 1027 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
| 1028 | 1028 | $SpotterLive = new SpotterLive($this->db); |
| 1029 | 1029 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1031,19 +1031,19 @@ discard block |
||
| 1031 | 1031 | //SpotterLive->deleteLiveSpotterData(); |
| 1032 | 1032 | if ($globalDebug) echo " Done\n"; |
| 1033 | 1033 | $this->last_delete_hourly = time(); |
| 1034 | - } else { |
|
| 1034 | + } else { |
|
| 1035 | 1035 | $this->del(); |
| 1036 | 1036 | $this->last_delete_hourly = time(); |
| 1037 | - } |
|
| 1037 | + } |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - } |
|
| 1041 | - //$ignoreImport = false; |
|
| 1040 | + } |
|
| 1041 | + //$ignoreImport = false; |
|
| 1042 | 1042 | } |
| 1043 | 1043 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1044 | 1044 | if ($send) return $this->all_flights[$id]; |
| 1045 | - } |
|
| 1045 | + } |
|
| 1046 | + } |
|
| 1046 | 1047 | } |
| 1047 | - } |
|
| 1048 | 1048 | } |
| 1049 | 1049 | ?> |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $currentdate = date('Y-m-d'); |
| 34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 35 | 35 | if (!empty($sourcestat)) { |
| 36 | - foreach($sourcestat as $srcst) { |
|
| 36 | + foreach ($sourcestat as $srcst) { |
|
| 37 | 37 | $type = $srcst['stats_type']; |
| 38 | 38 | if ($type == 'polar' || $type == 'hist') { |
| 39 | 39 | $source = $srcst['source_name']; |
| 40 | 40 | $data = $srcst['source_data']; |
| 41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 41 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function get_Schedule($id,$ident) { |
|
| 53 | + public function get_Schedule($id, $ident) { |
|
| 54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 55 | 55 | // Get schedule here, so it's done only one time |
| 56 | 56 | |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
| 76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 77 | 77 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 80 | 80 | // Should also check if route schedule = route from DB |
| 81 | 81 | if ($schedule['DepartureAirportIATA'] != '') { |
| 82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 99 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
| 100 | 100 | } |
| 101 | 101 | } else $scheduleexist = true; |
| 102 | 102 | } else $scheduleexist = true; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if ($scheduleexist) { |
| 105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 106 | 106 | $sch = $Schedule->getSchedule($operator); |
| 107 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 107 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 108 | 108 | } |
| 109 | 109 | $Spotter->db = null; |
| 110 | 110 | $Schedule->db = null; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 132 | 132 | $Spotter = new Spotter($this->db); |
| 133 | 133 | $real_arrival = $this->arrival($key); |
| 134 | - if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 134 | + if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $airport_time = ''; |
| 146 | 146 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 149 | 149 | if (isset($closestAirports[0])) { |
| 150 | 150 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 151 | 151 | $airport_icao = $closestAirports[0]['icao']; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 163 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
| 164 | 164 | $airport_icao = $closestAirports[0]['icao']; |
| 165 | 165 | $airport_time = $this->all_flights[$key]['datetime']; |
| 166 | 166 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | } else { |
| 174 | 174 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 175 | 175 | } |
| 176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 176 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 185 | 185 | foreach ($this->all_flights as $key => $flight) { |
| 186 | 186 | if (isset($flight['lastupdate'])) { |
| 187 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
| 187 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
| 188 | 188 | $this->delKey($key); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $real_arrival = $this->arrival($key); |
| 201 | 201 | $Spotter = new Spotter($this->db); |
| 202 | 202 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 203 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 203 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 204 | 204 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $send = false; |
| 234 | 234 | |
| 235 | 235 | // SBS format is CSV format |
| 236 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 236 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 237 | 237 | //print_r($line); |
| 238 | 238 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
| 239 | 239 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -269,25 +269,25 @@ discard block |
||
| 269 | 269 | if (!isset($this->all_flights[$id])) { |
| 270 | 270 | if ($globalDebug) echo 'New flight...'."\n"; |
| 271 | 271 | $this->all_flights[$id] = array(); |
| 272 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 273 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 274 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 272 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 273 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
| 274 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 275 | 275 | if (!isset($line['id'])) { |
| 276 | 276 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 277 | 277 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 278 | 278 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 279 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 279 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 280 | 280 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 281 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 281 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 282 | 282 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 283 | 283 | } |
| 284 | 284 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 285 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 285 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | //print_r($this->all_flights); |
| 289 | 289 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 290 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 290 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 291 | 291 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 292 | 292 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 293 | 293 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -296,27 +296,27 @@ discard block |
||
| 296 | 296 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 297 | 297 | $Spotter = new Spotter($this->db); |
| 298 | 298 | if (isset($this->all_flights[$id]['source_type'])) { |
| 299 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 299 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 300 | 300 | } else { |
| 301 | 301 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 302 | 302 | } |
| 303 | 303 | $Spotter->db = null; |
| 304 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 305 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 304 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 305 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 309 | 309 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 310 | 310 | } |
| 311 | 311 | if (isset($line['id']) && !isset($line['hex'])) { |
| 312 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 312 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
| 313 | 313 | } |
| 314 | 314 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 315 | 315 | $icao = $line['aircraft_icao']; |
| 316 | 316 | $Spotter = new Spotter($this->db); |
| 317 | 317 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
| 318 | 318 | $Spotter->db = null; |
| 319 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
| 319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
| 320 | 320 | } |
| 321 | 321 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 322 | 322 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $Spotter = new Spotter($this->db); |
| 325 | 325 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 326 | 326 | $Spotter->db = null; |
| 327 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 327 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -332,15 +332,15 @@ discard block |
||
| 332 | 332 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 333 | 333 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 334 | 334 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 335 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 335 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 336 | 336 | } |
| 337 | 337 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 339 | 339 | } |
| 340 | 340 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 341 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 341 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 342 | 342 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 343 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 343 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 344 | 344 | } else { |
| 345 | 345 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 346 | 346 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -351,32 +351,32 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | return ''; |
| 353 | 353 | } |
| 354 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 354 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 355 | 355 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
| 356 | 356 | return ''; |
| 357 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 357 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 358 | 358 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n |
| 359 | 359 | "; |
| 360 | 360 | return ''; |
| 361 | 361 | } elseif (!isset($line['datetime'])) { |
| 362 | 362 | date_default_timezone_set('UTC'); |
| 363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 364 | 364 | } else { |
| 365 | 365 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 366 | 366 | return ''; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 371 | 371 | } |
| 372 | 372 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 373 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 373 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 374 | 374 | } |
| 375 | 375 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 376 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
| 377 | 377 | } |
| 378 | 378 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -384,13 +384,13 @@ discard block |
||
| 384 | 384 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 385 | 385 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 386 | 386 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 389 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 390 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 391 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 389 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 390 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 391 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 392 | 392 | } else { |
| 393 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 393 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | 395 | $timeelapsed = microtime(true); |
| 396 | 396 | $Spotter = new Spotter($this->db); |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 401 | 401 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 402 | 402 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 403 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 403 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 404 | 404 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 405 | 405 | $Spotter->db = null; |
| 406 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 406 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 409 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 410 | 410 | |
| 411 | 411 | /* |
| 412 | 412 | if (!isset($line['id'])) { |
@@ -416,25 +416,25 @@ discard block |
||
| 416 | 416 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 417 | 417 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 418 | 418 | */ |
| 419 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 419 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 420 | 420 | |
| 421 | 421 | //$putinarchive = true; |
| 422 | 422 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 423 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 423 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 424 | 424 | } |
| 425 | 425 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 426 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 426 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 427 | 427 | } |
| 428 | 428 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 429 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 429 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 430 | 430 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 431 | 431 | $timeelapsed = microtime(true); |
| 432 | 432 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 433 | 433 | $Spotter = new Spotter($this->db); |
| 434 | 434 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 435 | 435 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 437 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 437 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 438 | 438 | } |
| 439 | 439 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 440 | 440 | $timeelapsed = microtime(true); |
@@ -448,34 +448,34 @@ discard block |
||
| 448 | 448 | $Translation->db = null; |
| 449 | 449 | } |
| 450 | 450 | $Spotter->db = null; |
| 451 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 451 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 452 | 452 | } |
| 453 | 453 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 454 | 454 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 455 | 455 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 456 | 456 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 457 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 457 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | if (!isset($globalFork)) $globalFork = TRUE; |
| 461 | 461 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 462 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 462 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | if (isset($line['speed']) && $line['speed'] != '') { |
| 468 | 468 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 469 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 470 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 469 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 470 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 471 | 471 | //$dataFound = true; |
| 472 | 472 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 473 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 473 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 474 | 474 | if ($distance > 1000 && $distance < 10000) { |
| 475 | 475 | // use datetime |
| 476 | 476 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 477 | 477 | $speed = $speed*3.6; |
| 478 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 478 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 479 | 479 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 480 | 480 | } |
| 481 | 481 | } |
@@ -487,9 +487,9 @@ discard block |
||
| 487 | 487 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
| 488 | 488 | return false; |
| 489 | 489 | } |
| 490 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 490 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 491 | 491 | else unset($timediff); |
| 492 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 492 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
| 493 | 493 | else unset($timediff_archive); |
| 494 | 494 | if ($this->tmd > 5 |
| 495 | 495 | || (isset($line['format_source']) |
@@ -513,14 +513,14 @@ discard block |
||
| 513 | 513 | || ($timediff > 30 |
| 514 | 514 | && isset($this->all_flights[$id]['latitude']) |
| 515 | 515 | && isset($this->all_flights[$id]['longitude']) |
| 516 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 516 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
| 517 | 517 | ) |
| 518 | 518 | ) { |
| 519 | 519 | |
| 520 | 520 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 521 | 521 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
| 522 | 522 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 523 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 523 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 524 | 524 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 525 | 525 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 526 | 526 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -530,11 +530,11 @@ discard block |
||
| 530 | 530 | $timeelapsed = microtime(true); |
| 531 | 531 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 532 | 532 | $Spotter = new Spotter($this->db); |
| 533 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 533 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 534 | 534 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 535 | 535 | else $this->all_flights[$id]['over_country'] = ''; |
| 536 | 536 | $Spotter->db = null; |
| 537 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 537 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 538 | 538 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 539 | 539 | } |
| 540 | 540 | } |
@@ -560,13 +560,13 @@ discard block |
||
| 560 | 560 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 561 | 561 | } |
| 562 | 562 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 563 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
| 563 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
| 564 | 564 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 565 | 565 | $dataFound = true; |
| 566 | 566 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 567 | 567 | } |
| 568 | 568 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 569 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 569 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 570 | 570 | /* |
| 571 | 571 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 572 | 572 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -588,13 +588,13 @@ discard block |
||
| 588 | 588 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 589 | 589 | } |
| 590 | 590 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 591 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
| 591 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
| 592 | 592 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 593 | 593 | $dataFound = true; |
| 594 | 594 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 595 | 595 | } |
| 596 | 596 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 597 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 597 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 598 | 598 | /* |
| 599 | 599 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 600 | 600 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -612,46 +612,46 @@ discard block |
||
| 612 | 612 | } else if ($globalDebug && $timediff > 30) { |
| 613 | 613 | $this->tmd = $this->tmd + 1; |
| 614 | 614 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 615 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 616 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 615 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 616 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 617 | 617 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 621 | 621 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 622 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 622 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 623 | 623 | } |
| 624 | 624 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 625 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 625 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 626 | 626 | //$dataFound = true; |
| 627 | 627 | } |
| 628 | 628 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 629 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 629 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 630 | 630 | } |
| 631 | 631 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 632 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 632 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 633 | 633 | } |
| 634 | 634 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 636 | 636 | //$dataFound = true; |
| 637 | 637 | } |
| 638 | 638 | if (isset($line['ground']) && $line['ground'] != '') { |
| 639 | 639 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 640 | 640 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 641 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 643 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 644 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 645 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 641 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 643 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 644 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 645 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 646 | 646 | } |
| 647 | 647 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 649 | 649 | //$dataFound = true; |
| 650 | 650 | } |
| 651 | 651 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 652 | 652 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 653 | 653 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 654 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 654 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 655 | 655 | $highlight = ''; |
| 656 | 656 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 657 | 657 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -660,59 +660,59 @@ discard block |
||
| 660 | 660 | $timeelapsed = microtime(true); |
| 661 | 661 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 662 | 662 | $Spotter = new Spotter($this->db); |
| 663 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 663 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 664 | 664 | $Spotter->db = null; |
| 665 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 665 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 666 | 666 | } |
| 667 | 667 | //$putinarchive = true; |
| 668 | 668 | //$highlight = ''; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 671 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 672 | 672 | //$dataFound = true; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 676 | 676 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 677 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 678 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 679 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 677 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 678 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 679 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 680 | 680 | //$dataFound = true; |
| 681 | 681 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 682 | 682 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 683 | 683 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 684 | 684 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 685 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 686 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 687 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 688 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 689 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 685 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 686 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 687 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 688 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 689 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 692 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | if (isset($line['heading']) && $line['heading'] != '') { |
| 700 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 701 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 702 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 700 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 701 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 702 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 703 | 703 | //$dataFound = true; |
| 704 | 704 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 705 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 707 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 705 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 707 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 708 | 708 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
| 709 | 709 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 710 | 710 | // If not enough messages and ACARS set heading to 0 |
| 711 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 711 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 712 | 712 | } |
| 713 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 714 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 715 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 713 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 714 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 715 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 716 | 716 | |
| 717 | 717 | // print_r($this->all_flights[$id]); |
| 718 | 718 | //gets the callsign from the last hour |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 724 | 724 | $this->all_flights[$id]['lastupdate'] = time(); |
| 725 | 725 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
| 726 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 726 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 727 | 727 | //print_r($this->all_flights); |
| 728 | 728 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 729 | 729 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -734,61 +734,61 @@ discard block |
||
| 734 | 734 | $SpotterLive = new SpotterLive($this->db); |
| 735 | 735 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 736 | 736 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 737 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 737 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 738 | 738 | } elseif (isset($line['id'])) { |
| 739 | 739 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 740 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 740 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 741 | 741 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 742 | 742 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 743 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 743 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 744 | 744 | } else $recent_ident = ''; |
| 745 | - $SpotterLive->db=null; |
|
| 745 | + $SpotterLive->db = null; |
|
| 746 | 746 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 747 | 747 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 748 | 748 | } else $recent_ident = ''; |
| 749 | 749 | } else { |
| 750 | 750 | $recent_ident = ''; |
| 751 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 751 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 752 | 752 | } |
| 753 | 753 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 754 | - if($recent_ident == "") |
|
| 754 | + if ($recent_ident == "") |
|
| 755 | 755 | { |
| 756 | 756 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 757 | 757 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 758 | 758 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 759 | 759 | //adds the spotter data for the archive |
| 760 | 760 | $ignoreImport = false; |
| 761 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 761 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 762 | 762 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 763 | 763 | $ignoreImport = true; |
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | if (count($globalAirportAccept) > 0) { |
| 767 | 767 | $ignoreImport = true; |
| 768 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 768 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 769 | 769 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 770 | 770 | $ignoreImport = false; |
| 771 | 771 | } |
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 775 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 776 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 775 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 776 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 777 | 777 | $ignoreImport = true; |
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 782 | 782 | $ignoreImport = true; |
| 783 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 784 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 783 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 784 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 785 | 785 | $ignoreImport = false; |
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 790 | 790 | $ignoreImport = true; |
| 791 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 791 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 792 | 792 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 793 | 793 | $ignoreImport = false; |
| 794 | 794 | } |
@@ -800,32 +800,32 @@ discard block |
||
| 800 | 800 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 801 | 801 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 802 | 802 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 803 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 803 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 804 | 804 | $timeelapsed = microtime(true); |
| 805 | 805 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 806 | 806 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 807 | 807 | $Spotter = new Spotter($this->db); |
| 808 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 808 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
| 809 | 809 | $Spotter->db = null; |
| 810 | 810 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 813 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 814 | 814 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 815 | 815 | |
| 816 | 816 | // Add source stat in DB |
| 817 | 817 | $Stats = new Stats($this->db); |
| 818 | 818 | if (!empty($this->stats)) { |
| 819 | 819 | if ($globalDebug) echo 'Add source stats : '; |
| 820 | - foreach($this->stats as $date => $data) { |
|
| 821 | - foreach($data as $source => $sourced) { |
|
| 820 | + foreach ($this->stats as $date => $data) { |
|
| 821 | + foreach ($data as $source => $sourced) { |
|
| 822 | 822 | //print_r($sourced); |
| 823 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 824 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 823 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 824 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 825 | 825 | if (isset($sourced['msg'])) { |
| 826 | 826 | if (time() - $sourced['msg']['date'] > 10) { |
| 827 | 827 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 828 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 828 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 829 | 829 | unset($this->stats[$date][$source]['msg']); |
| 830 | 830 | } |
| 831 | 831 | } |
@@ -863,14 +863,14 @@ discard block |
||
| 863 | 863 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 864 | 864 | $SpotterLive = new SpotterLive($this->db); |
| 865 | 865 | $SpotterLive->deleteLiveSpotterData(); |
| 866 | - $SpotterLive->db=null; |
|
| 866 | + $SpotterLive->db = null; |
|
| 867 | 867 | } |
| 868 | 868 | } |
| 869 | 869 | if ($globalDebug) echo " Done\n"; |
| 870 | 870 | $this->last_delete = time(); |
| 871 | 871 | } |
| 872 | 872 | } else { |
| 873 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 873 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 874 | 874 | $this->all_flights[$id]['id'] = $recent_ident; |
| 875 | 875 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 876 | 876 | } |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 879 | 879 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 880 | 880 | $Spotter = new Spotter($this->db); |
| 881 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 881 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
| 882 | 882 | $Spotter->db = null; |
| 883 | 883 | } |
| 884 | 884 | } |
@@ -904,37 +904,37 @@ discard block |
||
| 904 | 904 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 905 | 905 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 906 | 906 | |
| 907 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 907 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 908 | 908 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 909 | 909 | $ignoreImport = true; |
| 910 | 910 | } |
| 911 | 911 | } |
| 912 | 912 | if (count($globalAirportAccept) > 0) { |
| 913 | 913 | $ignoreImport = true; |
| 914 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 914 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 915 | 915 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 916 | 916 | $ignoreImport = false; |
| 917 | 917 | } |
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | 920 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 921 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 922 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 921 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 922 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 923 | 923 | $ignoreImport = true; |
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | 926 | } |
| 927 | 927 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 928 | 928 | $ignoreImport = true; |
| 929 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 930 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 929 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 930 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 931 | 931 | $ignoreImport = false; |
| 932 | 932 | } |
| 933 | 933 | } |
| 934 | 934 | } |
| 935 | 935 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 936 | 936 | $ignoreImport = true; |
| 937 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 937 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 938 | 938 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 939 | 939 | $ignoreImport = false; |
| 940 | 940 | } |
@@ -942,23 +942,23 @@ discard block |
||
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | if (!$ignoreImport) { |
| 945 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 946 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 945 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 946 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 947 | 947 | $timeelapsed = microtime(true); |
| 948 | 948 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 949 | 949 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 950 | 950 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 951 | 951 | $SpotterLive = new SpotterLive($this->db); |
| 952 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 952 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 953 | 953 | $SpotterLive->db = null; |
| 954 | 954 | if ($globalDebug) echo $result."\n"; |
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 958 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 958 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 959 | 959 | } |
| 960 | 960 | $this->all_flights[$id]['putinarchive'] = false; |
| 961 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 961 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 962 | 962 | |
| 963 | 963 | // Put statistics in $this->stats variable |
| 964 | 964 | //if ($line['format_source'] != 'aprs') { |
@@ -977,19 +977,19 @@ discard block |
||
| 977 | 977 | $latitude = $globalCenterLatitude; |
| 978 | 978 | $longitude = $globalCenterLongitude; |
| 979 | 979 | } |
| 980 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 980 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 981 | 981 | } else { |
| 982 | 982 | $latitude = $this->source_location[$source]['latitude']; |
| 983 | 983 | $longitude = $this->source_location[$source]['longitude']; |
| 984 | 984 | } |
| 985 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 985 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 986 | 986 | //$stats_heading = $stats_heading%22.5; |
| 987 | 987 | $stats_heading = round($stats_heading/22.5); |
| 988 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 988 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 989 | 989 | $current_date = date('Y-m-d'); |
| 990 | 990 | if ($stats_heading == 16) $stats_heading = 0; |
| 991 | 991 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 992 | - for ($i=0;$i<=15;$i++) { |
|
| 992 | + for ($i = 0; $i <= 15; $i++) { |
|
| 993 | 993 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 994 | 994 | } |
| 995 | 995 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1004,9 +1004,9 @@ discard block |
||
| 1004 | 1004 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1005 | 1005 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1006 | 1006 | end($this->stats[$current_date][$source]['hist']); |
| 1007 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1007 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 1008 | 1008 | } else $mini = 0; |
| 1009 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 1009 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 1010 | 1010 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1011 | 1011 | } |
| 1012 | 1012 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1020 | 1020 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 1021 | 1021 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1022 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1022 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 1023 | 1023 | //$this->del(); |
| 1024 | 1024 | |
| 1025 | 1025 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -63,7 +63,9 @@ discard block |
||
| 63 | 63 | $dbc = $this->db; |
| 64 | 64 | $this->all_flights[$id]['schedule_check'] = true; |
| 65 | 65 | if ($globalSchedulesFetch) { |
| 66 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 66 | + if ($globalDebug) { |
|
| 67 | + echo 'Getting schedule info...'."\n"; |
|
| 68 | + } |
|
| 67 | 69 | $Spotter = new Spotter($dbc); |
| 68 | 70 | $Schedule = new Schedule($dbc); |
| 69 | 71 | $Translation = new Translation($dbc); |
@@ -74,7 +76,9 @@ discard block |
||
| 74 | 76 | if ($Schedule->checkSchedule($operator) == 0) { |
| 75 | 77 | $schedule = $Schedule->fetchSchedule($operator); |
| 76 | 78 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 79 | + if ($globalDebug) { |
|
| 80 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 81 | + } |
|
| 78 | 82 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 79 | 83 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 80 | 84 | // Should also check if route schedule = route from DB |
@@ -83,7 +87,9 @@ discard block |
||
| 83 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 84 | 88 | if (trim($airport_icao) != '') { |
| 85 | 89 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 86 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 90 | + if ($globalDebug) { |
|
| 91 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 92 | + } |
|
| 87 | 93 | } |
| 88 | 94 | } |
| 89 | 95 | } |
@@ -92,17 +98,25 @@ discard block |
||
| 92 | 98 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 93 | 99 | if (trim($airport_icao) != '') { |
| 94 | 100 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 95 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 101 | + if ($globalDebug) { |
|
| 102 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 103 | + } |
|
| 96 | 104 | } |
| 97 | 105 | } |
| 98 | 106 | } |
| 99 | 107 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
| 100 | 108 | } |
| 101 | - } else $scheduleexist = true; |
|
| 102 | - } else $scheduleexist = true; |
|
| 109 | + } else { |
|
| 110 | + $scheduleexist = true; |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 113 | + $scheduleexist = true; |
|
| 114 | + } |
|
| 103 | 115 | // close connection, at least one way will work ? |
| 104 | 116 | if ($scheduleexist) { |
| 105 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 117 | + if ($globalDebug) { |
|
| 118 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 119 | + } |
|
| 106 | 120 | $sch = $Schedule->getSchedule($operator); |
| 107 | 121 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 108 | 122 | } |
@@ -124,14 +138,18 @@ discard block |
||
| 124 | 138 | |
| 125 | 139 | public function checkAll() { |
| 126 | 140 | global $globalDebug, $globalNoImport; |
| 127 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 141 | + if ($globalDebug) { |
|
| 142 | + echo "Update last seen flights data...\n"; |
|
| 143 | + } |
|
| 128 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 129 | 145 | foreach ($this->all_flights as $key => $flight) { |
| 130 | 146 | if (isset($this->all_flights[$key]['id'])) { |
| 131 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 132 | 148 | $Spotter = new Spotter($this->db); |
| 133 | 149 | $real_arrival = $this->arrival($key); |
| 134 | - if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 150 | + if (isset($this->all_flights[$key]['altitude'])) { |
|
| 151 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 152 | + } |
|
| 135 | 153 | } |
| 136 | 154 | } |
| 137 | 155 | } |
@@ -139,24 +157,32 @@ discard block |
||
| 139 | 157 | |
| 140 | 158 | public function arrival($key) { |
| 141 | 159 | global $globalClosestMinDist, $globalDebug; |
| 142 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 160 | + if ($globalDebug) { |
|
| 161 | + echo 'Update arrival...'."\n"; |
|
| 162 | + } |
|
| 143 | 163 | $Spotter = new Spotter($this->db); |
| 144 | 164 | $airport_icao = ''; |
| 145 | 165 | $airport_time = ''; |
| 146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 166 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 167 | + $globalClosestMinDist = 50; |
|
| 168 | + } |
|
| 147 | 169 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 148 | 170 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 149 | 171 | if (isset($closestAirports[0])) { |
| 150 | 172 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 151 | 173 | $airport_icao = $closestAirports[0]['icao']; |
| 152 | 174 | $airport_time = $this->all_flights[$key]['datetime']; |
| 153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 175 | + if ($globalDebug) { |
|
| 176 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 177 | + } |
|
| 154 | 178 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 155 | 179 | foreach ($closestAirports as $airport) { |
| 156 | 180 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 157 | 181 | $airport_icao = $airport['icao']; |
| 158 | 182 | $airport_time = $this->all_flights[$key]['datetime']; |
| 159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 183 | + if ($globalDebug) { |
|
| 184 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 185 | + } |
|
| 160 | 186 | break; |
| 161 | 187 | } |
| 162 | 188 | } |
@@ -164,14 +190,20 @@ discard block |
||
| 164 | 190 | $airport_icao = $closestAirports[0]['icao']; |
| 165 | 191 | $airport_time = $this->all_flights[$key]['datetime']; |
| 166 | 192 | } else { |
| 167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 193 | + if ($globalDebug) { |
|
| 194 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 195 | + } |
|
| 168 | 196 | } |
| 169 | 197 | } else { |
| 170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 198 | + if ($globalDebug) { |
|
| 199 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 200 | + } |
|
| 171 | 201 | } |
| 172 | 202 | |
| 173 | 203 | } else { |
| 174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 204 | + if ($globalDebug) { |
|
| 205 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 206 | + } |
|
| 175 | 207 | } |
| 176 | 208 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 177 | 209 | } |
@@ -181,7 +213,9 @@ discard block |
||
| 181 | 213 | public function del() { |
| 182 | 214 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 183 | 215 | // Delete old infos |
| 184 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 216 | + if ($globalDebug) { |
|
| 217 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 218 | + } |
|
| 185 | 219 | foreach ($this->all_flights as $key => $flight) { |
| 186 | 220 | if (isset($flight['lastupdate'])) { |
| 187 | 221 | if ($flight['lastupdate'] < (time()-5900)) { |
@@ -195,13 +229,17 @@ discard block |
||
| 195 | 229 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 196 | 230 | // Delete old infos |
| 197 | 231 | if (isset($this->all_flights[$key]['id'])) { |
| 198 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 234 | + } |
|
| 199 | 235 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 200 | 236 | $real_arrival = $this->arrival($key); |
| 201 | 237 | $Spotter = new Spotter($this->db); |
| 202 | 238 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 203 | 239 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 204 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 240 | + if ($globalDebug && $result != 'success') { |
|
| 241 | + echo '!!! ERROR : '.$result."\n"; |
|
| 242 | + } |
|
| 205 | 243 | } |
| 206 | 244 | } |
| 207 | 245 | } |
@@ -211,9 +249,13 @@ discard block |
||
| 211 | 249 | public function add($line) { |
| 212 | 250 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval; |
| 213 | 251 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 214 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 215 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
| 216 | -/* |
|
| 252 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 253 | + $globalCoordMinChange = '0.02'; |
|
| 254 | + } |
|
| 255 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
| 256 | + $globalAircraftMaxUpdate = 3000; |
|
| 257 | + } |
|
| 258 | + /* |
|
| 217 | 259 | $Spotter = new Spotter(); |
| 218 | 260 | $dbc = $Spotter->db; |
| 219 | 261 | $SpotterLive = new SpotterLive($dbc); |
@@ -235,19 +277,28 @@ discard block |
||
| 235 | 277 | // SBS format is CSV format |
| 236 | 278 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 237 | 279 | //print_r($line); |
| 238 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 280 | + if (isset($line['hex'])) { |
|
| 281 | + $line['hex'] = strtoupper($line['hex']); |
|
| 282 | + } |
|
| 239 | 283 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
| 240 | 284 | |
| 241 | 285 | // Increment message number |
| 242 | 286 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 243 | 287 | $current_date = date('Y-m-d'); |
| 244 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 245 | - else $source = ''; |
|
| 246 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 288 | + if (isset($line['source_name'])) { |
|
| 289 | + $source = $line['source_name']; |
|
| 290 | + } else { |
|
| 291 | + $source = ''; |
|
| 292 | + } |
|
| 293 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 294 | + $source = $line['format_source']; |
|
| 295 | + } |
|
| 247 | 296 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 248 | 297 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 249 | 298 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 250 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 299 | + } else { |
|
| 300 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 301 | + } |
|
| 251 | 302 | } |
| 252 | 303 | |
| 253 | 304 | /* |
@@ -263,23 +314,38 @@ discard block |
||
| 263 | 314 | //$this->db = $dbc; |
| 264 | 315 | |
| 265 | 316 | //$hex = trim($line['hex']); |
| 266 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 267 | - else $id = trim($line['id']); |
|
| 317 | + if (!isset($line['id'])) { |
|
| 318 | + $id = trim($line['hex']); |
|
| 319 | + } else { |
|
| 320 | + $id = trim($line['id']); |
|
| 321 | + } |
|
| 268 | 322 | |
| 269 | 323 | if (!isset($this->all_flights[$id])) { |
| 270 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 324 | + if ($globalDebug) { |
|
| 325 | + echo 'New flight...'."\n"; |
|
| 326 | + } |
|
| 271 | 327 | $this->all_flights[$id] = array(); |
| 272 | 328 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 273 | 329 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
| 274 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 330 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
| 331 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 332 | + } |
|
| 275 | 333 | if (!isset($line['id'])) { |
| 276 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 277 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 334 | + if (!isset($globalDaemon)) { |
|
| 335 | + $globalDaemon = TRUE; |
|
| 336 | + } |
|
| 337 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 278 | 338 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 279 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 339 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 340 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 341 | + } |
|
| 280 | 342 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 281 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 282 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 343 | + } else { |
|
| 344 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 345 | + } |
|
| 346 | + if ($globalAllFlights !== FALSE) { |
|
| 347 | + $dataFound = true; |
|
| 348 | + } |
|
| 283 | 349 | } |
| 284 | 350 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 285 | 351 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -301,12 +367,20 @@ discard block |
||
| 301 | 367 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 302 | 368 | } |
| 303 | 369 | $Spotter->db = null; |
| 304 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 305 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 370 | + if ($globalDebugTimeElapsed) { |
|
| 371 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 372 | + } |
|
| 373 | + if ($aircraft_icao != '') { |
|
| 374 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 375 | + } |
|
| 306 | 376 | } |
| 307 | 377 | } |
| 308 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 309 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 378 | + if ($globalAllFlights !== FALSE) { |
|
| 379 | + $dataFound = true; |
|
| 380 | + } |
|
| 381 | + if ($globalDebug) { |
|
| 382 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 383 | + } |
|
| 310 | 384 | } |
| 311 | 385 | if (isset($line['id']) && !isset($line['hex'])) { |
| 312 | 386 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -314,7 +388,9 @@ discard block |
||
| 314 | 388 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 315 | 389 | $icao = $line['aircraft_icao']; |
| 316 | 390 | $Spotter = new Spotter($this->db); |
| 317 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 391 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
| 392 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 393 | + } |
|
| 318 | 394 | $Spotter->db = null; |
| 319 | 395 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
| 320 | 396 | } |
@@ -324,15 +400,24 @@ discard block |
||
| 324 | 400 | $Spotter = new Spotter($this->db); |
| 325 | 401 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 326 | 402 | $Spotter->db = null; |
| 327 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 403 | + if ($aircraft_icao != '') { |
|
| 404 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 405 | + } |
|
| 328 | 406 | } |
| 329 | 407 | } |
| 330 | 408 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 331 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 332 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 333 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 334 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 335 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 409 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 410 | + $aircraft_icao = 'GLID'; |
|
| 411 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 412 | + $aircraft_icao = 'UHEL'; |
|
| 413 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 414 | + $aircraft_icao = 'TOWPLANE'; |
|
| 415 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 416 | + $aircraft_icao = 'POWAIRC'; |
|
| 417 | + } |
|
| 418 | + if (isset($aircraft_icao)) { |
|
| 419 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 420 | + } |
|
| 336 | 421 | } |
| 337 | 422 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 338 | 423 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -342,8 +427,11 @@ discard block |
||
| 342 | 427 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 343 | 428 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 344 | 429 | } else { |
| 345 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 346 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 430 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 431 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 432 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 433 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 434 | + } |
|
| 347 | 435 | /* |
| 348 | 436 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 349 | 437 | print_r($this->all_flights[$id]); |
@@ -352,17 +440,23 @@ discard block |
||
| 352 | 440 | return ''; |
| 353 | 441 | } |
| 354 | 442 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 355 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
| 443 | + if ($globalDebug) { |
|
| 444 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
| 445 | + } |
|
| 356 | 446 | return ''; |
| 357 | 447 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 358 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n |
|
| 448 | + if ($globalDebug) { |
|
| 449 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n |
|
| 359 | 450 | "; |
| 451 | + } |
|
| 360 | 452 | return ''; |
| 361 | 453 | } elseif (!isset($line['datetime'])) { |
| 362 | 454 | date_default_timezone_set('UTC'); |
| 363 | 455 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 364 | 456 | } else { |
| 365 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 457 | + if ($globalDebug) { |
|
| 458 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 459 | + } |
|
| 366 | 460 | return ''; |
| 367 | 461 | } |
| 368 | 462 | |
@@ -383,30 +477,48 @@ discard block |
||
| 383 | 477 | |
| 384 | 478 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 385 | 479 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 386 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 480 | + if ($globalDebug) { |
|
| 481 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 482 | + } |
|
| 387 | 483 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 388 | 484 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 389 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 390 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 391 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 485 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 486 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 487 | + } elseif (isset($line['id'])) { |
|
| 488 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 489 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 490 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 491 | + } |
|
| 392 | 492 | } else { |
| 393 | 493 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
| 394 | 494 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | 495 | $timeelapsed = microtime(true); |
| 396 | 496 | $Spotter = new Spotter($this->db); |
| 397 | 497 | $fromsource = NULL; |
| 398 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 399 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 400 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 401 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 402 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 498 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 499 | + $fromsource = $globalAirlinesSource; |
|
| 500 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 501 | + $fromsource = 'vatsim'; |
|
| 502 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 503 | + $fromsource = 'ivao'; |
|
| 504 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 505 | + $fromsource = 'vatsim'; |
|
| 506 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 507 | + $fromsource = 'ivao'; |
|
| 508 | + } |
|
| 403 | 509 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
| 404 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 510 | + if ($globalDebug && $result != 'success') { |
|
| 511 | + echo '!!! ERROR : '.$result."\n"; |
|
| 512 | + } |
|
| 405 | 513 | $Spotter->db = null; |
| 406 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 514 | + if ($globalDebugTimeElapsed) { |
|
| 515 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 516 | + } |
|
| 407 | 517 | } |
| 408 | 518 | } |
| 409 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 519 | + } else { |
|
| 520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 521 | + } |
|
| 410 | 522 | |
| 411 | 523 | /* |
| 412 | 524 | if (!isset($line['id'])) { |
@@ -416,7 +528,9 @@ discard block |
||
| 416 | 528 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 417 | 529 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 418 | 530 | */ |
| 419 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 531 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 532 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 533 | + } |
|
| 420 | 534 | |
| 421 | 535 | //$putinarchive = true; |
| 422 | 536 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -434,7 +548,9 @@ discard block |
||
| 434 | 548 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 435 | 549 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 436 | 550 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
| 437 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 551 | + if ($globalDebugTimeElapsed) { |
|
| 552 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 553 | + } |
|
| 438 | 554 | } |
| 439 | 555 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 440 | 556 | $timeelapsed = microtime(true); |
@@ -448,7 +564,9 @@ discard block |
||
| 448 | 564 | $Translation->db = null; |
| 449 | 565 | } |
| 450 | 566 | $Spotter->db = null; |
| 451 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 567 | + if ($globalDebugTimeElapsed) { |
|
| 568 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 569 | + } |
|
| 452 | 570 | } |
| 453 | 571 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 454 | 572 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -457,9 +575,13 @@ discard block |
||
| 457 | 575 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
| 458 | 576 | } |
| 459 | 577 | } |
| 460 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 578 | + if (!isset($globalFork)) { |
|
| 579 | + $globalFork = TRUE; |
|
| 580 | + } |
|
| 461 | 581 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 462 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 582 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 583 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 584 | + } |
|
| 463 | 585 | } |
| 464 | 586 | } |
| 465 | 587 | } |
@@ -475,8 +597,12 @@ discard block |
||
| 475 | 597 | // use datetime |
| 476 | 598 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 477 | 599 | $speed = $speed*3.6; |
| 478 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 479 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 600 | + if ($speed < 1000) { |
|
| 601 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 602 | + } |
|
| 603 | + if ($globalDebug) { |
|
| 604 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 605 | + } |
|
| 480 | 606 | } |
| 481 | 607 | } |
| 482 | 608 | |
@@ -484,13 +610,21 @@ discard block |
||
| 484 | 610 | |
| 485 | 611 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 486 | 612 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
| 487 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 613 | + if ($globalDebug) { |
|
| 614 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 615 | + } |
|
| 488 | 616 | return false; |
| 489 | 617 | } |
| 490 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 491 | - else unset($timediff); |
|
| 492 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 493 | - else unset($timediff_archive); |
|
| 618 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 619 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 620 | + } else { |
|
| 621 | + unset($timediff); |
|
| 622 | + } |
|
| 623 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
| 624 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 625 | + } else { |
|
| 626 | + unset($timediff_archive); |
|
| 627 | + } |
|
| 494 | 628 | if ($this->tmd > 5 |
| 495 | 629 | || (isset($line['format_source']) |
| 496 | 630 | && $line['format_source'] == 'airwhere' |
@@ -526,16 +660,25 @@ discard block |
||
| 526 | 660 | $this->all_flights[$id]['putinarchive'] = true; |
| 527 | 661 | $this->tmd = 0; |
| 528 | 662 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 529 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 663 | + if ($globalDebug) { |
|
| 664 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 665 | + } |
|
| 530 | 666 | $timeelapsed = microtime(true); |
| 531 | 667 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 532 | 668 | $Spotter = new Spotter($this->db); |
| 533 | 669 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 534 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 535 | - else $this->all_flights[$id]['over_country'] = ''; |
|
| 670 | + if (!empty($all_country)) { |
|
| 671 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 672 | + } else { |
|
| 673 | + $this->all_flights[$id]['over_country'] = ''; |
|
| 674 | + } |
|
| 536 | 675 | $Spotter->db = null; |
| 537 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 538 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 676 | + if ($globalDebugTimeElapsed) { |
|
| 677 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 678 | + } |
|
| 679 | + if ($globalDebug) { |
|
| 680 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 681 | + } |
|
| 539 | 682 | } |
| 540 | 683 | } |
| 541 | 684 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -581,7 +724,9 @@ discard block |
||
| 581 | 724 | */ |
| 582 | 725 | } |
| 583 | 726 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 584 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 727 | + if ($line['longitude'] > 180) { |
|
| 728 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 729 | + } |
|
| 585 | 730 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 586 | 731 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 587 | 732 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -618,7 +763,9 @@ discard block |
||
| 618 | 763 | } |
| 619 | 764 | } |
| 620 | 765 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 621 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 766 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 767 | + $dataFound = true; |
|
| 768 | + } |
|
| 622 | 769 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 623 | 770 | } |
| 624 | 771 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -640,53 +787,79 @@ discard block |
||
| 640 | 787 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 641 | 788 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 642 | 789 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 643 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 644 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 645 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 790 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 791 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 792 | + } elseif (isset($line['id'])) { |
|
| 793 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 794 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 795 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 796 | + } |
|
| 797 | + } |
|
| 798 | + if ($line['ground'] != 1) { |
|
| 799 | + $line['ground'] = 0; |
|
| 646 | 800 | } |
| 647 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 648 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 649 | 802 | //$dataFound = true; |
| 650 | 803 | } |
| 651 | 804 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 652 | 805 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 653 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 806 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
| 807 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 808 | + } |
|
| 654 | 809 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 655 | 810 | $highlight = ''; |
| 656 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 657 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 658 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 811 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 812 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 813 | + } |
|
| 814 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 815 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 816 | + } |
|
| 817 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 818 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 819 | + } |
|
| 659 | 820 | if ($highlight != '') { |
| 660 | 821 | $timeelapsed = microtime(true); |
| 661 | 822 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 662 | 823 | $Spotter = new Spotter($this->db); |
| 663 | 824 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 664 | 825 | $Spotter->db = null; |
| 665 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 826 | + if ($globalDebugTimeElapsed) { |
|
| 827 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 828 | + } |
|
| 666 | 829 | } |
| 667 | 830 | //$putinarchive = true; |
| 668 | 831 | //$highlight = ''; |
| 669 | 832 | } |
| 670 | 833 | |
| 671 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 834 | + } else { |
|
| 835 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 836 | + } |
|
| 672 | 837 | //$dataFound = true; |
| 673 | 838 | } |
| 674 | 839 | |
| 675 | 840 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 676 | 841 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 677 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 842 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
| 843 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 844 | + } |
|
| 678 | 845 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 679 | 846 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 680 | 847 | //$dataFound = true; |
| 681 | 848 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 682 | 849 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 683 | 850 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 684 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
| 851 | + if ($globalDebug) { |
|
| 852 | + echo '--- Reset because of altitude'."\n"; |
|
| 853 | + } |
|
| 685 | 854 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 686 | 855 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 687 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 688 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 689 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 856 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 857 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 858 | + } elseif (isset($line['id'])) { |
|
| 859 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 860 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 861 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 862 | + } |
|
| 690 | 863 | } |
| 691 | 864 | } |
| 692 | 865 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -697,22 +870,32 @@ discard block |
||
| 697 | 870 | } |
| 698 | 871 | |
| 699 | 872 | if (isset($line['heading']) && $line['heading'] != '') { |
| 700 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 873 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
| 874 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 875 | + } |
|
| 701 | 876 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 702 | 877 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 703 | 878 | //$dataFound = true; |
| 704 | 879 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 705 | 880 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 706 | 881 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 707 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 708 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 882 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
| 883 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 884 | + } |
|
| 885 | + if ($globalDebug) { |
|
| 886 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 887 | + } |
|
| 709 | 888 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 710 | 889 | // If not enough messages and ACARS set heading to 0 |
| 711 | 890 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 712 | 891 | } |
| 713 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 714 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 715 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 892 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 893 | + $dataFound = false; |
|
| 894 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 895 | + $dataFound = false; |
|
| 896 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) { |
|
| 897 | + $dataFound = false; |
|
| 898 | + } |
|
| 716 | 899 | |
| 717 | 900 | // print_r($this->all_flights[$id]); |
| 718 | 901 | //gets the callsign from the last hour |
@@ -729,23 +912,38 @@ discard block |
||
| 729 | 912 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 730 | 913 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 731 | 914 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 732 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 915 | + if ($globalDebug) { |
|
| 916 | + echo "Check if aircraft is already in DB..."; |
|
| 917 | + } |
|
| 733 | 918 | $timeelapsed = microtime(true); |
| 734 | 919 | $SpotterLive = new SpotterLive($this->db); |
| 735 | 920 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 736 | 921 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 737 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 922 | + if ($globalDebugTimeElapsed) { |
|
| 923 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 924 | + } |
|
| 738 | 925 | } elseif (isset($line['id'])) { |
| 739 | 926 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 740 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 927 | + if ($globalDebugTimeElapsed) { |
|
| 928 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 929 | + } |
|
| 741 | 930 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 742 | 931 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 743 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 744 | - } else $recent_ident = ''; |
|
| 932 | + if ($globalDebugTimeElapsed) { |
|
| 933 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 934 | + } |
|
| 935 | + } else { |
|
| 936 | + $recent_ident = ''; |
|
| 937 | + } |
|
| 745 | 938 | $SpotterLive->db=null; |
| 746 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 747 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 748 | - } else $recent_ident = ''; |
|
| 939 | + if ($globalDebug && $recent_ident == '') { |
|
| 940 | + echo " Not in DB.\n"; |
|
| 941 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 942 | + echo " Already in DB.\n"; |
|
| 943 | + } |
|
| 944 | + } else { |
|
| 945 | + $recent_ident = ''; |
|
| 946 | + } |
|
| 749 | 947 | } else { |
| 750 | 948 | $recent_ident = ''; |
| 751 | 949 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -753,7 +951,9 @@ discard block |
||
| 753 | 951 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 754 | 952 | if($recent_ident == "") |
| 755 | 953 | { |
| 756 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 954 | + if ($globalDebug) { |
|
| 955 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 956 | + } |
|
| 757 | 957 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 758 | 958 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 759 | 959 | //adds the spotter data for the archive |
@@ -797,31 +997,49 @@ discard block |
||
| 797 | 997 | |
| 798 | 998 | if (!$ignoreImport) { |
| 799 | 999 | $highlight = ''; |
| 800 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 801 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 802 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 803 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1000 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 1001 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 1002 | + } |
|
| 1003 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 1004 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 1005 | + } |
|
| 1006 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 1007 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 1008 | + } |
|
| 1009 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1010 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1011 | + } |
|
| 804 | 1012 | $timeelapsed = microtime(true); |
| 805 | 1013 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 806 | 1014 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 807 | 1015 | $Spotter = new Spotter($this->db); |
| 808 | 1016 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
| 809 | 1017 | $Spotter->db = null; |
| 810 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 1018 | + if ($globalDebug && isset($result)) { |
|
| 1019 | + echo $result."\n"; |
|
| 1020 | + } |
|
| 811 | 1021 | } |
| 812 | 1022 | } |
| 813 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1023 | + if ($globalDebugTimeElapsed) { |
|
| 1024 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1025 | + } |
|
| 814 | 1026 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 815 | 1027 | |
| 816 | 1028 | // Add source stat in DB |
| 817 | 1029 | $Stats = new Stats($this->db); |
| 818 | 1030 | if (!empty($this->stats)) { |
| 819 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 1031 | + if ($globalDebug) { |
|
| 1032 | + echo 'Add source stats : '; |
|
| 1033 | + } |
|
| 820 | 1034 | foreach($this->stats as $date => $data) { |
| 821 | 1035 | foreach($data as $source => $sourced) { |
| 822 | 1036 | //print_r($sourced); |
| 823 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 824 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1037 | + if (isset($sourced['polar'])) { |
|
| 1038 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 1039 | + } |
|
| 1040 | + if (isset($sourced['hist'])) { |
|
| 1041 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1042 | + } |
|
| 825 | 1043 | if (isset($sourced['msg'])) { |
| 826 | 1044 | if (time() - $sourced['msg']['date'] > 10) { |
| 827 | 1045 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -834,13 +1052,17 @@ discard block |
||
| 834 | 1052 | unset($this->stats[$date]); |
| 835 | 1053 | } |
| 836 | 1054 | } |
| 837 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1055 | + if ($globalDebug) { |
|
| 1056 | + echo 'Done'."\n"; |
|
| 1057 | + } |
|
| 838 | 1058 | |
| 839 | 1059 | } |
| 840 | 1060 | $Stats->db = null; |
| 841 | 1061 | } |
| 842 | 1062 | $this->del(); |
| 843 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 1063 | + } elseif ($globalDebug) { |
|
| 1064 | + echo 'Ignore data'."\n"; |
|
| 1065 | + } |
|
| 844 | 1066 | //$ignoreImport = false; |
| 845 | 1067 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 846 | 1068 | //print_r($this->all_flights[$id]); |
@@ -857,7 +1079,9 @@ discard block |
||
| 857 | 1079 | */ |
| 858 | 1080 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 859 | 1081 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 860 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1082 | + if ($globalDebug) { |
|
| 1083 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1084 | + } |
|
| 861 | 1085 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 862 | 1086 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 863 | 1087 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -866,7 +1090,9 @@ discard block |
||
| 866 | 1090 | $SpotterLive->db=null; |
| 867 | 1091 | } |
| 868 | 1092 | } |
| 869 | - if ($globalDebug) echo " Done\n"; |
|
| 1093 | + if ($globalDebug) { |
|
| 1094 | + echo " Done\n"; |
|
| 1095 | + } |
|
| 870 | 1096 | $this->last_delete = time(); |
| 871 | 1097 | } |
| 872 | 1098 | } else { |
@@ -893,11 +1119,17 @@ discard block |
||
| 893 | 1119 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
| 894 | 1120 | if ($globalDebug) { |
| 895 | 1121 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 896 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 897 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1122 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1123 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1124 | + } else { |
|
| 1125 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1126 | + } |
|
| 898 | 1127 | } else { |
| 899 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 900 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1128 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1129 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1130 | + } else { |
|
| 1131 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1132 | + } |
|
| 901 | 1133 | } |
| 902 | 1134 | } |
| 903 | 1135 | $ignoreImport = false; |
@@ -943,22 +1175,30 @@ discard block |
||
| 943 | 1175 | |
| 944 | 1176 | if (!$ignoreImport) { |
| 945 | 1177 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 946 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1178 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1179 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1180 | + } |
|
| 947 | 1181 | $timeelapsed = microtime(true); |
| 948 | 1182 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 949 | 1183 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 950 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1184 | + if ($globalDebug) { |
|
| 1185 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1186 | + } |
|
| 951 | 1187 | $SpotterLive = new SpotterLive($this->db); |
| 952 | 1188 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 953 | 1189 | $SpotterLive->db = null; |
| 954 | - if ($globalDebug) echo $result."\n"; |
|
| 1190 | + if ($globalDebug) { |
|
| 1191 | + echo $result."\n"; |
|
| 1192 | + } |
|
| 955 | 1193 | } |
| 956 | 1194 | } |
| 957 | 1195 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 958 | 1196 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 959 | 1197 | } |
| 960 | 1198 | $this->all_flights[$id]['putinarchive'] = false; |
| 961 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1199 | + if ($globalDebugTimeElapsed) { |
|
| 1200 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1201 | + } |
|
| 962 | 1202 | |
| 963 | 1203 | // Put statistics in $this->stats variable |
| 964 | 1204 | //if ($line['format_source'] != 'aprs') { |
@@ -966,7 +1206,9 @@ discard block |
||
| 966 | 1206 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 967 | 1207 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 968 | 1208 | $source = $this->all_flights[$id]['source_name']; |
| 969 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 1209 | + if ($source == '') { |
|
| 1210 | + $source = $this->all_flights[$id]['format_source']; |
|
| 1211 | + } |
|
| 970 | 1212 | if (!isset($this->source_location[$source])) { |
| 971 | 1213 | $Location = new Source(); |
| 972 | 1214 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -987,7 +1229,9 @@ discard block |
||
| 987 | 1229 | $stats_heading = round($stats_heading/22.5); |
| 988 | 1230 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 989 | 1231 | $current_date = date('Y-m-d'); |
| 990 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1232 | + if ($stats_heading == 16) { |
|
| 1233 | + $stats_heading = 0; |
|
| 1234 | + } |
|
| 991 | 1235 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 992 | 1236 | for ($i=0;$i<=15;$i++) { |
| 993 | 1237 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1005,7 +1249,9 @@ discard block |
||
| 1005 | 1249 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1006 | 1250 | end($this->stats[$current_date][$source]['hist']); |
| 1007 | 1251 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 1008 | - } else $mini = 0; |
|
| 1252 | + } else { |
|
| 1253 | + $mini = 0; |
|
| 1254 | + } |
|
| 1009 | 1255 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1010 | 1256 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1011 | 1257 | } |
@@ -1017,19 +1263,27 @@ discard block |
||
| 1017 | 1263 | } |
| 1018 | 1264 | |
| 1019 | 1265 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1020 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1266 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1267 | + $send = true; |
|
| 1268 | + } |
|
| 1021 | 1269 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1022 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1270 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1271 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1272 | + } |
|
| 1023 | 1273 | //$this->del(); |
| 1024 | 1274 | |
| 1025 | 1275 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1026 | 1276 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 1027 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1277 | + if ($globalDebug) { |
|
| 1278 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1279 | + } |
|
| 1028 | 1280 | $SpotterLive = new SpotterLive($this->db); |
| 1029 | 1281 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 1030 | 1282 | $SpotterLive->db = null; |
| 1031 | 1283 | //SpotterLive->deleteLiveSpotterData(); |
| 1032 | - if ($globalDebug) echo " Done\n"; |
|
| 1284 | + if ($globalDebug) { |
|
| 1285 | + echo " Done\n"; |
|
| 1286 | + } |
|
| 1033 | 1287 | $this->last_delete_hourly = time(); |
| 1034 | 1288 | } else { |
| 1035 | 1289 | $this->del(); |
@@ -1041,7 +1295,9 @@ discard block |
||
| 1041 | 1295 | //$ignoreImport = false; |
| 1042 | 1296 | } |
| 1043 | 1297 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1044 | - if ($send) return $this->all_flights[$id]; |
|
| 1298 | + if ($send) { |
|
| 1299 | + return $this->all_flights[$id]; |
|
| 1300 | + } |
|
| 1045 | 1301 | } |
| 1046 | 1302 | } |
| 1047 | 1303 | } |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | $s3 = sin($bank/2); |
| 49 | 49 | $c1c2 = $c1*$c2; |
| 50 | 50 | $s1s2 = $s1*$s2; |
| 51 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
| 52 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
| 53 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 54 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 55 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
| 51 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
| 52 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
| 53 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 54 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 55 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
| 56 | 56 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
| 57 | 57 | |
| 58 | 58 | } |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | $min = false; |
| 74 | 74 | $allhistory = false; |
| 75 | 75 | $filter['source'] = array(); |
| 76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 76 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 77 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 79 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 80 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 81 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 82 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 83 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 84 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 85 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 86 | 86 | /* |
| 87 | 87 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 88 | 88 | $min = true; |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | $from_archive = true; |
| 130 | 130 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 131 | 131 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 132 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 133 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 134 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 135 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 136 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 137 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
| 132 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 133 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 134 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 135 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 136 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 137 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
| 138 | 138 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
| 139 | 139 | $from_archive = true; |
| 140 | 140 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | $begindate = $_COOKIE['archive_begin']; |
| 145 | 145 | $enddate = $_COOKIE['archive_end']; |
| 146 | 146 | |
| 147 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 149 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 147 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 149 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 150 | 150 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
| 151 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 151 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 152 | 152 | } elseif ($tracker) { |
| 153 | 153 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter); |
| 154 | 154 | } elseif ($marine) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | //print_r($spotter_array); |
| 160 | 160 | if (!empty($spotter_array)) { |
| 161 | 161 | if (isset($_GET['archive'])) { |
| 162 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 162 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 163 | 163 | } elseif ($tracker) { |
| 164 | 164 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
| 165 | 165 | } elseif ($marine) { |
@@ -170,16 +170,16 @@ discard block |
||
| 170 | 170 | if ($flightcnt == '') $flightcnt = 0; |
| 171 | 171 | } else $flightcnt = 0; |
| 172 | 172 | |
| 173 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 173 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 174 | 174 | $minitime = time(); |
| 175 | 175 | $maxitime = 0; |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | $modelsdb = array(); |
| 179 | 179 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
| 180 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
| 181 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
| 182 | - if (isset($row[1]) ){ |
|
| 180 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
| 181 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
| 182 | + if (isset($row[1])) { |
|
| 183 | 183 | $model = $row[0]; |
| 184 | 184 | $modelsdb[$model] = $row[1]; |
| 185 | 185 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $output .= '},'; |
| 216 | 216 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 217 | 217 | { |
| 218 | - foreach($spotter_array as $spotter_item) |
|
| 218 | + foreach ($spotter_array as $spotter_item) |
|
| 219 | 219 | { |
| 220 | 220 | $j++; |
| 221 | 221 | if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $output .= '"cartographicDegrees": ['; |
| 541 | 541 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
| 542 | 542 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 543 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 543 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 544 | 544 | $output .= $spotter_item['longitude'].', '; |
| 545 | 545 | $output .= $spotter_item['latitude']; |
| 546 | 546 | $prevlong = $spotter_item['longitude']; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 560 | 560 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
| 561 | 561 | } else { |
| 562 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 562 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 563 | 563 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 564 | 564 | if ($spotter_item['ground_speed'] == 0) { |
| 565 | 565 | $output .= $prevlong.', '; |
@@ -593,9 +593,9 @@ discard block |
||
| 593 | 593 | } |
| 594 | 594 | $output .= ']'; |
| 595 | 595 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 596 | - if ((time()-$globalLiveInterval) > $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
| 597 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 598 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 599 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
| 596 | + if ((time() - $globalLiveInterval) > $minitime) $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
| 597 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 598 | +} else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 599 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
| 600 | 600 | print $output; |
| 601 | 601 | ?> |
@@ -8,8 +8,12 @@ discard block |
||
| 8 | 8 | } |
| 9 | 9 | $tracker = false; |
| 10 | 10 | $marine = false; |
| 11 | -if (isset($_GET['tracker'])) $tracker = true; |
|
| 12 | -if (isset($_GET['marine'])) $marine = true; |
|
| 11 | +if (isset($_GET['tracker'])) { |
|
| 12 | + $tracker = true; |
|
| 13 | +} |
|
| 14 | +if (isset($_GET['marine'])) { |
|
| 15 | + $marine = true; |
|
| 16 | +} |
|
| 13 | 17 | if ($tracker) { |
| 14 | 18 | require_once('require/class.Tracker.php'); |
| 15 | 19 | require_once('require/class.TrackerLive.php'); |
@@ -66,23 +70,46 @@ discard block |
||
| 66 | 70 | } |
| 67 | 71 | header('Content-Type: text/javascript'); |
| 68 | 72 | |
| 69 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 70 | -else $compress = $globalJsonCompress; |
|
| 73 | +if (!isset($globalJsonCompress)) { |
|
| 74 | + $compress = true; |
|
| 75 | +} else { |
|
| 76 | + $compress = $globalJsonCompress; |
|
| 77 | +} |
|
| 71 | 78 | |
| 72 | 79 | $from_archive = false; |
| 73 | 80 | $min = false; |
| 74 | 81 | $allhistory = false; |
| 75 | 82 | $filter['source'] = array(); |
| 76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 83 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
| 84 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 85 | +} |
|
| 86 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
| 87 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 88 | +} |
|
| 89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
| 90 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 91 | +} |
|
| 92 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
| 93 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 94 | +} |
|
| 95 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
| 96 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 97 | +} |
|
| 98 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
| 99 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 100 | +} |
|
| 101 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
| 102 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 103 | +} |
|
| 104 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
| 105 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 106 | +} |
|
| 107 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
| 108 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 109 | +} |
|
| 110 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
| 111 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 112 | +} |
|
| 86 | 113 | /* |
| 87 | 114 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 88 | 115 | $min = true; |
@@ -167,8 +194,12 @@ discard block |
||
| 167 | 194 | } else { |
| 168 | 195 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 169 | 196 | } |
| 170 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 171 | -} else $flightcnt = 0; |
|
| 197 | + if ($flightcnt == '') { |
|
| 198 | + $flightcnt = 0; |
|
| 199 | + } |
|
| 200 | + } else { |
|
| 201 | + $flightcnt = 0; |
|
| 202 | +} |
|
| 172 | 203 | |
| 173 | 204 | $sqltime = round(microtime(true)-$begintime,2); |
| 174 | 205 | $minitime = time(); |
@@ -192,7 +223,9 @@ discard block |
||
| 192 | 223 | $j = 0; |
| 193 | 224 | $prev_flightaware_id = ''; |
| 194 | 225 | $speed = 1; |
| 195 | -if (isset($archivespeed)) $speed = $archivespeed; |
|
| 226 | +if (isset($archivespeed)) { |
|
| 227 | + $speed = $archivespeed; |
|
| 228 | +} |
|
| 196 | 229 | $output = '['; |
| 197 | 230 | if ($tracker) { |
| 198 | 231 | $output .= '{"id" : "document", "name" : "tracker","version" : "1.0"'; |
@@ -218,7 +251,9 @@ discard block |
||
| 218 | 251 | foreach($spotter_array as $spotter_item) |
| 219 | 252 | { |
| 220 | 253 | $j++; |
| 221 | - if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
|
| 254 | + if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') { |
|
| 255 | + $heightrelative = 'RELATIVE_TO_GROUND'; |
|
| 256 | + } |
|
| 222 | 257 | date_default_timezone_set('UTC'); |
| 223 | 258 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
| 224 | 259 | { |
@@ -227,9 +262,13 @@ discard block |
||
| 227 | 262 | $image = "images/placeholder_thumb.png"; |
| 228 | 263 | } |
| 229 | 264 | |
| 230 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
| 231 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
| 232 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
| 265 | + if (isset($spotter_item['flightaware_id'])) { |
|
| 266 | + $id = $spotter_item['flightaware_id']; |
|
| 267 | + } elseif (isset($spotter_item['famtrackid'])) { |
|
| 268 | + $id = $spotter_item['famtrackid']; |
|
| 269 | + } elseif (isset($spotter_item['fammarine_id'])) { |
|
| 270 | + $id = $spotter_item['fammarine_id']; |
|
| 271 | + } |
|
| 233 | 272 | if ($prev_flightaware_id != $id) { |
| 234 | 273 | if ($prev_flightaware_id != '') { |
| 235 | 274 | $output .= ']'; |
@@ -271,7 +310,9 @@ discard block |
||
| 271 | 310 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
| 272 | 311 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
| 273 | 312 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
| 274 | - } else $aircraft_shadow = ''; |
|
| 313 | + } else { |
|
| 314 | + $aircraft_shadow = ''; |
|
| 315 | + } |
|
| 275 | 316 | $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
| 276 | 317 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) { |
| 277 | 318 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
@@ -279,7 +320,9 @@ discard block |
||
| 279 | 320 | } |
| 280 | 321 | $output .= '},'; |
| 281 | 322 | } |
| 282 | - } else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
| 323 | + } else { |
|
| 324 | + $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
| 325 | + } |
|
| 283 | 326 | } elseif ($one3dmodel) { |
| 284 | 327 | if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') { |
| 285 | 328 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -310,7 +353,9 @@ discard block |
||
| 310 | 353 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
| 311 | 354 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
| 312 | 355 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
| 313 | - } else $aircraft_shadow = ''; |
|
| 356 | + } else { |
|
| 357 | + $aircraft_shadow = ''; |
|
| 358 | + } |
|
| 314 | 359 | if ($aircraft_shadow != '') { |
| 315 | 360 | if (isset($modelsdb[$aircraft_shadow])) { |
| 316 | 361 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -447,7 +492,9 @@ discard block |
||
| 447 | 492 | } |
| 448 | 493 | $output .= '},'; |
| 449 | 494 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
| 450 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 495 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 496 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 497 | + } |
|
| 451 | 498 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
| 452 | 499 | } |
| 453 | 500 | } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
@@ -469,7 +516,9 @@ discard block |
||
| 469 | 516 | } |
| 470 | 517 | $output .= '},'; |
| 471 | 518 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
| 472 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 519 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 520 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 521 | + } |
|
| 473 | 522 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
| 474 | 523 | } |
| 475 | 524 | } else { |
@@ -482,7 +531,9 @@ discard block |
||
| 482 | 531 | } |
| 483 | 532 | $output .= '},'; |
| 484 | 533 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
| 485 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 534 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 535 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 536 | + } |
|
| 486 | 537 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
| 487 | 538 | } |
| 488 | 539 | } elseif ($tracker && isset($spotter_item['type'])) { |
@@ -538,8 +589,12 @@ discard block |
||
| 538 | 589 | // $output .= '"interpolationDegree" : 5,'; |
| 539 | 590 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
| 540 | 591 | $output .= '"cartographicDegrees": ['; |
| 541 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
| 542 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
| 592 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
| 593 | + $minitime = strtotime($spotter_item['date']); |
|
| 594 | + } |
|
| 595 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
| 596 | + $maxitime = strtotime($spotter_item['date']); |
|
| 597 | + } |
|
| 543 | 598 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
| 544 | 599 | $output .= $spotter_item['longitude'].', '; |
| 545 | 600 | $output .= $spotter_item['latitude']; |
@@ -553,19 +608,26 @@ discard block |
||
| 553 | 608 | $output .= ', '.round($spotter_item['altitude']*30.48); |
| 554 | 609 | $prevalt = round($spotter_item['altitude']*30.48); |
| 555 | 610 | } |
| 556 | - } else $output .= ', 0'; |
|
| 611 | + } else { |
|
| 612 | + $output .= ', 0'; |
|
| 613 | + } |
|
| 557 | 614 | //$orientation = '"orientation" : { '; |
| 558 | 615 | //$orientation .= '"unitQuaternion": ['; |
| 559 | 616 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 560 | 617 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
| 561 | 618 | } else { |
| 562 | 619 | $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
| 563 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
| 620 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
| 621 | + $maxitime = strtotime($spotter_item['date']); |
|
| 622 | + } |
|
| 564 | 623 | if ($spotter_item['ground_speed'] == 0) { |
| 565 | 624 | $output .= $prevlong.', '; |
| 566 | 625 | $output .= $prevlat; |
| 567 | - if (!$tracker && !$marine) $output .= ', '.$prevalt; |
|
| 568 | - else $output .= ', 0'; |
|
| 626 | + if (!$tracker && !$marine) { |
|
| 627 | + $output .= ', '.$prevalt; |
|
| 628 | + } else { |
|
| 629 | + $output .= ', 0'; |
|
| 630 | + } |
|
| 569 | 631 | } else { |
| 570 | 632 | $output .= $spotter_item['longitude'].', '; |
| 571 | 633 | $output .= $spotter_item['latitude']; |
@@ -577,10 +639,15 @@ discard block |
||
| 577 | 639 | $output .= ', 0'; |
| 578 | 640 | } |
| 579 | 641 | } else { |
| 580 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
| 581 | - else $output .= ', '.round($spotter_item['altitude']*30.48); |
|
| 642 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 643 | + $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
| 644 | + } else { |
|
| 645 | + $output .= ', '.round($spotter_item['altitude']*30.48); |
|
| 646 | + } |
|
| 582 | 647 | } |
| 583 | - } else $output .= ', 0'; |
|
| 648 | + } else { |
|
| 649 | + $output .= ', 0'; |
|
| 650 | + } |
|
| 584 | 651 | } |
| 585 | 652 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 586 | 653 | //$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
@@ -593,9 +660,14 @@ discard block |
||
| 593 | 660 | } |
| 594 | 661 | $output .= ']'; |
| 595 | 662 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 596 | - if ((time()-$globalLiveInterval) > $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
| 597 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 598 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 663 | + if ((time()-$globalLiveInterval) > $minitime) { |
|
| 664 | + $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
| 665 | + } else { |
|
| 666 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 667 | + } |
|
| 668 | + } else { |
|
| 669 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 670 | +} |
|
| 599 | 671 | $output = str_replace('%maxitime%',date("c",$maxitime),$output); |
| 600 | 672 | print $output; |
| 601 | 673 | ?> |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 18 | 18 | if (isset($globalMarine) && $globalMarine) { |
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,42 +25,42 @@ discard block |
||
| 25 | 25 | // Check if schema is at latest version |
| 26 | 26 | $Connection = new Connection(); |
| 27 | 27 | if ($Connection->latest() === false) { |
| 28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 29 | - exit(); |
|
| 28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 29 | + exit(); |
|
| 30 | 30 | } |
| 31 | 31 | if (PHP_SAPI != 'cli') { |
| 32 | - echo "This script MUST be called from console, not a web browser."; |
|
| 32 | + echo "This script MUST be called from console, not a web browser."; |
|
| 33 | 33 | // exit(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // This is to be compatible with old version of settings.php |
| 37 | 37 | if (!isset($globalSources)) { |
| 38 | - if (isset($globalSBS1Hosts)) { |
|
| 39 | - //$hosts = $globalSBS1Hosts; |
|
| 40 | - foreach ($globalSBS1Hosts as $host) { |
|
| 41 | - $globalSources[] = array('host' => $host); |
|
| 42 | - } |
|
| 43 | - } else { |
|
| 44 | - if (!isset($globalSBS1Host)) { |
|
| 45 | - echo '$globalSources MUST be defined !'; |
|
| 46 | - die; |
|
| 38 | + if (isset($globalSBS1Hosts)) { |
|
| 39 | + //$hosts = $globalSBS1Hosts; |
|
| 40 | + foreach ($globalSBS1Hosts as $host) { |
|
| 41 | + $globalSources[] = array('host' => $host); |
|
| 42 | + } |
|
| 43 | + } else { |
|
| 44 | + if (!isset($globalSBS1Host)) { |
|
| 45 | + echo '$globalSources MUST be defined !'; |
|
| 46 | + die; |
|
| 47 | 47 | } |
| 48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
| 54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 56 | 56 | if (isset($options['s'])) { |
| 57 | - $globalSources = array(); |
|
| 58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 59 | - else $globalSources[] = array('host' => $options['s']); |
|
| 57 | + $globalSources = array(); |
|
| 58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 59 | + else $globalSources[] = array('host' => $options['s']); |
|
| 60 | 60 | } elseif (isset($options['source'])) { |
| 61 | - $globalSources = array(); |
|
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['source']); |
|
| 61 | + $globalSources = array(); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 63 | + else $globalSources[] = array('host' => $options['source']); |
|
| 64 | 64 | } |
| 65 | 65 | if (isset($options['aprsserverhost'])) { |
| 66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 76 | 76 | else $id_source = 1; |
| 77 | 77 | if (isset($globalServer) && $globalServer) { |
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 79 | - $SI=new SpotterServer(); |
|
| 78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 79 | + $SI=new SpotterServer(); |
|
| 80 | 80 | /* |
| 81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | } else $SI=new SpotterImport($Connection->db); |
| 86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 87 | 87 | if (isset($globalMarine) && $globalMarine) { |
| 88 | - $AIS = new AIS(); |
|
| 89 | - $MI = new MarineImport($Connection->db); |
|
| 88 | + $AIS = new AIS(); |
|
| 89 | + $MI = new MarineImport($Connection->db); |
|
| 90 | 90 | } |
| 91 | 91 | //$APRS=new APRS($Connection->db); |
| 92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | //$servertz = system('date +%Z'); |
| 98 | 98 | // signal handler - playing nice with sockets and dump1090 |
| 99 | 99 | if (function_exists('pcntl_fork')) { |
| 100 | - pcntl_signal(SIGINT, function() { |
|
| 101 | - global $sockets; |
|
| 102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 103 | - die("Bye!\n"); |
|
| 104 | - }); |
|
| 105 | - pcntl_signal_dispatch(); |
|
| 100 | + pcntl_signal(SIGINT, function() { |
|
| 101 | + global $sockets; |
|
| 102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 103 | + die("Bye!\n"); |
|
| 104 | + }); |
|
| 105 | + pcntl_signal_dispatch(); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
| 112 | 112 | $reset = 0; |
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 117 | - $reset++; |
|
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | - foreach ($hosts as $id => $value) { |
|
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 117 | + $reset++; |
|
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | + foreach ($hosts as $id => $value) { |
|
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'deltadbtxt'; |
|
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | - //$last_exec['deltadbtxt'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'vatsimtxt'; |
|
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | - //$last_exec['vatsimtxt'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | - /* |
|
| 124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'deltadbtxt'; |
|
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | + //$last_exec['deltadbtxt'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'vatsimtxt'; |
|
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | + //$last_exec['vatsimtxt'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | + /* |
|
| 145 | 145 | // Disabled for now, site change source format |
| 146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,118 +153,118 @@ discard block |
||
| 153 | 153 | exit(0); |
| 154 | 154 | } |
| 155 | 155 | */ |
| 156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 157 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 159 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 163 | - exit(0); |
|
| 164 | - } |
|
| 165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 166 | - //$formats[$id] = 'phpvmacars'; |
|
| 167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 168 | - //$last_exec['phpvmacars'] = 0; |
|
| 169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 171 | - //$formats[$id] = 'phpvmacars'; |
|
| 172 | - $globalSources[$id]['format'] = 'vam'; |
|
| 173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 175 | - //$formats[$id] = 'whazzup'; |
|
| 176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 177 | - //$last_exec['whazzup'] = 0; |
|
| 178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 180 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 183 | - //$formats[$id] = 'pirepsjson'; |
|
| 184 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 185 | - //$last_exec['pirepsjson'] = 0; |
|
| 186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 188 | - //$formats[$id] = 'fr24json'; |
|
| 189 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 190 | - //$last_exec['fr24json'] = 0; |
|
| 191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 192 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 193 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 194 | - exit(0); |
|
| 195 | - } |
|
| 196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 197 | - //$formats[$id] = 'fr24json'; |
|
| 198 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 199 | - //$last_exec['fr24json'] = 0; |
|
| 200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 201 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 202 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 203 | - exit(0); |
|
| 204 | - } |
|
| 205 | - //} else if (preg_match('/10001/',$host)) { |
|
| 206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 207 | - //$formats[$id] = 'tsv'; |
|
| 208 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 210 | - } |
|
| 211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 212 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 214 | - if ($idf !== false) { |
|
| 215 | - $httpfeeds[$id] = $idf; |
|
| 216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 217 | - } |
|
| 218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 221 | - $hostport = explode(':',$host); |
|
| 222 | - if (isset($hostport[1])) { |
|
| 156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 157 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 159 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 163 | + exit(0); |
|
| 164 | + } |
|
| 165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 166 | + //$formats[$id] = 'phpvmacars'; |
|
| 167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 168 | + //$last_exec['phpvmacars'] = 0; |
|
| 169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 171 | + //$formats[$id] = 'phpvmacars'; |
|
| 172 | + $globalSources[$id]['format'] = 'vam'; |
|
| 173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 175 | + //$formats[$id] = 'whazzup'; |
|
| 176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 177 | + //$last_exec['whazzup'] = 0; |
|
| 178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 179 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 180 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 181 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 182 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 183 | + //$formats[$id] = 'pirepsjson'; |
|
| 184 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 185 | + //$last_exec['pirepsjson'] = 0; |
|
| 186 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 188 | + //$formats[$id] = 'fr24json'; |
|
| 189 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 190 | + //$last_exec['fr24json'] = 0; |
|
| 191 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 192 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 193 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 194 | + exit(0); |
|
| 195 | + } |
|
| 196 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 197 | + //$formats[$id] = 'fr24json'; |
|
| 198 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 199 | + //$last_exec['fr24json'] = 0; |
|
| 200 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 201 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 202 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 203 | + exit(0); |
|
| 204 | + } |
|
| 205 | + //} else if (preg_match('/10001/',$host)) { |
|
| 206 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 207 | + //$formats[$id] = 'tsv'; |
|
| 208 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 209 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 210 | + } |
|
| 211 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 212 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 213 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 214 | + if ($idf !== false) { |
|
| 215 | + $httpfeeds[$id] = $idf; |
|
| 216 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 217 | + } |
|
| 218 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 219 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 220 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 221 | + $hostport = explode(':',$host); |
|
| 222 | + if (isset($hostport[1])) { |
|
| 223 | 223 | $port = $hostport[1]; |
| 224 | 224 | $hostn = $hostport[0]; |
| 225 | - } else { |
|
| 225 | + } else { |
|
| 226 | 226 | $port = $globalSources[$id]['port']; |
| 227 | 227 | $hostn = $globalSources[$id]['host']; |
| 228 | - } |
|
| 229 | - $Common = new Common(); |
|
| 230 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 232 | - } else { |
|
| 233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 234 | - } |
|
| 235 | - if ($s) { |
|
| 236 | - $sockets[$id] = $s; |
|
| 237 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 228 | + } |
|
| 229 | + $Common = new Common(); |
|
| 230 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 231 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 232 | + } else { |
|
| 233 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 234 | + } |
|
| 235 | + if ($s) { |
|
| 236 | + $sockets[$id] = $s; |
|
| 237 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 238 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 239 | 239 | //$formats[$id] = 'aprs'; |
| 240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
| 241 | 241 | //$aprs_connect = 0; |
| 242 | 242 | //$use_aprs = true; |
| 243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 243 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
| 245 | - } elseif ($port == '10001') { |
|
| 246 | - //$formats[$id] = 'tsv'; |
|
| 247 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 248 | - } elseif ($port == '30002') { |
|
| 249 | - //$formats[$id] = 'raw'; |
|
| 250 | - $globalSources[$id]['format'] = 'raw'; |
|
| 251 | - } elseif ($port == '5001') { |
|
| 252 | - //$formats[$id] = 'raw'; |
|
| 253 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 254 | - } elseif ($port == '30005') { |
|
| 245 | + } elseif ($port == '10001') { |
|
| 246 | + //$formats[$id] = 'tsv'; |
|
| 247 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 248 | + } elseif ($port == '30002') { |
|
| 249 | + //$formats[$id] = 'raw'; |
|
| 250 | + $globalSources[$id]['format'] = 'raw'; |
|
| 251 | + } elseif ($port == '5001') { |
|
| 252 | + //$formats[$id] = 'raw'; |
|
| 253 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 254 | + } elseif ($port == '30005') { |
|
| 255 | 255 | // Not yet supported |
| 256 | - //$formats[$id] = 'beast'; |
|
| 257 | - $globalSources[$id]['format'] = 'beast'; |
|
| 258 | - //} else $formats[$id] = 'sbs'; |
|
| 259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 260 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 256 | + //$formats[$id] = 'beast'; |
|
| 257 | + $globalSources[$id]['format'] = 'beast'; |
|
| 258 | + //} else $formats[$id] = 'sbs'; |
|
| 259 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 260 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 261 | 261 | } |
| 262 | 262 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 263 | - } else { |
|
| 263 | + } else { |
|
| 264 | 264 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | 268 | } |
| 269 | 269 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 270 | 270 | |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | //connect_all($globalSources); |
| 288 | 288 | |
| 289 | 289 | if (isset($globalProxy) && $globalProxy) { |
| 290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 291 | 291 | } else { |
| 292 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 292 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // APRS Configuration |
@@ -298,18 +298,18 @@ discard block |
||
| 298 | 298 | die; |
| 299 | 299 | } |
| 300 | 300 | foreach ($globalSources as $key => $source) { |
| 301 | - if (!isset($source['format'])) { |
|
| 302 | - $globalSources[$key]['format'] = 'auto'; |
|
| 303 | - } |
|
| 301 | + if (!isset($source['format'])) { |
|
| 302 | + $globalSources[$key]['format'] = 'auto'; |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | connect_all($globalSources); |
| 306 | 306 | foreach ($globalSources as $key => $source) { |
| 307 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 307 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 308 | 308 | $aprs_connect = 0; |
| 309 | 309 | $use_aprs = true; |
| 310 | 310 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 311 | 311 | break; |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | if ($use_aprs) { |
@@ -350,115 +350,115 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 352 | 352 | while ($i > 0) { |
| 353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 354 | - // Delete old ATC |
|
| 355 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 353 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 354 | + // Delete old ATC |
|
| 355 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 357 | - $ATC->deleteOldATC(); |
|
| 358 | - } |
|
| 357 | + $ATC->deleteOldATC(); |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - if (count($last_exec) == count($globalSources)) { |
|
| 360 | + if (count($last_exec) == count($globalSources)) { |
|
| 361 | 361 | $max = $globalMinFetch; |
| 362 | 362 | foreach ($last_exec as $last) { |
| 363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 363 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 364 | 364 | } |
| 365 | 365 | if ($max != $globalMinFetch) { |
| 366 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 367 | - sleep($globalMinFetch-$max+2); |
|
| 366 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 367 | + sleep($globalMinFetch-$max+2); |
|
| 368 | + } |
|
| 368 | 369 | } |
| 369 | - } |
|
| 370 | 370 | |
| 371 | 371 | |
| 372 | - //foreach ($formats as $id => $value) { |
|
| 373 | - foreach ($globalSources as $id => $value) { |
|
| 372 | + //foreach ($formats as $id => $value) { |
|
| 373 | + foreach ($globalSources as $id => $value) { |
|
| 374 | 374 | date_default_timezone_set('UTC'); |
| 375 | 375 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 376 | 376 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 377 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 378 | - $buffer = $Common->getData($value['host']); |
|
| 379 | - if ($buffer != '') $reset = 0; |
|
| 380 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 381 | - $buffer = explode('\n',$buffer); |
|
| 382 | - foreach ($buffer as $line) { |
|
| 383 | - if ($line != '' && count($line) > 7) { |
|
| 384 | - $line = explode(',', $line); |
|
| 385 | - $data = array(); |
|
| 386 | - $data['hex'] = $line[1]; // hex |
|
| 387 | - $data['ident'] = $line[2]; // ident |
|
| 388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 393 | - $data['verticalrate'] = ''; // vertical rate |
|
| 394 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 395 | - $data['emergency'] = ''; // emergency |
|
| 396 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 397 | - $data['format_source'] = 'deltadbtxt'; |
|
| 398 | - $data['id_source'] = $id_source; |
|
| 399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 402 | - $SI->add($data); |
|
| 403 | - unset($data); |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - $last_exec[$id]['last'] = time(); |
|
| 377 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 378 | + $buffer = $Common->getData($value['host']); |
|
| 379 | + if ($buffer != '') $reset = 0; |
|
| 380 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 381 | + $buffer = explode('\n',$buffer); |
|
| 382 | + foreach ($buffer as $line) { |
|
| 383 | + if ($line != '' && count($line) > 7) { |
|
| 384 | + $line = explode(',', $line); |
|
| 385 | + $data = array(); |
|
| 386 | + $data['hex'] = $line[1]; // hex |
|
| 387 | + $data['ident'] = $line[2]; // ident |
|
| 388 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 389 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 390 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 391 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 392 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 393 | + $data['verticalrate'] = ''; // vertical rate |
|
| 394 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 395 | + $data['emergency'] = ''; // emergency |
|
| 396 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 397 | + $data['format_source'] = 'deltadbtxt'; |
|
| 398 | + $data['id_source'] = $id_source; |
|
| 399 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 400 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 401 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 402 | + $SI->add($data); |
|
| 403 | + unset($data); |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + $last_exec[$id]['last'] = time(); |
|
| 407 | 407 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 408 | - date_default_timezone_set('CET'); |
|
| 409 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 410 | - date_default_timezone_set('UTC'); |
|
| 411 | - if ($buffer != '') $reset = 0; |
|
| 412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 413 | - $buffer = explode('\n',$buffer); |
|
| 414 | - foreach ($buffer as $line) { |
|
| 408 | + date_default_timezone_set('CET'); |
|
| 409 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 410 | + date_default_timezone_set('UTC'); |
|
| 411 | + if ($buffer != '') $reset = 0; |
|
| 412 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 413 | + $buffer = explode('\n',$buffer); |
|
| 414 | + foreach ($buffer as $line) { |
|
| 415 | 415 | if ($line != '') { |
| 416 | - echo "'".$line."'\n"; |
|
| 417 | - $add = false; |
|
| 418 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 419 | - $data = array(); |
|
| 420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 430 | - if (isset($ais_data['timestamp'])) { |
|
| 416 | + echo "'".$line."'\n"; |
|
| 417 | + $add = false; |
|
| 418 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 419 | + $data = array(); |
|
| 420 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 421 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 422 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 423 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 424 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 425 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 426 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 427 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 428 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 429 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 430 | + if (isset($ais_data['timestamp'])) { |
|
| 431 | 431 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 432 | 432 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 433 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 434 | - $add = true; |
|
| 433 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 434 | + $add = true; |
|
| 435 | 435 | } |
| 436 | - } else { |
|
| 436 | + } else { |
|
| 437 | 437 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 438 | 438 | $add = true; |
| 439 | - } |
|
| 440 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 441 | - $data['id_source'] = $id_source; |
|
| 442 | - //print_r($data); |
|
| 443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 445 | - unset($data); |
|
| 439 | + } |
|
| 440 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 441 | + $data['id_source'] = $id_source; |
|
| 442 | + //print_r($data); |
|
| 443 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 444 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 445 | + unset($data); |
|
| 446 | 446 | } |
| 447 | - } |
|
| 448 | - $last_exec[$id]['last'] = time(); |
|
| 447 | + } |
|
| 448 | + $last_exec[$id]['last'] = time(); |
|
| 449 | 449 | } elseif ($value['format'] == 'aisnmeahttp') { |
| 450 | - $arr = $httpfeeds; |
|
| 451 | - $w = $e = null; |
|
| 450 | + $arr = $httpfeeds; |
|
| 451 | + $w = $e = null; |
|
| 452 | 452 | |
| 453 | - if (isset($arr[$id])) { |
|
| 453 | + if (isset($arr[$id])) { |
|
| 454 | 454 | $nn = stream_select($arr,$w,$e,$timeout); |
| 455 | 455 | if ($nn > 0) { |
| 456 | - foreach ($httpfeeds as $feed) { |
|
| 456 | + foreach ($httpfeeds as $feed) { |
|
| 457 | 457 | $buffer = stream_get_line($feed,2000,"\n"); |
| 458 | 458 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 459 | 459 | $buffer = explode('\n',$buffer); |
| 460 | 460 | foreach ($buffer as $line) { |
| 461 | - if ($line != '') { |
|
| 461 | + if ($line != '') { |
|
| 462 | 462 | $ais_data = $AIS->parse_line(trim($line)); |
| 463 | 463 | $data = array(); |
| 464 | 464 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -476,96 +476,96 @@ discard block |
||
| 476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 477 | 477 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 478 | 478 | if (isset($ais_data['timestamp'])) { |
| 479 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 479 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 480 | 480 | } else { |
| 481 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 481 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 482 | 482 | } |
| 483 | 483 | $data['format_source'] = 'aisnmeahttp'; |
| 484 | 484 | $data['id_source'] = $id_source; |
| 485 | 485 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 486 | 486 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
| 487 | 487 | unset($data); |
| 488 | - } |
|
| 488 | + } |
|
| 489 | + } |
|
| 489 | 490 | } |
| 490 | - } |
|
| 491 | 491 | } else { |
| 492 | - $format = $value['format']; |
|
| 493 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 494 | - else $tt[$format] = 0; |
|
| 495 | - if ($tt[$format] > 30) { |
|
| 492 | + $format = $value['format']; |
|
| 493 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 494 | + else $tt[$format] = 0; |
|
| 495 | + if ($tt[$format] > 30) { |
|
| 496 | 496 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 497 | 497 | sleep(2); |
| 498 | 498 | $sourceeen[] = $value; |
| 499 | 499 | connect_all($sourceeen); |
| 500 | 500 | $sourceeen = array(); |
| 501 | - } |
|
| 501 | + } |
|
| 502 | + } |
|
| 502 | 503 | } |
| 503 | - } |
|
| 504 | 504 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 506 | - if ($buffer != '') { |
|
| 505 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 506 | + if ($buffer != '') { |
|
| 507 | 507 | //echo $buffer; |
| 508 | 508 | $all_data = json_decode($buffer,true); |
| 509 | 509 | //print_r($all_data); |
| 510 | 510 | if (isset($all_data[0]['DATA'])) { |
| 511 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 511 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 512 | 512 | if ($line != '') { |
| 513 | - $data = array(); |
|
| 514 | - $data['ident'] = $line['NAME']; |
|
| 515 | - $data['mmsi'] = $line['MMSI']; |
|
| 516 | - $data['speed'] = $line['SOG']; |
|
| 517 | - $data['heading'] = $line['COG']; |
|
| 518 | - $data['latitude'] = $line['LAT']; |
|
| 519 | - $data['longitude'] = $line['LNG']; |
|
| 520 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 521 | - $data['imo'] = $line['IMO']; |
|
| 522 | - //$data['arrival_code'] = $ais_data['destination']; |
|
| 523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 524 | - $data['format_source'] = 'myshiptracking'; |
|
| 525 | - $data['id_source'] = $id_source; |
|
| 526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 527 | - $MI->add($data); |
|
| 528 | - unset($data); |
|
| 513 | + $data = array(); |
|
| 514 | + $data['ident'] = $line['NAME']; |
|
| 515 | + $data['mmsi'] = $line['MMSI']; |
|
| 516 | + $data['speed'] = $line['SOG']; |
|
| 517 | + $data['heading'] = $line['COG']; |
|
| 518 | + $data['latitude'] = $line['LAT']; |
|
| 519 | + $data['longitude'] = $line['LNG']; |
|
| 520 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 521 | + $data['imo'] = $line['IMO']; |
|
| 522 | + //$data['arrival_code'] = $ais_data['destination']; |
|
| 523 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 524 | + $data['format_source'] = 'myshiptracking'; |
|
| 525 | + $data['id_source'] = $id_source; |
|
| 526 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 527 | + $MI->add($data); |
|
| 528 | + unset($data); |
|
| 529 | + } |
|
| 529 | 530 | } |
| 530 | - } |
|
| 531 | 531 | } |
| 532 | - } |
|
| 533 | - $last_exec[$id]['last'] = time(); |
|
| 532 | + } |
|
| 533 | + $last_exec[$id]['last'] = time(); |
|
| 534 | 534 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 535 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 536 | - if ($buffer != '') { |
|
| 535 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 536 | + if ($buffer != '') { |
|
| 537 | 537 | $all_data = json_decode($buffer,true); |
| 538 | 538 | if (isset($all_data[0]['mmsi'])) { |
| 539 | - foreach ($all_data as $line) { |
|
| 539 | + foreach ($all_data as $line) { |
|
| 540 | 540 | if ($line != '') { |
| 541 | - $data = array(); |
|
| 542 | - $data['ident'] = $line['shipname']; |
|
| 543 | - $data['callsign'] = $line['callsign']; |
|
| 544 | - $data['mmsi'] = $line['mmsi']; |
|
| 545 | - $data['speed'] = $line['sog']; |
|
| 546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 547 | - $data['latitude'] = $line['latitude']; |
|
| 548 | - $data['longitude'] = $line['longitude']; |
|
| 549 | - $data['type_id'] = $line['shiptype']; |
|
| 550 | - $data['arrival_code'] = $line['destination']; |
|
| 551 | - $data['datetime'] = $line['time']; |
|
| 552 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 553 | - $data['id_source'] = $id_source; |
|
| 554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 555 | - $MI->add($data); |
|
| 556 | - unset($data); |
|
| 541 | + $data = array(); |
|
| 542 | + $data['ident'] = $line['shipname']; |
|
| 543 | + $data['callsign'] = $line['callsign']; |
|
| 544 | + $data['mmsi'] = $line['mmsi']; |
|
| 545 | + $data['speed'] = $line['sog']; |
|
| 546 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 547 | + $data['latitude'] = $line['latitude']; |
|
| 548 | + $data['longitude'] = $line['longitude']; |
|
| 549 | + $data['type_id'] = $line['shiptype']; |
|
| 550 | + $data['arrival_code'] = $line['destination']; |
|
| 551 | + $data['datetime'] = $line['time']; |
|
| 552 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 553 | + $data['id_source'] = $id_source; |
|
| 554 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 555 | + $MI->add($data); |
|
| 556 | + unset($data); |
|
| 557 | + } |
|
| 557 | 558 | } |
| 558 | - } |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - } |
|
| 562 | - $last_exec[$id]['last'] = time(); |
|
| 561 | + } |
|
| 562 | + $last_exec[$id]['last'] = time(); |
|
| 563 | 563 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 564 | - $buffer = $Common->getData($value['host']); |
|
| 565 | - if ($buffer != '') { |
|
| 564 | + $buffer = $Common->getData($value['host']); |
|
| 565 | + if ($buffer != '') { |
|
| 566 | 566 | $all_data = json_decode($buffer,true); |
| 567 | 567 | if (isset($all_data['features'][0]['id'])) { |
| 568 | - foreach ($all_data['features'] as $line) { |
|
| 568 | + foreach ($all_data['features'] as $line) { |
|
| 569 | 569 | $data = array(); |
| 570 | 570 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
| 571 | 571 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -584,59 +584,59 @@ discard block |
||
| 584 | 584 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 585 | 585 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 586 | 586 | unset($data); |
| 587 | - } |
|
| 587 | + } |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - } |
|
| 591 | - $last_exec[$id]['last'] = time(); |
|
| 590 | + } |
|
| 591 | + $last_exec[$id]['last'] = time(); |
|
| 592 | 592 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 593 | - echo 'download...'; |
|
| 594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 595 | - echo 'done !'."\n"; |
|
| 596 | - if ($buffer != '') $reset = 0; |
|
| 597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 598 | - $buffer = explode('\n',$buffer); |
|
| 599 | - foreach ($buffer as $line) { |
|
| 593 | + echo 'download...'; |
|
| 594 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 595 | + echo 'done !'."\n"; |
|
| 596 | + if ($buffer != '') $reset = 0; |
|
| 597 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 598 | + $buffer = explode('\n',$buffer); |
|
| 599 | + foreach ($buffer as $line) { |
|
| 600 | 600 | if ($line != '') { |
| 601 | - $data = array(); |
|
| 602 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 603 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 604 | - //$data['status'] = substr($line,21,2); |
|
| 605 | - //$data['type'] = substr($line,24,3); |
|
| 606 | - $data['latitude'] = substr($line,29,9); |
|
| 607 | - $data['longitude'] = substr($line,41,9); |
|
| 608 | - $data['speed'] = round(substr($line,51,5)); |
|
| 609 | - //$data['course'] = substr($line,57,5); |
|
| 610 | - $data['heading'] = round(substr($line,63,3)); |
|
| 611 | - //$data['draft'] = substr($line,67,4); |
|
| 612 | - //$data['length'] = substr($line,72,3); |
|
| 613 | - //$data['beam'] = substr($line,76,2); |
|
| 614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 615 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 616 | - //$data['dest'] = substr($line,108,20); |
|
| 617 | - //$data['etaDate'] = substr($line,129,5); |
|
| 618 | - //$data['etaTime'] = substr($line,135,5); |
|
| 619 | - $data['format_source'] = 'shipplotter'; |
|
| 620 | - $data['id_source'] = $id_source; |
|
| 621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 622 | - //print_r($data); |
|
| 623 | - echo 'Add...'."\n"; |
|
| 624 | - $MI->add($data); |
|
| 625 | - unset($data); |
|
| 601 | + $data = array(); |
|
| 602 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 603 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 604 | + //$data['status'] = substr($line,21,2); |
|
| 605 | + //$data['type'] = substr($line,24,3); |
|
| 606 | + $data['latitude'] = substr($line,29,9); |
|
| 607 | + $data['longitude'] = substr($line,41,9); |
|
| 608 | + $data['speed'] = round(substr($line,51,5)); |
|
| 609 | + //$data['course'] = substr($line,57,5); |
|
| 610 | + $data['heading'] = round(substr($line,63,3)); |
|
| 611 | + //$data['draft'] = substr($line,67,4); |
|
| 612 | + //$data['length'] = substr($line,72,3); |
|
| 613 | + //$data['beam'] = substr($line,76,2); |
|
| 614 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 615 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 616 | + //$data['dest'] = substr($line,108,20); |
|
| 617 | + //$data['etaDate'] = substr($line,129,5); |
|
| 618 | + //$data['etaTime'] = substr($line,135,5); |
|
| 619 | + $data['format_source'] = 'shipplotter'; |
|
| 620 | + $data['id_source'] = $id_source; |
|
| 621 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 622 | + //print_r($data); |
|
| 623 | + echo 'Add...'."\n"; |
|
| 624 | + $MI->add($data); |
|
| 625 | + unset($data); |
|
| 626 | 626 | } |
| 627 | - } |
|
| 628 | - $last_exec[$id]['last'] = time(); |
|
| 627 | + } |
|
| 628 | + $last_exec[$id]['last'] = time(); |
|
| 629 | 629 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 630 | 630 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 631 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 632 | - $buffer = $Common->getData($value['host']); |
|
| 633 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 634 | - $buffer = explode('\n',$buffer); |
|
| 635 | - $reset = 0; |
|
| 636 | - foreach ($buffer as $line) { |
|
| 637 | - if ($line != '') { |
|
| 638 | - $line = explode(':', $line); |
|
| 639 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 631 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 632 | + $buffer = $Common->getData($value['host']); |
|
| 633 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 634 | + $buffer = explode('\n',$buffer); |
|
| 635 | + $reset = 0; |
|
| 636 | + foreach ($buffer as $line) { |
|
| 637 | + if ($line != '') { |
|
| 638 | + $line = explode(':', $line); |
|
| 639 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 640 | 640 | $data = array(); |
| 641 | 641 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -649,37 +649,37 @@ discard block |
||
| 649 | 649 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 650 | 650 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 651 | 651 | $data['latitude'] = $line[5]; // lat |
| 652 | - $data['longitude'] = $line[6]; // long |
|
| 653 | - $data['verticalrate'] = ''; // vertical rate |
|
| 654 | - $data['squawk'] = ''; // squawk |
|
| 655 | - $data['emergency'] = ''; // emergency |
|
| 656 | - $data['waypoints'] = $line[30]; |
|
| 652 | + $data['longitude'] = $line[6]; // long |
|
| 653 | + $data['verticalrate'] = ''; // vertical rate |
|
| 654 | + $data['squawk'] = ''; // squawk |
|
| 655 | + $data['emergency'] = ''; // emergency |
|
| 656 | + $data['waypoints'] = $line[30]; |
|
| 657 | 657 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 658 | 658 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 660 | - $data['departure_airport_icao'] = $line[11]; |
|
| 661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 662 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 660 | + $data['departure_airport_icao'] = $line[11]; |
|
| 661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 662 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 663 | 663 | $data['frequency'] = $line[4]; |
| 664 | 664 | $data['type'] = $line[18]; |
| 665 | 665 | $data['range'] = $line[19]; |
| 666 | 666 | if (isset($line[35])) $data['info'] = $line[35]; |
| 667 | - $data['id_source'] = $id_source; |
|
| 668 | - //$data['arrival_airport_time'] = ; |
|
| 669 | - if ($line[9] != '') { |
|
| 670 | - $aircraft_data = explode('/',$line[9]); |
|
| 671 | - if (isset($aircraft_data[1])) { |
|
| 672 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - /* |
|
| 667 | + $data['id_source'] = $id_source; |
|
| 668 | + //$data['arrival_airport_time'] = ; |
|
| 669 | + if ($line[9] != '') { |
|
| 670 | + $aircraft_data = explode('/',$line[9]); |
|
| 671 | + if (isset($aircraft_data[1])) { |
|
| 672 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + /* |
|
| 676 | 676 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 677 | 677 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 678 | 678 | */ |
| 679 | - $data['format_source'] = $value['format']; |
|
| 679 | + $data['format_source'] = $value['format']; |
|
| 680 | 680 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 681 | 681 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 682 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 682 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 683 | 683 | elseif ($line[3] == 'ATC') { |
| 684 | 684 | //print_r($data); |
| 685 | 685 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -700,16 +700,16 @@ discard block |
||
| 700 | 700 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | - unset($data); |
|
| 704 | - } |
|
| 705 | - } |
|
| 706 | - } |
|
| 707 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 708 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 709 | - $last_exec[$id]['last'] = time(); |
|
| 710 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 711 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 712 | - if ($buffer != '') { |
|
| 703 | + unset($data); |
|
| 704 | + } |
|
| 705 | + } |
|
| 706 | + } |
|
| 707 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 708 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 709 | + $last_exec[$id]['last'] = time(); |
|
| 710 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 711 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 712 | + if ($buffer != '') { |
|
| 713 | 713 | $all_data = simplexml_load_string($buffer); |
| 714 | 714 | foreach($all_data->children() as $childdata) { |
| 715 | 715 | $data = array(); |
@@ -730,10 +730,10 @@ discard block |
||
| 730 | 730 | $SI->add($data); |
| 731 | 731 | unset($data); |
| 732 | 732 | } |
| 733 | - } |
|
| 734 | - $Source->deleteOldLocationByType('gs'); |
|
| 735 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 736 | - if ($buffer != '') { |
|
| 733 | + } |
|
| 734 | + $Source->deleteOldLocationByType('gs'); |
|
| 735 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 736 | + if ($buffer != '') { |
|
| 737 | 737 | $all_data = simplexml_load_string($buffer); |
| 738 | 738 | foreach($all_data->children() as $childdata) { |
| 739 | 739 | $data = array(); |
@@ -750,249 +750,249 @@ discard block |
||
| 750 | 750 | } |
| 751 | 751 | unset($data); |
| 752 | 752 | } |
| 753 | - } |
|
| 754 | - $last_exec[$id]['last'] = time(); |
|
| 753 | + } |
|
| 754 | + $last_exec[$id]['last'] = time(); |
|
| 755 | 755 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 756 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 757 | - if ($buffer != '') { |
|
| 758 | - $all_data = json_decode($buffer,true); |
|
| 759 | - if (isset($all_data['acList'])) { |
|
| 756 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 757 | + if ($buffer != '') { |
|
| 758 | + $all_data = json_decode($buffer,true); |
|
| 759 | + if (isset($all_data['acList'])) { |
|
| 760 | 760 | $reset = 0; |
| 761 | 761 | foreach ($all_data['acList'] as $line) { |
| 762 | - $data = array(); |
|
| 763 | - $data['hex'] = $line['Icao']; // hex |
|
| 764 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 765 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 766 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 767 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 768 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 769 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 770 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 771 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 772 | - $data['emergency'] = ''; // emergency |
|
| 773 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 762 | + $data = array(); |
|
| 763 | + $data['hex'] = $line['Icao']; // hex |
|
| 764 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 765 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 766 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 767 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 768 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 769 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 770 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 771 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 772 | + $data['emergency'] = ''; // emergency |
|
| 773 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 774 | 774 | |
| 775 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 776 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 775 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 776 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 777 | 777 | |
| 778 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 779 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 780 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 781 | - $data['id_source'] = $id_source; |
|
| 782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 783 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 784 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 785 | - unset($data); |
|
| 778 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 779 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 780 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 781 | + $data['id_source'] = $id_source; |
|
| 782 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 783 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 784 | + if (isset($data['latitude'])) $SI->add($data); |
|
| 785 | + unset($data); |
|
| 786 | 786 | } |
| 787 | - } elseif (is_array($all_data)) { |
|
| 787 | + } elseif (is_array($all_data)) { |
|
| 788 | 788 | $reset = 0; |
| 789 | 789 | foreach ($all_data as $line) { |
| 790 | - $data = array(); |
|
| 791 | - $data['hex'] = $line['hex']; // hex |
|
| 792 | - $data['ident'] = $line['flight']; // ident |
|
| 793 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 794 | - $data['speed'] = $line['speed']; // speed |
|
| 795 | - $data['heading'] = $line['track']; // heading |
|
| 796 | - $data['latitude'] = $line['lat']; // lat |
|
| 797 | - $data['longitude'] = $line['lon']; // long |
|
| 798 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 799 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 800 | - $data['emergency'] = ''; // emergency |
|
| 801 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 802 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 803 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 804 | - $data['id_source'] = $id_source; |
|
| 805 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 806 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 807 | - $SI->add($data); |
|
| 808 | - unset($data); |
|
| 790 | + $data = array(); |
|
| 791 | + $data['hex'] = $line['hex']; // hex |
|
| 792 | + $data['ident'] = $line['flight']; // ident |
|
| 793 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 794 | + $data['speed'] = $line['speed']; // speed |
|
| 795 | + $data['heading'] = $line['track']; // heading |
|
| 796 | + $data['latitude'] = $line['lat']; // lat |
|
| 797 | + $data['longitude'] = $line['lon']; // long |
|
| 798 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 799 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 800 | + $data['emergency'] = ''; // emergency |
|
| 801 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 802 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 803 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 804 | + $data['id_source'] = $id_source; |
|
| 805 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 806 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 807 | + $SI->add($data); |
|
| 808 | + unset($data); |
|
| 809 | + } |
|
| 810 | + } |
|
| 809 | 811 | } |
| 810 | - } |
|
| 811 | - } |
|
| 812 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 813 | - $last_exec[$id]['last'] = time(); |
|
| 814 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 815 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 816 | - $buffer = $Common->getData($value['host']); |
|
| 817 | - $all_data = json_decode($buffer,true); |
|
| 818 | - if (isset($all_data['planes'])) { |
|
| 812 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 813 | + $last_exec[$id]['last'] = time(); |
|
| 814 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 815 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 816 | + $buffer = $Common->getData($value['host']); |
|
| 817 | + $all_data = json_decode($buffer,true); |
|
| 818 | + if (isset($all_data['planes'])) { |
|
| 819 | 819 | $reset = 0; |
| 820 | 820 | foreach ($all_data['planes'] as $key => $line) { |
| 821 | - $data = array(); |
|
| 822 | - $data['hex'] = $key; // hex |
|
| 823 | - $data['ident'] = $line[3]; // ident |
|
| 824 | - $data['altitude'] = $line[6]; // altitude |
|
| 825 | - $data['speed'] = $line[8]; // speed |
|
| 826 | - $data['heading'] = $line[7]; // heading |
|
| 827 | - $data['latitude'] = $line[4]; // lat |
|
| 828 | - $data['longitude'] = $line[5]; // long |
|
| 829 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 830 | - $data['squawk'] = $line[10]; // squawk |
|
| 831 | - $data['emergency'] = ''; // emergency |
|
| 832 | - $data['registration'] = $line[2]; |
|
| 833 | - $data['aircraft_icao'] = $line[0]; |
|
| 834 | - $deparr = explode('-',$line[1]); |
|
| 835 | - if (count($deparr) == 2) { |
|
| 821 | + $data = array(); |
|
| 822 | + $data['hex'] = $key; // hex |
|
| 823 | + $data['ident'] = $line[3]; // ident |
|
| 824 | + $data['altitude'] = $line[6]; // altitude |
|
| 825 | + $data['speed'] = $line[8]; // speed |
|
| 826 | + $data['heading'] = $line[7]; // heading |
|
| 827 | + $data['latitude'] = $line[4]; // lat |
|
| 828 | + $data['longitude'] = $line[5]; // long |
|
| 829 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 830 | + $data['squawk'] = $line[10]; // squawk |
|
| 831 | + $data['emergency'] = ''; // emergency |
|
| 832 | + $data['registration'] = $line[2]; |
|
| 833 | + $data['aircraft_icao'] = $line[0]; |
|
| 834 | + $deparr = explode('-',$line[1]); |
|
| 835 | + if (count($deparr) == 2) { |
|
| 836 | 836 | $data['departure_airport_icao'] = $deparr[0]; |
| 837 | 837 | $data['arrival_airport_icao'] = $deparr[1]; |
| 838 | - } |
|
| 839 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 840 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 841 | - $data['id_source'] = $id_source; |
|
| 842 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 843 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 844 | - $SI->add($data); |
|
| 845 | - unset($data); |
|
| 838 | + } |
|
| 839 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 840 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 841 | + $data['id_source'] = $id_source; |
|
| 842 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 843 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 844 | + $SI->add($data); |
|
| 845 | + unset($data); |
|
| 846 | + } |
|
| 846 | 847 | } |
| 847 | - } |
|
| 848 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 849 | - $last_exec[$id]['last'] = time(); |
|
| 850 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 851 | - $buffer = $Common->getData($value['host']); |
|
| 852 | - $all_data = json_decode($buffer,true); |
|
| 853 | - if (isset($all_data['states'])) { |
|
| 848 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 849 | + $last_exec[$id]['last'] = time(); |
|
| 850 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 851 | + $buffer = $Common->getData($value['host']); |
|
| 852 | + $all_data = json_decode($buffer,true); |
|
| 853 | + if (isset($all_data['states'])) { |
|
| 854 | 854 | $reset = 0; |
| 855 | 855 | foreach ($all_data['states'] as $key => $line) { |
| 856 | - $data = array(); |
|
| 857 | - $data['hex'] = $line[0]; // hex |
|
| 858 | - $data['ident'] = trim($line[1]); // ident |
|
| 859 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 860 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 861 | - $data['heading'] = round($line[10]); // heading |
|
| 862 | - $data['latitude'] = $line[6]; // lat |
|
| 863 | - $data['longitude'] = $line[5]; // long |
|
| 864 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 865 | - //$data['squawk'] = $line[10]; // squawk |
|
| 866 | - //$data['emergency'] = ''; // emergency |
|
| 867 | - //$data['registration'] = $line[2]; |
|
| 868 | - //$data['aircraft_icao'] = $line[0]; |
|
| 869 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 870 | - $data['format_source'] = 'opensky'; |
|
| 871 | - $data['id_source'] = $id_source; |
|
| 872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 873 | - $SI->add($data); |
|
| 874 | - unset($data); |
|
| 856 | + $data = array(); |
|
| 857 | + $data['hex'] = $line[0]; // hex |
|
| 858 | + $data['ident'] = trim($line[1]); // ident |
|
| 859 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 860 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 861 | + $data['heading'] = round($line[10]); // heading |
|
| 862 | + $data['latitude'] = $line[6]; // lat |
|
| 863 | + $data['longitude'] = $line[5]; // long |
|
| 864 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 865 | + //$data['squawk'] = $line[10]; // squawk |
|
| 866 | + //$data['emergency'] = ''; // emergency |
|
| 867 | + //$data['registration'] = $line[2]; |
|
| 868 | + //$data['aircraft_icao'] = $line[0]; |
|
| 869 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 870 | + $data['format_source'] = 'opensky'; |
|
| 871 | + $data['id_source'] = $id_source; |
|
| 872 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 873 | + $SI->add($data); |
|
| 874 | + unset($data); |
|
| 875 | 875 | } |
| 876 | - } |
|
| 877 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 878 | - $last_exec[$id]['last'] = time(); |
|
| 879 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 880 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 881 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 882 | - $buffer = $Common->getData($value['host']); |
|
| 883 | - $all_data = json_decode($buffer,true); |
|
| 884 | - if (!empty($all_data)) $reset = 0; |
|
| 885 | - foreach ($all_data as $key => $line) { |
|
| 876 | + } |
|
| 877 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 878 | + $last_exec[$id]['last'] = time(); |
|
| 879 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 880 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 881 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 882 | + $buffer = $Common->getData($value['host']); |
|
| 883 | + $all_data = json_decode($buffer,true); |
|
| 884 | + if (!empty($all_data)) $reset = 0; |
|
| 885 | + foreach ($all_data as $key => $line) { |
|
| 886 | 886 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 887 | - $data = array(); |
|
| 888 | - $data['hex'] = $line[0]; |
|
| 889 | - $data['ident'] = $line[16]; //$line[13] |
|
| 890 | - $data['altitude'] = $line[4]; // altitude |
|
| 891 | - $data['speed'] = $line[5]; // speed |
|
| 892 | - $data['heading'] = $line[3]; // heading |
|
| 893 | - $data['latitude'] = $line[1]; // lat |
|
| 894 | - $data['longitude'] = $line[2]; // long |
|
| 895 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 896 | - $data['squawk'] = $line[6]; // squawk |
|
| 897 | - $data['aircraft_icao'] = $line[8]; |
|
| 898 | - $data['registration'] = $line[9]; |
|
| 899 | - $data['departure_airport_iata'] = $line[11]; |
|
| 900 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 901 | - $data['emergency'] = ''; // emergency |
|
| 902 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 903 | - $data['format_source'] = 'fr24json'; |
|
| 904 | - $data['id_source'] = $id_source; |
|
| 905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 907 | - $SI->add($data); |
|
| 908 | - unset($data); |
|
| 887 | + $data = array(); |
|
| 888 | + $data['hex'] = $line[0]; |
|
| 889 | + $data['ident'] = $line[16]; //$line[13] |
|
| 890 | + $data['altitude'] = $line[4]; // altitude |
|
| 891 | + $data['speed'] = $line[5]; // speed |
|
| 892 | + $data['heading'] = $line[3]; // heading |
|
| 893 | + $data['latitude'] = $line[1]; // lat |
|
| 894 | + $data['longitude'] = $line[2]; // long |
|
| 895 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 896 | + $data['squawk'] = $line[6]; // squawk |
|
| 897 | + $data['aircraft_icao'] = $line[8]; |
|
| 898 | + $data['registration'] = $line[9]; |
|
| 899 | + $data['departure_airport_iata'] = $line[11]; |
|
| 900 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 901 | + $data['emergency'] = ''; // emergency |
|
| 902 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 903 | + $data['format_source'] = 'fr24json'; |
|
| 904 | + $data['id_source'] = $id_source; |
|
| 905 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 906 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 907 | + $SI->add($data); |
|
| 908 | + unset($data); |
|
| 909 | + } |
|
| 909 | 910 | } |
| 910 | - } |
|
| 911 | - //$last_exec['fr24json'] = time(); |
|
| 912 | - $last_exec[$id]['last'] = time(); |
|
| 913 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 914 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 915 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 916 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 917 | - //echo $buffer; |
|
| 918 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 919 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 920 | - $all_data = json_decode($buffer,true); |
|
| 921 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 911 | + //$last_exec['fr24json'] = time(); |
|
| 912 | + $last_exec[$id]['last'] = time(); |
|
| 913 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 914 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 915 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 916 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 917 | + //echo $buffer; |
|
| 918 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 919 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 920 | + $all_data = json_decode($buffer,true); |
|
| 921 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 922 | 922 | die(json_last_error_msg()); |
| 923 | - } |
|
| 924 | - if (isset($all_data['mrkrs'])) { |
|
| 923 | + } |
|
| 924 | + if (isset($all_data['mrkrs'])) { |
|
| 925 | 925 | $reset = 0; |
| 926 | 926 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 927 | - if (isset($line['inf'])) { |
|
| 927 | + if (isset($line['inf'])) { |
|
| 928 | 928 | $data = array(); |
| 929 | 929 | $data['hex'] = $line['inf']['ia']; |
| 930 | 930 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 931 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 932 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 933 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 934 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 935 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 936 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 937 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 938 | - //$data['aircraft_icao'] = $line[8]; |
|
| 939 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 931 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 932 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 933 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 934 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 935 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 936 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 937 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 938 | + //$data['aircraft_icao'] = $line[8]; |
|
| 939 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 940 | 940 | //$data['departure_airport_iata'] = $line[11]; |
| 941 | 941 | //$data['arrival_airport_iata'] = $line[12]; |
| 942 | - //$data['emergency'] = ''; // emergency |
|
| 942 | + //$data['emergency'] = ''; // emergency |
|
| 943 | 943 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 944 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 945 | - $data['id_source'] = $id_source; |
|
| 944 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 945 | + $data['id_source'] = $id_source; |
|
| 946 | 946 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 947 | 947 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 948 | 948 | $SI->add($data); |
| 949 | 949 | unset($data); |
| 950 | - } |
|
| 950 | + } |
|
| 951 | 951 | } |
| 952 | - } |
|
| 953 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 954 | - $last_exec[$id]['last'] = time(); |
|
| 955 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 956 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 957 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 958 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 959 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 952 | + } |
|
| 953 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 954 | + $last_exec[$id]['last'] = time(); |
|
| 955 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 956 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 957 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 958 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 959 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 960 | 960 | |
| 961 | - if (isset($all_data['pireps'])) { |
|
| 961 | + if (isset($all_data['pireps'])) { |
|
| 962 | 962 | $reset = 0; |
| 963 | - foreach ($all_data['pireps'] as $line) { |
|
| 964 | - $data = array(); |
|
| 965 | - $data['id'] = $line['id']; |
|
| 966 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 967 | - $data['ident'] = $line['callsign']; // ident |
|
| 968 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 969 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 970 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 971 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 972 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 973 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 974 | - $data['latitude'] = $line['lat']; // lat |
|
| 975 | - $data['longitude'] = $line['lon']; // long |
|
| 976 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 977 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 978 | - //$data['emergency'] = ''; // emergency |
|
| 979 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 980 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 981 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 982 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 983 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 984 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 985 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 986 | - else $data['info'] = ''; |
|
| 987 | - $data['format_source'] = 'pireps'; |
|
| 988 | - $data['id_source'] = $id_source; |
|
| 989 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 990 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 991 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 992 | - if ($line['icon'] == 'plane') { |
|
| 963 | + foreach ($all_data['pireps'] as $line) { |
|
| 964 | + $data = array(); |
|
| 965 | + $data['id'] = $line['id']; |
|
| 966 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 967 | + $data['ident'] = $line['callsign']; // ident |
|
| 968 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 969 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 970 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 971 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 972 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 973 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 974 | + $data['latitude'] = $line['lat']; // lat |
|
| 975 | + $data['longitude'] = $line['lon']; // long |
|
| 976 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 977 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 978 | + //$data['emergency'] = ''; // emergency |
|
| 979 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 980 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 981 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 982 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 983 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 984 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 985 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 986 | + else $data['info'] = ''; |
|
| 987 | + $data['format_source'] = 'pireps'; |
|
| 988 | + $data['id_source'] = $id_source; |
|
| 989 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 990 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 991 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 992 | + if ($line['icon'] == 'plane') { |
|
| 993 | 993 | $SI->add($data); |
| 994 | - // print_r($data); |
|
| 995 | - } elseif ($line['icon'] == 'ct') { |
|
| 994 | + // print_r($data); |
|
| 995 | + } elseif ($line['icon'] == 'ct') { |
|
| 996 | 996 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 997 | 997 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 998 | 998 | $typec = substr($data['ident'],-3); |
@@ -1007,199 +1007,199 @@ discard block |
||
| 1007 | 1007 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1008 | 1008 | else $data['type'] = 'Observer'; |
| 1009 | 1009 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
| 1010 | - } |
|
| 1011 | - unset($data); |
|
| 1010 | + } |
|
| 1011 | + unset($data); |
|
| 1012 | 1012 | } |
| 1013 | - } |
|
| 1014 | - //$last_exec['pirepsjson'] = time(); |
|
| 1015 | - $last_exec[$id]['last'] = time(); |
|
| 1016 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 1017 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1018 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1019 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1020 | - $buffer = $Common->getData($value['host']); |
|
| 1021 | - $all_data = json_decode($buffer,true); |
|
| 1022 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1013 | + } |
|
| 1014 | + //$last_exec['pirepsjson'] = time(); |
|
| 1015 | + $last_exec[$id]['last'] = time(); |
|
| 1016 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 1017 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1018 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1019 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1020 | + $buffer = $Common->getData($value['host']); |
|
| 1021 | + $all_data = json_decode($buffer,true); |
|
| 1022 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1023 | 1023 | $reset = 0; |
| 1024 | 1024 | foreach ($all_data as $line) { |
| 1025 | - $data = array(); |
|
| 1026 | - //$data['id'] = $line['id']; // id not usable |
|
| 1027 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1028 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1029 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1030 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1031 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1032 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1033 | - $data['speed'] = $line['gs']; // speed |
|
| 1034 | - $data['heading'] = $line['heading']; // heading |
|
| 1035 | - $data['latitude'] = $line['lat']; // lat |
|
| 1036 | - $data['longitude'] = $line['lng']; // long |
|
| 1037 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1038 | - $data['squawk'] = ''; // squawk |
|
| 1039 | - $data['emergency'] = ''; // emergency |
|
| 1040 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1041 | - $data['last_update'] = $line['lastupdate']; |
|
| 1042 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1043 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1044 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1045 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1046 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1047 | - $data['registration'] = $line['aircraft']; |
|
| 1048 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1049 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1050 | - if (isset($line['aircraftname'])) { |
|
| 1025 | + $data = array(); |
|
| 1026 | + //$data['id'] = $line['id']; // id not usable |
|
| 1027 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1028 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1029 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1030 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1031 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1032 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1033 | + $data['speed'] = $line['gs']; // speed |
|
| 1034 | + $data['heading'] = $line['heading']; // heading |
|
| 1035 | + $data['latitude'] = $line['lat']; // lat |
|
| 1036 | + $data['longitude'] = $line['lng']; // long |
|
| 1037 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1038 | + $data['squawk'] = ''; // squawk |
|
| 1039 | + $data['emergency'] = ''; // emergency |
|
| 1040 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1041 | + $data['last_update'] = $line['lastupdate']; |
|
| 1042 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1043 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1044 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1045 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1046 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1047 | + $data['registration'] = $line['aircraft']; |
|
| 1048 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1049 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1050 | + if (isset($line['aircraftname'])) { |
|
| 1051 | 1051 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1052 | 1052 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1053 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1054 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1055 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1056 | - else { |
|
| 1057 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1058 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1059 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1060 | - } |
|
| 1061 | - } |
|
| 1062 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1063 | - $data['id_source'] = $id_source; |
|
| 1064 | - $data['format_source'] = 'phpvmacars'; |
|
| 1065 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1066 | - $SI->add($data); |
|
| 1067 | - unset($data); |
|
| 1053 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1054 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1055 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1056 | + else { |
|
| 1057 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1058 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1059 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1060 | + } |
|
| 1061 | + } |
|
| 1062 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1063 | + $data['id_source'] = $id_source; |
|
| 1064 | + $data['format_source'] = 'phpvmacars'; |
|
| 1065 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1066 | + $SI->add($data); |
|
| 1067 | + unset($data); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1070 | 1070 | unset($buffer); |
| 1071 | 1071 | unset($all_data); |
| 1072 | - } |
|
| 1073 | - //$last_exec['phpvmacars'] = time(); |
|
| 1074 | - $last_exec[$id]['last'] = time(); |
|
| 1075 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1076 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1077 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1078 | - $buffer = $Common->getData($value['host']); |
|
| 1079 | - $all_data = json_decode($buffer,true); |
|
| 1080 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1072 | + } |
|
| 1073 | + //$last_exec['phpvmacars'] = time(); |
|
| 1074 | + $last_exec[$id]['last'] = time(); |
|
| 1075 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1076 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1077 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1078 | + $buffer = $Common->getData($value['host']); |
|
| 1079 | + $all_data = json_decode($buffer,true); |
|
| 1080 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1081 | 1081 | $reset = 0; |
| 1082 | 1082 | foreach ($all_data as $line) { |
| 1083 | - $data = array(); |
|
| 1084 | - //$data['id'] = $line['id']; // id not usable |
|
| 1085 | - $data['id'] = trim($line['flight_id']); |
|
| 1086 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1087 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1088 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1089 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1090 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1091 | - $data['speed'] = $line['gs']; // speed |
|
| 1092 | - $data['heading'] = $line['heading']; // heading |
|
| 1093 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1094 | - $data['longitude'] = $line['longitude']; // long |
|
| 1095 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1096 | - $data['squawk'] = ''; // squawk |
|
| 1097 | - $data['emergency'] = ''; // emergency |
|
| 1098 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1099 | - $data['last_update'] = $line['last_update']; |
|
| 1100 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1101 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1102 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1103 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1104 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1105 | - //$data['registration'] = $line['aircraft']; |
|
| 1106 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1107 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1108 | - $data['id_source'] = $id_source; |
|
| 1109 | - $data['format_source'] = 'vam'; |
|
| 1110 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1111 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1112 | - $SI->add($data); |
|
| 1113 | - unset($data); |
|
| 1083 | + $data = array(); |
|
| 1084 | + //$data['id'] = $line['id']; // id not usable |
|
| 1085 | + $data['id'] = trim($line['flight_id']); |
|
| 1086 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1087 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1088 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1089 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1090 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1091 | + $data['speed'] = $line['gs']; // speed |
|
| 1092 | + $data['heading'] = $line['heading']; // heading |
|
| 1093 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1094 | + $data['longitude'] = $line['longitude']; // long |
|
| 1095 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1096 | + $data['squawk'] = ''; // squawk |
|
| 1097 | + $data['emergency'] = ''; // emergency |
|
| 1098 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1099 | + $data['last_update'] = $line['last_update']; |
|
| 1100 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1101 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1102 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1103 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1104 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1105 | + //$data['registration'] = $line['aircraft']; |
|
| 1106 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1107 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1108 | + $data['id_source'] = $id_source; |
|
| 1109 | + $data['format_source'] = 'vam'; |
|
| 1110 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1111 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1112 | + $SI->add($data); |
|
| 1113 | + unset($data); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1116 | 1116 | unset($buffer); |
| 1117 | 1117 | unset($all_data); |
| 1118 | - } |
|
| 1119 | - //$last_exec['phpvmacars'] = time(); |
|
| 1120 | - $last_exec[$id]['last'] = time(); |
|
| 1118 | + } |
|
| 1119 | + //$last_exec['phpvmacars'] = time(); |
|
| 1120 | + $last_exec[$id]['last'] = time(); |
|
| 1121 | 1121 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1122 | 1122 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1123 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1124 | - //$last_exec[$id]['last'] = time(); |
|
| 1123 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1124 | + //$last_exec[$id]['last'] = time(); |
|
| 1125 | 1125 | |
| 1126 | - //$read = array( $sockets[$id] ); |
|
| 1127 | - $read = $sockets; |
|
| 1128 | - $write = NULL; |
|
| 1129 | - $e = NULL; |
|
| 1130 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1131 | - if ($e != NULL) var_dump($e); |
|
| 1132 | - if ($n > 0) { |
|
| 1126 | + //$read = array( $sockets[$id] ); |
|
| 1127 | + $read = $sockets; |
|
| 1128 | + $write = NULL; |
|
| 1129 | + $e = NULL; |
|
| 1130 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1131 | + if ($e != NULL) var_dump($e); |
|
| 1132 | + if ($n > 0) { |
|
| 1133 | 1133 | $reset = 0; |
| 1134 | 1134 | foreach ($read as $nb => $r) { |
| 1135 | - //$value = $formats[$nb]; |
|
| 1136 | - $format = $globalSources[$nb]['format']; |
|
| 1137 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1135 | + //$value = $formats[$nb]; |
|
| 1136 | + $format = $globalSources[$nb]['format']; |
|
| 1137 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1138 | 1138 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1139 | - } elseif ($format == 'vrstcp') { |
|
| 1139 | + } elseif ($format == 'vrstcp') { |
|
| 1140 | 1140 | $buffer = @socket_read($r, 6000); |
| 1141 | - } else { |
|
| 1141 | + } else { |
|
| 1142 | 1142 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1143 | - } |
|
| 1144 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1145 | - //echo $buffer."\n"; |
|
| 1146 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1147 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1148 | - $error = false; |
|
| 1149 | - //$SI::del(); |
|
| 1150 | - if ($format == 'vrstcp') { |
|
| 1143 | + } |
|
| 1144 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1145 | + //echo $buffer."\n"; |
|
| 1146 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1147 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1148 | + $error = false; |
|
| 1149 | + //$SI::del(); |
|
| 1150 | + if ($format == 'vrstcp') { |
|
| 1151 | 1151 | $buffer = explode('},{',$buffer); |
| 1152 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1153 | - // SBS format is CSV format |
|
| 1154 | - if ($buffer !== FALSE && $buffer != '') { |
|
| 1152 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1153 | + // SBS format is CSV format |
|
| 1154 | + if ($buffer !== FALSE && $buffer != '') { |
|
| 1155 | 1155 | $tt[$format] = 0; |
| 1156 | 1156 | if ($format == 'acarssbs3') { |
| 1157 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1158 | - $ACARS->add(trim($buffer)); |
|
| 1159 | - $ACARS->deleteLiveAcarsData(); |
|
| 1157 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1158 | + $ACARS->add(trim($buffer)); |
|
| 1159 | + $ACARS->deleteLiveAcarsData(); |
|
| 1160 | 1160 | } elseif ($format == 'raw') { |
| 1161 | - // AVR format |
|
| 1162 | - $data = $SBS->parse($buffer); |
|
| 1163 | - if (is_array($data)) { |
|
| 1161 | + // AVR format |
|
| 1162 | + $data = $SBS->parse($buffer); |
|
| 1163 | + if (is_array($data)) { |
|
| 1164 | 1164 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1165 | 1165 | $data['format_source'] = 'raw'; |
| 1166 | 1166 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1167 | 1167 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1168 | 1168 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1169 | 1169 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1170 | - } |
|
| 1170 | + } |
|
| 1171 | 1171 | } elseif ($format == 'ais') { |
| 1172 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1173 | - $data = array(); |
|
| 1174 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1175 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1176 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1177 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1178 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1179 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1180 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1181 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1182 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1183 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1184 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1185 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1186 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1187 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1188 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1189 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1172 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1173 | + $data = array(); |
|
| 1174 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1175 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1176 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1177 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1178 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1179 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1180 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1181 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1182 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1183 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1184 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1185 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1186 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1187 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1188 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1189 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1190 | 1190 | |
| 1191 | - if (isset($ais_data['timestamp'])) { |
|
| 1191 | + if (isset($ais_data['timestamp'])) { |
|
| 1192 | 1192 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1193 | - } else { |
|
| 1193 | + } else { |
|
| 1194 | 1194 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1195 | - } |
|
| 1196 | - $data['format_source'] = 'aisnmea'; |
|
| 1197 | - $data['id_source'] = $id_source; |
|
| 1198 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1199 | - unset($data); |
|
| 1200 | - } elseif ($format == 'flightgearsp') { |
|
| 1201 | - //echo $buffer."\n"; |
|
| 1202 | - if (strlen($buffer) > 5) { |
|
| 1195 | + } |
|
| 1196 | + $data['format_source'] = 'aisnmea'; |
|
| 1197 | + $data['id_source'] = $id_source; |
|
| 1198 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1199 | + unset($data); |
|
| 1200 | + } elseif ($format == 'flightgearsp') { |
|
| 1201 | + //echo $buffer."\n"; |
|
| 1202 | + if (strlen($buffer) > 5) { |
|
| 1203 | 1203 | $line = explode(',',$buffer); |
| 1204 | 1204 | $data = array(); |
| 1205 | 1205 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1216,38 +1216,38 @@ discard block |
||
| 1216 | 1216 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1217 | 1217 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1218 | 1218 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1219 | - } |
|
| 1220 | - } elseif ($format == 'acars') { |
|
| 1221 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1222 | - $ACARS->add(trim($buffer)); |
|
| 1223 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1224 | - $ACARS->deleteLiveAcarsData(); |
|
| 1219 | + } |
|
| 1220 | + } elseif ($format == 'acars') { |
|
| 1221 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1222 | + $ACARS->add(trim($buffer)); |
|
| 1223 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1224 | + $ACARS->deleteLiveAcarsData(); |
|
| 1225 | 1225 | } elseif ($format == 'flightgearmp') { |
| 1226 | - if (substr($buffer,0,1) != '#') { |
|
| 1226 | + if (substr($buffer,0,1) != '#') { |
|
| 1227 | 1227 | $data = array(); |
| 1228 | 1228 | //echo $buffer."\n"; |
| 1229 | 1229 | $line = explode(' ',$buffer); |
| 1230 | 1230 | if (count($line) == 11) { |
| 1231 | - $userserver = explode('@',$line[0]); |
|
| 1232 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1233 | - $data['ident'] = $userserver[0]; |
|
| 1234 | - $data['registration'] = $userserver[0]; |
|
| 1235 | - $data['latitude'] = $line[4]; |
|
| 1236 | - $data['longitude'] = $line[5]; |
|
| 1237 | - $data['altitude'] = $line[6]; |
|
| 1238 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1239 | - $aircraft_type = $line[10]; |
|
| 1240 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1241 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1242 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1243 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1231 | + $userserver = explode('@',$line[0]); |
|
| 1232 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1233 | + $data['ident'] = $userserver[0]; |
|
| 1234 | + $data['registration'] = $userserver[0]; |
|
| 1235 | + $data['latitude'] = $line[4]; |
|
| 1236 | + $data['longitude'] = $line[5]; |
|
| 1237 | + $data['altitude'] = $line[6]; |
|
| 1238 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1239 | + $aircraft_type = $line[10]; |
|
| 1240 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1241 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1242 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1243 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1244 | + } |
|
| 1244 | 1245 | } |
| 1245 | - } |
|
| 1246 | 1246 | } elseif ($format == 'beast') { |
| 1247 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1248 | - die; |
|
| 1247 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1248 | + die; |
|
| 1249 | 1249 | } elseif ($format == 'vrstcp') { |
| 1250 | - foreach($buffer as $all_data) { |
|
| 1250 | + foreach($buffer as $all_data) { |
|
| 1251 | 1251 | $line = json_decode('{'.$all_data.'}',true); |
| 1252 | 1252 | $data = array(); |
| 1253 | 1253 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1267,125 +1267,125 @@ discard block |
||
| 1267 | 1267 | */ |
| 1268 | 1268 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1269 | 1269 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1270 | - $data['format_source'] = 'vrstcp'; |
|
| 1270 | + $data['format_source'] = 'vrstcp'; |
|
| 1271 | 1271 | $data['id_source'] = $id_source; |
| 1272 | 1272 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1273 | 1273 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1274 | 1274 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1275 | 1275 | unset($data); |
| 1276 | - } |
|
| 1276 | + } |
|
| 1277 | 1277 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 1278 | - $line = explode("\t", $buffer); |
|
| 1279 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1278 | + $line = explode("\t", $buffer); |
|
| 1279 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1280 | 1280 | $key = $line[$k]; |
| 1281 | - $lined[$key] = $line[$k+1]; |
|
| 1282 | - } |
|
| 1283 | - if (count($lined) > 3) { |
|
| 1284 | - $data['hex'] = $lined['hexid']; |
|
| 1285 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1286 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1287 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1288 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1289 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1290 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1291 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1292 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1293 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1294 | - $data['id_source'] = $id_source; |
|
| 1295 | - $data['format_source'] = 'tsv'; |
|
| 1296 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1297 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1281 | + $lined[$key] = $line[$k+1]; |
|
| 1282 | + } |
|
| 1283 | + if (count($lined) > 3) { |
|
| 1284 | + $data['hex'] = $lined['hexid']; |
|
| 1285 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1286 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1287 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1288 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1289 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1290 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1291 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1292 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1293 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1294 | + $data['id_source'] = $id_source; |
|
| 1295 | + $data['format_source'] = 'tsv'; |
|
| 1296 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1297 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1298 | 1298 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1299 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1300 | - unset($lined); |
|
| 1301 | - unset($data); |
|
| 1302 | - } else $error = true; |
|
| 1299 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1300 | + unset($lined); |
|
| 1301 | + unset($data); |
|
| 1302 | + } else $error = true; |
|
| 1303 | 1303 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1304 | - if ($aprs_connect == 0) { |
|
| 1304 | + if ($aprs_connect == 0) { |
|
| 1305 | 1305 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1306 | 1306 | $aprs_connect = 1; |
| 1307 | - } |
|
| 1307 | + } |
|
| 1308 | 1308 | |
| 1309 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1309 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1310 | 1310 | $aprs_last_tx = time(); |
| 1311 | 1311 | $data_aprs = "# Keep alive"; |
| 1312 | 1312 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1313 | - } |
|
| 1313 | + } |
|
| 1314 | 1314 | |
| 1315 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1316 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1317 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1318 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1319 | - //echo $buffer."\n"; |
|
| 1320 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1315 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1316 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1317 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1318 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1319 | + //echo $buffer."\n"; |
|
| 1320 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1321 | 1321 | $line = $APRS->parse($buffer); |
| 1322 | 1322 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1323 | 1323 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1324 | - $aprs_last_tx = time(); |
|
| 1325 | - $data = array(); |
|
| 1326 | - //print_r($line); |
|
| 1327 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1328 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1329 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1330 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1331 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1332 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1333 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1334 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1335 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1336 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1337 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1338 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1339 | - $data['latitude'] = $line['latitude']; |
|
| 1340 | - $data['longitude'] = $line['longitude']; |
|
| 1341 | - //$data['verticalrate'] = $line[16]; |
|
| 1342 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1343 | - else $data['speed'] = 0; |
|
| 1344 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1345 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1346 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1347 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1348 | - //else $data['heading'] = 0; |
|
| 1349 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1350 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1351 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1352 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1353 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1354 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1355 | - $data['id_source'] = $id_source; |
|
| 1356 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1357 | - else $data['format_source'] = 'aprs'; |
|
| 1358 | - $data['source_name'] = $line['source']; |
|
| 1359 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1360 | - else $data['source_type'] = 'flarm'; |
|
| 1361 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1362 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1363 | - $aprsdate = strtotime($data['datetime']); |
|
| 1364 | - // Accept data if time <= system time + 20s |
|
| 1365 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1366 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1324 | + $aprs_last_tx = time(); |
|
| 1325 | + $data = array(); |
|
| 1326 | + //print_r($line); |
|
| 1327 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1328 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1329 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1330 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1331 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1332 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1333 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1334 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1335 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1336 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1337 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1338 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1339 | + $data['latitude'] = $line['latitude']; |
|
| 1340 | + $data['longitude'] = $line['longitude']; |
|
| 1341 | + //$data['verticalrate'] = $line[16]; |
|
| 1342 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1343 | + else $data['speed'] = 0; |
|
| 1344 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1345 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1346 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1347 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1348 | + //else $data['heading'] = 0; |
|
| 1349 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1350 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1351 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1352 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1353 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1354 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1355 | + $data['id_source'] = $id_source; |
|
| 1356 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1357 | + else $data['format_source'] = 'aprs'; |
|
| 1358 | + $data['source_name'] = $line['source']; |
|
| 1359 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1360 | + else $data['source_type'] = 'flarm'; |
|
| 1361 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1362 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1363 | + $aprsdate = strtotime($data['datetime']); |
|
| 1364 | + // Accept data if time <= system time + 20s |
|
| 1365 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1366 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1367 | 1367 | $send = $SI->add($data); |
| 1368 | - } elseif ($data['source_type'] == 'ais') { |
|
| 1368 | + } elseif ($data['source_type'] == 'ais') { |
|
| 1369 | 1369 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1370 | - } elseif (isset($line['stealth'])) { |
|
| 1370 | + } elseif (isset($line['stealth'])) { |
|
| 1371 | 1371 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1372 | 1372 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 1373 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1374 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1373 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1374 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1375 | 1375 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1376 | 1376 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1377 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { |
|
| 1377 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { |
|
| 1378 | 1378 | $Source->deleteOldLocationByType('gs'); |
| 1379 | 1379 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
| 1380 | 1380 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1381 | 1381 | } else { |
| 1382 | 1382 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1383 | 1383 | } |
| 1384 | - } else { |
|
| 1385 | - echo '/!\ Not added'."\n"; |
|
| 1386 | - print_r($data); |
|
| 1387 | - } |
|
| 1388 | - unset($data); |
|
| 1384 | + } else { |
|
| 1385 | + echo '/!\ Not added'."\n"; |
|
| 1386 | + print_r($data); |
|
| 1387 | + } |
|
| 1388 | + unset($data); |
|
| 1389 | 1389 | } |
| 1390 | 1390 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 1391 | 1391 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1401,12 +1401,12 @@ discard block |
||
| 1401 | 1401 | */ |
| 1402 | 1402 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1403 | 1403 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 1404 | - } |
|
| 1404 | + } |
|
| 1405 | 1405 | } else { |
| 1406 | - $line = explode(',', $buffer); |
|
| 1407 | - if (count($line) > 20) { |
|
| 1408 | - $data['hex'] = $line[4]; |
|
| 1409 | - /* |
|
| 1406 | + $line = explode(',', $buffer); |
|
| 1407 | + if (count($line) > 20) { |
|
| 1408 | + $data['hex'] = $line[4]; |
|
| 1409 | + /* |
|
| 1410 | 1410 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1411 | 1411 | date_default_timezone_set($globalTimezone); |
| 1412 | 1412 | $datetime = new DateTime($data['datetime']); |
@@ -1414,30 +1414,30 @@ discard block |
||
| 1414 | 1414 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1415 | 1415 | date_default_timezone_set('UTC'); |
| 1416 | 1416 | */ |
| 1417 | - // Force datetime to current UTC datetime |
|
| 1418 | - date_default_timezone_set('UTC'); |
|
| 1419 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1420 | - $data['ident'] = trim($line[10]); |
|
| 1421 | - $data['latitude'] = $line[14]; |
|
| 1422 | - $data['longitude'] = $line[15]; |
|
| 1423 | - $data['verticalrate'] = $line[16]; |
|
| 1424 | - $data['emergency'] = $line[20]; |
|
| 1425 | - $data['speed'] = $line[12]; |
|
| 1426 | - $data['squawk'] = $line[17]; |
|
| 1427 | - $data['altitude'] = $line[11]; |
|
| 1428 | - $data['heading'] = $line[13]; |
|
| 1429 | - $data['ground'] = $line[21]; |
|
| 1430 | - $data['emergency'] = $line[19]; |
|
| 1431 | - $data['format_source'] = 'sbs'; |
|
| 1417 | + // Force datetime to current UTC datetime |
|
| 1418 | + date_default_timezone_set('UTC'); |
|
| 1419 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1420 | + $data['ident'] = trim($line[10]); |
|
| 1421 | + $data['latitude'] = $line[14]; |
|
| 1422 | + $data['longitude'] = $line[15]; |
|
| 1423 | + $data['verticalrate'] = $line[16]; |
|
| 1424 | + $data['emergency'] = $line[20]; |
|
| 1425 | + $data['speed'] = $line[12]; |
|
| 1426 | + $data['squawk'] = $line[17]; |
|
| 1427 | + $data['altitude'] = $line[11]; |
|
| 1428 | + $data['heading'] = $line[13]; |
|
| 1429 | + $data['ground'] = $line[21]; |
|
| 1430 | + $data['emergency'] = $line[19]; |
|
| 1431 | + $data['format_source'] = 'sbs'; |
|
| 1432 | 1432 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1433 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1433 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1434 | 1434 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1435 | - $data['id_source'] = $id_source; |
|
| 1436 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1437 | - else $error = true; |
|
| 1438 | - unset($data); |
|
| 1439 | - } else $error = true; |
|
| 1440 | - if ($error) { |
|
| 1435 | + $data['id_source'] = $id_source; |
|
| 1436 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1437 | + else $error = true; |
|
| 1438 | + unset($data); |
|
| 1439 | + } else $error = true; |
|
| 1440 | + if ($error) { |
|
| 1441 | 1441 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1442 | 1442 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1443 | 1443 | } else { |
@@ -1453,13 +1453,13 @@ discard block |
||
| 1453 | 1453 | connect_all($sourceer); |
| 1454 | 1454 | $sourceer = array(); |
| 1455 | 1455 | } |
| 1456 | - } |
|
| 1456 | + } |
|
| 1457 | 1457 | } |
| 1458 | 1458 | // Sleep for xxx microseconds |
| 1459 | 1459 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1460 | - } else { |
|
| 1460 | + } else { |
|
| 1461 | 1461 | if ($format == 'flightgearmp') { |
| 1462 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1462 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1463 | 1463 | //@socket_close($r); |
| 1464 | 1464 | sleep($globalMinFetch); |
| 1465 | 1465 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1468,9 +1468,9 @@ discard block |
||
| 1468 | 1468 | break; |
| 1469 | 1469 | |
| 1470 | 1470 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1471 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1472 | - else $tt[$format] = 0; |
|
| 1473 | - if ($tt[$format] > 30) { |
|
| 1471 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1472 | + else $tt[$format] = 0; |
|
| 1473 | + if ($tt[$format] > 30) { |
|
| 1474 | 1474 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1475 | 1475 | //@socket_close($r); |
| 1476 | 1476 | sleep(2); |
@@ -1481,23 +1481,23 @@ discard block |
||
| 1481 | 1481 | //connect_all($globalSources); |
| 1482 | 1482 | $tt[$format]=0; |
| 1483 | 1483 | break; |
| 1484 | - } |
|
| 1484 | + } |
|
| 1485 | + } |
|
| 1485 | 1486 | } |
| 1486 | - } |
|
| 1487 | 1487 | } |
| 1488 | - } else { |
|
| 1488 | + } else { |
|
| 1489 | 1489 | $error = socket_strerror(socket_last_error()); |
| 1490 | 1490 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1491 | 1491 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1492 | 1492 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1493 | 1493 | // Restart the script if possible |
| 1494 | 1494 | if (is_array($sockets)) { |
| 1495 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1495 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1496 | 1496 | |
| 1497 | - foreach ($sockets as $sock) { |
|
| 1497 | + foreach ($sockets as $sock) { |
|
| 1498 | 1498 | @socket_shutdown($sock,2); |
| 1499 | 1499 | @socket_close($sock); |
| 1500 | - } |
|
| 1500 | + } |
|
| 1501 | 1501 | |
| 1502 | 1502 | } |
| 1503 | 1503 | if ($globalDebug) echo "Waiting..."; |
@@ -1512,13 +1512,13 @@ discard block |
||
| 1512 | 1512 | if ($globalDebug) echo "Restart all connections..."; |
| 1513 | 1513 | connect_all($globalSources); |
| 1514 | 1514 | } |
| 1515 | - } |
|
| 1515 | + } |
|
| 1516 | 1516 | } |
| 1517 | 1517 | if ($globalDaemon === false) { |
| 1518 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1519 | - $SI->checkAll(); |
|
| 1518 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1519 | + $SI->checkAll(); |
|
| 1520 | + } |
|
| 1520 | 1521 | } |
| 1521 | - } |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | ?> |
@@ -14,13 +14,17 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 17 | +if (isset($globalTracker) && $globalTracker) { |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | +} |
|
| 18 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version |
| 26 | 30 | $Connection = new Connection(); |
@@ -55,35 +59,62 @@ discard block |
||
| 55 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 56 | 60 | if (isset($options['s'])) { |
| 57 | 61 | $globalSources = array(); |
| 58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 59 | - else $globalSources[] = array('host' => $options['s']); |
|
| 60 | -} elseif (isset($options['source'])) { |
|
| 62 | + if (isset($options['format'])) { |
|
| 63 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 64 | + } else { |
|
| 65 | + $globalSources[] = array('host' => $options['s']); |
|
| 66 | + } |
|
| 67 | + } elseif (isset($options['source'])) { |
|
| 61 | 68 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['source']); |
|
| 64 | -} |
|
| 69 | + if (isset($options['format'])) { |
|
| 70 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 71 | + } else { |
|
| 72 | + $globalSources[] = array('host' => $options['source']); |
|
| 73 | + } |
|
| 74 | + } |
|
| 65 | 75 | if (isset($options['aprsserverhost'])) { |
| 66 | 76 | $globalServerAPRS = TRUE; |
| 67 | 77 | $globalServerAPRShost = $options['aprsserverhost']; |
| 68 | 78 | } |
| 69 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 70 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 71 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 72 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 73 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 74 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 75 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 76 | -else $id_source = 1; |
|
| 79 | +if (isset($options['aprsserverport'])) { |
|
| 80 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 81 | +} |
|
| 82 | +if (isset($options['aprsserverssid'])) { |
|
| 83 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | +} |
|
| 85 | +if (isset($options['aprsserverpass'])) { |
|
| 86 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 87 | +} |
|
| 88 | +if (isset($options['noaprsserver'])) { |
|
| 89 | + $globalServerAPRS = FALSE; |
|
| 90 | +} |
|
| 91 | +if (isset($options['nodaemon'])) { |
|
| 92 | + $globalDaemon = FALSE; |
|
| 93 | +} |
|
| 94 | +if (isset($options['server'])) { |
|
| 95 | + $globalServer = TRUE; |
|
| 96 | +} |
|
| 97 | +if (isset($options['idsource'])) { |
|
| 98 | + $id_source = $options['idsource']; |
|
| 99 | +} else { |
|
| 100 | + $id_source = 1; |
|
| 101 | +} |
|
| 77 | 102 | if (isset($globalServer) && $globalServer) { |
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo "Using Server Mode\n"; |
|
| 105 | + } |
|
| 79 | 106 | $SI=new SpotterServer(); |
| 80 | 107 | /* |
| 81 | 108 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 82 | 109 | $SI = new adsb2aprs(); |
| 83 | 110 | $SI->connect(); |
| 84 | 111 | */ |
| 85 | -} else $SI=new SpotterImport($Connection->db); |
|
| 86 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 112 | +} else { |
|
| 113 | + $SI=new SpotterImport($Connection->db); |
|
| 114 | +} |
|
| 115 | +if (isset($globalTracker) && $globalTracker) { |
|
| 116 | + $TI = new TrackerImport($Connection->db); |
|
| 117 | +} |
|
| 87 | 118 | if (isset($globalMarine) && $globalMarine) { |
| 88 | 119 | $AIS = new AIS(); |
| 89 | 120 | $MI = new MarineImport($Connection->db); |
@@ -106,7 +137,9 @@ discard block |
||
| 106 | 137 | } |
| 107 | 138 | |
| 108 | 139 | // let's try and connect |
| 109 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 140 | +if ($globalDebug) { |
|
| 141 | + echo "Connecting...\n"; |
|
| 142 | +} |
|
| 110 | 143 | $use_aprs = false; |
| 111 | 144 | $aprs_full = false; |
| 112 | 145 | $reset = 0; |
@@ -115,7 +148,9 @@ discard block |
||
| 115 | 148 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 116 | 149 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 117 | 150 | $reset++; |
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 151 | + if ($globalDebug) { |
|
| 152 | + echo 'Connect to all...'."\n"; |
|
| 153 | + } |
|
| 119 | 154 | foreach ($hosts as $id => $value) { |
| 120 | 155 | $host = $value['host']; |
| 121 | 156 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,22 +160,30 @@ discard block |
||
| 125 | 160 | //$formats[$id] = 'deltadbtxt'; |
| 126 | 161 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 127 | 162 | //$last_exec['deltadbtxt'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 163 | + if ($globalDebug) { |
|
| 164 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 165 | + } |
|
| 129 | 166 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 130 | 167 | //$formats[$id] = 'vatsimtxt'; |
| 131 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 132 | 169 | //$last_exec['vatsimtxt'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 170 | + if ($globalDebug) { |
|
| 171 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 172 | + } |
|
| 134 | 173 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 135 | 174 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 175 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 137 | 176 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 179 | + } |
|
| 139 | 180 | } else if (preg_match('/opensky/i',$host)) { |
| 140 | 181 | //$formats[$id] = 'aircraftlistjson'; |
| 141 | 182 | $globalSources[$id]['format'] = 'opensky'; |
| 142 | 183 | //$last_exec['aircraftlistjson'] = 0; |
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 184 | + if ($globalDebug) { |
|
| 185 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 186 | + } |
|
| 144 | 187 | /* |
| 145 | 188 | // Disabled for now, site change source format |
| 146 | 189 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -157,7 +200,9 @@ discard block |
||
| 157 | 200 | //$formats[$id] = 'planeupdatefaa'; |
| 158 | 201 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 159 | 202 | //$last_exec['planeupdatefaa'] = 0; |
| 160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 203 | + if ($globalDebug) { |
|
| 204 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 205 | + } |
|
| 161 | 206 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 162 | 207 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 163 | 208 | exit(0); |
@@ -166,29 +211,41 @@ discard block |
||
| 166 | 211 | //$formats[$id] = 'phpvmacars'; |
| 167 | 212 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 168 | 213 | //$last_exec['phpvmacars'] = 0; |
| 169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 214 | + if ($globalDebug) { |
|
| 215 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 216 | + } |
|
| 170 | 217 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 171 | 218 | //$formats[$id] = 'phpvmacars'; |
| 172 | 219 | $globalSources[$id]['format'] = 'vam'; |
| 173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 220 | + if ($globalDebug) { |
|
| 221 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 222 | + } |
|
| 174 | 223 | } else if (preg_match('/whazzup/i',$host)) { |
| 175 | 224 | //$formats[$id] = 'whazzup'; |
| 176 | 225 | $globalSources[$id]['format'] = 'whazzup'; |
| 177 | 226 | //$last_exec['whazzup'] = 0; |
| 178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 227 | + if ($globalDebug) { |
|
| 228 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 229 | + } |
|
| 179 | 230 | } else if (preg_match('/airwhere/i',$host)) { |
| 180 | 231 | $globalSources[$id]['format'] = 'airwhere'; |
| 181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 234 | + } |
|
| 182 | 235 | } else if (preg_match('/recentpireps/i',$host)) { |
| 183 | 236 | //$formats[$id] = 'pirepsjson'; |
| 184 | 237 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 185 | 238 | //$last_exec['pirepsjson'] = 0; |
| 186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 239 | + if ($globalDebug) { |
|
| 240 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 241 | + } |
|
| 187 | 242 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 188 | 243 | //$formats[$id] = 'fr24json'; |
| 189 | 244 | $globalSources[$id]['format'] = 'fr24json'; |
| 190 | 245 | //$last_exec['fr24json'] = 0; |
| 191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 246 | + if ($globalDebug) { |
|
| 247 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 248 | + } |
|
| 192 | 249 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 193 | 250 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 194 | 251 | exit(0); |
@@ -197,7 +254,9 @@ discard block |
||
| 197 | 254 | //$formats[$id] = 'fr24json'; |
| 198 | 255 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 199 | 256 | //$last_exec['fr24json'] = 0; |
| 200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 259 | + } |
|
| 201 | 260 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 202 | 261 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 203 | 262 | exit(0); |
@@ -206,17 +265,24 @@ discard block |
||
| 206 | 265 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 207 | 266 | //$formats[$id] = 'tsv'; |
| 208 | 267 | $globalSources[$id]['format'] = 'tsv'; |
| 209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 268 | + if ($globalDebug) { |
|
| 269 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 270 | + } |
|
| 210 | 271 | } |
| 211 | 272 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 212 | 273 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 213 | 274 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 214 | 275 | if ($idf !== false) { |
| 215 | 276 | $httpfeeds[$id] = $idf; |
| 216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 279 | + } |
|
| 280 | + } elseif ($globalDebug) { |
|
| 281 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 217 | 282 | } |
| 218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 283 | + } elseif ($globalDebug) { |
|
| 284 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 285 | + } |
|
| 220 | 286 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 221 | 287 | $hostport = explode(':',$host); |
| 222 | 288 | if (isset($hostport[1])) { |
@@ -256,17 +322,25 @@ discard block |
||
| 256 | 322 | //$formats[$id] = 'beast'; |
| 257 | 323 | $globalSources[$id]['format'] = 'beast'; |
| 258 | 324 | //} else $formats[$id] = 'sbs'; |
| 259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 325 | + } else { |
|
| 326 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 327 | + } |
|
| 260 | 328 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 261 | 329 | } |
| 262 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 330 | + if ($globalDebug) { |
|
| 331 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 332 | + } |
|
| 263 | 333 | } else { |
| 264 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 334 | + if ($globalDebug) { |
|
| 335 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 336 | + } |
|
| 265 | 337 | } |
| 266 | 338 | } |
| 267 | 339 | } |
| 268 | 340 | } |
| 269 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 341 | +if (!isset($globalMinFetch)) { |
|
| 342 | + $globalMinFetch = 15; |
|
| 343 | +} |
|
| 270 | 344 | |
| 271 | 345 | // Initialize all |
| 272 | 346 | $status = array(); |
@@ -275,13 +349,19 @@ discard block |
||
| 275 | 349 | $formats = array(); |
| 276 | 350 | $last_exec = array(); |
| 277 | 351 | $time = time(); |
| 278 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 279 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 280 | -else $timeout = 20; |
|
| 352 | +if (isset($globalSourcesTimeout)) { |
|
| 353 | + $timeout = $globalSourcesTimeOut; |
|
| 354 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 355 | + $timeout = $globalSBS1TimeOut; |
|
| 356 | +} else { |
|
| 357 | + $timeout = 20; |
|
| 358 | +} |
|
| 281 | 359 | $errno = ''; |
| 282 | 360 | $errstr=''; |
| 283 | 361 | |
| 284 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 362 | +if (!isset($globalDaemon)) { |
|
| 363 | + $globalDaemon = TRUE; |
|
| 364 | +} |
|
| 285 | 365 | /* Initiate connections to all the hosts simultaneously */ |
| 286 | 366 | //connect_all($hosts); |
| 287 | 367 | //connect_all($globalSources); |
@@ -307,7 +387,9 @@ discard block |
||
| 307 | 387 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 308 | 388 | $aprs_connect = 0; |
| 309 | 389 | $use_aprs = true; |
| 310 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 390 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 391 | + $aprs_full = true; |
|
| 392 | + } |
|
| 311 | 393 | break; |
| 312 | 394 | } |
| 313 | 395 | } |
@@ -318,25 +400,48 @@ discard block |
||
| 318 | 400 | $aprs_connect = 0; |
| 319 | 401 | $aprs_keep = 120; |
| 320 | 402 | $aprs_last_tx = time(); |
| 321 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 322 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 323 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 324 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 325 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 327 | - if ($aprs_full) $aprs_filter = ''; |
|
| 328 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 329 | - else $aprs_pass = '-1'; |
|
| 403 | + if (isset($globalAPRSversion)) { |
|
| 404 | + $aprs_version = $globalAPRSversion; |
|
| 405 | + } else { |
|
| 406 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 407 | + } |
|
| 408 | + if (isset($globalAPRSssid)) { |
|
| 409 | + $aprs_ssid = $globalAPRSssid; |
|
| 410 | + } else { |
|
| 411 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 412 | + } |
|
| 413 | + if (isset($globalAPRSfilter)) { |
|
| 414 | + $aprs_filter = $globalAPRSfilter; |
|
| 415 | + } else { |
|
| 416 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 417 | + } |
|
| 418 | + if ($aprs_full) { |
|
| 419 | + $aprs_filter = ''; |
|
| 420 | + } |
|
| 421 | + if (isset($globalAPRSpass)) { |
|
| 422 | + $aprs_pass = $globalAPRSpass; |
|
| 423 | + } else { |
|
| 424 | + $aprs_pass = '-1'; |
|
| 425 | + } |
|
| 330 | 426 | |
| 331 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 332 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 333 | -} |
|
| 427 | + if ($aprs_filter != '') { |
|
| 428 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 429 | + } else { |
|
| 430 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 431 | + } |
|
| 432 | + } |
|
| 334 | 433 | |
| 335 | 434 | // connected - lets do some work |
| 336 | -if ($globalDebug) echo "Connected!\n"; |
|
| 435 | +if ($globalDebug) { |
|
| 436 | + echo "Connected!\n"; |
|
| 437 | +} |
|
| 337 | 438 | sleep(1); |
| 338 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 339 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 439 | +if ($globalDebug) { |
|
| 440 | + echo "SCAN MODE \n\n"; |
|
| 441 | +} |
|
| 442 | +if (!isset($globalCronEnd)) { |
|
| 443 | + $globalCronEnd = 60; |
|
| 444 | +} |
|
| 340 | 445 | $endtime = time()+$globalCronEnd; |
| 341 | 446 | $i = 1; |
| 342 | 447 | $tt = array(); |
@@ -350,20 +455,28 @@ discard block |
||
| 350 | 455 | |
| 351 | 456 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 352 | 457 | while ($i > 0) { |
| 353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 458 | + if (!$globalDaemon) { |
|
| 459 | + $i = $endtime-time(); |
|
| 460 | + } |
|
| 354 | 461 | // Delete old ATC |
| 355 | 462 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 356 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 463 | + if ($globalDebug) { |
|
| 464 | + echo 'Delete old ATC...'."\n"; |
|
| 465 | + } |
|
| 357 | 466 | $ATC->deleteOldATC(); |
| 358 | 467 | } |
| 359 | 468 | |
| 360 | 469 | if (count($last_exec) == count($globalSources)) { |
| 361 | 470 | $max = $globalMinFetch; |
| 362 | 471 | foreach ($last_exec as $last) { |
| 363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 472 | + if ((time() - $last['last']) < $max) { |
|
| 473 | + $max = time() - $last['last']; |
|
| 474 | + } |
|
| 364 | 475 | } |
| 365 | 476 | if ($max != $globalMinFetch) { |
| 366 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 477 | + if ($globalDebug) { |
|
| 478 | + echo 'Sleeping...'."\n"; |
|
| 479 | + } |
|
| 367 | 480 | sleep($globalMinFetch-$max+2); |
| 368 | 481 | } |
| 369 | 482 | } |
@@ -372,11 +485,15 @@ discard block |
||
| 372 | 485 | //foreach ($formats as $id => $value) { |
| 373 | 486 | foreach ($globalSources as $id => $value) { |
| 374 | 487 | date_default_timezone_set('UTC'); |
| 375 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 488 | + if (!isset($last_exec[$id]['last'])) { |
|
| 489 | + $last_exec[$id]['last'] = 0; |
|
| 490 | + } |
|
| 376 | 491 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 377 | 492 | //$buffer = $Common->getData($hosts[$id]); |
| 378 | 493 | $buffer = $Common->getData($value['host']); |
| 379 | - if ($buffer != '') $reset = 0; |
|
| 494 | + if ($buffer != '') { |
|
| 495 | + $reset = 0; |
|
| 496 | + } |
|
| 380 | 497 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 381 | 498 | $buffer = explode('\n',$buffer); |
| 382 | 499 | foreach ($buffer as $line) { |
@@ -385,20 +502,41 @@ discard block |
||
| 385 | 502 | $data = array(); |
| 386 | 503 | $data['hex'] = $line[1]; // hex |
| 387 | 504 | $data['ident'] = $line[2]; // ident |
| 388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 505 | + if (isset($line[3])) { |
|
| 506 | + $data['altitude'] = $line[3]; |
|
| 507 | + } |
|
| 508 | + // altitude |
|
| 509 | + if (isset($line[4])) { |
|
| 510 | + $data['speed'] = $line[4]; |
|
| 511 | + } |
|
| 512 | + // speed |
|
| 513 | + if (isset($line[5])) { |
|
| 514 | + $data['heading'] = $line[5]; |
|
| 515 | + } |
|
| 516 | + // heading |
|
| 517 | + if (isset($line[6])) { |
|
| 518 | + $data['latitude'] = $line[6]; |
|
| 519 | + } |
|
| 520 | + // lat |
|
| 521 | + if (isset($line[7])) { |
|
| 522 | + $data['longitude'] = $line[7]; |
|
| 523 | + } |
|
| 524 | + // long |
|
| 393 | 525 | $data['verticalrate'] = ''; // vertical rate |
| 394 | 526 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 395 | 527 | $data['emergency'] = ''; // emergency |
| 396 | 528 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 397 | 529 | $data['format_source'] = 'deltadbtxt'; |
| 398 | 530 | $data['id_source'] = $id_source; |
| 399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 531 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 532 | + $data['source_name'] = $value['name']; |
|
| 533 | + } |
|
| 534 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 535 | + $data['noarchive'] = true; |
|
| 536 | + } |
|
| 537 | + if (isset($value['sourcestats'])) { |
|
| 538 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 539 | + } |
|
| 402 | 540 | $SI->add($data); |
| 403 | 541 | unset($data); |
| 404 | 542 | } |
@@ -408,7 +546,9 @@ discard block |
||
| 408 | 546 | date_default_timezone_set('CET'); |
| 409 | 547 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 410 | 548 | date_default_timezone_set('UTC'); |
| 411 | - if ($buffer != '') $reset = 0; |
|
| 549 | + if ($buffer != '') { |
|
| 550 | + $reset = 0; |
|
| 551 | + } |
|
| 412 | 552 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 413 | 553 | $buffer = explode('\n',$buffer); |
| 414 | 554 | foreach ($buffer as $line) { |
@@ -417,16 +557,36 @@ discard block |
||
| 417 | 557 | $add = false; |
| 418 | 558 | $ais_data = $AIS->parse_line(trim($line)); |
| 419 | 559 | $data = array(); |
| 420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 560 | + if (isset($ais_data['ident'])) { |
|
| 561 | + $data['ident'] = $ais_data['ident']; |
|
| 562 | + } |
|
| 563 | + if (isset($ais_data['mmsi'])) { |
|
| 564 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 565 | + } |
|
| 566 | + if (isset($ais_data['speed'])) { |
|
| 567 | + $data['speed'] = $ais_data['speed']; |
|
| 568 | + } |
|
| 569 | + if (isset($ais_data['heading'])) { |
|
| 570 | + $data['heading'] = $ais_data['heading']; |
|
| 571 | + } |
|
| 572 | + if (isset($ais_data['latitude'])) { |
|
| 573 | + $data['latitude'] = $ais_data['latitude']; |
|
| 574 | + } |
|
| 575 | + if (isset($ais_data['longitude'])) { |
|
| 576 | + $data['longitude'] = $ais_data['longitude']; |
|
| 577 | + } |
|
| 578 | + if (isset($ais_data['status'])) { |
|
| 579 | + $data['status'] = $ais_data['status']; |
|
| 580 | + } |
|
| 581 | + if (isset($ais_data['type'])) { |
|
| 582 | + $data['type'] = $ais_data['type']; |
|
| 583 | + } |
|
| 584 | + if (isset($ais_data['imo'])) { |
|
| 585 | + $data['imo'] = $ais_data['imo']; |
|
| 586 | + } |
|
| 587 | + if (isset($ais_data['callsign'])) { |
|
| 588 | + $data['callsign'] = $ais_data['callsign']; |
|
| 589 | + } |
|
| 430 | 590 | if (isset($ais_data['timestamp'])) { |
| 431 | 591 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 432 | 592 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -440,8 +600,12 @@ discard block |
||
| 440 | 600 | $data['format_source'] = 'aisnmeatxt'; |
| 441 | 601 | $data['id_source'] = $id_source; |
| 442 | 602 | //print_r($data); |
| 443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 603 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 604 | + $data['noarchive'] = true; |
|
| 605 | + } |
|
| 606 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 607 | + $MI->add($data); |
|
| 608 | + } |
|
| 445 | 609 | unset($data); |
| 446 | 610 | } |
| 447 | 611 | } |
@@ -461,20 +625,48 @@ discard block |
||
| 461 | 625 | if ($line != '') { |
| 462 | 626 | $ais_data = $AIS->parse_line(trim($line)); |
| 463 | 627 | $data = array(); |
| 464 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 465 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 466 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 467 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 468 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 469 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 470 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 471 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 472 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 473 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 474 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 475 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 476 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 477 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 628 | + if (isset($ais_data['ident'])) { |
|
| 629 | + $data['ident'] = $ais_data['ident']; |
|
| 630 | + } |
|
| 631 | + if (isset($ais_data['mmsi'])) { |
|
| 632 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 633 | + } |
|
| 634 | + if (isset($ais_data['speed'])) { |
|
| 635 | + $data['speed'] = $ais_data['speed']; |
|
| 636 | + } |
|
| 637 | + if (isset($ais_data['heading'])) { |
|
| 638 | + $data['heading'] = $ais_data['heading']; |
|
| 639 | + } |
|
| 640 | + if (isset($ais_data['latitude'])) { |
|
| 641 | + $data['latitude'] = $ais_data['latitude']; |
|
| 642 | + } |
|
| 643 | + if (isset($ais_data['longitude'])) { |
|
| 644 | + $data['longitude'] = $ais_data['longitude']; |
|
| 645 | + } |
|
| 646 | + if (isset($ais_data['status'])) { |
|
| 647 | + $data['status'] = $ais_data['status']; |
|
| 648 | + } |
|
| 649 | + if (isset($ais_data['statusid'])) { |
|
| 650 | + $data['status_id'] = $ais_data['statusid']; |
|
| 651 | + } |
|
| 652 | + if (isset($ais_data['type'])) { |
|
| 653 | + $data['type'] = $ais_data['type']; |
|
| 654 | + } |
|
| 655 | + if (isset($ais_data['typeid'])) { |
|
| 656 | + $data['type_id'] = $ais_data['typeid']; |
|
| 657 | + } |
|
| 658 | + if (isset($ais_data['imo'])) { |
|
| 659 | + $data['imo'] = $ais_data['imo']; |
|
| 660 | + } |
|
| 661 | + if (isset($ais_data['callsign'])) { |
|
| 662 | + $data['callsign'] = $ais_data['callsign']; |
|
| 663 | + } |
|
| 664 | + if (isset($ais_data['destination'])) { |
|
| 665 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 666 | + } |
|
| 667 | + if (isset($ais_data['eta_ts'])) { |
|
| 668 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 669 | + } |
|
| 478 | 670 | if (isset($ais_data['timestamp'])) { |
| 479 | 671 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 480 | 672 | } else { |
@@ -482,18 +674,27 @@ discard block |
||
| 482 | 674 | } |
| 483 | 675 | $data['format_source'] = 'aisnmeahttp'; |
| 484 | 676 | $data['id_source'] = $id_source; |
| 485 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 486 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 677 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 678 | + $data['noarchive'] = true; |
|
| 679 | + } |
|
| 680 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 681 | + $MI->add($data); |
|
| 682 | + } |
|
| 487 | 683 | unset($data); |
| 488 | 684 | } |
| 489 | 685 | } |
| 490 | 686 | } |
| 491 | 687 | } else { |
| 492 | 688 | $format = $value['format']; |
| 493 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 494 | - else $tt[$format] = 0; |
|
| 689 | + if (isset($tt[$format])) { |
|
| 690 | + $tt[$format]++; |
|
| 691 | + } else { |
|
| 692 | + $tt[$format] = 0; |
|
| 693 | + } |
|
| 495 | 694 | if ($tt[$format] > 30) { |
| 496 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 695 | + if ($globalDebug) { |
|
| 696 | + echo 'Reconnect...'."\n"; |
|
| 697 | + } |
|
| 497 | 698 | sleep(2); |
| 498 | 699 | $sourceeen[] = $value; |
| 499 | 700 | connect_all($sourceeen); |
@@ -523,7 +724,9 @@ discard block |
||
| 523 | 724 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 524 | 725 | $data['format_source'] = 'myshiptracking'; |
| 525 | 726 | $data['id_source'] = $id_source; |
| 526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 727 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 728 | + $data['noarchive'] = true; |
|
| 729 | + } |
|
| 527 | 730 | $MI->add($data); |
| 528 | 731 | unset($data); |
| 529 | 732 | } |
@@ -543,7 +746,9 @@ discard block |
||
| 543 | 746 | $data['callsign'] = $line['callsign']; |
| 544 | 747 | $data['mmsi'] = $line['mmsi']; |
| 545 | 748 | $data['speed'] = $line['sog']; |
| 546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 749 | + if ($line['heading'] != '511') { |
|
| 750 | + $data['heading'] = $line['heading']; |
|
| 751 | + } |
|
| 547 | 752 | $data['latitude'] = $line['latitude']; |
| 548 | 753 | $data['longitude'] = $line['longitude']; |
| 549 | 754 | $data['type_id'] = $line['shiptype']; |
@@ -551,7 +756,9 @@ discard block |
||
| 551 | 756 | $data['datetime'] = $line['time']; |
| 552 | 757 | $data['format_source'] = 'boatbeaconapp'; |
| 553 | 758 | $data['id_source'] = $id_source; |
| 554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 759 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 760 | + $data['noarchive'] = true; |
|
| 761 | + } |
|
| 555 | 762 | $MI->add($data); |
| 556 | 763 | unset($data); |
| 557 | 764 | } |
@@ -567,22 +774,44 @@ discard block |
||
| 567 | 774 | if (isset($all_data['features'][0]['id'])) { |
| 568 | 775 | foreach ($all_data['features'] as $line) { |
| 569 | 776 | $data = array(); |
| 570 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 571 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 572 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
| 573 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
| 574 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 575 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
| 777 | + if (isset($line['properties']['name'])) { |
|
| 778 | + $data['ident'] = $line['properties']['name']; |
|
| 779 | + } |
|
| 780 | + if (isset($line['properties']['callsign'])) { |
|
| 781 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 782 | + } |
|
| 783 | + if (isset($line['properties']['mmsi'])) { |
|
| 784 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
| 785 | + } |
|
| 786 | + if (isset($line['properties']['imo'])) { |
|
| 787 | + $data['mmsi'] = $line['properties']['imo']; |
|
| 788 | + } |
|
| 789 | + if (isset($line['properties']['speed'])) { |
|
| 790 | + $data['speed'] = $line['properties']['speed']; |
|
| 791 | + } |
|
| 792 | + if (isset($line['properties']['heading'])) { |
|
| 793 | + $data['heading'] = $line['properties']['heading']; |
|
| 794 | + } |
|
| 576 | 795 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 577 | 796 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 578 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 579 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 580 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 797 | + if (isset($line['properties']['vesselType'])) { |
|
| 798 | + $data['type'] = $line['properties']['vesselType']; |
|
| 799 | + } |
|
| 800 | + if (isset($line['properties']['destination'])) { |
|
| 801 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 802 | + } |
|
| 803 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 804 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 805 | + } |
|
| 581 | 806 | $data['format_source'] = 'boatnerd'; |
| 582 | 807 | $data['id_source'] = $id_source; |
| 583 | 808 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 585 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 809 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 810 | + $data['noarchive'] = true; |
|
| 811 | + } |
|
| 812 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 813 | + $MI->add($data); |
|
| 814 | + } |
|
| 586 | 815 | unset($data); |
| 587 | 816 | } |
| 588 | 817 | } |
@@ -593,7 +822,9 @@ discard block |
||
| 593 | 822 | echo 'download...'; |
| 594 | 823 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 595 | 824 | echo 'done !'."\n"; |
| 596 | - if ($buffer != '') $reset = 0; |
|
| 825 | + if ($buffer != '') { |
|
| 826 | + $reset = 0; |
|
| 827 | + } |
|
| 597 | 828 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 598 | 829 | $buffer = explode('\n',$buffer); |
| 599 | 830 | foreach ($buffer as $line) { |
@@ -618,7 +849,9 @@ discard block |
||
| 618 | 849 | //$data['etaTime'] = substr($line,135,5); |
| 619 | 850 | $data['format_source'] = 'shipplotter'; |
| 620 | 851 | $data['id_source'] = $id_source; |
| 621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 852 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 853 | + $data['noarchive'] = true; |
|
| 854 | + } |
|
| 622 | 855 | //print_r($data); |
| 623 | 856 | echo 'Add...'."\n"; |
| 624 | 857 | $MI->add($data); |
@@ -638,16 +871,28 @@ discard block |
||
| 638 | 871 | $line = explode(':', $line); |
| 639 | 872 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 640 | 873 | $data = array(); |
| 641 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 642 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 874 | + if (isset($line[37]) && $line[37] != '') { |
|
| 875 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 876 | + } else { |
|
| 877 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 878 | + } |
|
| 643 | 879 | $data['pilot_id'] = $line[1]; |
| 644 | 880 | $data['pilot_name'] = $line[2]; |
| 645 | 881 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 646 | 882 | $data['ident'] = $line[0]; // ident |
| 647 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 883 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 884 | + $data['altitude'] = $line[7]; |
|
| 885 | + } |
|
| 886 | + // altitude |
|
| 648 | 887 | $data['speed'] = $line[8]; // speed |
| 649 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 650 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 888 | + if (isset($line[45])) { |
|
| 889 | + $data['heading'] = $line[45]; |
|
| 890 | + } |
|
| 891 | + // heading |
|
| 892 | + elseif (isset($line[38])) { |
|
| 893 | + $data['heading'] = $line[38]; |
|
| 894 | + } |
|
| 895 | + // heading |
|
| 651 | 896 | $data['latitude'] = $line[5]; // lat |
| 652 | 897 | $data['longitude'] = $line[6]; // long |
| 653 | 898 | $data['verticalrate'] = ''; // vertical rate |
@@ -663,7 +908,9 @@ discard block |
||
| 663 | 908 | $data['frequency'] = $line[4]; |
| 664 | 909 | $data['type'] = $line[18]; |
| 665 | 910 | $data['range'] = $line[19]; |
| 666 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 911 | + if (isset($line[35])) { |
|
| 912 | + $data['info'] = $line[35]; |
|
| 913 | + } |
|
| 667 | 914 | $data['id_source'] = $id_source; |
| 668 | 915 | //$data['arrival_airport_time'] = ; |
| 669 | 916 | if ($line[9] != '') { |
@@ -677,27 +924,47 @@ discard block |
||
| 677 | 924 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 678 | 925 | */ |
| 679 | 926 | $data['format_source'] = $value['format']; |
| 680 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 681 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 682 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 683 | - elseif ($line[3] == 'ATC') { |
|
| 927 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 928 | + $data['noarchive'] = true; |
|
| 929 | + } |
|
| 930 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 931 | + $data['source_name'] = $value['name']; |
|
| 932 | + } |
|
| 933 | + if ($line[3] == 'PILOT') { |
|
| 934 | + $SI->add($data); |
|
| 935 | + } elseif ($line[3] == 'ATC') { |
|
| 684 | 936 | //print_r($data); |
| 685 | 937 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 686 | 938 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 687 | 939 | $typec = substr($data['ident'],-3); |
| 688 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 689 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 690 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 691 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 692 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 693 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 694 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 695 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 696 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 697 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 940 | + if ($typec == 'APP') { |
|
| 941 | + $data['type'] = 'Approach'; |
|
| 942 | + } elseif ($typec == 'TWR') { |
|
| 943 | + $data['type'] = 'Tower'; |
|
| 944 | + } elseif ($typec == 'OBS') { |
|
| 945 | + $data['type'] = 'Observer'; |
|
| 946 | + } elseif ($typec == 'GND') { |
|
| 947 | + $data['type'] = 'Ground'; |
|
| 948 | + } elseif ($typec == 'DEL') { |
|
| 949 | + $data['type'] = 'Delivery'; |
|
| 950 | + } elseif ($typec == 'DEP') { |
|
| 951 | + $data['type'] = 'Departure'; |
|
| 952 | + } elseif ($typec == 'FSS') { |
|
| 953 | + $data['type'] = 'Flight Service Station'; |
|
| 954 | + } elseif ($typec == 'CTR') { |
|
| 955 | + $data['type'] = 'Control Radar or Centre'; |
|
| 956 | + } elseif ($data['type'] == '') { |
|
| 957 | + $data['type'] = 'Observer'; |
|
| 958 | + } |
|
| 959 | + if (!isset($data['source_name'])) { |
|
| 960 | + $data['source_name'] = ''; |
|
| 961 | + } |
|
| 698 | 962 | if (isset($ATC)) { |
| 699 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 700 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 963 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 964 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 965 | + } else { |
|
| 966 | + echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 967 | + } |
|
| 701 | 968 | } |
| 702 | 969 | } |
| 703 | 970 | unset($data); |
@@ -719,13 +986,19 @@ discard block |
||
| 719 | 986 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 720 | 987 | $data['latitude'] = (float)$line['pktLatitude']; |
| 721 | 988 | $data['longitude'] = (float)$line['pktLongitude']; |
| 722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 989 | + if ((float)$line['pktTrack'] != 0) { |
|
| 990 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 991 | + } |
|
| 992 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 993 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 994 | + } |
|
| 724 | 995 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 725 | 996 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 726 | 997 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 727 | 998 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 728 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 999 | + if (isset($pilot_data[4])) { |
|
| 1000 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1001 | + } |
|
| 729 | 1002 | $data['format_source'] = $value['format']; |
| 730 | 1003 | $SI->add($data); |
| 731 | 1004 | unset($data); |
@@ -761,27 +1034,61 @@ discard block |
||
| 761 | 1034 | foreach ($all_data['acList'] as $line) { |
| 762 | 1035 | $data = array(); |
| 763 | 1036 | $data['hex'] = $line['Icao']; // hex |
| 764 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 765 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 766 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 767 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 768 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 769 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1037 | + if (isset($line['Call'])) { |
|
| 1038 | + $data['ident'] = $line['Call']; |
|
| 1039 | + } |
|
| 1040 | + // ident |
|
| 1041 | + if (isset($line['Alt'])) { |
|
| 1042 | + $data['altitude'] = $line['Alt']; |
|
| 1043 | + } |
|
| 1044 | + // altitude |
|
| 1045 | + if (isset($line['Spd'])) { |
|
| 1046 | + $data['speed'] = $line['Spd']; |
|
| 1047 | + } |
|
| 1048 | + // speed |
|
| 1049 | + if (isset($line['Trak'])) { |
|
| 1050 | + $data['heading'] = $line['Trak']; |
|
| 1051 | + } |
|
| 1052 | + // heading |
|
| 1053 | + if (isset($line['Lat'])) { |
|
| 1054 | + $data['latitude'] = $line['Lat']; |
|
| 1055 | + } |
|
| 1056 | + // lat |
|
| 1057 | + if (isset($line['Long'])) { |
|
| 1058 | + $data['longitude'] = $line['Long']; |
|
| 1059 | + } |
|
| 1060 | + // long |
|
| 770 | 1061 | //$data['verticalrate'] = $line['']; // verticale rate |
| 771 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1062 | + if (isset($line['Sqk'])) { |
|
| 1063 | + $data['squawk'] = $line['Sqk']; |
|
| 1064 | + } |
|
| 1065 | + // squawk |
|
| 772 | 1066 | $data['emergency'] = ''; // emergency |
| 773 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1067 | + if (isset($line['Reg'])) { |
|
| 1068 | + $data['registration'] = $line['Reg']; |
|
| 1069 | + } |
|
| 774 | 1070 | |
| 775 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 776 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1071 | + if (isset($line['PosTime'])) { |
|
| 1072 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1073 | + } else { |
|
| 1074 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1075 | + } |
|
| 777 | 1076 | |
| 778 | 1077 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 779 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1078 | + if (isset($line['Type'])) { |
|
| 1079 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1080 | + } |
|
| 780 | 1081 | $data['format_source'] = 'aircraftlistjson'; |
| 781 | 1082 | $data['id_source'] = $id_source; |
| 782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 783 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 784 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1083 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1084 | + $data['source_name'] = $value['name']; |
|
| 1085 | + } |
|
| 1086 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1087 | + $data['noarchive'] = true; |
|
| 1088 | + } |
|
| 1089 | + if (isset($data['latitude'])) { |
|
| 1090 | + $SI->add($data); |
|
| 1091 | + } |
|
| 785 | 1092 | unset($data); |
| 786 | 1093 | } |
| 787 | 1094 | } elseif (is_array($all_data)) { |
@@ -798,12 +1105,19 @@ discard block |
||
| 798 | 1105 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 799 | 1106 | $data['squawk'] = $line['squawk']; // squawk |
| 800 | 1107 | $data['emergency'] = ''; // emergency |
| 801 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 802 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1108 | + if (isset($line['PosTime'])) { |
|
| 1109 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1110 | + } else { |
|
| 1111 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1112 | + } |
|
| 803 | 1113 | $data['format_source'] = 'aircraftlistjson'; |
| 804 | 1114 | $data['id_source'] = $id_source; |
| 805 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 806 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1115 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1116 | + $data['noarchive'] = true; |
|
| 1117 | + } |
|
| 1118 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1119 | + $data['source_name'] = $value['name']; |
|
| 1120 | + } |
|
| 807 | 1121 | $SI->add($data); |
| 808 | 1122 | unset($data); |
| 809 | 1123 | } |
@@ -839,8 +1153,12 @@ discard block |
||
| 839 | 1153 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 840 | 1154 | $data['format_source'] = 'planeupdatefaa'; |
| 841 | 1155 | $data['id_source'] = $id_source; |
| 842 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 843 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1156 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1157 | + $data['noarchive'] = true; |
|
| 1158 | + } |
|
| 1159 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1160 | + $data['source_name'] = $value['name']; |
|
| 1161 | + } |
|
| 844 | 1162 | $SI->add($data); |
| 845 | 1163 | unset($data); |
| 846 | 1164 | } |
@@ -869,7 +1187,9 @@ discard block |
||
| 869 | 1187 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 870 | 1188 | $data['format_source'] = 'opensky'; |
| 871 | 1189 | $data['id_source'] = $id_source; |
| 872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1190 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1191 | + $data['noarchive'] = true; |
|
| 1192 | + } |
|
| 873 | 1193 | $SI->add($data); |
| 874 | 1194 | unset($data); |
| 875 | 1195 | } |
@@ -881,7 +1201,9 @@ discard block |
||
| 881 | 1201 | //$buffer = $Common->getData($hosts[$id]); |
| 882 | 1202 | $buffer = $Common->getData($value['host']); |
| 883 | 1203 | $all_data = json_decode($buffer,true); |
| 884 | - if (!empty($all_data)) $reset = 0; |
|
| 1204 | + if (!empty($all_data)) { |
|
| 1205 | + $reset = 0; |
|
| 1206 | + } |
|
| 885 | 1207 | foreach ($all_data as $key => $line) { |
| 886 | 1208 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 887 | 1209 | $data = array(); |
@@ -902,8 +1224,12 @@ discard block |
||
| 902 | 1224 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 903 | 1225 | $data['format_source'] = 'fr24json'; |
| 904 | 1226 | $data['id_source'] = $id_source; |
| 905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1227 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1228 | + $data['noarchive'] = true; |
|
| 1229 | + } |
|
| 1230 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1231 | + $data['source_name'] = $value['name']; |
|
| 1232 | + } |
|
| 907 | 1233 | $SI->add($data); |
| 908 | 1234 | unset($data); |
| 909 | 1235 | } |
@@ -927,24 +1253,42 @@ discard block |
||
| 927 | 1253 | if (isset($line['inf'])) { |
| 928 | 1254 | $data = array(); |
| 929 | 1255 | $data['hex'] = $line['inf']['ia']; |
| 930 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1256 | + if (isset($line['inf']['cs'])) { |
|
| 1257 | + $data['ident'] = $line['inf']['cs']; |
|
| 1258 | + } |
|
| 1259 | + //$line[13] |
|
| 931 | 1260 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 932 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 933 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1261 | + if (isset($line['inf']['gs'])) { |
|
| 1262 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1263 | + } |
|
| 1264 | + // speed |
|
| 1265 | + if (isset($line['inf']['tr'])) { |
|
| 1266 | + $data['heading'] = $line['inf']['tr']; |
|
| 1267 | + } |
|
| 1268 | + // heading |
|
| 934 | 1269 | $data['latitude'] = $line['pt'][0]; // lat |
| 935 | 1270 | $data['longitude'] = $line['pt'][1]; // long |
| 936 | 1271 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 937 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1272 | + if (isset($line['inf']['sq'])) { |
|
| 1273 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1274 | + } |
|
| 1275 | + // squawk |
|
| 938 | 1276 | //$data['aircraft_icao'] = $line[8]; |
| 939 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1277 | + if (isset($line['inf']['rc'])) { |
|
| 1278 | + $data['registration'] = $line['inf']['rc']; |
|
| 1279 | + } |
|
| 940 | 1280 | //$data['departure_airport_iata'] = $line[11]; |
| 941 | 1281 | //$data['arrival_airport_iata'] = $line[12]; |
| 942 | 1282 | //$data['emergency'] = ''; // emergency |
| 943 | 1283 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 944 | 1284 | $data['format_source'] = 'radarvirtueljson'; |
| 945 | 1285 | $data['id_source'] = $id_source; |
| 946 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1286 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1287 | + $data['noarchive'] = true; |
|
| 1288 | + } |
|
| 1289 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1290 | + $data['source_name'] = $value['name']; |
|
| 1291 | + } |
|
| 948 | 1292 | $SI->add($data); |
| 949 | 1293 | unset($data); |
| 950 | 1294 | } |
@@ -965,30 +1309,65 @@ discard block |
||
| 965 | 1309 | $data['id'] = $line['id']; |
| 966 | 1310 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 967 | 1311 | $data['ident'] = $line['callsign']; // ident |
| 968 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 969 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 970 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 971 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 972 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 973 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1312 | + if (isset($line['pilotid'])) { |
|
| 1313 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1314 | + } |
|
| 1315 | + // pilot id |
|
| 1316 | + if (isset($line['name'])) { |
|
| 1317 | + $data['pilot_name'] = $line['name']; |
|
| 1318 | + } |
|
| 1319 | + // pilot name |
|
| 1320 | + if (isset($line['alt'])) { |
|
| 1321 | + $data['altitude'] = $line['alt']; |
|
| 1322 | + } |
|
| 1323 | + // altitude |
|
| 1324 | + if (isset($line['gs'])) { |
|
| 1325 | + $data['speed'] = $line['gs']; |
|
| 1326 | + } |
|
| 1327 | + // speed |
|
| 1328 | + if (isset($line['heading'])) { |
|
| 1329 | + $data['heading'] = $line['heading']; |
|
| 1330 | + } |
|
| 1331 | + // heading |
|
| 1332 | + if (isset($line['route'])) { |
|
| 1333 | + $data['waypoints'] = $line['route']; |
|
| 1334 | + } |
|
| 1335 | + // route |
|
| 974 | 1336 | $data['latitude'] = $line['lat']; // lat |
| 975 | 1337 | $data['longitude'] = $line['lon']; // long |
| 976 | 1338 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 977 | 1339 | //$data['squawk'] = $line['squawk']; // squawk |
| 978 | 1340 | //$data['emergency'] = ''; // emergency |
| 979 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 980 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 981 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1341 | + if (isset($line['depicao'])) { |
|
| 1342 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1343 | + } |
|
| 1344 | + if (isset($line['deptime'])) { |
|
| 1345 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1346 | + } |
|
| 1347 | + if (isset($line['arricao'])) { |
|
| 1348 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1349 | + } |
|
| 982 | 1350 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 983 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 984 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 985 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 986 | - else $data['info'] = ''; |
|
| 1351 | + if (isset($line['aircraft'])) { |
|
| 1352 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1353 | + } |
|
| 1354 | + if (isset($line['transponder'])) { |
|
| 1355 | + $data['squawk'] = $line['transponder']; |
|
| 1356 | + } |
|
| 1357 | + if (isset($line['atis'])) { |
|
| 1358 | + $data['info'] = $line['atis']; |
|
| 1359 | + } else { |
|
| 1360 | + $data['info'] = ''; |
|
| 1361 | + } |
|
| 987 | 1362 | $data['format_source'] = 'pireps'; |
| 988 | 1363 | $data['id_source'] = $id_source; |
| 989 | 1364 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 990 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 991 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1365 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1366 | + $data['noarchive'] = true; |
|
| 1367 | + } |
|
| 1368 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1369 | + $data['source_name'] = $value['name']; |
|
| 1370 | + } |
|
| 992 | 1371 | if ($line['icon'] == 'plane') { |
| 993 | 1372 | $SI->add($data); |
| 994 | 1373 | // print_r($data); |
@@ -997,16 +1376,28 @@ discard block |
||
| 997 | 1376 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 998 | 1377 | $typec = substr($data['ident'],-3); |
| 999 | 1378 | $data['type'] = ''; |
| 1000 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 1001 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 1002 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 1003 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 1004 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 1005 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 1006 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1007 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1008 | - else $data['type'] = 'Observer'; |
|
| 1009 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1379 | + if ($typec == 'APP') { |
|
| 1380 | + $data['type'] = 'Approach'; |
|
| 1381 | + } elseif ($typec == 'TWR') { |
|
| 1382 | + $data['type'] = 'Tower'; |
|
| 1383 | + } elseif ($typec == 'OBS') { |
|
| 1384 | + $data['type'] = 'Observer'; |
|
| 1385 | + } elseif ($typec == 'GND') { |
|
| 1386 | + $data['type'] = 'Ground'; |
|
| 1387 | + } elseif ($typec == 'DEL') { |
|
| 1388 | + $data['type'] = 'Delivery'; |
|
| 1389 | + } elseif ($typec == 'DEP') { |
|
| 1390 | + $data['type'] = 'Departure'; |
|
| 1391 | + } elseif ($typec == 'FSS') { |
|
| 1392 | + $data['type'] = 'Flight Service Station'; |
|
| 1393 | + } elseif ($typec == 'CTR') { |
|
| 1394 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1395 | + } else { |
|
| 1396 | + $data['type'] = 'Observer'; |
|
| 1397 | + } |
|
| 1398 | + if (isset($ATC)) { |
|
| 1399 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1400 | + } |
|
| 1010 | 1401 | } |
| 1011 | 1402 | unset($data); |
| 1012 | 1403 | } |
@@ -1016,7 +1407,9 @@ discard block |
||
| 1016 | 1407 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1017 | 1408 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 1018 | 1409 | //$buffer = $Common->getData($hosts[$id]); |
| 1019 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1410 | + if ($globalDebug) { |
|
| 1411 | + echo 'Get Data...'."\n"; |
|
| 1412 | + } |
|
| 1020 | 1413 | $buffer = $Common->getData($value['host']); |
| 1021 | 1414 | $all_data = json_decode($buffer,true); |
| 1022 | 1415 | if ($buffer != '' && is_array($all_data)) { |
@@ -1024,10 +1417,16 @@ discard block |
||
| 1024 | 1417 | foreach ($all_data as $line) { |
| 1025 | 1418 | $data = array(); |
| 1026 | 1419 | //$data['id'] = $line['id']; // id not usable |
| 1027 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1420 | + if (isset($line['pilotid'])) { |
|
| 1421 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1422 | + } |
|
| 1028 | 1423 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1029 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1030 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1424 | + if (isset($line['pilotname'])) { |
|
| 1425 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1426 | + } |
|
| 1427 | + if (isset($line['pilotid'])) { |
|
| 1428 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1429 | + } |
|
| 1031 | 1430 | $data['ident'] = $line['flightnum']; // ident |
| 1032 | 1431 | $data['altitude'] = $line['alt']; // altitude |
| 1033 | 1432 | $data['speed'] = $line['gs']; // speed |
@@ -1045,28 +1444,44 @@ discard block |
||
| 1045 | 1444 | $data['arrival_airport_icao'] = $line['arricao']; |
| 1046 | 1445 | $data['arrival_airport_time'] = $line['arrtime']; |
| 1047 | 1446 | $data['registration'] = $line['aircraft']; |
| 1048 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1049 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1447 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1448 | + $data['noarchive'] = true; |
|
| 1449 | + } |
|
| 1450 | + if (isset($line['route'])) { |
|
| 1451 | + $data['waypoints'] = $line['route']; |
|
| 1452 | + } |
|
| 1453 | + // route |
|
| 1050 | 1454 | if (isset($line['aircraftname'])) { |
| 1051 | 1455 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1052 | 1456 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1053 | 1457 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1054 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1055 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1056 | - else { |
|
| 1458 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1459 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1460 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1461 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1462 | + } else { |
|
| 1057 | 1463 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1058 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1059 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1464 | + if (isset($aircraft_data[1])) { |
|
| 1465 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1466 | + } else { |
|
| 1467 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1468 | + } |
|
| 1060 | 1469 | } |
| 1061 | 1470 | } |
| 1062 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1471 | + if (isset($line['route'])) { |
|
| 1472 | + $data['waypoints'] = $line['route']; |
|
| 1473 | + } |
|
| 1063 | 1474 | $data['id_source'] = $id_source; |
| 1064 | 1475 | $data['format_source'] = 'phpvmacars'; |
| 1065 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1476 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1477 | + $data['source_name'] = $value['name']; |
|
| 1478 | + } |
|
| 1066 | 1479 | $SI->add($data); |
| 1067 | 1480 | unset($data); |
| 1068 | 1481 | } |
| 1069 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1482 | + if ($globalDebug) { |
|
| 1483 | + echo 'No more data...'."\n"; |
|
| 1484 | + } |
|
| 1070 | 1485 | unset($buffer); |
| 1071 | 1486 | unset($all_data); |
| 1072 | 1487 | } |
@@ -1074,7 +1489,9 @@ discard block |
||
| 1074 | 1489 | $last_exec[$id]['last'] = time(); |
| 1075 | 1490 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 1076 | 1491 | //$buffer = $Common->getData($hosts[$id]); |
| 1077 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1492 | + if ($globalDebug) { |
|
| 1493 | + echo 'Get Data...'."\n"; |
|
| 1494 | + } |
|
| 1078 | 1495 | $buffer = $Common->getData($value['host']); |
| 1079 | 1496 | $all_data = json_decode($buffer,true); |
| 1080 | 1497 | if ($buffer != '' && is_array($all_data)) { |
@@ -1103,16 +1520,25 @@ discard block |
||
| 1103 | 1520 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1104 | 1521 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1105 | 1522 | //$data['registration'] = $line['aircraft']; |
| 1106 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1523 | + if (isset($line['route'])) { |
|
| 1524 | + $data['waypoints'] = $line['route']; |
|
| 1525 | + } |
|
| 1526 | + // route |
|
| 1107 | 1527 | $data['aircraft_icao'] = $line['plane_type']; |
| 1108 | 1528 | $data['id_source'] = $id_source; |
| 1109 | 1529 | $data['format_source'] = 'vam'; |
| 1110 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1111 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1530 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1531 | + $data['noarchive'] = true; |
|
| 1532 | + } |
|
| 1533 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1534 | + $data['source_name'] = $value['name']; |
|
| 1535 | + } |
|
| 1112 | 1536 | $SI->add($data); |
| 1113 | 1537 | unset($data); |
| 1114 | 1538 | } |
| 1115 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1539 | + if ($globalDebug) { |
|
| 1540 | + echo 'No more data...'."\n"; |
|
| 1541 | + } |
|
| 1116 | 1542 | unset($buffer); |
| 1117 | 1543 | unset($all_data); |
| 1118 | 1544 | } |
@@ -1120,7 +1546,9 @@ discard block |
||
| 1120 | 1546 | $last_exec[$id]['last'] = time(); |
| 1121 | 1547 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1122 | 1548 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1123 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1549 | + if (function_exists('pcntl_fork')) { |
|
| 1550 | + pcntl_signal_dispatch(); |
|
| 1551 | + } |
|
| 1124 | 1552 | //$last_exec[$id]['last'] = time(); |
| 1125 | 1553 | |
| 1126 | 1554 | //$read = array( $sockets[$id] ); |
@@ -1128,7 +1556,9 @@ discard block |
||
| 1128 | 1556 | $write = NULL; |
| 1129 | 1557 | $e = NULL; |
| 1130 | 1558 | $n = socket_select($read, $write, $e, $timeout); |
| 1131 | - if ($e != NULL) var_dump($e); |
|
| 1559 | + if ($e != NULL) { |
|
| 1560 | + var_dump($e); |
|
| 1561 | + } |
|
| 1132 | 1562 | if ($n > 0) { |
| 1133 | 1563 | $reset = 0; |
| 1134 | 1564 | foreach ($read as $nb => $r) { |
@@ -1149,12 +1579,16 @@ discard block |
||
| 1149 | 1579 | //$SI::del(); |
| 1150 | 1580 | if ($format == 'vrstcp') { |
| 1151 | 1581 | $buffer = explode('},{',$buffer); |
| 1152 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1582 | + } else { |
|
| 1583 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1584 | + } |
|
| 1153 | 1585 | // SBS format is CSV format |
| 1154 | 1586 | if ($buffer !== FALSE && $buffer != '') { |
| 1155 | 1587 | $tt[$format] = 0; |
| 1156 | 1588 | if ($format == 'acarssbs3') { |
| 1157 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1589 | + if ($globalDebug) { |
|
| 1590 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1591 | + } |
|
| 1158 | 1592 | $ACARS->add(trim($buffer)); |
| 1159 | 1593 | $ACARS->deleteLiveAcarsData(); |
| 1160 | 1594 | } elseif ($format == 'raw') { |
@@ -1163,30 +1597,70 @@ discard block |
||
| 1163 | 1597 | if (is_array($data)) { |
| 1164 | 1598 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1165 | 1599 | $data['format_source'] = 'raw'; |
| 1166 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1167 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1168 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1169 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1600 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1601 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1602 | + } |
|
| 1603 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1604 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1605 | + } |
|
| 1606 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1607 | + $data['noarchive'] = true; |
|
| 1608 | + } |
|
| 1609 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1610 | + $SI->add($data); |
|
| 1611 | + } |
|
| 1170 | 1612 | } |
| 1171 | 1613 | } elseif ($format == 'ais') { |
| 1172 | 1614 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1173 | 1615 | $data = array(); |
| 1174 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1175 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1176 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1177 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1178 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1179 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1180 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1181 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1182 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1183 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1184 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1185 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1186 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1187 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1188 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1189 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1616 | + if (isset($ais_data['ident'])) { |
|
| 1617 | + $data['ident'] = $ais_data['ident']; |
|
| 1618 | + } |
|
| 1619 | + if (isset($ais_data['mmsi'])) { |
|
| 1620 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1621 | + } |
|
| 1622 | + if (isset($ais_data['speed'])) { |
|
| 1623 | + $data['speed'] = $ais_data['speed']; |
|
| 1624 | + } |
|
| 1625 | + if (isset($ais_data['heading'])) { |
|
| 1626 | + $data['heading'] = $ais_data['heading']; |
|
| 1627 | + } |
|
| 1628 | + if (isset($ais_data['latitude'])) { |
|
| 1629 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1630 | + } |
|
| 1631 | + if (isset($ais_data['longitude'])) { |
|
| 1632 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1633 | + } |
|
| 1634 | + if (isset($ais_data['status'])) { |
|
| 1635 | + $data['status'] = $ais_data['status']; |
|
| 1636 | + } |
|
| 1637 | + if (isset($ais_data['statusid'])) { |
|
| 1638 | + $data['status_id'] = $ais_data['statusid']; |
|
| 1639 | + } |
|
| 1640 | + if (isset($ais_data['type'])) { |
|
| 1641 | + $data['type'] = $ais_data['type']; |
|
| 1642 | + } |
|
| 1643 | + if (isset($ais_data['imo'])) { |
|
| 1644 | + $data['imo'] = $ais_data['imo']; |
|
| 1645 | + } |
|
| 1646 | + if (isset($ais_data['callsign'])) { |
|
| 1647 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1648 | + } |
|
| 1649 | + if (isset($ais_data['destination'])) { |
|
| 1650 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1651 | + } |
|
| 1652 | + if (isset($ais_data['eta_ts'])) { |
|
| 1653 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1654 | + } |
|
| 1655 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1656 | + $data['noarchive'] = true; |
|
| 1657 | + } |
|
| 1658 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1659 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1660 | + } |
|
| 1661 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1662 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1663 | + } |
|
| 1190 | 1664 | |
| 1191 | 1665 | if (isset($ais_data['timestamp'])) { |
| 1192 | 1666 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1195,7 +1669,9 @@ discard block |
||
| 1195 | 1669 | } |
| 1196 | 1670 | $data['format_source'] = 'aisnmea'; |
| 1197 | 1671 | $data['id_source'] = $id_source; |
| 1198 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1672 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1673 | + $MI->add($data); |
|
| 1674 | + } |
|
| 1199 | 1675 | unset($data); |
| 1200 | 1676 | } elseif ($format == 'flightgearsp') { |
| 1201 | 1677 | //echo $buffer."\n"; |
@@ -1213,12 +1689,18 @@ discard block |
||
| 1213 | 1689 | $data['speed'] = round($line[5]*1.94384); |
| 1214 | 1690 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1215 | 1691 | $data['format_source'] = 'flightgearsp'; |
| 1216 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1217 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1692 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1693 | + $data['noarchive'] = true; |
|
| 1694 | + } |
|
| 1695 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1696 | + $SI->add($data); |
|
| 1697 | + } |
|
| 1218 | 1698 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1219 | 1699 | } |
| 1220 | 1700 | } elseif ($format == 'acars') { |
| 1221 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1701 | + if ($globalDebug) { |
|
| 1702 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1703 | + } |
|
| 1222 | 1704 | $ACARS->add(trim($buffer)); |
| 1223 | 1705 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1224 | 1706 | $ACARS->deleteLiveAcarsData(); |
@@ -1239,8 +1721,12 @@ discard block |
||
| 1239 | 1721 | $aircraft_type = $line[10]; |
| 1240 | 1722 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1241 | 1723 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1242 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1243 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1724 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1725 | + $data['noarchive'] = true; |
|
| 1726 | + } |
|
| 1727 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1728 | + $SI->add($data); |
|
| 1729 | + } |
|
| 1244 | 1730 | } |
| 1245 | 1731 | } |
| 1246 | 1732 | } elseif ($format == 'beast') { |
@@ -1250,28 +1736,62 @@ discard block |
||
| 1250 | 1736 | foreach($buffer as $all_data) { |
| 1251 | 1737 | $line = json_decode('{'.$all_data.'}',true); |
| 1252 | 1738 | $data = array(); |
| 1253 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1254 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1255 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1256 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1257 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1258 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1259 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1739 | + if (isset($line['Icao'])) { |
|
| 1740 | + $data['hex'] = $line['Icao']; |
|
| 1741 | + } |
|
| 1742 | + // hex |
|
| 1743 | + if (isset($line['Call'])) { |
|
| 1744 | + $data['ident'] = $line['Call']; |
|
| 1745 | + } |
|
| 1746 | + // ident |
|
| 1747 | + if (isset($line['Alt'])) { |
|
| 1748 | + $data['altitude'] = $line['Alt']; |
|
| 1749 | + } |
|
| 1750 | + // altitude |
|
| 1751 | + if (isset($line['Spd'])) { |
|
| 1752 | + $data['speed'] = $line['Spd']; |
|
| 1753 | + } |
|
| 1754 | + // speed |
|
| 1755 | + if (isset($line['Trak'])) { |
|
| 1756 | + $data['heading'] = $line['Trak']; |
|
| 1757 | + } |
|
| 1758 | + // heading |
|
| 1759 | + if (isset($line['Lat'])) { |
|
| 1760 | + $data['latitude'] = $line['Lat']; |
|
| 1761 | + } |
|
| 1762 | + // lat |
|
| 1763 | + if (isset($line['Long'])) { |
|
| 1764 | + $data['longitude'] = $line['Long']; |
|
| 1765 | + } |
|
| 1766 | + // long |
|
| 1260 | 1767 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1261 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1768 | + if (isset($line['Sqk'])) { |
|
| 1769 | + $data['squawk'] = $line['Sqk']; |
|
| 1770 | + } |
|
| 1771 | + // squawk |
|
| 1262 | 1772 | $data['emergency'] = ''; // emergency |
| 1263 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1773 | + if (isset($line['Reg'])) { |
|
| 1774 | + $data['registration'] = $line['Reg']; |
|
| 1775 | + } |
|
| 1264 | 1776 | /* |
| 1265 | 1777 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1266 | 1778 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1267 | 1779 | */ |
| 1268 | 1780 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1269 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1781 | + if (isset($line['Type'])) { |
|
| 1782 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1783 | + } |
|
| 1270 | 1784 | $data['format_source'] = 'vrstcp'; |
| 1271 | 1785 | $data['id_source'] = $id_source; |
| 1272 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1273 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1274 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1786 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1787 | + $data['noarchive'] = true; |
|
| 1788 | + } |
|
| 1789 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1790 | + $data['source_name'] = $value['name']; |
|
| 1791 | + } |
|
| 1792 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1793 | + $SI->add($data); |
|
| 1794 | + } |
|
| 1275 | 1795 | unset($data); |
| 1276 | 1796 | } |
| 1277 | 1797 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1284,22 +1804,46 @@ discard block |
||
| 1284 | 1804 | $data['hex'] = $lined['hexid']; |
| 1285 | 1805 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1286 | 1806 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1287 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1288 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1289 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1290 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1291 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1292 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1293 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1807 | + if (isset($lined['ident'])) { |
|
| 1808 | + $data['ident'] = $lined['ident']; |
|
| 1809 | + } |
|
| 1810 | + if (isset($lined['lat'])) { |
|
| 1811 | + $data['latitude'] = $lined['lat']; |
|
| 1812 | + } |
|
| 1813 | + if (isset($lined['lon'])) { |
|
| 1814 | + $data['longitude'] = $lined['lon']; |
|
| 1815 | + } |
|
| 1816 | + if (isset($lined['speed'])) { |
|
| 1817 | + $data['speed'] = $lined['speed']; |
|
| 1818 | + } |
|
| 1819 | + if (isset($lined['squawk'])) { |
|
| 1820 | + $data['squawk'] = $lined['squawk']; |
|
| 1821 | + } |
|
| 1822 | + if (isset($lined['alt'])) { |
|
| 1823 | + $data['altitude'] = $lined['alt']; |
|
| 1824 | + } |
|
| 1825 | + if (isset($lined['heading'])) { |
|
| 1826 | + $data['heading'] = $lined['heading']; |
|
| 1827 | + } |
|
| 1294 | 1828 | $data['id_source'] = $id_source; |
| 1295 | 1829 | $data['format_source'] = 'tsv'; |
| 1296 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1297 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1298 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1299 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1830 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1831 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1832 | + } |
|
| 1833 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1834 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1835 | + } |
|
| 1836 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1837 | + $data['noarchive'] = true; |
|
| 1838 | + } |
|
| 1839 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1840 | + $SI->add($data); |
|
| 1841 | + } |
|
| 1300 | 1842 | unset($lined); |
| 1301 | 1843 | unset($data); |
| 1302 | - } else $error = true; |
|
| 1844 | + } else { |
|
| 1845 | + $error = true; |
|
| 1846 | + } |
|
| 1303 | 1847 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1304 | 1848 | if ($aprs_connect == 0) { |
| 1305 | 1849 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1324,41 +1868,89 @@ discard block |
||
| 1324 | 1868 | $aprs_last_tx = time(); |
| 1325 | 1869 | $data = array(); |
| 1326 | 1870 | //print_r($line); |
| 1327 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1328 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1329 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1330 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1331 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1332 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1333 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1334 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1335 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1336 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1871 | + if (isset($line['address'])) { |
|
| 1872 | + $data['hex'] = $line['address']; |
|
| 1873 | + } |
|
| 1874 | + if (isset($line['mmsi'])) { |
|
| 1875 | + $data['mmsi'] = $line['mmsi']; |
|
| 1876 | + } |
|
| 1877 | + if (isset($line['imo'])) { |
|
| 1878 | + $data['imo'] = $line['imo']; |
|
| 1879 | + } |
|
| 1880 | + if (isset($line['squawk'])) { |
|
| 1881 | + $data['squawk'] = $line['squawk']; |
|
| 1882 | + } |
|
| 1883 | + if (isset($line['arrival_code'])) { |
|
| 1884 | + $data['arrical_code'] = $line['arrival_code']; |
|
| 1885 | + } |
|
| 1886 | + if (isset($line['arrival_date'])) { |
|
| 1887 | + $data['arrical_date'] = $line['arrival_date']; |
|
| 1888 | + } |
|
| 1889 | + if (isset($line['type_id'])) { |
|
| 1890 | + $data['type_id'] = $line['typeid']; |
|
| 1891 | + } |
|
| 1892 | + if (isset($line['status_id'])) { |
|
| 1893 | + $data['status_id'] = $line['statusid']; |
|
| 1894 | + } |
|
| 1895 | + if (isset($line['timestamp'])) { |
|
| 1896 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1897 | + } else { |
|
| 1898 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1899 | + } |
|
| 1337 | 1900 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1338 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1901 | + if (isset($line['ident'])) { |
|
| 1902 | + $data['ident'] = $line['ident']; |
|
| 1903 | + } |
|
| 1339 | 1904 | $data['latitude'] = $line['latitude']; |
| 1340 | 1905 | $data['longitude'] = $line['longitude']; |
| 1341 | 1906 | //$data['verticalrate'] = $line[16]; |
| 1342 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1343 | - else $data['speed'] = 0; |
|
| 1344 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1345 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1346 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1347 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1907 | + if (isset($line['speed'])) { |
|
| 1908 | + $data['speed'] = $line['speed']; |
|
| 1909 | + } else { |
|
| 1910 | + $data['speed'] = 0; |
|
| 1911 | + } |
|
| 1912 | + if (isset($line['altitude'])) { |
|
| 1913 | + $data['altitude'] = $line['altitude']; |
|
| 1914 | + } |
|
| 1915 | + if (isset($line['comment'])) { |
|
| 1916 | + $data['comment'] = $line['comment']; |
|
| 1917 | + } |
|
| 1918 | + if (isset($line['symbol'])) { |
|
| 1919 | + $data['type'] = $line['symbol']; |
|
| 1920 | + } |
|
| 1921 | + if (isset($line['heading'])) { |
|
| 1922 | + $data['heading'] = $line['heading']; |
|
| 1923 | + } |
|
| 1348 | 1924 | //else $data['heading'] = 0; |
| 1349 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1925 | + if (isset($line['stealth'])) { |
|
| 1926 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1927 | + } |
|
| 1350 | 1928 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1351 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1352 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1353 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1354 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1929 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 1930 | + $data['noarchive'] = true; |
|
| 1931 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 1932 | + $data['noarchive'] = false; |
|
| 1933 | + } |
|
| 1934 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1935 | + $data['noarchive'] = true; |
|
| 1936 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 1937 | + $data['noarchive'] = false; |
|
| 1938 | + } |
|
| 1355 | 1939 | $data['id_source'] = $id_source; |
| 1356 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1357 | - else $data['format_source'] = 'aprs'; |
|
| 1940 | + if (isset($line['format_source'])) { |
|
| 1941 | + $data['format_source'] = $line['format_source']; |
|
| 1942 | + } else { |
|
| 1943 | + $data['format_source'] = 'aprs'; |
|
| 1944 | + } |
|
| 1358 | 1945 | $data['source_name'] = $line['source']; |
| 1359 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1360 | - else $data['source_type'] = 'flarm'; |
|
| 1361 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1946 | + if (isset($line['source_type'])) { |
|
| 1947 | + $data['source_type'] = $line['source_type']; |
|
| 1948 | + } else { |
|
| 1949 | + $data['source_type'] = 'flarm'; |
|
| 1950 | + } |
|
| 1951 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1952 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1953 | + } |
|
| 1362 | 1954 | $currentdate = date('Y-m-d H:i:s'); |
| 1363 | 1955 | $aprsdate = strtotime($data['datetime']); |
| 1364 | 1956 | // Accept data if time <= system time + 20s |
@@ -1366,14 +1958,21 @@ discard block |
||
| 1366 | 1958 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1367 | 1959 | $send = $SI->add($data); |
| 1368 | 1960 | } elseif ($data['source_type'] == 'ais') { |
| 1369 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 1961 | + if (isset($globalMarine) && $globalMarine) { |
|
| 1962 | + $send = $MI->add($data); |
|
| 1963 | + } |
|
| 1370 | 1964 | } elseif (isset($line['stealth'])) { |
| 1371 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1372 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1965 | + if ($line['stealth'] != 0) { |
|
| 1966 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1967 | + } else { |
|
| 1968 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1969 | + } |
|
| 1373 | 1970 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
| 1374 | 1971 | } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1375 | 1972 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1376 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 1973 | + if (isset($globalTracker) && $globalTracker) { |
|
| 1974 | + $send = $TI->add($data); |
|
| 1975 | + } |
|
| 1377 | 1976 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { |
| 1378 | 1977 | $Source->deleteOldLocationByType('gs'); |
| 1379 | 1978 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
@@ -1386,12 +1985,9 @@ discard block |
||
| 1386 | 1985 | print_r($data); |
| 1387 | 1986 | } |
| 1388 | 1987 | unset($data); |
| 1389 | - } |
|
| 1390 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1988 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1391 | 1989 | echo '!! Weather Station not yet supported'."\n"; |
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1990 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1395 | 1991 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1396 | 1992 | } |
| 1397 | 1993 | /* |
@@ -1400,7 +1996,9 @@ discard block |
||
| 1400 | 1996 | } |
| 1401 | 1997 | */ |
| 1402 | 1998 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1403 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 1999 | + elseif ($line == true && $globalDebug) { |
|
| 2000 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2001 | + } |
|
| 1404 | 2002 | } |
| 1405 | 2003 | } else { |
| 1406 | 2004 | $line = explode(',', $buffer); |
@@ -1429,26 +2027,45 @@ discard block |
||
| 1429 | 2027 | $data['ground'] = $line[21]; |
| 1430 | 2028 | $data['emergency'] = $line[19]; |
| 1431 | 2029 | $data['format_source'] = 'sbs'; |
| 1432 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1433 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1434 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2030 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2031 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2032 | + } |
|
| 2033 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2034 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2035 | + } |
|
| 2036 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2037 | + $data['noarchive'] = true; |
|
| 2038 | + } |
|
| 1435 | 2039 | $data['id_source'] = $id_source; |
| 1436 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1437 | - else $error = true; |
|
| 2040 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2041 | + $send = $SI->add($data); |
|
| 2042 | + } else { |
|
| 2043 | + $error = true; |
|
| 2044 | + } |
|
| 1438 | 2045 | unset($data); |
| 1439 | - } else $error = true; |
|
| 2046 | + } else { |
|
| 2047 | + $error = true; |
|
| 2048 | + } |
|
| 1440 | 2049 | if ($error) { |
| 1441 | 2050 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1442 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2051 | + if ($globalDebug) { |
|
| 2052 | + echo "Not a message. Ignoring... \n"; |
|
| 2053 | + } |
|
| 1443 | 2054 | } else { |
| 1444 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2055 | + if ($globalDebug) { |
|
| 2056 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2057 | + } |
|
| 1445 | 2058 | if ($globalDebug) { |
| 1446 | 2059 | echo $buffer; |
| 1447 | 2060 | //print_r($line); |
| 1448 | 2061 | } |
| 1449 | 2062 | //socket_close($r); |
| 1450 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1451 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 2063 | + if ($globalDebug) { |
|
| 2064 | + echo "Reconnect after an error...\n"; |
|
| 2065 | + } |
|
| 2066 | + if ($format == 'aprs') { |
|
| 2067 | + $aprs_connect = 0; |
|
| 2068 | + } |
|
| 1452 | 2069 | $sourceer[$nb] = $globalSources[$nb]; |
| 1453 | 2070 | connect_all($sourceer); |
| 1454 | 2071 | $sourceer = array(); |
@@ -1456,10 +2073,14 @@ discard block |
||
| 1456 | 2073 | } |
| 1457 | 2074 | } |
| 1458 | 2075 | // Sleep for xxx microseconds |
| 1459 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2076 | + if (isset($globalSBSSleep)) { |
|
| 2077 | + usleep($globalSBSSleep); |
|
| 2078 | + } |
|
| 1460 | 2079 | } else { |
| 1461 | 2080 | if ($format == 'flightgearmp') { |
| 1462 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2081 | + if ($globalDebug) { |
|
| 2082 | + echo "Reconnect FlightGear MP..."; |
|
| 2083 | + } |
|
| 1463 | 2084 | //@socket_close($r); |
| 1464 | 2085 | sleep($globalMinFetch); |
| 1465 | 2086 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1468,10 +2089,15 @@ discard block |
||
| 1468 | 2089 | break; |
| 1469 | 2090 | |
| 1470 | 2091 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1471 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1472 | - else $tt[$format] = 0; |
|
| 2092 | + if (isset($tt[$format])) { |
|
| 2093 | + $tt[$format]++; |
|
| 2094 | + } else { |
|
| 2095 | + $tt[$format] = 0; |
|
| 2096 | + } |
|
| 1473 | 2097 | if ($tt[$format] > 30) { |
| 1474 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2098 | + if ($globalDebug) { |
|
| 2099 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2100 | + } |
|
| 1475 | 2101 | //@socket_close($r); |
| 1476 | 2102 | sleep(2); |
| 1477 | 2103 | $aprs_connect = 0; |
@@ -1488,11 +2114,17 @@ discard block |
||
| 1488 | 2114 | } else { |
| 1489 | 2115 | $error = socket_strerror(socket_last_error()); |
| 1490 | 2116 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1491 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1492 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2117 | + if ($globalDebug) { |
|
| 2118 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2119 | + } |
|
| 2120 | + if (isset($globalDebug)) { |
|
| 2121 | + echo "Restarting...\n"; |
|
| 2122 | + } |
|
| 1493 | 2123 | // Restart the script if possible |
| 1494 | 2124 | if (is_array($sockets)) { |
| 1495 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2125 | + if ($globalDebug) { |
|
| 2126 | + echo "Shutdown all sockets..."; |
|
| 2127 | + } |
|
| 1496 | 2128 | |
| 1497 | 2129 | foreach ($sockets as $sock) { |
| 1498 | 2130 | @socket_shutdown($sock,2); |
@@ -1500,22 +2132,36 @@ discard block |
||
| 1500 | 2132 | } |
| 1501 | 2133 | |
| 1502 | 2134 | } |
| 1503 | - if ($globalDebug) echo "Waiting..."; |
|
| 2135 | + if ($globalDebug) { |
|
| 2136 | + echo "Waiting..."; |
|
| 2137 | + } |
|
| 1504 | 2138 | sleep(2); |
| 1505 | 2139 | $time = time(); |
| 1506 | 2140 | //connect_all($hosts); |
| 1507 | 2141 | $aprs_connect = 0; |
| 1508 | - if ($reset%5 == 0) sleep(20); |
|
| 1509 | - if ($reset%10 == 0) sleep(100); |
|
| 1510 | - if ($reset%20 == 0) sleep(200); |
|
| 1511 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1512 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2142 | + if ($reset%5 == 0) { |
|
| 2143 | + sleep(20); |
|
| 2144 | + } |
|
| 2145 | + if ($reset%10 == 0) { |
|
| 2146 | + sleep(100); |
|
| 2147 | + } |
|
| 2148 | + if ($reset%20 == 0) { |
|
| 2149 | + sleep(200); |
|
| 2150 | + } |
|
| 2151 | + if ($reset > 100) { |
|
| 2152 | + exit('Too many attempts...'); |
|
| 2153 | + } |
|
| 2154 | + if ($globalDebug) { |
|
| 2155 | + echo "Restart all connections..."; |
|
| 2156 | + } |
|
| 1513 | 2157 | connect_all($globalSources); |
| 1514 | 2158 | } |
| 1515 | 2159 | } |
| 1516 | 2160 | } |
| 1517 | 2161 | if ($globalDaemon === false) { |
| 1518 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2162 | + if ($globalDebug) { |
|
| 2163 | + echo 'Check all...'."\n"; |
|
| 2164 | + } |
|
| 1519 | 2165 | $SI->checkAll(); |
| 1520 | 2166 | } |
| 1521 | 2167 | } |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 57 | 57 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 58 | - } else $image = $spotter_item['image_thumbnail']; |
|
| 58 | + } else { |
|
| 59 | + $image = $spotter_item['image_thumbnail']; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | } |
| 61 | 63 | /* else { |
@@ -68,8 +70,12 @@ discard block |
||
| 68 | 70 | } |
| 69 | 71 | print '<div class="right">'; |
| 70 | 72 | print '<div class="callsign-details">'; |
| 71 | -if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
|
| 72 | -if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 73 | +if ($spotter_item['ident'] != 'Not Available') { |
|
| 74 | + print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
|
| 75 | +} |
|
| 76 | +if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') { |
|
| 77 | + print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 78 | +} |
|
| 73 | 79 | print '</div>'; |
| 74 | 80 | if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') { |
| 75 | 81 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
@@ -101,21 +107,35 @@ discard block |
||
| 101 | 107 | print '</div>'; |
| 102 | 108 | print '<div id="aircraft">'; |
| 103 | 109 | print '<span>'._("Aircraft").'</span>'; |
| 104 | -if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 105 | -if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 106 | -elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
| 107 | -else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 110 | +if (isset($spotter_item['aircraft_wiki'])) { |
|
| 111 | + print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 112 | +} |
|
| 113 | +if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') { |
|
| 114 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 115 | +} elseif (isset($spotter_item['aircraft_type'])) { |
|
| 116 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
| 117 | +} else { |
|
| 118 | + print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 119 | +} |
|
| 108 | 120 | print '</div>'; |
| 109 | 121 | print '<div id ="altitude"><span>'._("Altitude").'</span>'; |
| 110 | 122 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
| 111 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
| 112 | - else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
| 113 | -} else { |
|
| 114 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
| 115 | - else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
| 116 | -} |
|
| 123 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 124 | + print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
| 125 | + } else { |
|
| 126 | + print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
| 127 | + } |
|
| 128 | + } else { |
|
| 129 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 130 | + print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
| 131 | + } else { |
|
| 132 | + print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
| 133 | + } |
|
| 134 | + } |
|
| 117 | 135 | print '</div>'; |
| 118 | -if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 136 | +if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') { |
|
| 137 | + print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 138 | +} |
|
| 119 | 139 | print '<div id="speed"><span>'._("Speed").'</span>'; |
| 120 | 140 | if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
| 121 | 141 | print round($spotter_item['ground_speed']*1.15078).' mph'; |
@@ -129,8 +149,11 @@ discard block |
||
| 129 | 149 | print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>'; |
| 130 | 150 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') { |
| 131 | 151 | print '<div id="pilot"><span>'._("Pilot").'</span>'; |
| 132 | - if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 133 | - else print $spotter_item['pilot_name']; |
|
| 152 | + if (isset($spotter_item['pilot_id'])) { |
|
| 153 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 154 | + } else { |
|
| 155 | + print $spotter_item['pilot_name']; |
|
| 156 | + } |
|
| 134 | 157 | print '</div>'; |
| 135 | 158 | } |
| 136 | 159 | |
@@ -158,10 +181,18 @@ discard block |
||
| 158 | 181 | print '</div>'; |
| 159 | 182 | print '</div>'; |
| 160 | 183 | |
| 161 | -if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 162 | -if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 163 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 164 | -if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 184 | +if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') { |
|
| 185 | + print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 186 | +} |
|
| 187 | +if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
|
| 188 | + print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 189 | +} |
|
| 190 | +if (isset($spotter_item['acars']['message'])) { |
|
| 191 | + print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 192 | +} |
|
| 193 | +if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) { |
|
| 194 | + print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 195 | +} |
|
| 165 | 196 | print '</div>'; |
| 166 | 197 | ?> |
| 167 | 198 | </div> |
| 168 | 199 | \ No newline at end of file |