@@ -100,6 +100,10 @@ discard block |
||
| 100 | 100 | return strlen($headerLine); // Needed by curl |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | + /** |
|
| 104 | + * @param string $url |
|
| 105 | + * @param string $file |
|
| 106 | + */ |
|
| 103 | 107 | public static function download($url, $file, $referer = '') { |
| 104 | 108 | global $globalDebug, $globalProxy, $globalForceIPv4; |
| 105 | 109 | $fp = fopen($file, 'w'); |
@@ -124,6 +128,9 @@ discard block |
||
| 124 | 128 | fclose($fp); |
| 125 | 129 | } |
| 126 | 130 | |
| 131 | + /** |
|
| 132 | + * @param string $in_file |
|
| 133 | + */ |
|
| 127 | 134 | public static function gunzip($in_file,$out_file_name = '') { |
| 128 | 135 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 129 | 136 | $buffer_size = 4096; // read 4kb at a time |
@@ -285,7 +292,7 @@ discard block |
||
| 285 | 292 | * Check is distance realistic |
| 286 | 293 | * @param int $timeDifference the time between the reception of both messages |
| 287 | 294 | * @param float $distance distance covered |
| 288 | - * @return whether distance is realistic |
|
| 295 | + * @return boolean distance is realistic |
|
| 289 | 296 | */ |
| 290 | 297 | public function withinThreshold ($timeDifference, $distance) { |
| 291 | 298 | $x = abs($timeDifference); |
@@ -309,6 +316,9 @@ discard block |
||
| 309 | 316 | } |
| 310 | 317 | |
| 311 | 318 | |
| 319 | + /** |
|
| 320 | + * @param string $latlong |
|
| 321 | + */ |
|
| 312 | 322 | public function convertDec($dms,$latlong) { |
| 313 | 323 | if ($latlong == 'latitude') { |
| 314 | 324 | $deg = substr($dms, 0, 2); |
@@ -343,6 +353,9 @@ discard block |
||
| 343 | 353 | return array('latitude' => round($latitude,5),'longitude' => round($longitude,5)); |
| 344 | 354 | } |
| 345 | 355 | |
| 356 | + /** |
|
| 357 | + * @param string $latlong |
|
| 358 | + */ |
|
| 346 | 359 | public function convertDM($coord,$latlong) { |
| 347 | 360 | if ($latlong == 'latitude') { |
| 348 | 361 | if ($coord < 0) $NSEW = 'S'; |
@@ -480,7 +493,7 @@ discard block |
||
| 480 | 493 | /** |
| 481 | 494 | * Returns list of available locales |
| 482 | 495 | * |
| 483 | - * @return array |
|
| 496 | + * @return string[] |
|
| 484 | 497 | */ |
| 485 | 498 | public function listLocaleDir() |
| 486 | 499 | { |
@@ -6,6 +6,9 @@ discard block |
||
| 6 | 6 | public $dbs = array(); |
| 7 | 7 | public $latest_schema = 52; |
| 8 | 8 | |
| 9 | + /** |
|
| 10 | + * @param string $dbname |
|
| 11 | + */ |
|
| 9 | 12 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 10 | 13 | global $globalNoDB; |
| 11 | 14 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
@@ -142,6 +145,9 @@ discard block |
||
| 142 | 145 | return true; |
| 143 | 146 | } |
| 144 | 147 | |
| 148 | + /** |
|
| 149 | + * @param string $table |
|
| 150 | + */ |
|
| 145 | 151 | public function tableExists($table) |
| 146 | 152 | { |
| 147 | 153 | global $globalDBdriver, $globalDBname; |
@@ -192,6 +198,11 @@ discard block |
||
| 192 | 198 | /* |
| 193 | 199 | * Check if index exist |
| 194 | 200 | */ |
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @param string $table |
|
| 204 | + * @param string $index |
|
| 205 | + */ |
|
| 195 | 206 | public function indexExists($table,$index) |
| 196 | 207 | { |
| 197 | 208 | global $globalDBdriver, $globalDBname; |
@@ -234,6 +245,10 @@ discard block |
||
| 234 | 245 | return $columns; |
| 235 | 246 | } |
| 236 | 247 | |
| 248 | + /** |
|
| 249 | + * @param string $table |
|
| 250 | + * @param string $column |
|
| 251 | + */ |
|
| 237 | 252 | public function getColumnType($table,$column) { |
| 238 | 253 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 239 | 254 | $tomet = $select->getColumnMeta(0); |
@@ -244,6 +259,11 @@ discard block |
||
| 244 | 259 | * Check if a column name exist in a table |
| 245 | 260 | * @return Boolean column exist or not |
| 246 | 261 | */ |
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * @param string $table |
|
| 265 | + * @param string $name |
|
| 266 | + */ |
|
| 247 | 267 | public function checkColumnName($table,$name) |
| 248 | 268 | { |
| 249 | 269 | global $globalDBdriver, $globalDBname; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -694,25 +694,6 @@ discard block |
||
| 694 | 694 | * |
| 695 | 695 | * @param String $fammarine_id the ID |
| 696 | 696 | * @param String $ident the marine ident |
| 697 | - * @param String $departure_airport_icao the departure airport |
|
| 698 | - * @param String $arrival_airport_icao the arrival airport |
|
| 699 | - * @param String $latitude latitude of flight |
|
| 700 | - * @param String $longitude latitude of flight |
|
| 701 | - * @param String $waypoints waypoints of flight |
|
| 702 | - * @param String $heading heading of flight |
|
| 703 | - * @param String $groundspeed speed of flight |
|
| 704 | - * @param String $date date of flight |
|
| 705 | - * @param String $departure_airport_time departure time of flight |
|
| 706 | - * @param String $arrival_airport_time arrival time of flight |
|
| 707 | - * @param String $squawk squawk code of flight |
|
| 708 | - * @param String $route_stop route stop of flight |
|
| 709 | - * @param String $highlight highlight or not |
|
| 710 | - * @param String $ModeS ModesS code of flight |
|
| 711 | - * @param String $registration registration code of flight |
|
| 712 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 713 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 714 | - * @param String $verticalrate vertival rate of flight |
|
| 715 | - * @return String success or false |
|
| 716 | 697 | */ |
| 717 | 698 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
| 718 | 699 | { |
@@ -1310,6 +1291,7 @@ discard block |
||
| 1310 | 1291 | /** |
| 1311 | 1292 | * Counts all hours |
| 1312 | 1293 | * |
| 1294 | + * @param string $orderby |
|
| 1313 | 1295 | * @return Array the hour list |
| 1314 | 1296 | * |
| 1315 | 1297 | */ |
@@ -1661,7 +1643,7 @@ discard block |
||
| 1661 | 1643 | /** |
| 1662 | 1644 | * Parses the direction degrees to working |
| 1663 | 1645 | * |
| 1664 | - * @param Float $direction the direction in degrees |
|
| 1646 | + * @param integer $direction the direction in degrees |
|
| 1665 | 1647 | * @return Array the direction information |
| 1666 | 1648 | * |
| 1667 | 1649 | */ |
@@ -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 | |
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Executes the SQL statements to get the spotter information |
|
| 92 | - * |
|
| 93 | - * @param String $query the SQL query |
|
| 94 | - * @param Array $params parameter of the query |
|
| 95 | - * @param String $limitQuery the limit query |
|
| 96 | - * @return Array the spotter information |
|
| 97 | - * |
|
| 98 | - */ |
|
| 91 | + * Executes the SQL statements to get the spotter information |
|
| 92 | + * |
|
| 93 | + * @param String $query the SQL query |
|
| 94 | + * @param Array $params parameter of the query |
|
| 95 | + * @param String $limitQuery the limit query |
|
| 96 | + * @return Array the spotter information |
|
| 97 | + * |
|
| 98 | + */ |
|
| 99 | 99 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 100 | 100 | { |
| 101 | 101 | date_default_timezone_set('UTC'); |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | - * Gets all the spotter information based on the latest data entry |
|
| 234 | - * |
|
| 235 | - * @return Array the spotter information |
|
| 236 | - * |
|
| 237 | - */ |
|
| 233 | + * Gets all the spotter information based on the latest data entry |
|
| 234 | + * |
|
| 235 | + * @return Array the spotter information |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | 238 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 239 | 239 | { |
| 240 | 240 | global $global_query; |
@@ -283,11 +283,11 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | - * Gets all the spotter information based on the callsign |
|
| 287 | - * |
|
| 288 | - * @return Array the spotter information |
|
| 289 | - * |
|
| 290 | - */ |
|
| 286 | + * Gets all the spotter information based on the callsign |
|
| 287 | + * |
|
| 288 | + * @return Array the spotter information |
|
| 289 | + * |
|
| 290 | + */ |
|
| 291 | 291 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 292 | 292 | { |
| 293 | 293 | global $global_query; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | - * Gets all the marine information based on the type |
|
| 343 | - * |
|
| 344 | - * @return Array the marine information |
|
| 345 | - * |
|
| 346 | - */ |
|
| 342 | + * Gets all the marine information based on the type |
|
| 343 | + * |
|
| 344 | + * @return Array the marine information |
|
| 345 | + * |
|
| 346 | + */ |
|
| 347 | 347 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
| 348 | 348 | { |
| 349 | 349 | global $global_query; |
@@ -451,12 +451,12 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | - * Gets all source name |
|
| 455 | - * |
|
| 456 | - * @param String type format of source |
|
| 457 | - * @return Array list of source name |
|
| 458 | - * |
|
| 459 | - */ |
|
| 454 | + * Gets all source name |
|
| 455 | + * |
|
| 456 | + * @param String type format of source |
|
| 457 | + * @return Array list of source name |
|
| 458 | + * |
|
| 459 | + */ |
|
| 460 | 460 | public function getAllSourceName($type = '',$filters = array()) |
| 461 | 461 | { |
| 462 | 462 | $filter_query = $this->getFilter($filters,true,true); |
@@ -486,11 +486,11 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | /** |
| 489 | - * Gets a list of all idents/callsigns |
|
| 490 | - * |
|
| 491 | - * @return Array list of ident/callsign names |
|
| 492 | - * |
|
| 493 | - */ |
|
| 489 | + * Gets a list of all idents/callsigns |
|
| 490 | + * |
|
| 491 | + * @return Array list of ident/callsign names |
|
| 492 | + * |
|
| 493 | + */ |
|
| 494 | 494 | public function getAllIdents($filters = array()) |
| 495 | 495 | { |
| 496 | 496 | $filter_query = $this->getFilter($filters,true,true); |
@@ -514,11 +514,11 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
| 517 | - * Gets all info from a mmsi |
|
| 518 | - * |
|
| 519 | - * @return Array ident |
|
| 520 | - * |
|
| 521 | - */ |
|
| 517 | + * Gets all info from a mmsi |
|
| 518 | + * |
|
| 519 | + * @return Array ident |
|
| 520 | + * |
|
| 521 | + */ |
|
| 522 | 522 | public function getIdentity($mmsi) |
| 523 | 523 | { |
| 524 | 524 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -531,9 +531,9 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | - * Add identity |
|
| 535 | - * |
|
| 536 | - */ |
|
| 534 | + * Add identity |
|
| 535 | + * |
|
| 536 | + */ |
|
| 537 | 537 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
| 538 | 538 | { |
| 539 | 539 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -599,13 +599,13 @@ discard block |
||
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | - * Update ident tracker data |
|
| 603 | - * |
|
| 604 | - * @param String $fammarine_id the ID |
|
| 605 | - * @param String $ident the marine ident |
|
| 606 | - * @return String success or false |
|
| 607 | - * |
|
| 608 | - */ |
|
| 602 | + * Update ident tracker data |
|
| 603 | + * |
|
| 604 | + * @param String $fammarine_id the ID |
|
| 605 | + * @param String $ident the marine ident |
|
| 606 | + * @return String success or false |
|
| 607 | + * |
|
| 608 | + */ |
|
| 609 | 609 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 610 | 610 | { |
| 611 | 611 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -620,13 +620,13 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /** |
| 623 | - * Update arrival marine data |
|
| 624 | - * |
|
| 625 | - * @param String $fammarine_id the ID |
|
| 626 | - * @param String $arrival_code the marine ident |
|
| 627 | - * @return String success or false |
|
| 628 | - * |
|
| 629 | - */ |
|
| 623 | + * Update arrival marine data |
|
| 624 | + * |
|
| 625 | + * @param String $fammarine_id the ID |
|
| 626 | + * @param String $arrival_code the marine ident |
|
| 627 | + * @return String success or false |
|
| 628 | + * |
|
| 629 | + */ |
|
| 630 | 630 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
| 631 | 631 | { |
| 632 | 632 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -641,19 +641,19 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | - * Update Status data |
|
| 645 | - * |
|
| 646 | - * @param String $fammarine_id the ID |
|
| 647 | - * @param String $status_id the marine status id |
|
| 648 | - * @param String $status the marine status |
|
| 649 | - * @return String success or false |
|
| 650 | - * |
|
| 651 | - */ |
|
| 644 | + * Update Status data |
|
| 645 | + * |
|
| 646 | + * @param String $fammarine_id the ID |
|
| 647 | + * @param String $status_id the marine status id |
|
| 648 | + * @param String $status the marine status |
|
| 649 | + * @return String success or false |
|
| 650 | + * |
|
| 651 | + */ |
|
| 652 | 652 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
| 653 | 653 | { |
| 654 | 654 | |
| 655 | 655 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 656 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 656 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 657 | 657 | |
| 658 | 658 | try { |
| 659 | 659 | $sth = $this->db->prepare($query); |
@@ -666,17 +666,17 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | } |
| 668 | 668 | /** |
| 669 | - * Update latest marine data |
|
| 670 | - * |
|
| 671 | - * @param String $fammarine_id the ID |
|
| 672 | - * @param String $ident the marine ident |
|
| 673 | - * @return String success or false |
|
| 674 | - * |
|
| 675 | - */ |
|
| 669 | + * Update latest marine data |
|
| 670 | + * |
|
| 671 | + * @param String $fammarine_id the ID |
|
| 672 | + * @param String $ident the marine ident |
|
| 673 | + * @return String success or false |
|
| 674 | + * |
|
| 675 | + */ |
|
| 676 | 676 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 677 | 677 | { |
| 678 | 678 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 679 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 679 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 680 | 680 | |
| 681 | 681 | try { |
| 682 | 682 | $sth = $this->db->prepare($query); |
@@ -690,30 +690,30 @@ discard block |
||
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
| 693 | - * Adds a new spotter data |
|
| 694 | - * |
|
| 695 | - * @param String $fammarine_id the ID |
|
| 696 | - * @param String $ident the marine ident |
|
| 697 | - * @param String $departure_airport_icao the departure airport |
|
| 698 | - * @param String $arrival_airport_icao the arrival airport |
|
| 699 | - * @param String $latitude latitude of flight |
|
| 700 | - * @param String $longitude latitude of flight |
|
| 701 | - * @param String $waypoints waypoints of flight |
|
| 702 | - * @param String $heading heading of flight |
|
| 703 | - * @param String $groundspeed speed of flight |
|
| 704 | - * @param String $date date of flight |
|
| 705 | - * @param String $departure_airport_time departure time of flight |
|
| 706 | - * @param String $arrival_airport_time arrival time of flight |
|
| 707 | - * @param String $squawk squawk code of flight |
|
| 708 | - * @param String $route_stop route stop of flight |
|
| 709 | - * @param String $highlight highlight or not |
|
| 710 | - * @param String $ModeS ModesS code of flight |
|
| 711 | - * @param String $registration registration code of flight |
|
| 712 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 713 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 714 | - * @param String $verticalrate vertival rate of flight |
|
| 715 | - * @return String success or false |
|
| 716 | - */ |
|
| 693 | + * Adds a new spotter data |
|
| 694 | + * |
|
| 695 | + * @param String $fammarine_id the ID |
|
| 696 | + * @param String $ident the marine ident |
|
| 697 | + * @param String $departure_airport_icao the departure airport |
|
| 698 | + * @param String $arrival_airport_icao the arrival airport |
|
| 699 | + * @param String $latitude latitude of flight |
|
| 700 | + * @param String $longitude latitude of flight |
|
| 701 | + * @param String $waypoints waypoints of flight |
|
| 702 | + * @param String $heading heading of flight |
|
| 703 | + * @param String $groundspeed speed of flight |
|
| 704 | + * @param String $date date of flight |
|
| 705 | + * @param String $departure_airport_time departure time of flight |
|
| 706 | + * @param String $arrival_airport_time arrival time of flight |
|
| 707 | + * @param String $squawk squawk code of flight |
|
| 708 | + * @param String $route_stop route stop of flight |
|
| 709 | + * @param String $highlight highlight or not |
|
| 710 | + * @param String $ModeS ModesS code of flight |
|
| 711 | + * @param String $registration registration code of flight |
|
| 712 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 713 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 714 | + * @param String $verticalrate vertival rate of flight |
|
| 715 | + * @return String success or false |
|
| 716 | + */ |
|
| 717 | 717 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
| 718 | 718 | { |
| 719 | 719 | global $globalURL, $globalMarineImageFetch; |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | $sth->execute($query_values); |
| 833 | 833 | $this->db = null; |
| 834 | 834 | } catch (PDOException $e) { |
| 835 | - return "error : ".$e->getMessage(); |
|
| 835 | + return "error : ".$e->getMessage(); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | return "success"; |
@@ -841,11 +841,11 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | |
| 843 | 843 | /** |
| 844 | - * Gets the aircraft ident within the last hour |
|
| 845 | - * |
|
| 846 | - * @return String the ident |
|
| 847 | - * |
|
| 848 | - */ |
|
| 844 | + * Gets the aircraft ident within the last hour |
|
| 845 | + * |
|
| 846 | + * @return String the ident |
|
| 847 | + * |
|
| 848 | + */ |
|
| 849 | 849 | public function getIdentFromLastHour($ident) |
| 850 | 850 | { |
| 851 | 851 | global $globalDBdriver, $globalTimezone; |
@@ -861,11 +861,11 @@ discard block |
||
| 861 | 861 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 862 | 862 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 863 | 863 | $query_data = array(':ident' => $ident); |
| 864 | - } |
|
| 864 | + } |
|
| 865 | 865 | |
| 866 | 866 | $sth = $this->db->prepare($query); |
| 867 | 867 | $sth->execute($query_data); |
| 868 | - $ident_result=''; |
|
| 868 | + $ident_result=''; |
|
| 869 | 869 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 870 | 870 | { |
| 871 | 871 | $ident_result = $row['ident']; |
@@ -876,11 +876,11 @@ discard block |
||
| 876 | 876 | |
| 877 | 877 | |
| 878 | 878 | /** |
| 879 | - * Gets the aircraft data from the last 20 seconds |
|
| 880 | - * |
|
| 881 | - * @return Array the spotter data |
|
| 882 | - * |
|
| 883 | - */ |
|
| 879 | + * Gets the aircraft data from the last 20 seconds |
|
| 880 | + * |
|
| 881 | + * @return Array the spotter data |
|
| 882 | + * |
|
| 883 | + */ |
|
| 884 | 884 | public function getRealTimeData($q = '') |
| 885 | 885 | { |
| 886 | 886 | global $globalDBdriver; |
@@ -918,11 +918,11 @@ discard block |
||
| 918 | 918 | |
| 919 | 919 | |
| 920 | 920 | /** |
| 921 | - * Gets all number of flight over countries |
|
| 922 | - * |
|
| 923 | - * @return Array the airline country list |
|
| 924 | - * |
|
| 925 | - */ |
|
| 921 | + * Gets all number of flight over countries |
|
| 922 | + * |
|
| 923 | + * @return Array the airline country list |
|
| 924 | + * |
|
| 925 | + */ |
|
| 926 | 926 | |
| 927 | 927 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 928 | 928 | { |
@@ -995,11 +995,11 @@ discard block |
||
| 995 | 995 | |
| 996 | 996 | |
| 997 | 997 | /** |
| 998 | - * Gets all callsigns that have flown over |
|
| 999 | - * |
|
| 1000 | - * @return Array the callsign list |
|
| 1001 | - * |
|
| 1002 | - */ |
|
| 998 | + * Gets all callsigns that have flown over |
|
| 999 | + * |
|
| 1000 | + * @return Array the callsign list |
|
| 1001 | + * |
|
| 1002 | + */ |
|
| 1003 | 1003 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 1004 | 1004 | { |
| 1005 | 1005 | global $globalDBdriver; |
@@ -1066,11 +1066,11 @@ discard block |
||
| 1066 | 1066 | |
| 1067 | 1067 | |
| 1068 | 1068 | /** |
| 1069 | - * Counts all dates |
|
| 1070 | - * |
|
| 1071 | - * @return Array the date list |
|
| 1072 | - * |
|
| 1073 | - */ |
|
| 1069 | + * Counts all dates |
|
| 1070 | + * |
|
| 1071 | + * @return Array the date list |
|
| 1072 | + * |
|
| 1073 | + */ |
|
| 1074 | 1074 | public function countAllDates($filters = array()) |
| 1075 | 1075 | { |
| 1076 | 1076 | global $globalTimezone, $globalDBdriver; |
@@ -1116,11 +1116,11 @@ discard block |
||
| 1116 | 1116 | |
| 1117 | 1117 | |
| 1118 | 1118 | /** |
| 1119 | - * Counts all dates during the last 7 days |
|
| 1120 | - * |
|
| 1121 | - * @return Array the date list |
|
| 1122 | - * |
|
| 1123 | - */ |
|
| 1119 | + * Counts all dates during the last 7 days |
|
| 1120 | + * |
|
| 1121 | + * @return Array the date list |
|
| 1122 | + * |
|
| 1123 | + */ |
|
| 1124 | 1124 | public function countAllDatesLast7Days($filters = array()) |
| 1125 | 1125 | { |
| 1126 | 1126 | global $globalTimezone, $globalDBdriver; |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | $query .= " GROUP BY date_name |
| 1143 | 1143 | ORDER BY date_name ASC"; |
| 1144 | 1144 | $query_data = array(':offset' => $offset); |
| 1145 | - } |
|
| 1145 | + } |
|
| 1146 | 1146 | |
| 1147 | 1147 | $sth = $this->db->prepare($query); |
| 1148 | 1148 | $sth->execute($query_data); |
@@ -1162,11 +1162,11 @@ discard block |
||
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | /** |
| 1165 | - * Counts all dates during the last month |
|
| 1166 | - * |
|
| 1167 | - * @return Array the date list |
|
| 1168 | - * |
|
| 1169 | - */ |
|
| 1165 | + * Counts all dates during the last month |
|
| 1166 | + * |
|
| 1167 | + * @return Array the date list |
|
| 1168 | + * |
|
| 1169 | + */ |
|
| 1170 | 1170 | public function countAllDatesLastMonth($filters = array()) |
| 1171 | 1171 | { |
| 1172 | 1172 | global $globalTimezone, $globalDBdriver; |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | $query .= " GROUP BY date_name |
| 1189 | 1189 | ORDER BY date_name ASC"; |
| 1190 | 1190 | $query_data = array(':offset' => $offset); |
| 1191 | - } |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | 1193 | $sth = $this->db->prepare($query); |
| 1194 | 1194 | $sth->execute($query_data); |
@@ -1210,11 +1210,11 @@ discard block |
||
| 1210 | 1210 | |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
| 1213 | - * Counts all month |
|
| 1214 | - * |
|
| 1215 | - * @return Array the month list |
|
| 1216 | - * |
|
| 1217 | - */ |
|
| 1213 | + * Counts all month |
|
| 1214 | + * |
|
| 1215 | + * @return Array the month list |
|
| 1216 | + * |
|
| 1217 | + */ |
|
| 1218 | 1218 | public function countAllMonths($filters = array()) |
| 1219 | 1219 | { |
| 1220 | 1220 | global $globalTimezone, $globalDBdriver; |
@@ -1259,11 +1259,11 @@ discard block |
||
| 1259 | 1259 | |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
| 1262 | - * Counts all dates during the last year |
|
| 1263 | - * |
|
| 1264 | - * @return Array the date list |
|
| 1265 | - * |
|
| 1266 | - */ |
|
| 1262 | + * Counts all dates during the last year |
|
| 1263 | + * |
|
| 1264 | + * @return Array the date list |
|
| 1265 | + * |
|
| 1266 | + */ |
|
| 1267 | 1267 | public function countAllMonthsLastYear($filters) |
| 1268 | 1268 | { |
| 1269 | 1269 | global $globalTimezone, $globalDBdriver; |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | $query .= " GROUP BY year_name, month_name |
| 1286 | 1286 | ORDER BY year_name, month_name ASC"; |
| 1287 | 1287 | $query_data = array(':offset' => $offset); |
| 1288 | - } |
|
| 1288 | + } |
|
| 1289 | 1289 | |
| 1290 | 1290 | $sth = $this->db->prepare($query); |
| 1291 | 1291 | $sth->execute($query_data); |
@@ -1308,11 +1308,11 @@ discard block |
||
| 1308 | 1308 | |
| 1309 | 1309 | |
| 1310 | 1310 | /** |
| 1311 | - * Counts all hours |
|
| 1312 | - * |
|
| 1313 | - * @return Array the hour list |
|
| 1314 | - * |
|
| 1315 | - */ |
|
| 1311 | + * Counts all hours |
|
| 1312 | + * |
|
| 1313 | + * @return Array the hour list |
|
| 1314 | + * |
|
| 1315 | + */ |
|
| 1316 | 1316 | public function countAllHours($orderby,$filters = array()) |
| 1317 | 1317 | { |
| 1318 | 1318 | global $globalTimezone, $globalDBdriver; |
@@ -1375,11 +1375,11 @@ discard block |
||
| 1375 | 1375 | |
| 1376 | 1376 | |
| 1377 | 1377 | /** |
| 1378 | - * Counts all hours by date |
|
| 1379 | - * |
|
| 1380 | - * @return Array the hour list |
|
| 1381 | - * |
|
| 1382 | - */ |
|
| 1378 | + * Counts all hours by date |
|
| 1379 | + * |
|
| 1380 | + * @return Array the hour list |
|
| 1381 | + * |
|
| 1382 | + */ |
|
| 1383 | 1383 | public function countAllHoursByDate($date, $filters = array()) |
| 1384 | 1384 | { |
| 1385 | 1385 | global $globalTimezone, $globalDBdriver; |
@@ -1423,11 +1423,11 @@ discard block |
||
| 1423 | 1423 | |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
| 1426 | - * Counts all hours by a ident/callsign |
|
| 1427 | - * |
|
| 1428 | - * @return Array the hour list |
|
| 1429 | - * |
|
| 1430 | - */ |
|
| 1426 | + * Counts all hours by a ident/callsign |
|
| 1427 | + * |
|
| 1428 | + * @return Array the hour list |
|
| 1429 | + * |
|
| 1430 | + */ |
|
| 1431 | 1431 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1432 | 1432 | { |
| 1433 | 1433 | global $globalTimezone, $globalDBdriver; |
@@ -1472,11 +1472,11 @@ discard block |
||
| 1472 | 1472 | |
| 1473 | 1473 | |
| 1474 | 1474 | /** |
| 1475 | - * Counts all vessels |
|
| 1476 | - * |
|
| 1477 | - * @return Integer the number of vessels |
|
| 1478 | - * |
|
| 1479 | - */ |
|
| 1475 | + * Counts all vessels |
|
| 1476 | + * |
|
| 1477 | + * @return Integer the number of vessels |
|
| 1478 | + * |
|
| 1479 | + */ |
|
| 1480 | 1480 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
| 1481 | 1481 | { |
| 1482 | 1482 | global $globalDBdriver; |
@@ -1511,11 +1511,11 @@ discard block |
||
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | /** |
| 1514 | - * Counts all vessel type |
|
| 1515 | - * |
|
| 1516 | - * @return Integer the number of vessels |
|
| 1517 | - * |
|
| 1518 | - */ |
|
| 1514 | + * Counts all vessel type |
|
| 1515 | + * |
|
| 1516 | + * @return Integer the number of vessels |
|
| 1517 | + * |
|
| 1518 | + */ |
|
| 1519 | 1519 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
| 1520 | 1520 | { |
| 1521 | 1521 | global $globalDBdriver; |
@@ -1550,11 +1550,11 @@ discard block |
||
| 1550 | 1550 | |
| 1551 | 1551 | |
| 1552 | 1552 | /** |
| 1553 | - * Counts all hours of today |
|
| 1554 | - * |
|
| 1555 | - * @return Array the hour list |
|
| 1556 | - * |
|
| 1557 | - */ |
|
| 1553 | + * Counts all hours of today |
|
| 1554 | + * |
|
| 1555 | + * @return Array the hour list |
|
| 1556 | + * |
|
| 1557 | + */ |
|
| 1558 | 1558 | public function countAllHoursFromToday($filters = array()) |
| 1559 | 1559 | { |
| 1560 | 1560 | global $globalTimezone, $globalDBdriver; |
@@ -1594,12 +1594,12 @@ discard block |
||
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | |
| 1597 | - /** |
|
| 1598 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1599 | - * |
|
| 1600 | - * @return Integer the Barrie Spotter ID |
|
| 1597 | + /** |
|
| 1598 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1599 | + * |
|
| 1600 | + * @return Integer the Barrie Spotter ID |
|
| 1601 | 1601 | q * |
| 1602 | - */ |
|
| 1602 | + */ |
|
| 1603 | 1603 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1604 | 1604 | { |
| 1605 | 1605 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1620,13 +1620,13 @@ discard block |
||
| 1620 | 1620 | |
| 1621 | 1621 | |
| 1622 | 1622 | /** |
| 1623 | - * Parses a date string |
|
| 1624 | - * |
|
| 1625 | - * @param String $dateString the date string |
|
| 1626 | - * @param String $timezone the timezone of a user |
|
| 1627 | - * @return Array the time information |
|
| 1628 | - * |
|
| 1629 | - */ |
|
| 1623 | + * Parses a date string |
|
| 1624 | + * |
|
| 1625 | + * @param String $dateString the date string |
|
| 1626 | + * @param String $timezone the timezone of a user |
|
| 1627 | + * @return Array the time information |
|
| 1628 | + * |
|
| 1629 | + */ |
|
| 1630 | 1630 | public function parseDateString($dateString, $timezone = '') |
| 1631 | 1631 | { |
| 1632 | 1632 | $time_array = array(); |
@@ -1659,12 +1659,12 @@ discard block |
||
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | /** |
| 1662 | - * Parses the direction degrees to working |
|
| 1663 | - * |
|
| 1664 | - * @param Float $direction the direction in degrees |
|
| 1665 | - * @return Array the direction information |
|
| 1666 | - * |
|
| 1667 | - */ |
|
| 1662 | + * Parses the direction degrees to working |
|
| 1663 | + * |
|
| 1664 | + * @param Float $direction the direction in degrees |
|
| 1665 | + * @return Array the direction information |
|
| 1666 | + * |
|
| 1667 | + */ |
|
| 1668 | 1668 | public function parseDirection($direction = 0) |
| 1669 | 1669 | { |
| 1670 | 1670 | if ($direction == '') $direction = 0; |
@@ -1743,12 +1743,12 @@ discard block |
||
| 1743 | 1743 | |
| 1744 | 1744 | |
| 1745 | 1745 | /** |
| 1746 | - * Gets Country from latitude/longitude |
|
| 1747 | - * |
|
| 1748 | - * @param Float $latitude latitute of the flight |
|
| 1749 | - * @param Float $longitude longitute of the flight |
|
| 1750 | - * @return String the countrie |
|
| 1751 | - */ |
|
| 1746 | + * Gets Country from latitude/longitude |
|
| 1747 | + * |
|
| 1748 | + * @param Float $latitude latitute of the flight |
|
| 1749 | + * @param Float $longitude longitute of the flight |
|
| 1750 | + * @return String the countrie |
|
| 1751 | + */ |
|
| 1752 | 1752 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 1753 | 1753 | { |
| 1754 | 1754 | global $globalDBdriver, $globalDebug; |
@@ -1785,11 +1785,11 @@ discard block |
||
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | /** |
| 1788 | - * Gets Country from iso2 |
|
| 1789 | - * |
|
| 1790 | - * @param String $iso2 ISO2 country code |
|
| 1791 | - * @return String the countrie |
|
| 1792 | - */ |
|
| 1788 | + * Gets Country from iso2 |
|
| 1789 | + * |
|
| 1790 | + * @param String $iso2 ISO2 country code |
|
| 1791 | + * @return String the countrie |
|
| 1792 | + */ |
|
| 1793 | 1793 | public function getCountryFromISO2($iso2) |
| 1794 | 1794 | { |
| 1795 | 1795 | global $globalDBdriver, $globalDebug; |
@@ -1818,12 +1818,12 @@ discard block |
||
| 1818 | 1818 | |
| 1819 | 1819 | |
| 1820 | 1820 | /** |
| 1821 | - * Gets the short url from bit.ly |
|
| 1822 | - * |
|
| 1823 | - * @param String $url the full url |
|
| 1824 | - * @return String the bit.ly url |
|
| 1825 | - * |
|
| 1826 | - */ |
|
| 1821 | + * Gets the short url from bit.ly |
|
| 1822 | + * |
|
| 1823 | + * @param String $url the full url |
|
| 1824 | + * @return String the bit.ly url |
|
| 1825 | + * |
|
| 1826 | + */ |
|
| 1827 | 1827 | public function getBitlyURL($url) |
| 1828 | 1828 | { |
| 1829 | 1829 | global $globalBitlyAccessToken; |
@@ -1850,11 +1850,11 @@ discard block |
||
| 1850 | 1850 | |
| 1851 | 1851 | |
| 1852 | 1852 | /** |
| 1853 | - * Gets all vessels types that have flown over |
|
| 1854 | - * |
|
| 1855 | - * @return Array the vessel type list |
|
| 1856 | - * |
|
| 1857 | - */ |
|
| 1853 | + * Gets all vessels types that have flown over |
|
| 1854 | + * |
|
| 1855 | + * @return Array the vessel type list |
|
| 1856 | + * |
|
| 1857 | + */ |
|
| 1858 | 1858 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 1859 | 1859 | { |
| 1860 | 1860 | global $globalDBdriver; |
@@ -1920,11 +1920,11 @@ discard block |
||
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | 1922 | /** |
| 1923 | - * Gets all the tracker information |
|
| 1924 | - * |
|
| 1925 | - * @return Array the tracker information |
|
| 1926 | - * |
|
| 1927 | - */ |
|
| 1923 | + * Gets all the tracker information |
|
| 1924 | + * |
|
| 1925 | + * @return Array the tracker information |
|
| 1926 | + * |
|
| 1927 | + */ |
|
| 1928 | 1928 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
| 1929 | 1929 | { |
| 1930 | 1930 | global $globalTimezone, $globalDBdriver; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Get SQL query part for filter used |
| 17 | 17 | * @param Array $filter the filter |
| 18 | - * @return Array the SQL part |
|
| 18 | + * @return string the SQL part |
|
| 19 | 19 | */ |
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -915,10 +915,6 @@ discard block |
||
| 915 | 915 | * |
| 916 | 916 | * @param String $fammarine_id the ID from flightaware |
| 917 | 917 | * @param String $ident the flight ident |
| 918 | - * @param String $aircraft_icao the aircraft type |
|
| 919 | - * @param String $departure_airport_icao the departure airport |
|
| 920 | - * @param String $arrival_airport_icao the arrival airport |
|
| 921 | - * @return String success or false |
|
| 922 | 918 | * |
| 923 | 919 | */ |
| 924 | 920 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Gets all the spotter information based on the latest data entry |
|
| 100 | - * |
|
| 101 | - * @return Array the spotter information |
|
| 102 | - * |
|
| 103 | - */ |
|
| 99 | + * Gets all the spotter information based on the latest data entry |
|
| 100 | + * |
|
| 101 | + * @return Array the spotter information |
|
| 102 | + * |
|
| 103 | + */ |
|
| 104 | 104 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
| 105 | 105 | { |
| 106 | 106 | global $globalDBdriver, $globalLiveInterval; |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | - * Gets Minimal Live Spotter data |
|
| 147 | - * |
|
| 148 | - * @return Array the spotter information |
|
| 149 | - * |
|
| 150 | - */ |
|
| 146 | + * Gets Minimal Live Spotter data |
|
| 147 | + * |
|
| 148 | + * @return Array the spotter information |
|
| 149 | + * |
|
| 150 | + */ |
|
| 151 | 151 | public function getMinLiveMarineData($filter = array()) |
| 152 | 152 | { |
| 153 | 153 | global $globalDBdriver, $globalLiveInterval; |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 181 | - * |
|
| 182 | - * @return Array the spotter information |
|
| 183 | - * |
|
| 184 | - */ |
|
| 180 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 181 | + * |
|
| 182 | + * @return Array the spotter information |
|
| 183 | + * |
|
| 184 | + */ |
|
| 185 | 185 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
| 186 | 186 | { |
| 187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * Gets number of latest data entry |
|
| 256 | - * |
|
| 257 | - * @return String number of entry |
|
| 258 | - * |
|
| 259 | - */ |
|
| 255 | + * Gets number of latest data entry |
|
| 256 | + * |
|
| 257 | + * @return String number of entry |
|
| 258 | + * |
|
| 259 | + */ |
|
| 260 | 260 | public function getLiveMarineCount($filter = array()) |
| 261 | 261 | { |
| 262 | 262 | global $globalDBdriver, $globalLiveInterval; |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 285 | - * |
|
| 286 | - * @return Array the spotter information |
|
| 287 | - * |
|
| 288 | - */ |
|
| 284 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 285 | + * |
|
| 286 | + * @return Array the spotter information |
|
| 287 | + * |
|
| 288 | + */ |
|
| 289 | 289 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
| 290 | 290 | { |
| 291 | 291 | global $globalDBdriver, $globalLiveInterval; |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 313 | - * |
|
| 314 | - * @return Array the spotter information |
|
| 315 | - * |
|
| 316 | - */ |
|
| 312 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 313 | + * |
|
| 314 | + * @return Array the spotter information |
|
| 315 | + * |
|
| 316 | + */ |
|
| 317 | 317 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
| 318 | 318 | { |
| 319 | 319 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
| 385 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 386 | - * |
|
| 387 | - * @return Array the spotter information |
|
| 388 | - * |
|
| 389 | - */ |
|
| 385 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 386 | + * |
|
| 387 | + * @return Array the spotter information |
|
| 388 | + * |
|
| 389 | + */ |
|
| 390 | 390 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
| 391 | 391 | { |
| 392 | 392 | $Marine = new Marine($this->db); |
@@ -399,75 +399,75 @@ discard block |
||
| 399 | 399 | if ($lng != '') |
| 400 | 400 | { |
| 401 | 401 | if (!is_numeric($lng)) |
| 402 | - { |
|
| 403 | - return false; |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - if ($radius != '') |
|
| 408 | - { |
|
| 409 | - if (!is_numeric($radius)) |
|
| 410 | - { |
|
| 411 | - return false; |
|
| 412 | - } |
|
| 413 | - } |
|
| 402 | + { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + if ($radius != '') |
|
| 408 | + { |
|
| 409 | + if (!is_numeric($radius)) |
|
| 410 | + { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | 414 | $additional_query = ''; |
| 415 | 415 | if ($interval != '') |
| 416 | - { |
|
| 417 | - if (!is_string($interval)) |
|
| 418 | - { |
|
| 419 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 420 | - return false; |
|
| 421 | - } else { |
|
| 422 | - if ($interval == '1m') |
|
| 423 | - { |
|
| 424 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 425 | - } else if ($interval == '15m'){ |
|
| 426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - } else { |
|
| 430 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 416 | + { |
|
| 417 | + if (!is_string($interval)) |
|
| 418 | + { |
|
| 419 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 420 | + return false; |
|
| 421 | + } else { |
|
| 422 | + if ($interval == '1m') |
|
| 423 | + { |
|
| 424 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 425 | + } else if ($interval == '15m'){ |
|
| 426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + } else { |
|
| 430 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 434 | 434 | WHERE marine_live.latitude <> '' |
| 435 | 435 | AND marine_live.longitude <> '' |
| 436 | 436 | ".$additional_query." |
| 437 | 437 | HAVING distance < :radius |
| 438 | 438 | ORDER BY distance"; |
| 439 | 439 | |
| 440 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 440 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 441 | 441 | |
| 442 | - return $spotter_array; |
|
| 443 | - } |
|
| 442 | + return $spotter_array; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | |
| 446 | - /** |
|
| 447 | - * Gets all the spotter information based on a particular callsign |
|
| 448 | - * |
|
| 449 | - * @return Array the spotter information |
|
| 450 | - * |
|
| 451 | - */ |
|
| 446 | + /** |
|
| 447 | + * Gets all the spotter information based on a particular callsign |
|
| 448 | + * |
|
| 449 | + * @return Array the spotter information |
|
| 450 | + * |
|
| 451 | + */ |
|
| 452 | 452 | public function getLastLiveMarineDataByIdent($ident) |
| 453 | 453 | { |
| 454 | 454 | $Marine = new Marine($this->db); |
| 455 | 455 | date_default_timezone_set('UTC'); |
| 456 | 456 | |
| 457 | 457 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 458 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 458 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 459 | 459 | |
| 460 | 460 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 461 | 461 | |
| 462 | 462 | return $spotter_array; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - /** |
|
| 466 | - * Gets all the spotter information based on a particular callsign |
|
| 467 | - * |
|
| 468 | - * @return Array the spotter information |
|
| 469 | - * |
|
| 470 | - */ |
|
| 465 | + /** |
|
| 466 | + * Gets all the spotter information based on a particular callsign |
|
| 467 | + * |
|
| 468 | + * @return Array the spotter information |
|
| 469 | + * |
|
| 470 | + */ |
|
| 471 | 471 | public function getDateLiveMarineDataByIdent($ident,$date) |
| 472 | 472 | { |
| 473 | 473 | $Marine = new Marine($this->db); |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
| 483 | - * Gets all the spotter information based on a particular MMSI |
|
| 484 | - * |
|
| 485 | - * @return Array the spotter information |
|
| 486 | - * |
|
| 487 | - */ |
|
| 483 | + * Gets all the spotter information based on a particular MMSI |
|
| 484 | + * |
|
| 485 | + * @return Array the spotter information |
|
| 486 | + * |
|
| 487 | + */ |
|
| 488 | 488 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
| 489 | 489 | { |
| 490 | 490 | $Marine = new Marine($this->db); |
@@ -496,51 +496,51 @@ discard block |
||
| 496 | 496 | return $spotter_array; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - /** |
|
| 500 | - * Gets last spotter information based on a particular callsign |
|
| 501 | - * |
|
| 502 | - * @return Array the spotter information |
|
| 503 | - * |
|
| 504 | - */ |
|
| 499 | + /** |
|
| 500 | + * Gets last spotter information based on a particular callsign |
|
| 501 | + * |
|
| 502 | + * @return Array the spotter information |
|
| 503 | + * |
|
| 504 | + */ |
|
| 505 | 505 | public function getLastLiveMarineDataById($id) |
| 506 | 506 | { |
| 507 | 507 | $Marine = new Marine($this->db); |
| 508 | 508 | date_default_timezone_set('UTC'); |
| 509 | 509 | |
| 510 | 510 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 511 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 511 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 512 | 512 | |
| 513 | 513 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
| 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 getDateLiveMarineDataById($id,$date) |
| 525 | 525 | { |
| 526 | 526 | $Marine = new Marine($this->db); |
| 527 | 527 | date_default_timezone_set('UTC'); |
| 528 | 528 | |
| 529 | 529 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 530 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 531 | - $date = date('c',$date); |
|
| 530 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 531 | + $date = date('c',$date); |
|
| 532 | 532 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 533 | 533 | |
| 534 | 534 | return $spotter_array; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
| 538 | - /** |
|
| 539 | - * Gets all the spotter information based on a particular id |
|
| 540 | - * |
|
| 541 | - * @return Array the spotter information |
|
| 542 | - * |
|
| 543 | - */ |
|
| 538 | + /** |
|
| 539 | + * Gets all the spotter information based on a particular id |
|
| 540 | + * |
|
| 541 | + * @return Array the spotter information |
|
| 542 | + * |
|
| 543 | + */ |
|
| 544 | 544 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
| 545 | 545 | { |
| 546 | 546 | global $globalDBdriver, $globalLiveInterval; |
@@ -568,18 +568,18 @@ discard block |
||
| 568 | 568 | return $spotter_array; |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - /** |
|
| 572 | - * Gets all the spotter information based on a particular ident |
|
| 573 | - * |
|
| 574 | - * @return Array the spotter information |
|
| 575 | - * |
|
| 576 | - */ |
|
| 571 | + /** |
|
| 572 | + * Gets all the spotter information based on a particular ident |
|
| 573 | + * |
|
| 574 | + * @return Array the spotter information |
|
| 575 | + * |
|
| 576 | + */ |
|
| 577 | 577 | public function getAllLiveMarineDataByIdent($ident) |
| 578 | 578 | { |
| 579 | 579 | date_default_timezone_set('UTC'); |
| 580 | 580 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 581 | 581 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
| 582 | - try { |
|
| 582 | + try { |
|
| 583 | 583 | |
| 584 | 584 | $sth = $this->db->prepare($query); |
| 585 | 585 | $sth->execute(array(':ident' => $ident)); |
@@ -593,23 +593,23 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | |
| 595 | 595 | /** |
| 596 | - * Deletes all info in the table |
|
| 597 | - * |
|
| 598 | - * @return String success or false |
|
| 599 | - * |
|
| 600 | - */ |
|
| 596 | + * Deletes all info in the table |
|
| 597 | + * |
|
| 598 | + * @return String success or false |
|
| 599 | + * |
|
| 600 | + */ |
|
| 601 | 601 | public function deleteLiveMarineData() |
| 602 | 602 | { |
| 603 | 603 | global $globalDBdriver; |
| 604 | 604 | if ($globalDBdriver == 'mysql') { |
| 605 | 605 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
| 606 | 606 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
| 607 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 607 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 608 | 608 | } else { |
| 609 | 609 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - try { |
|
| 612 | + try { |
|
| 613 | 613 | |
| 614 | 614 | $sth = $this->db->prepare($query); |
| 615 | 615 | $sth->execute(); |
@@ -621,18 +621,18 @@ discard block |
||
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
| 624 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 625 | - * |
|
| 626 | - * @return String success or false |
|
| 627 | - * |
|
| 628 | - */ |
|
| 624 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 625 | + * |
|
| 626 | + * @return String success or false |
|
| 627 | + * |
|
| 628 | + */ |
|
| 629 | 629 | public function deleteLiveMarineDataNotUpdated() |
| 630 | 630 | { |
| 631 | 631 | global $globalDBdriver, $globalDebug; |
| 632 | 632 | if ($globalDBdriver == 'mysql') { |
| 633 | 633 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
| 634 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 635 | - try { |
|
| 634 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 635 | + try { |
|
| 636 | 636 | |
| 637 | 637 | $sth = $this->db->prepare($query); |
| 638 | 638 | $sth->execute(); |
@@ -640,8 +640,8 @@ discard block |
||
| 640 | 640 | return "error"; |
| 641 | 641 | } |
| 642 | 642 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 643 | - $i = 0; |
|
| 644 | - $j =0; |
|
| 643 | + $i = 0; |
|
| 644 | + $j =0; |
|
| 645 | 645 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 646 | 646 | foreach($all as $row) |
| 647 | 647 | { |
@@ -649,20 +649,20 @@ discard block |
||
| 649 | 649 | $j++; |
| 650 | 650 | if ($j == 30) { |
| 651 | 651 | if ($globalDebug) echo "."; |
| 652 | - try { |
|
| 652 | + try { |
|
| 653 | 653 | |
| 654 | 654 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 655 | 655 | $sth->execute(); |
| 656 | 656 | } catch(PDOException $e) { |
| 657 | 657 | return "error"; |
| 658 | 658 | } |
| 659 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 660 | - $j = 0; |
|
| 659 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 660 | + $j = 0; |
|
| 661 | 661 | } |
| 662 | 662 | $query_delete .= "'".$row['fammarine_id']."',"; |
| 663 | 663 | } |
| 664 | 664 | if ($i > 0) { |
| 665 | - try { |
|
| 665 | + try { |
|
| 666 | 666 | |
| 667 | 667 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 668 | 668 | $sth->execute(); |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | return "success"; |
| 674 | 674 | } elseif ($globalDBdriver == 'pgsql') { |
| 675 | 675 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
| 676 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 677 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 678 | - try { |
|
| 676 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 677 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 678 | + try { |
|
| 679 | 679 | |
| 680 | 680 | $sth = $this->db->prepare($query); |
| 681 | 681 | $sth->execute(); |
@@ -719,17 +719,17 @@ discard block |
||
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
| 722 | - * Deletes all info in the table for an ident |
|
| 723 | - * |
|
| 724 | - * @return String success or false |
|
| 725 | - * |
|
| 726 | - */ |
|
| 722 | + * Deletes all info in the table for an ident |
|
| 723 | + * |
|
| 724 | + * @return String success or false |
|
| 725 | + * |
|
| 726 | + */ |
|
| 727 | 727 | public function deleteLiveMarineDataByIdent($ident) |
| 728 | 728 | { |
| 729 | 729 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 730 | 730 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
| 731 | 731 | |
| 732 | - try { |
|
| 732 | + try { |
|
| 733 | 733 | |
| 734 | 734 | $sth = $this->db->prepare($query); |
| 735 | 735 | $sth->execute(array(':ident' => $ident)); |
@@ -741,17 +741,17 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
| 744 | - * Deletes all info in the table for an id |
|
| 745 | - * |
|
| 746 | - * @return String success or false |
|
| 747 | - * |
|
| 748 | - */ |
|
| 744 | + * Deletes all info in the table for an id |
|
| 745 | + * |
|
| 746 | + * @return String success or false |
|
| 747 | + * |
|
| 748 | + */ |
|
| 749 | 749 | public function deleteLiveMarineDataById($id) |
| 750 | 750 | { |
| 751 | 751 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 752 | 752 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
| 753 | 753 | |
| 754 | - try { |
|
| 754 | + try { |
|
| 755 | 755 | |
| 756 | 756 | $sth = $this->db->prepare($query); |
| 757 | 757 | $sth->execute(array(':id' => $id)); |
@@ -764,11 +764,11 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | |
| 766 | 766 | /** |
| 767 | - * Gets the marine race |
|
| 768 | - * |
|
| 769 | - * @return String the ident |
|
| 770 | - * |
|
| 771 | - */ |
|
| 767 | + * Gets the marine race |
|
| 768 | + * |
|
| 769 | + * @return String the ident |
|
| 770 | + * |
|
| 771 | + */ |
|
| 772 | 772 | public function getAllRaces() |
| 773 | 773 | { |
| 774 | 774 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -779,11 +779,11 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
| 782 | - * Gets the aircraft ident within the last hour |
|
| 783 | - * |
|
| 784 | - * @return String the ident |
|
| 785 | - * |
|
| 786 | - */ |
|
| 782 | + * Gets the aircraft ident within the last hour |
|
| 783 | + * |
|
| 784 | + * @return String the ident |
|
| 785 | + * |
|
| 786 | + */ |
|
| 787 | 787 | public function getIdentFromLastHour($ident) |
| 788 | 788 | { |
| 789 | 789 | global $globalDBdriver, $globalTimezone; |
@@ -809,14 +809,14 @@ discard block |
||
| 809 | 809 | $ident_result = $row['ident']; |
| 810 | 810 | } |
| 811 | 811 | return $ident_result; |
| 812 | - } |
|
| 812 | + } |
|
| 813 | 813 | |
| 814 | 814 | /** |
| 815 | - * Check recent aircraft |
|
| 816 | - * |
|
| 817 | - * @return String the ident |
|
| 818 | - * |
|
| 819 | - */ |
|
| 815 | + * Check recent aircraft |
|
| 816 | + * |
|
| 817 | + * @return String the ident |
|
| 818 | + * |
|
| 819 | + */ |
|
| 820 | 820 | public function checkIdentRecent($ident) |
| 821 | 821 | { |
| 822 | 822 | global $globalDBdriver, $globalTimezone; |
@@ -842,14 +842,14 @@ discard block |
||
| 842 | 842 | $ident_result = $row['fammarine_id']; |
| 843 | 843 | } |
| 844 | 844 | return $ident_result; |
| 845 | - } |
|
| 845 | + } |
|
| 846 | 846 | |
| 847 | 847 | /** |
| 848 | - * Check recent aircraft by id |
|
| 849 | - * |
|
| 850 | - * @return String the ident |
|
| 851 | - * |
|
| 852 | - */ |
|
| 848 | + * Check recent aircraft by id |
|
| 849 | + * |
|
| 850 | + * @return String the ident |
|
| 851 | + * |
|
| 852 | + */ |
|
| 853 | 853 | public function checkIdRecent($id) |
| 854 | 854 | { |
| 855 | 855 | global $globalDBdriver, $globalTimezone; |
@@ -875,14 +875,14 @@ discard block |
||
| 875 | 875 | $ident_result = $row['fammarine_id']; |
| 876 | 876 | } |
| 877 | 877 | return $ident_result; |
| 878 | - } |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | 880 | /** |
| 881 | - * Check recent aircraft by mmsi |
|
| 882 | - * |
|
| 883 | - * @return String the ident |
|
| 884 | - * |
|
| 885 | - */ |
|
| 881 | + * Check recent aircraft by mmsi |
|
| 882 | + * |
|
| 883 | + * @return String the ident |
|
| 884 | + * |
|
| 885 | + */ |
|
| 886 | 886 | public function checkMMSIRecent($mmsi) |
| 887 | 887 | { |
| 888 | 888 | global $globalDBdriver, $globalTimezone; |
@@ -908,19 +908,19 @@ discard block |
||
| 908 | 908 | $ident_result = $row['fammarine_id']; |
| 909 | 909 | } |
| 910 | 910 | return $ident_result; |
| 911 | - } |
|
| 911 | + } |
|
| 912 | 912 | |
| 913 | 913 | /** |
| 914 | - * Adds a new spotter data |
|
| 915 | - * |
|
| 916 | - * @param String $fammarine_id the ID from flightaware |
|
| 917 | - * @param String $ident the flight ident |
|
| 918 | - * @param String $aircraft_icao the aircraft type |
|
| 919 | - * @param String $departure_airport_icao the departure airport |
|
| 920 | - * @param String $arrival_airport_icao the arrival airport |
|
| 921 | - * @return String success or false |
|
| 922 | - * |
|
| 923 | - */ |
|
| 914 | + * Adds a new spotter data |
|
| 915 | + * |
|
| 916 | + * @param String $fammarine_id the ID from flightaware |
|
| 917 | + * @param String $ident the flight ident |
|
| 918 | + * @param String $aircraft_icao the aircraft type |
|
| 919 | + * @param String $departure_airport_icao the departure airport |
|
| 920 | + * @param String $arrival_airport_icao the arrival airport |
|
| 921 | + * @return String success or false |
|
| 922 | + * |
|
| 923 | + */ |
|
| 924 | 924 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
| 925 | 925 | { |
| 926 | 926 | global $globalURL, $globalArchive, $globalDebug; |
@@ -998,10 +998,10 @@ discard block |
||
| 998 | 998 | if ($typeid == '') $typeid = NULL; |
| 999 | 999 | if ($statusid == '') $statusid = NULL; |
| 1000 | 1000 | |
| 1001 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1002 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1003 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1004 | - $query = ''; |
|
| 1001 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1002 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1003 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 1004 | + $query = ''; |
|
| 1005 | 1005 | if ($globalArchive) { |
| 1006 | 1006 | if ($globalDebug) echo '-- Delete previous data -- '; |
| 1007 | 1007 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -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,46 +25,46 @@ discard block |
||
| 25 | 25 | // Check if schema is at latest version |
| 26 | 26 | $Connection = new Connection(); |
| 27 | 27 | if ($Connection->connectionExists() === false) { |
| 28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | - exit(); |
|
| 28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | + exit(); |
|
| 30 | 30 | } |
| 31 | 31 | if ($Connection->latest() === false) { |
| 32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | - exit(); |
|
| 32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | + exit(); |
|
| 34 | 34 | } |
| 35 | 35 | if (PHP_SAPI != 'cli') { |
| 36 | - echo "This script MUST be called from console, not a web browser."; |
|
| 36 | + echo "This script MUST be called from console, not a web browser."; |
|
| 37 | 37 | // exit(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // This is to be compatible with old version of settings.php |
| 41 | 41 | if (!isset($globalSources)) { |
| 42 | - if (isset($globalSBS1Hosts)) { |
|
| 43 | - //$hosts = $globalSBS1Hosts; |
|
| 44 | - foreach ($globalSBS1Hosts as $host) { |
|
| 45 | - $globalSources[] = array('host' => $host); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - if (!isset($globalSBS1Host)) { |
|
| 49 | - echo '$globalSources MUST be defined !'; |
|
| 50 | - die; |
|
| 42 | + if (isset($globalSBS1Hosts)) { |
|
| 43 | + //$hosts = $globalSBS1Hosts; |
|
| 44 | + foreach ($globalSBS1Hosts as $host) { |
|
| 45 | + $globalSources[] = array('host' => $host); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + if (!isset($globalSBS1Host)) { |
|
| 49 | + echo '$globalSources MUST be defined !'; |
|
| 50 | + die; |
|
| 51 | 51 | } |
| 52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
| 58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 60 | if (isset($options['s'])) { |
| 61 | - $globalSources = array(); |
|
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 61 | + $globalSources = array(); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | + else $globalSources[] = array('host' => $options['s']); |
|
| 64 | 64 | } elseif (isset($options['source'])) { |
| 65 | - $globalSources = array(); |
|
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 65 | + $globalSources = array(); |
|
| 66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | + else $globalSources[] = array('host' => $options['source']); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($options['aprsserverhost'])) { |
| 70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 104 | 104 | else $id_source = 1; |
| 105 | 105 | if (isset($globalServer) && $globalServer) { |
| 106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | - $SI=new SpotterServer(); |
|
| 106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | + $SI=new SpotterServer(); |
|
| 108 | 108 | /* |
| 109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 116 | 116 | if (isset($globalMarine) && $globalMarine) { |
| 117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 122 | 122 | if (isset($globalMarine) && $globalMarine) { |
| 123 | - $AIS = new AIS(); |
|
| 124 | - $MI = new MarineImport($Connection->db); |
|
| 123 | + $AIS = new AIS(); |
|
| 124 | + $MI = new MarineImport($Connection->db); |
|
| 125 | 125 | } |
| 126 | 126 | //$APRS=new APRS($Connection->db); |
| 127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | //$servertz = system('date +%Z'); |
| 135 | 135 | // signal handler - playing nice with sockets and dump1090 |
| 136 | 136 | if (function_exists('pcntl_fork')) { |
| 137 | - pcntl_signal(SIGINT, function() { |
|
| 138 | - global $sockets; |
|
| 139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 140 | - die("Bye!\n"); |
|
| 141 | - }); |
|
| 142 | - pcntl_signal_dispatch(); |
|
| 137 | + pcntl_signal(SIGINT, function() { |
|
| 138 | + global $sockets; |
|
| 139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 140 | + die("Bye!\n"); |
|
| 141 | + }); |
|
| 142 | + pcntl_signal_dispatch(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // let's try and connect |
@@ -149,46 +149,46 @@ discard block |
||
| 149 | 149 | $reset = 0; |
| 150 | 150 | |
| 151 | 151 | function connect_all($hosts) { |
| 152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 154 | - $reset++; |
|
| 155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 156 | - foreach ($hosts as $id => $value) { |
|
| 152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 154 | + $reset++; |
|
| 155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 156 | + foreach ($hosts as $id => $value) { |
|
| 157 | 157 | $host = $value['host']; |
| 158 | 158 | $globalSources[$id]['last_exec'] = 0; |
| 159 | 159 | // Here we check type of source(s) |
| 160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 162 | - //$formats[$id] = 'deltadbtxt'; |
|
| 163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 164 | - //$last_exec['deltadbtxt'] = 0; |
|
| 165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 167 | - //$formats[$id] = 'vatsimtxt'; |
|
| 168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 169 | - //$last_exec['vatsimtxt'] = 0; |
|
| 170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 172 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 174 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 177 | - //$formats[$id] = 'aircraftjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 179 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 182 | - //$formats[$id] = 'planefinderclient'; |
|
| 183 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 184 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 186 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 187 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 188 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 189 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 191 | - /* |
|
| 161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 162 | + //$formats[$id] = 'deltadbtxt'; |
|
| 163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 164 | + //$last_exec['deltadbtxt'] = 0; |
|
| 165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 167 | + //$formats[$id] = 'vatsimtxt'; |
|
| 168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 169 | + //$last_exec['vatsimtxt'] = 0; |
|
| 170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 172 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 174 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 177 | + //$formats[$id] = 'aircraftjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 179 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
| 182 | + //$formats[$id] = 'planefinderclient'; |
|
| 183 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 184 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 186 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 187 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 188 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 189 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 191 | + /* |
|
| 192 | 192 | // Disabled for now, site change source format |
| 193 | 193 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 194 | 194 | //$formats[$id] = 'radarvirtueljson'; |
@@ -200,128 +200,128 @@ discard block |
||
| 200 | 200 | exit(0); |
| 201 | 201 | } |
| 202 | 202 | */ |
| 203 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 204 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 205 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 206 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 208 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 209 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 210 | - exit(0); |
|
| 211 | - } |
|
| 212 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 213 | - //$formats[$id] = 'phpvmacars'; |
|
| 214 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 215 | - //$last_exec['phpvmacars'] = 0; |
|
| 216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 217 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 218 | - //$formats[$id] = 'phpvmacars'; |
|
| 219 | - $globalSources[$id]['format'] = 'vaos'; |
|
| 220 | - //$last_exec['phpvmacars'] = 0; |
|
| 221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 222 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 223 | - //$formats[$id] = 'phpvmacars'; |
|
| 224 | - $globalSources[$id]['format'] = 'vam'; |
|
| 225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 226 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 227 | - //$formats[$id] = 'whazzup'; |
|
| 228 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 229 | - //$last_exec['whazzup'] = 0; |
|
| 230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 231 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 232 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
| 233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 234 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 235 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 237 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 238 | - //$formats[$id] = 'pirepsjson'; |
|
| 239 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 240 | - //$last_exec['pirepsjson'] = 0; |
|
| 241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 242 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 243 | - //$formats[$id] = 'fr24json'; |
|
| 244 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 245 | - //$last_exec['fr24json'] = 0; |
|
| 246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 247 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 248 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 249 | - exit(0); |
|
| 250 | - } |
|
| 251 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 252 | - //$formats[$id] = 'fr24json'; |
|
| 253 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 254 | - //$last_exec['fr24json'] = 0; |
|
| 255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 256 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 257 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 258 | - exit(0); |
|
| 259 | - } |
|
| 260 | - //} else if (preg_match('/10001/',$host)) { |
|
| 261 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 262 | - //$formats[$id] = 'tsv'; |
|
| 263 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 265 | - } |
|
| 266 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
| 267 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 268 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 269 | - if ($idf !== false) { |
|
| 270 | - $httpfeeds[$id] = $idf; |
|
| 271 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 272 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 273 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 274 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 275 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 276 | - $hostport = explode(':',$host); |
|
| 277 | - if (isset($hostport[1])) { |
|
| 203 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 204 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 205 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 206 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 207 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 208 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 209 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 210 | + exit(0); |
|
| 211 | + } |
|
| 212 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 213 | + //$formats[$id] = 'phpvmacars'; |
|
| 214 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 215 | + //$last_exec['phpvmacars'] = 0; |
|
| 216 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 217 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 218 | + //$formats[$id] = 'phpvmacars'; |
|
| 219 | + $globalSources[$id]['format'] = 'vaos'; |
|
| 220 | + //$last_exec['phpvmacars'] = 0; |
|
| 221 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 222 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 223 | + //$formats[$id] = 'phpvmacars'; |
|
| 224 | + $globalSources[$id]['format'] = 'vam'; |
|
| 225 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 226 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 227 | + //$formats[$id] = 'whazzup'; |
|
| 228 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 229 | + //$last_exec['whazzup'] = 0; |
|
| 230 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 231 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
| 232 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
| 233 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 234 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 235 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 236 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 237 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 238 | + //$formats[$id] = 'pirepsjson'; |
|
| 239 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 240 | + //$last_exec['pirepsjson'] = 0; |
|
| 241 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 242 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 243 | + //$formats[$id] = 'fr24json'; |
|
| 244 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 245 | + //$last_exec['fr24json'] = 0; |
|
| 246 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 247 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 248 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 249 | + exit(0); |
|
| 250 | + } |
|
| 251 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 252 | + //$formats[$id] = 'fr24json'; |
|
| 253 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 254 | + //$last_exec['fr24json'] = 0; |
|
| 255 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 256 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 257 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 258 | + exit(0); |
|
| 259 | + } |
|
| 260 | + //} else if (preg_match('/10001/',$host)) { |
|
| 261 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 262 | + //$formats[$id] = 'tsv'; |
|
| 263 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 264 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 265 | + } |
|
| 266 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
| 267 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 268 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 269 | + if ($idf !== false) { |
|
| 270 | + $httpfeeds[$id] = $idf; |
|
| 271 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 272 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 273 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 274 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 275 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 276 | + $hostport = explode(':',$host); |
|
| 277 | + if (isset($hostport[1])) { |
|
| 278 | 278 | $port = $hostport[1]; |
| 279 | 279 | $hostn = $hostport[0]; |
| 280 | - } else { |
|
| 280 | + } else { |
|
| 281 | 281 | $port = $globalSources[$id]['port']; |
| 282 | 282 | $hostn = $globalSources[$id]['host']; |
| 283 | - } |
|
| 284 | - $Common = new Common(); |
|
| 285 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 286 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 287 | - } else { |
|
| 288 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 289 | - } |
|
| 290 | - if ($s) { |
|
| 291 | - $sockets[$id] = $s; |
|
| 292 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 293 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 283 | + } |
|
| 284 | + $Common = new Common(); |
|
| 285 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 286 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 287 | + } else { |
|
| 288 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 289 | + } |
|
| 290 | + if ($s) { |
|
| 291 | + $sockets[$id] = $s; |
|
| 292 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 293 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 294 | 294 | //$formats[$id] = 'aprs'; |
| 295 | 295 | $globalSources[$id]['format'] = 'aprs'; |
| 296 | 296 | //$aprs_connect = 0; |
| 297 | 297 | //$use_aprs = true; |
| 298 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 298 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 299 | 299 | $globalSources[$id]['format'] = 'vrstcp'; |
| 300 | - } elseif ($port == '10001') { |
|
| 301 | - //$formats[$id] = 'tsv'; |
|
| 302 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 303 | - } elseif ($port == '30002') { |
|
| 304 | - //$formats[$id] = 'raw'; |
|
| 305 | - $globalSources[$id]['format'] = 'raw'; |
|
| 306 | - } elseif ($port == '5001') { |
|
| 307 | - //$formats[$id] = 'raw'; |
|
| 308 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 309 | - } elseif ($port == '30005') { |
|
| 300 | + } elseif ($port == '10001') { |
|
| 301 | + //$formats[$id] = 'tsv'; |
|
| 302 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 303 | + } elseif ($port == '30002') { |
|
| 304 | + //$formats[$id] = 'raw'; |
|
| 305 | + $globalSources[$id]['format'] = 'raw'; |
|
| 306 | + } elseif ($port == '5001') { |
|
| 307 | + //$formats[$id] = 'raw'; |
|
| 308 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 309 | + } elseif ($port == '30005') { |
|
| 310 | 310 | // Not yet supported |
| 311 | - //$formats[$id] = 'beast'; |
|
| 312 | - $globalSources[$id]['format'] = 'beast'; |
|
| 313 | - //} else $formats[$id] = 'sbs'; |
|
| 314 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 315 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 311 | + //$formats[$id] = 'beast'; |
|
| 312 | + $globalSources[$id]['format'] = 'beast'; |
|
| 313 | + //} else $formats[$id] = 'sbs'; |
|
| 314 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 315 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 316 | 316 | } |
| 317 | 317 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 318 | - } else { |
|
| 318 | + } else { |
|
| 319 | 319 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 320 | 320 | sleep(10); |
| 321 | 321 | connect_all($hosts); |
| 322 | - } |
|
| 323 | - } |
|
| 324 | - } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | 325 | } |
| 326 | 326 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 327 | 327 | |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | //connect_all($globalSources); |
| 345 | 345 | |
| 346 | 346 | if (isset($globalProxy) && $globalProxy) { |
| 347 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 347 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 348 | 348 | } else { |
| 349 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 349 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // APRS Configuration |
@@ -355,21 +355,21 @@ discard block |
||
| 355 | 355 | die; |
| 356 | 356 | } |
| 357 | 357 | foreach ($globalSources as $key => $source) { |
| 358 | - if (!isset($source['format'])) { |
|
| 359 | - $globalSources[$key]['format'] = 'auto'; |
|
| 360 | - } |
|
| 361 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 362 | - unset($globalSources[$key]); |
|
| 363 | - } |
|
| 358 | + if (!isset($source['format'])) { |
|
| 359 | + $globalSources[$key]['format'] = 'auto'; |
|
| 360 | + } |
|
| 361 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 362 | + unset($globalSources[$key]); |
|
| 363 | + } |
|
| 364 | 364 | } |
| 365 | 365 | connect_all($globalSources); |
| 366 | 366 | foreach ($globalSources as $key => $source) { |
| 367 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 367 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 368 | 368 | $aprs_connect = 0; |
| 369 | 369 | $use_aprs = true; |
| 370 | 370 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 371 | 371 | break; |
| 372 | - } |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | if ($use_aprs) { |
@@ -410,133 +410,133 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 412 | 412 | while ($i > 0) { |
| 413 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 413 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 414 | 414 | |
| 415 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 416 | - // Delete old ATC |
|
| 417 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 415 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 416 | + // Delete old ATC |
|
| 417 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 418 | 418 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 419 | - $ATC->deleteOldATC(); |
|
| 420 | - } |
|
| 419 | + $ATC->deleteOldATC(); |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - if (count($last_exec) == count($globalSources)) { |
|
| 422 | + if (count($last_exec) == count($globalSources)) { |
|
| 423 | 423 | $max = $globalMinFetch; |
| 424 | 424 | foreach ($last_exec as $last) { |
| 425 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 425 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 426 | 426 | } |
| 427 | 427 | if ($max < $globalMinFetch) { |
| 428 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 429 | - sleep($globalMinFetch-$max+2); |
|
| 428 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 429 | + sleep($globalMinFetch-$max+2); |
|
| 430 | + } |
|
| 430 | 431 | } |
| 431 | - } |
|
| 432 | 432 | |
| 433 | 433 | |
| 434 | - //foreach ($formats as $id => $value) { |
|
| 435 | - foreach ($globalSources as $id => $value) { |
|
| 434 | + //foreach ($formats as $id => $value) { |
|
| 435 | + foreach ($globalSources as $id => $value) { |
|
| 436 | 436 | date_default_timezone_set('UTC'); |
| 437 | 437 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 438 | 438 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 439 | 439 | if ($value['format'] === 'deltadbtxt' && |
| 440 | - ( |
|
| 440 | + ( |
|
| 441 | 441 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 442 | 442 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 443 | - ) |
|
| 443 | + ) |
|
| 444 | 444 | ) { |
| 445 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 446 | - $buffer = $Common->getData($value['host']); |
|
| 447 | - if ($buffer != '') $reset = 0; |
|
| 448 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 449 | - $buffer = explode('\n',$buffer); |
|
| 450 | - foreach ($buffer as $line) { |
|
| 451 | - if ($line != '' && count($line) > 7) { |
|
| 452 | - $line = explode(',', $line); |
|
| 453 | - $data = array(); |
|
| 454 | - $data['hex'] = $line[1]; // hex |
|
| 455 | - $data['ident'] = $line[2]; // ident |
|
| 456 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 457 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 458 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 459 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 460 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 461 | - $data['verticalrate'] = ''; // vertical rate |
|
| 462 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 463 | - $data['emergency'] = ''; // emergency |
|
| 464 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 465 | - $data['format_source'] = 'deltadbtxt'; |
|
| 466 | - $data['id_source'] = $id_source; |
|
| 467 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 468 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 469 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 470 | - $SI->add($data); |
|
| 471 | - unset($data); |
|
| 472 | - } |
|
| 473 | - } |
|
| 474 | - $last_exec[$id]['last'] = time(); |
|
| 445 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 446 | + $buffer = $Common->getData($value['host']); |
|
| 447 | + if ($buffer != '') $reset = 0; |
|
| 448 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 449 | + $buffer = explode('\n',$buffer); |
|
| 450 | + foreach ($buffer as $line) { |
|
| 451 | + if ($line != '' && count($line) > 7) { |
|
| 452 | + $line = explode(',', $line); |
|
| 453 | + $data = array(); |
|
| 454 | + $data['hex'] = $line[1]; // hex |
|
| 455 | + $data['ident'] = $line[2]; // ident |
|
| 456 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 457 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 458 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 459 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 460 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 461 | + $data['verticalrate'] = ''; // vertical rate |
|
| 462 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 463 | + $data['emergency'] = ''; // emergency |
|
| 464 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 465 | + $data['format_source'] = 'deltadbtxt'; |
|
| 466 | + $data['id_source'] = $id_source; |
|
| 467 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 468 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 469 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 470 | + $SI->add($data); |
|
| 471 | + unset($data); |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + $last_exec[$id]['last'] = time(); |
|
| 475 | 475 | } elseif ($value['format'] === 'aisnmeatxt' && |
| 476 | - ( |
|
| 476 | + ( |
|
| 477 | 477 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 478 | 478 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 479 | - ) |
|
| 479 | + ) |
|
| 480 | 480 | ) { |
| 481 | - date_default_timezone_set('CET'); |
|
| 482 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 483 | - date_default_timezone_set('UTC'); |
|
| 484 | - if ($buffer != '') $reset = 0; |
|
| 485 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 486 | - $buffer = explode('\n',$buffer); |
|
| 487 | - foreach ($buffer as $line) { |
|
| 481 | + date_default_timezone_set('CET'); |
|
| 482 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 483 | + date_default_timezone_set('UTC'); |
|
| 484 | + if ($buffer != '') $reset = 0; |
|
| 485 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 486 | + $buffer = explode('\n',$buffer); |
|
| 487 | + foreach ($buffer as $line) { |
|
| 488 | 488 | if ($line != '') { |
| 489 | - //echo "'".$line."'\n"; |
|
| 490 | - $add = false; |
|
| 491 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 492 | - $data = array(); |
|
| 493 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 494 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 495 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 496 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 497 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 498 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 499 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 500 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 501 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 502 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 503 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 504 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 505 | - if (isset($ais_data['timestamp'])) { |
|
| 489 | + //echo "'".$line."'\n"; |
|
| 490 | + $add = false; |
|
| 491 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 492 | + $data = array(); |
|
| 493 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 494 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 495 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 496 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 497 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 498 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 499 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 500 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 501 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 502 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 503 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 504 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 505 | + if (isset($ais_data['timestamp'])) { |
|
| 506 | 506 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 507 | 507 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 508 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 509 | - $add = true; |
|
| 508 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 509 | + $add = true; |
|
| 510 | 510 | } |
| 511 | - } else { |
|
| 511 | + } else { |
|
| 512 | 512 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 513 | 513 | $add = true; |
| 514 | - } |
|
| 515 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 516 | - $data['id_source'] = $id_source; |
|
| 517 | - //print_r($data); |
|
| 518 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 519 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 520 | - unset($data); |
|
| 514 | + } |
|
| 515 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 516 | + $data['id_source'] = $id_source; |
|
| 517 | + //print_r($data); |
|
| 518 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 519 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 520 | + unset($data); |
|
| 521 | 521 | } |
| 522 | - } |
|
| 523 | - $last_exec[$id]['last'] = time(); |
|
| 522 | + } |
|
| 523 | + $last_exec[$id]['last'] = time(); |
|
| 524 | 524 | } elseif ($value['format'] === 'aisnmeahttp') { |
| 525 | - $arr = $httpfeeds; |
|
| 526 | - $w = $e = null; |
|
| 525 | + $arr = $httpfeeds; |
|
| 526 | + $w = $e = null; |
|
| 527 | 527 | |
| 528 | - if (isset($arr[$id])) { |
|
| 528 | + if (isset($arr[$id])) { |
|
| 529 | 529 | $nn = stream_select($arr,$w,$e,$timeout); |
| 530 | 530 | if ($nn > 0) { |
| 531 | - foreach ($httpfeeds as $feed) { |
|
| 531 | + foreach ($httpfeeds as $feed) { |
|
| 532 | 532 | $buffer = stream_get_line($feed,2000,"\n"); |
| 533 | 533 | if ($buffer === FALSE) { |
| 534 | - connect_all($globalSources); |
|
| 534 | + connect_all($globalSources); |
|
| 535 | 535 | } |
| 536 | 536 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 537 | 537 | $buffer = explode('\n',$buffer); |
| 538 | 538 | foreach ($buffer as $line) { |
| 539 | - if ($line != '') { |
|
| 539 | + if ($line != '') { |
|
| 540 | 540 | $ais_data = $AIS->parse_line(trim($line)); |
| 541 | 541 | $data = array(); |
| 542 | 542 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -554,117 +554,117 @@ discard block |
||
| 554 | 554 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 555 | 555 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 556 | 556 | if (isset($ais_data['timestamp'])) { |
| 557 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 557 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 558 | 558 | } else { |
| 559 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 559 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 560 | 560 | } |
| 561 | 561 | $data['format_source'] = 'aisnmeahttp'; |
| 562 | 562 | $data['id_source'] = $id_source; |
| 563 | 563 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 564 | 564 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
| 565 | 565 | unset($data); |
| 566 | - } |
|
| 566 | + } |
|
| 567 | + } |
|
| 567 | 568 | } |
| 568 | - } |
|
| 569 | 569 | } else { |
| 570 | - $format = $value['format']; |
|
| 571 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | - else $tt[$format] = 0; |
|
| 573 | - if ($tt[$format] > 30) { |
|
| 570 | + $format = $value['format']; |
|
| 571 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | + else $tt[$format] = 0; |
|
| 573 | + if ($tt[$format] > 30) { |
|
| 574 | 574 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 575 | 575 | sleep(2); |
| 576 | 576 | //$sourceeen[] = $value; |
| 577 | 577 | //connect_all($sourceeen); |
| 578 | 578 | //$sourceeen = array(); |
| 579 | 579 | connect_all($globalSources); |
| 580 | - } |
|
| 580 | + } |
|
| 581 | + } |
|
| 581 | 582 | } |
| 582 | - } |
|
| 583 | 583 | } elseif ($value['format'] === 'myshiptracking' && |
| 584 | - ( |
|
| 584 | + ( |
|
| 585 | 585 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 586 | 586 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 587 | - ) |
|
| 587 | + ) |
|
| 588 | 588 | ) { |
| 589 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 590 | - if ($buffer != '') { |
|
| 589 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 590 | + if ($buffer != '') { |
|
| 591 | 591 | //echo $buffer; |
| 592 | 592 | $all_data = json_decode($buffer,true); |
| 593 | 593 | //print_r($all_data); |
| 594 | 594 | if (isset($all_data[0]['DATA'])) { |
| 595 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 595 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 596 | 596 | if ($line != '') { |
| 597 | - $data = array(); |
|
| 598 | - $data['ident'] = $line['NAME']; |
|
| 599 | - $data['mmsi'] = $line['MMSI']; |
|
| 600 | - if (strlen($data['mmsi']) > 9) { |
|
| 597 | + $data = array(); |
|
| 598 | + $data['ident'] = $line['NAME']; |
|
| 599 | + $data['mmsi'] = $line['MMSI']; |
|
| 600 | + if (strlen($data['mmsi']) > 9) { |
|
| 601 | 601 | $data['mmsi'] = substr($data['mmsi'],-9); |
| 602 | - } |
|
| 603 | - $data['speed'] = $line['SOG']; |
|
| 604 | - $data['heading'] = $line['COG']; |
|
| 605 | - $data['latitude'] = $line['LAT']; |
|
| 606 | - $data['longitude'] = $line['LNG']; |
|
| 607 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 608 | - //$data['type_id'] = $line['TYPE']; |
|
| 609 | - $data['imo'] = $line['IMO']; |
|
| 610 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 611 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 612 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 613 | - $data['format_source'] = 'myshiptracking'; |
|
| 614 | - $data['id_source'] = $id_source; |
|
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 616 | - $MI->add($data); |
|
| 617 | - unset($data); |
|
| 602 | + } |
|
| 603 | + $data['speed'] = $line['SOG']; |
|
| 604 | + $data['heading'] = $line['COG']; |
|
| 605 | + $data['latitude'] = $line['LAT']; |
|
| 606 | + $data['longitude'] = $line['LNG']; |
|
| 607 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 608 | + //$data['type_id'] = $line['TYPE']; |
|
| 609 | + $data['imo'] = $line['IMO']; |
|
| 610 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 611 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 612 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 613 | + $data['format_source'] = 'myshiptracking'; |
|
| 614 | + $data['id_source'] = $id_source; |
|
| 615 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 616 | + $MI->add($data); |
|
| 617 | + unset($data); |
|
| 618 | + } |
|
| 618 | 619 | } |
| 619 | - } |
|
| 620 | 620 | } |
| 621 | - } |
|
| 622 | - $last_exec[$id]['last'] = time(); |
|
| 621 | + } |
|
| 622 | + $last_exec[$id]['last'] = time(); |
|
| 623 | 623 | } elseif ($value['format'] === 'boatbeaconapp' && |
| 624 | - ( |
|
| 624 | + ( |
|
| 625 | 625 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 626 | 626 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 627 | - ) |
|
| 627 | + ) |
|
| 628 | 628 | ) { |
| 629 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 630 | - if ($buffer != '') { |
|
| 629 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 630 | + if ($buffer != '') { |
|
| 631 | 631 | $all_data = json_decode($buffer,true); |
| 632 | 632 | if (isset($all_data[0]['mmsi'])) { |
| 633 | - foreach ($all_data as $line) { |
|
| 633 | + foreach ($all_data as $line) { |
|
| 634 | 634 | if ($line != '') { |
| 635 | - $data = array(); |
|
| 636 | - $data['ident'] = $line['shipname']; |
|
| 637 | - $data['callsign'] = $line['callsign']; |
|
| 638 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 639 | - $data['speed'] = $line['sog']; |
|
| 640 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 641 | - $data['latitude'] = $line['latitude']; |
|
| 642 | - $data['longitude'] = $line['longitude']; |
|
| 643 | - $data['type_id'] = $line['shiptype']; |
|
| 644 | - $data['arrival_code'] = $line['destination']; |
|
| 645 | - $data['datetime'] = $line['time']; |
|
| 646 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 647 | - $data['id_source'] = $id_source; |
|
| 648 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 649 | - $MI->add($data); |
|
| 650 | - unset($data); |
|
| 635 | + $data = array(); |
|
| 636 | + $data['ident'] = $line['shipname']; |
|
| 637 | + $data['callsign'] = $line['callsign']; |
|
| 638 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 639 | + $data['speed'] = $line['sog']; |
|
| 640 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 641 | + $data['latitude'] = $line['latitude']; |
|
| 642 | + $data['longitude'] = $line['longitude']; |
|
| 643 | + $data['type_id'] = $line['shiptype']; |
|
| 644 | + $data['arrival_code'] = $line['destination']; |
|
| 645 | + $data['datetime'] = $line['time']; |
|
| 646 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 647 | + $data['id_source'] = $id_source; |
|
| 648 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 649 | + $MI->add($data); |
|
| 650 | + unset($data); |
|
| 651 | + } |
|
| 651 | 652 | } |
| 652 | - } |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - } |
|
| 656 | - $last_exec[$id]['last'] = time(); |
|
| 655 | + } |
|
| 656 | + $last_exec[$id]['last'] = time(); |
|
| 657 | 657 | } elseif ($value['format'] === 'boatnerd' && |
| 658 | - ( |
|
| 658 | + ( |
|
| 659 | 659 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 660 | 660 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 661 | - ) |
|
| 661 | + ) |
|
| 662 | 662 | ) { |
| 663 | - $buffer = $Common->getData($value['host']); |
|
| 664 | - if ($buffer != '') { |
|
| 663 | + $buffer = $Common->getData($value['host']); |
|
| 664 | + if ($buffer != '') { |
|
| 665 | 665 | $all_data = json_decode($buffer,true); |
| 666 | 666 | if (isset($all_data['features'][0]['id'])) { |
| 667 | - foreach ($all_data['features'] as $line) { |
|
| 667 | + foreach ($all_data['features'] as $line) { |
|
| 668 | 668 | print_r($line); |
| 669 | 669 | $data = array(); |
| 670 | 670 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -684,66 +684,66 @@ discard block |
||
| 684 | 684 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 685 | 685 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 686 | 686 | unset($data); |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - } |
|
| 691 | - $last_exec[$id]['last'] = time(); |
|
| 690 | + } |
|
| 691 | + $last_exec[$id]['last'] = time(); |
|
| 692 | 692 | } elseif ($value['format'] === 'shipplotter' && |
| 693 | - ( |
|
| 693 | + ( |
|
| 694 | 694 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 695 | 695 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 696 | - ) |
|
| 696 | + ) |
|
| 697 | 697 | ) { |
| 698 | - if ($globalDebug) echo 'download...'; |
|
| 699 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 700 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 701 | - // FIXME: Need more work |
|
| 702 | - if ($buffer != '') $reset = 0; |
|
| 703 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 704 | - $buffer = explode('\n',$buffer); |
|
| 705 | - foreach ($buffer as $line) { |
|
| 698 | + if ($globalDebug) echo 'download...'; |
|
| 699 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 700 | + if ($globalDebug) echo 'done !'."\n"; |
|
| 701 | + // FIXME: Need more work |
|
| 702 | + if ($buffer != '') $reset = 0; |
|
| 703 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 704 | + $buffer = explode('\n',$buffer); |
|
| 705 | + foreach ($buffer as $line) { |
|
| 706 | 706 | if ($line != '') { |
| 707 | - $data = array(); |
|
| 708 | - //echo $line."\n"; |
|
| 709 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 710 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 711 | - $data['status_id'] = substr($line,21,2); |
|
| 712 | - $data['type_id'] = substr($line,24,3); |
|
| 713 | - $data['latitude'] = substr($line,29,9); |
|
| 714 | - $data['longitude'] = substr($line,41,9); |
|
| 715 | - $data['speed'] = round(substr($line,51,5)); |
|
| 716 | - //$data['course'] = substr($line,57,5); |
|
| 717 | - $data['heading'] = round(substr($line,63,3)); |
|
| 718 | - //$data['draft'] = substr($line,67,4); |
|
| 719 | - //$data['length'] = substr($line,72,3); |
|
| 720 | - //$data['beam'] = substr($line,76,2); |
|
| 721 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 722 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 723 | - $data['arrival_code'] = substr($line,108,20); |
|
| 724 | - //$data['etaDate'] = substr($line,129,5); |
|
| 725 | - //$data['etaTime'] = substr($line,135,5); |
|
| 726 | - $data['format_source'] = 'shipplotter'; |
|
| 727 | - $data['id_source'] = $id_source; |
|
| 728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 729 | - //print_r($data); |
|
| 730 | - //echo 'Add...'."\n"; |
|
| 731 | - $MI->add($data); |
|
| 732 | - unset($data); |
|
| 707 | + $data = array(); |
|
| 708 | + //echo $line."\n"; |
|
| 709 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 710 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 711 | + $data['status_id'] = substr($line,21,2); |
|
| 712 | + $data['type_id'] = substr($line,24,3); |
|
| 713 | + $data['latitude'] = substr($line,29,9); |
|
| 714 | + $data['longitude'] = substr($line,41,9); |
|
| 715 | + $data['speed'] = round(substr($line,51,5)); |
|
| 716 | + //$data['course'] = substr($line,57,5); |
|
| 717 | + $data['heading'] = round(substr($line,63,3)); |
|
| 718 | + //$data['draft'] = substr($line,67,4); |
|
| 719 | + //$data['length'] = substr($line,72,3); |
|
| 720 | + //$data['beam'] = substr($line,76,2); |
|
| 721 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 722 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 723 | + $data['arrival_code'] = substr($line,108,20); |
|
| 724 | + //$data['etaDate'] = substr($line,129,5); |
|
| 725 | + //$data['etaTime'] = substr($line,135,5); |
|
| 726 | + $data['format_source'] = 'shipplotter'; |
|
| 727 | + $data['id_source'] = $id_source; |
|
| 728 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 729 | + //print_r($data); |
|
| 730 | + //echo 'Add...'."\n"; |
|
| 731 | + $MI->add($data); |
|
| 732 | + unset($data); |
|
| 733 | 733 | } |
| 734 | - } |
|
| 735 | - $last_exec[$id]['last'] = time(); |
|
| 734 | + } |
|
| 735 | + $last_exec[$id]['last'] = time(); |
|
| 736 | 736 | } elseif ($value['format'] === 'sailaway' && |
| 737 | - ( |
|
| 737 | + ( |
|
| 738 | 738 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 739 | 739 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 740 | - ) |
|
| 740 | + ) |
|
| 741 | 741 | ) { |
| 742 | - if ($globalDebug) echo 'download...'; |
|
| 743 | - for ($i =0; $i <= 1; $i++) { |
|
| 744 | - $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
|
| 745 | - if ($globalDebug) echo 'done'."\n"; |
|
| 746 | - if ($buffer != '') { |
|
| 742 | + if ($globalDebug) echo 'download...'; |
|
| 743 | + for ($i =0; $i <= 1; $i++) { |
|
| 744 | + $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
|
| 745 | + if ($globalDebug) echo 'done'."\n"; |
|
| 746 | + if ($buffer != '') { |
|
| 747 | 747 | $all_data = json_decode($buffer,true); |
| 748 | 748 | if (isset($all_data['missions'])) { |
| 749 | 749 | foreach ($all_data['missions'] as $mission) { |
@@ -791,34 +791,34 @@ discard block |
||
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | - } |
|
| 795 | - } |
|
| 796 | - $last_exec[$id]['last'] = time(); |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + $last_exec[$id]['last'] = time(); |
|
| 797 | 797 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 798 | 798 | } elseif ( |
| 799 | - ( |
|
| 799 | + ( |
|
| 800 | 800 | $value['format'] === 'whazzup' && |
| 801 | 801 | ( |
| 802 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 803 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 802 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 803 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 804 | 804 | ) |
| 805 | - ) || ( |
|
| 805 | + ) || ( |
|
| 806 | 806 | $value['format'] === 'vatsimtxt' && |
| 807 | 807 | ( |
| 808 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 809 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 808 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 809 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 810 | + ) |
|
| 810 | 811 | ) |
| 811 | - ) |
|
| 812 | 812 | ) { |
| 813 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 814 | - $buffer = $Common->getData($value['host']); |
|
| 815 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 816 | - $buffer = explode('\n',$buffer); |
|
| 817 | - $reset = 0; |
|
| 818 | - foreach ($buffer as $line) { |
|
| 819 | - if ($line != '') { |
|
| 820 | - $line = explode(':', $line); |
|
| 821 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 813 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 814 | + $buffer = $Common->getData($value['host']); |
|
| 815 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 816 | + $buffer = explode('\n',$buffer); |
|
| 817 | + $reset = 0; |
|
| 818 | + foreach ($buffer as $line) { |
|
| 819 | + if ($line != '') { |
|
| 820 | + $line = explode(':', $line); |
|
| 821 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 822 | 822 | $data = array(); |
| 823 | 823 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 824 | 824 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -831,37 +831,37 @@ discard block |
||
| 831 | 831 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 832 | 832 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 833 | 833 | $data['latitude'] = $line[5]; // lat |
| 834 | - $data['longitude'] = $line[6]; // long |
|
| 835 | - $data['verticalrate'] = ''; // vertical rate |
|
| 836 | - $data['squawk'] = ''; // squawk |
|
| 837 | - $data['emergency'] = ''; // emergency |
|
| 838 | - $data['waypoints'] = $line[30]; |
|
| 834 | + $data['longitude'] = $line[6]; // long |
|
| 835 | + $data['verticalrate'] = ''; // vertical rate |
|
| 836 | + $data['squawk'] = ''; // squawk |
|
| 837 | + $data['emergency'] = ''; // emergency |
|
| 838 | + $data['waypoints'] = $line[30]; |
|
| 839 | 839 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 840 | 840 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 841 | 841 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 842 | - $data['departure_airport_icao'] = $line[11]; |
|
| 843 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 844 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 842 | + $data['departure_airport_icao'] = $line[11]; |
|
| 843 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 844 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 845 | 845 | $data['frequency'] = $line[4]; |
| 846 | 846 | $data['type'] = $line[18]; |
| 847 | 847 | $data['range'] = $line[19]; |
| 848 | 848 | if (isset($line[35])) $data['info'] = $line[35]; |
| 849 | - $data['id_source'] = $id_source; |
|
| 850 | - //$data['arrival_airport_time'] = ; |
|
| 851 | - if ($line[9] != '') { |
|
| 852 | - $aircraft_data = explode('/',$line[9]); |
|
| 853 | - if (isset($aircraft_data[1])) { |
|
| 854 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 855 | - } |
|
| 856 | - } |
|
| 857 | - /* |
|
| 849 | + $data['id_source'] = $id_source; |
|
| 850 | + //$data['arrival_airport_time'] = ; |
|
| 851 | + if ($line[9] != '') { |
|
| 852 | + $aircraft_data = explode('/',$line[9]); |
|
| 853 | + if (isset($aircraft_data[1])) { |
|
| 854 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | + /* |
|
| 858 | 858 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
| 859 | 859 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 860 | 860 | */ |
| 861 | - $data['format_source'] = $value['format']; |
|
| 861 | + $data['format_source'] = $value['format']; |
|
| 862 | 862 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 863 | 863 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 864 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 864 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
| 865 | 865 | elseif ($line[3] === 'ATC') { |
| 866 | 866 | //print_r($data); |
| 867 | 867 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -882,21 +882,21 @@ discard block |
||
| 882 | 882 | 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']); |
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | - unset($data); |
|
| 886 | - } |
|
| 887 | - } |
|
| 888 | - } |
|
| 889 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 890 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 891 | - $last_exec[$id]['last'] = time(); |
|
| 892 | - } elseif ($value['format'] === 'airwhere' && |
|
| 893 | - ( |
|
| 894 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 895 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 896 | - ) |
|
| 897 | - ) { |
|
| 898 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 899 | - if ($buffer != '') { |
|
| 885 | + unset($data); |
|
| 886 | + } |
|
| 887 | + } |
|
| 888 | + } |
|
| 889 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 890 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 891 | + $last_exec[$id]['last'] = time(); |
|
| 892 | + } elseif ($value['format'] === 'airwhere' && |
|
| 893 | + ( |
|
| 894 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 895 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 896 | + ) |
|
| 897 | + ) { |
|
| 898 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 899 | + if ($buffer != '') { |
|
| 900 | 900 | $all_data = simplexml_load_string($buffer); |
| 901 | 901 | foreach($all_data->children() as $childdata) { |
| 902 | 902 | $data = array(); |
@@ -918,10 +918,10 @@ discard block |
||
| 918 | 918 | $SI->add($data); |
| 919 | 919 | unset($data); |
| 920 | 920 | } |
| 921 | - } |
|
| 922 | - $Source->deleteOldLocationByType('gs'); |
|
| 923 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 924 | - if ($buffer != '') { |
|
| 921 | + } |
|
| 922 | + $Source->deleteOldLocationByType('gs'); |
|
| 923 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 924 | + if ($buffer != '') { |
|
| 925 | 925 | $all_data = simplexml_load_string($buffer); |
| 926 | 926 | foreach($all_data->children() as $childdata) { |
| 927 | 927 | $data = array(); |
@@ -939,8 +939,8 @@ discard block |
||
| 939 | 939 | } |
| 940 | 940 | unset($data); |
| 941 | 941 | } |
| 942 | - } |
|
| 943 | - $last_exec[$id]['last'] = time(); |
|
| 942 | + } |
|
| 943 | + $last_exec[$id]['last'] = time(); |
|
| 944 | 944 | /* |
| 945 | 945 | } if ($value['format'] === 'aircraftlistjson') { |
| 946 | 946 | print_r($globalSources); |
@@ -948,17 +948,17 @@ discard block |
||
| 948 | 948 | echo $globalMinFetch; |
| 949 | 949 | */ |
| 950 | 950 | } elseif ($value['format'] === 'aircraftlistjson' && |
| 951 | - ( |
|
| 951 | + ( |
|
| 952 | 952 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 953 | 953 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 954 | - ) |
|
| 954 | + ) |
|
| 955 | 955 | ) { |
| 956 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 957 | - if ($buffer != '') { |
|
| 958 | - $all_data = json_decode($buffer,true); |
|
| 956 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 957 | + if ($buffer != '') { |
|
| 958 | + $all_data = json_decode($buffer,true); |
|
| 959 | 959 | if (isset($all_data['acList'])) { |
| 960 | - $reset = 0; |
|
| 961 | - foreach ($all_data['acList'] as $line) { |
|
| 960 | + $reset = 0; |
|
| 961 | + foreach ($all_data['acList'] as $line) { |
|
| 962 | 962 | $data = array(); |
| 963 | 963 | $data['hex'] = $line['Icao']; // hex |
| 964 | 964 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -981,10 +981,10 @@ discard block |
||
| 981 | 981 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 982 | 982 | if (isset($data['latitude'])) $SI->add($data); |
| 983 | 983 | unset($data); |
| 984 | - } |
|
| 984 | + } |
|
| 985 | 985 | } elseif (is_array($all_data)) { |
| 986 | - $reset = 0; |
|
| 987 | - foreach ($all_data as $line) { |
|
| 986 | + $reset = 0; |
|
| 987 | + foreach ($all_data as $line) { |
|
| 988 | 988 | $data = array(); |
| 989 | 989 | $data['hex'] = $line['hex']; // hex |
| 990 | 990 | $data['ident'] = $line['flight']; // ident |
@@ -1004,291 +1004,291 @@ discard block |
||
| 1004 | 1004 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1005 | 1005 | $SI->add($data); |
| 1006 | 1006 | unset($data); |
| 1007 | - } |
|
| 1007 | + } |
|
| 1008 | 1008 | } |
| 1009 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1010 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 1011 | - $last_exec[$id]['last'] = time(); |
|
| 1012 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1013 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1014 | - ( |
|
| 1015 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1016 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1017 | - ) |
|
| 1018 | - ) { |
|
| 1019 | - $buffer = $Common->getData($value['host']); |
|
| 1020 | - $all_data = json_decode($buffer,true); |
|
| 1021 | - if (isset($all_data['planes'])) { |
|
| 1009 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1010 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 1011 | + $last_exec[$id]['last'] = time(); |
|
| 1012 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1013 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1014 | + ( |
|
| 1015 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1016 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1017 | + ) |
|
| 1018 | + ) { |
|
| 1019 | + $buffer = $Common->getData($value['host']); |
|
| 1020 | + $all_data = json_decode($buffer,true); |
|
| 1021 | + if (isset($all_data['planes'])) { |
|
| 1022 | 1022 | $reset = 0; |
| 1023 | 1023 | foreach ($all_data['planes'] as $key => $line) { |
| 1024 | - $data = array(); |
|
| 1025 | - $data['hex'] = $key; // hex |
|
| 1026 | - $data['ident'] = $line[3]; // ident |
|
| 1027 | - $data['altitude'] = $line[6]; // altitude |
|
| 1028 | - $data['speed'] = $line[8]; // speed |
|
| 1029 | - $data['heading'] = $line[7]; // heading |
|
| 1030 | - $data['latitude'] = $line[4]; // lat |
|
| 1031 | - $data['longitude'] = $line[5]; // long |
|
| 1032 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1033 | - $data['squawk'] = $line[10]; // squawk |
|
| 1034 | - $data['emergency'] = ''; // emergency |
|
| 1035 | - $data['registration'] = $line[2]; |
|
| 1036 | - $data['aircraft_icao'] = $line[0]; |
|
| 1037 | - $deparr = explode('-',$line[1]); |
|
| 1038 | - if (count($deparr) === 2) { |
|
| 1024 | + $data = array(); |
|
| 1025 | + $data['hex'] = $key; // hex |
|
| 1026 | + $data['ident'] = $line[3]; // ident |
|
| 1027 | + $data['altitude'] = $line[6]; // altitude |
|
| 1028 | + $data['speed'] = $line[8]; // speed |
|
| 1029 | + $data['heading'] = $line[7]; // heading |
|
| 1030 | + $data['latitude'] = $line[4]; // lat |
|
| 1031 | + $data['longitude'] = $line[5]; // long |
|
| 1032 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1033 | + $data['squawk'] = $line[10]; // squawk |
|
| 1034 | + $data['emergency'] = ''; // emergency |
|
| 1035 | + $data['registration'] = $line[2]; |
|
| 1036 | + $data['aircraft_icao'] = $line[0]; |
|
| 1037 | + $deparr = explode('-',$line[1]); |
|
| 1038 | + if (count($deparr) === 2) { |
|
| 1039 | 1039 | $data['departure_airport_icao'] = $deparr[0]; |
| 1040 | 1040 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1041 | - } |
|
| 1042 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1043 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 1044 | - $data['id_source'] = $id_source; |
|
| 1045 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1046 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1047 | - $SI->add($data); |
|
| 1048 | - unset($data); |
|
| 1041 | + } |
|
| 1042 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1043 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 1044 | + $data['id_source'] = $id_source; |
|
| 1045 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1046 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1047 | + $SI->add($data); |
|
| 1048 | + unset($data); |
|
| 1049 | 1049 | } |
| 1050 | - } |
|
| 1051 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1052 | - $last_exec[$id]['last'] = time(); |
|
| 1050 | + } |
|
| 1051 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1052 | + $last_exec[$id]['last'] = time(); |
|
| 1053 | 1053 | } elseif ($value['format'] === 'opensky' && |
| 1054 | - ( |
|
| 1054 | + ( |
|
| 1055 | 1055 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1056 | 1056 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1057 | - ) |
|
| 1057 | + ) |
|
| 1058 | 1058 | ) { |
| 1059 | - $buffer = $Common->getData($value['host']); |
|
| 1060 | - $all_data = json_decode($buffer,true); |
|
| 1061 | - if (isset($all_data['states'])) { |
|
| 1059 | + $buffer = $Common->getData($value['host']); |
|
| 1060 | + $all_data = json_decode($buffer,true); |
|
| 1061 | + if (isset($all_data['states'])) { |
|
| 1062 | 1062 | $reset = 0; |
| 1063 | 1063 | foreach ($all_data['states'] as $key => $line) { |
| 1064 | - $data = array(); |
|
| 1065 | - $data['hex'] = $line[0]; // hex |
|
| 1066 | - $data['ident'] = trim($line[1]); // ident |
|
| 1067 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1068 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1069 | - $data['heading'] = round($line[10]); // heading |
|
| 1070 | - $data['latitude'] = $line[6]; // lat |
|
| 1071 | - $data['longitude'] = $line[5]; // long |
|
| 1072 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1073 | - //$data['squawk'] = $line[10]; // squawk |
|
| 1074 | - //$data['emergency'] = ''; // emergency |
|
| 1075 | - //$data['registration'] = $line[2]; |
|
| 1076 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1077 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1078 | - $data['format_source'] = 'opensky'; |
|
| 1079 | - $data['id_source'] = $id_source; |
|
| 1080 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1081 | - $SI->add($data); |
|
| 1082 | - unset($data); |
|
| 1064 | + $data = array(); |
|
| 1065 | + $data['hex'] = $line[0]; // hex |
|
| 1066 | + $data['ident'] = trim($line[1]); // ident |
|
| 1067 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1068 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1069 | + $data['heading'] = round($line[10]); // heading |
|
| 1070 | + $data['latitude'] = $line[6]; // lat |
|
| 1071 | + $data['longitude'] = $line[5]; // long |
|
| 1072 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1073 | + //$data['squawk'] = $line[10]; // squawk |
|
| 1074 | + //$data['emergency'] = ''; // emergency |
|
| 1075 | + //$data['registration'] = $line[2]; |
|
| 1076 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1077 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1078 | + $data['format_source'] = 'opensky'; |
|
| 1079 | + $data['id_source'] = $id_source; |
|
| 1080 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1081 | + $SI->add($data); |
|
| 1082 | + unset($data); |
|
| 1083 | + } |
|
| 1083 | 1084 | } |
| 1084 | - } |
|
| 1085 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1086 | - $last_exec[$id]['last'] = time(); |
|
| 1085 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1086 | + $last_exec[$id]['last'] = time(); |
|
| 1087 | 1087 | } elseif ($value['format'] === 'aircraftjson' && |
| 1088 | - ( |
|
| 1088 | + ( |
|
| 1089 | 1089 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1090 | 1090 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1091 | - ) |
|
| 1091 | + ) |
|
| 1092 | 1092 | ) { |
| 1093 | - $buffer = $Common->getData($value['host']); |
|
| 1094 | - $all_data = json_decode($buffer,true); |
|
| 1095 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1093 | + $buffer = $Common->getData($value['host']); |
|
| 1094 | + $all_data = json_decode($buffer,true); |
|
| 1095 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1096 | 1096 | $reset = 0; |
| 1097 | 1097 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1098 | - $data = array(); |
|
| 1099 | - // add support for ground vehicule with ~ in front of hex |
|
| 1100 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1101 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1102 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1103 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1104 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1105 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1106 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1107 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1108 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1109 | - //$data['emergency'] = ''; // emergency |
|
| 1110 | - //$data['registration'] = $line[2]; |
|
| 1111 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1112 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1113 | - $data['format_source'] = 'aircraftjson'; |
|
| 1114 | - $data['id_source'] = $id_source; |
|
| 1115 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 1116 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1117 | - else $data['source_name'] = $value['name']; |
|
| 1118 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1119 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1120 | - $SI->add($data); |
|
| 1121 | - unset($data); |
|
| 1098 | + $data = array(); |
|
| 1099 | + // add support for ground vehicule with ~ in front of hex |
|
| 1100 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1101 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1102 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1103 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1104 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1105 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1106 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1107 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1108 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1109 | + //$data['emergency'] = ''; // emergency |
|
| 1110 | + //$data['registration'] = $line[2]; |
|
| 1111 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1112 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1113 | + $data['format_source'] = 'aircraftjson'; |
|
| 1114 | + $data['id_source'] = $id_source; |
|
| 1115 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1116 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1117 | + else $data['source_name'] = $value['name']; |
|
| 1118 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1119 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1120 | + $SI->add($data); |
|
| 1121 | + unset($data); |
|
| 1122 | 1122 | } |
| 1123 | - } |
|
| 1124 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1125 | - $last_exec[$id]['last'] = time(); |
|
| 1123 | + } |
|
| 1124 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1125 | + $last_exec[$id]['last'] = time(); |
|
| 1126 | 1126 | } elseif ($value['format'] === 'planefinderclient' && |
| 1127 | - ( |
|
| 1127 | + ( |
|
| 1128 | 1128 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1129 | 1129 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1130 | - ) |
|
| 1130 | + ) |
|
| 1131 | 1131 | ) { |
| 1132 | - $buffer = $Common->getData($value['host']); |
|
| 1133 | - $all_data = json_decode($buffer,true); |
|
| 1134 | - if (isset($all_data['aircraft'])) { |
|
| 1132 | + $buffer = $Common->getData($value['host']); |
|
| 1133 | + $all_data = json_decode($buffer,true); |
|
| 1134 | + if (isset($all_data['aircraft'])) { |
|
| 1135 | 1135 | $reset = 0; |
| 1136 | 1136 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1137 | - $data = array(); |
|
| 1138 | - $data['hex'] = $key; // hex |
|
| 1139 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1140 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1141 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1142 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1143 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1144 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1145 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1146 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1147 | - //$data['emergency'] = ''; // emergency |
|
| 1148 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1149 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1150 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1151 | - $data['format_source'] = 'planefinderclient'; |
|
| 1152 | - $data['id_source'] = $id_source; |
|
| 1153 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1154 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1155 | - $SI->add($data); |
|
| 1156 | - unset($data); |
|
| 1137 | + $data = array(); |
|
| 1138 | + $data['hex'] = $key; // hex |
|
| 1139 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1140 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1141 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1142 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1143 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1144 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1145 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1146 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1147 | + //$data['emergency'] = ''; // emergency |
|
| 1148 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1149 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1150 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1151 | + $data['format_source'] = 'planefinderclient'; |
|
| 1152 | + $data['id_source'] = $id_source; |
|
| 1153 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1154 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1155 | + $SI->add($data); |
|
| 1156 | + unset($data); |
|
| 1157 | + } |
|
| 1157 | 1158 | } |
| 1158 | - } |
|
| 1159 | - $last_exec[$id]['last'] = time(); |
|
| 1159 | + $last_exec[$id]['last'] = time(); |
|
| 1160 | 1160 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 1161 | 1161 | } elseif ($value['format'] === 'fr24json' && |
| 1162 | - ( |
|
| 1162 | + ( |
|
| 1163 | 1163 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1164 | 1164 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1165 | - ) |
|
| 1165 | + ) |
|
| 1166 | 1166 | ) { |
| 1167 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1168 | - $buffer = $Common->getData($value['host']); |
|
| 1169 | - $all_data = json_decode($buffer,true); |
|
| 1170 | - if (!empty($all_data)) $reset = 0; |
|
| 1171 | - foreach ($all_data as $key => $line) { |
|
| 1167 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1168 | + $buffer = $Common->getData($value['host']); |
|
| 1169 | + $all_data = json_decode($buffer,true); |
|
| 1170 | + if (!empty($all_data)) $reset = 0; |
|
| 1171 | + foreach ($all_data as $key => $line) { |
|
| 1172 | 1172 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1173 | - $data = array(); |
|
| 1174 | - $data['hex'] = $line[0]; |
|
| 1175 | - $data['ident'] = $line[16]; //$line[13] |
|
| 1176 | - $data['altitude'] = $line[4]; // altitude |
|
| 1177 | - $data['speed'] = $line[5]; // speed |
|
| 1178 | - $data['heading'] = $line[3]; // heading |
|
| 1179 | - $data['latitude'] = $line[1]; // lat |
|
| 1180 | - $data['longitude'] = $line[2]; // long |
|
| 1181 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1182 | - $data['squawk'] = $line[6]; // squawk |
|
| 1183 | - $data['aircraft_icao'] = $line[8]; |
|
| 1184 | - $data['registration'] = $line[9]; |
|
| 1185 | - $data['departure_airport_iata'] = $line[11]; |
|
| 1186 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 1187 | - $data['emergency'] = ''; // emergency |
|
| 1188 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1189 | - $data['format_source'] = 'fr24json'; |
|
| 1190 | - $data['id_source'] = $id_source; |
|
| 1191 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1192 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1193 | - $SI->add($data); |
|
| 1194 | - unset($data); |
|
| 1173 | + $data = array(); |
|
| 1174 | + $data['hex'] = $line[0]; |
|
| 1175 | + $data['ident'] = $line[16]; //$line[13] |
|
| 1176 | + $data['altitude'] = $line[4]; // altitude |
|
| 1177 | + $data['speed'] = $line[5]; // speed |
|
| 1178 | + $data['heading'] = $line[3]; // heading |
|
| 1179 | + $data['latitude'] = $line[1]; // lat |
|
| 1180 | + $data['longitude'] = $line[2]; // long |
|
| 1181 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1182 | + $data['squawk'] = $line[6]; // squawk |
|
| 1183 | + $data['aircraft_icao'] = $line[8]; |
|
| 1184 | + $data['registration'] = $line[9]; |
|
| 1185 | + $data['departure_airport_iata'] = $line[11]; |
|
| 1186 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 1187 | + $data['emergency'] = ''; // emergency |
|
| 1188 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1189 | + $data['format_source'] = 'fr24json'; |
|
| 1190 | + $data['id_source'] = $id_source; |
|
| 1191 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1192 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1193 | + $SI->add($data); |
|
| 1194 | + unset($data); |
|
| 1195 | 1195 | } |
| 1196 | - } |
|
| 1197 | - //$last_exec['fr24json'] = time(); |
|
| 1198 | - $last_exec[$id]['last'] = time(); |
|
| 1196 | + } |
|
| 1197 | + //$last_exec['fr24json'] = time(); |
|
| 1198 | + $last_exec[$id]['last'] = time(); |
|
| 1199 | 1199 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1200 | 1200 | } elseif ($value['format'] === 'radarvirtueljson' && |
| 1201 | - ( |
|
| 1201 | + ( |
|
| 1202 | 1202 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1203 | 1203 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1204 | - ) |
|
| 1204 | + ) |
|
| 1205 | 1205 | ) { |
| 1206 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1207 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1208 | - //echo $buffer; |
|
| 1209 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1210 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1211 | - $all_data = json_decode($buffer,true); |
|
| 1212 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1206 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1207 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1208 | + //echo $buffer; |
|
| 1209 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1210 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1211 | + $all_data = json_decode($buffer,true); |
|
| 1212 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1213 | 1213 | die(json_last_error_msg()); |
| 1214 | - } |
|
| 1215 | - if (isset($all_data['mrkrs'])) { |
|
| 1214 | + } |
|
| 1215 | + if (isset($all_data['mrkrs'])) { |
|
| 1216 | 1216 | $reset = 0; |
| 1217 | 1217 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1218 | - if (isset($line['inf'])) { |
|
| 1218 | + if (isset($line['inf'])) { |
|
| 1219 | 1219 | $data = array(); |
| 1220 | 1220 | $data['hex'] = $line['inf']['ia']; |
| 1221 | 1221 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1222 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1223 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1224 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1225 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1226 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1227 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1228 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1229 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1230 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1222 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1223 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1224 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1225 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1226 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1227 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1228 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1229 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1230 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1231 | 1231 | //$data['departure_airport_iata'] = $line[11]; |
| 1232 | 1232 | //$data['arrival_airport_iata'] = $line[12]; |
| 1233 | - //$data['emergency'] = ''; // emergency |
|
| 1233 | + //$data['emergency'] = ''; // emergency |
|
| 1234 | 1234 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1235 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1236 | - $data['id_source'] = $id_source; |
|
| 1235 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1236 | + $data['id_source'] = $id_source; |
|
| 1237 | 1237 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1238 | 1238 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1239 | 1239 | $SI->add($data); |
| 1240 | 1240 | unset($data); |
| 1241 | - } |
|
| 1241 | + } |
|
| 1242 | + } |
|
| 1242 | 1243 | } |
| 1243 | - } |
|
| 1244 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1245 | - $last_exec[$id]['last'] = time(); |
|
| 1244 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1245 | + $last_exec[$id]['last'] = time(); |
|
| 1246 | 1246 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1247 | 1247 | } elseif ($value['format'] === 'pirepsjson' && |
| 1248 | - ( |
|
| 1248 | + ( |
|
| 1249 | 1249 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1250 | 1250 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1251 | - ) |
|
| 1251 | + ) |
|
| 1252 | 1252 | ) { |
| 1253 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1254 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1255 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1253 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1254 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1255 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1256 | 1256 | |
| 1257 | - if (isset($all_data['pireps'])) { |
|
| 1257 | + if (isset($all_data['pireps'])) { |
|
| 1258 | 1258 | $reset = 0; |
| 1259 | - foreach ($all_data['pireps'] as $line) { |
|
| 1260 | - $data = array(); |
|
| 1261 | - $data['id'] = $line['id']; |
|
| 1262 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1263 | - $data['ident'] = $line['callsign']; // ident |
|
| 1264 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1265 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1266 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1267 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1268 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1269 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1270 | - $data['latitude'] = $line['lat']; // lat |
|
| 1271 | - $data['longitude'] = $line['lon']; // long |
|
| 1272 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1273 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1274 | - //$data['emergency'] = ''; // emergency |
|
| 1275 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1276 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1277 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1278 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1279 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1280 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1281 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1282 | - else $data['info'] = ''; |
|
| 1283 | - $data['format_source'] = 'pireps'; |
|
| 1284 | - $data['id_source'] = $id_source; |
|
| 1285 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1286 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1287 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1288 | - if ($line['icon'] === 'plane') { |
|
| 1259 | + foreach ($all_data['pireps'] as $line) { |
|
| 1260 | + $data = array(); |
|
| 1261 | + $data['id'] = $line['id']; |
|
| 1262 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1263 | + $data['ident'] = $line['callsign']; // ident |
|
| 1264 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1265 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1266 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1267 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1268 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1269 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1270 | + $data['latitude'] = $line['lat']; // lat |
|
| 1271 | + $data['longitude'] = $line['lon']; // long |
|
| 1272 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1273 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1274 | + //$data['emergency'] = ''; // emergency |
|
| 1275 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1276 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1277 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1278 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1279 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1280 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1281 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1282 | + else $data['info'] = ''; |
|
| 1283 | + $data['format_source'] = 'pireps'; |
|
| 1284 | + $data['id_source'] = $id_source; |
|
| 1285 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1286 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1287 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1288 | + if ($line['icon'] === 'plane') { |
|
| 1289 | 1289 | $SI->add($data); |
| 1290 | - // print_r($data); |
|
| 1291 | - } elseif ($line['icon'] === 'ct') { |
|
| 1290 | + // print_r($data); |
|
| 1291 | + } elseif ($line['icon'] === 'ct') { |
|
| 1292 | 1292 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1293 | 1293 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1294 | 1294 | $typec = substr($data['ident'],-3); |
@@ -1303,209 +1303,209 @@ discard block |
||
| 1303 | 1303 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1304 | 1304 | else $data['type'] = 'Observer'; |
| 1305 | 1305 | 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']); |
| 1306 | - } |
|
| 1307 | - unset($data); |
|
| 1306 | + } |
|
| 1307 | + unset($data); |
|
| 1308 | + } |
|
| 1308 | 1309 | } |
| 1309 | - } |
|
| 1310 | - //$last_exec['pirepsjson'] = time(); |
|
| 1311 | - $last_exec[$id]['last'] = time(); |
|
| 1310 | + //$last_exec['pirepsjson'] = time(); |
|
| 1311 | + $last_exec[$id]['last'] = time(); |
|
| 1312 | 1312 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1313 | 1313 | } elseif ($value['format'] === 'phpvmacars' && |
| 1314 | - ( |
|
| 1314 | + ( |
|
| 1315 | 1315 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1316 | 1316 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1317 | - ) |
|
| 1317 | + ) |
|
| 1318 | 1318 | ) { |
| 1319 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1320 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1321 | - $buffer = $Common->getData($value['host']); |
|
| 1322 | - $all_data = json_decode($buffer,true); |
|
| 1323 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1319 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1320 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1321 | + $buffer = $Common->getData($value['host']); |
|
| 1322 | + $all_data = json_decode($buffer,true); |
|
| 1323 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1324 | 1324 | $reset = 0; |
| 1325 | 1325 | foreach ($all_data as $line) { |
| 1326 | - $data = array(); |
|
| 1327 | - //$data['id'] = $line['id']; // id not usable |
|
| 1328 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1329 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1330 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1331 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1332 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1333 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1334 | - $data['speed'] = $line['gs']; // speed |
|
| 1335 | - $data['heading'] = $line['heading']; // heading |
|
| 1336 | - $data['latitude'] = $line['lat']; // lat |
|
| 1337 | - $data['longitude'] = $line['lng']; // long |
|
| 1338 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1339 | - $data['squawk'] = ''; // squawk |
|
| 1340 | - $data['emergency'] = ''; // emergency |
|
| 1341 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1342 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1343 | - if (isset($value['timezone'])) { |
|
| 1344 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1345 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1346 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1347 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1348 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1349 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1350 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1351 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1352 | - if (isset($line['registration'])) { |
|
| 1353 | - $data['registration'] = $line['registration']; |
|
| 1354 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1355 | - } else $data['registration'] = $line['aircraft']; |
|
| 1356 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1357 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1358 | - if (isset($line['aircraftname'])) { |
|
| 1326 | + $data = array(); |
|
| 1327 | + //$data['id'] = $line['id']; // id not usable |
|
| 1328 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1329 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1330 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1331 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1332 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1333 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1334 | + $data['speed'] = $line['gs']; // speed |
|
| 1335 | + $data['heading'] = $line['heading']; // heading |
|
| 1336 | + $data['latitude'] = $line['lat']; // lat |
|
| 1337 | + $data['longitude'] = $line['lng']; // long |
|
| 1338 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1339 | + $data['squawk'] = ''; // squawk |
|
| 1340 | + $data['emergency'] = ''; // emergency |
|
| 1341 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1342 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1343 | + if (isset($value['timezone'])) { |
|
| 1344 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1345 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1346 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1347 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1348 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1349 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1350 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1351 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1352 | + if (isset($line['registration'])) { |
|
| 1353 | + $data['registration'] = $line['registration']; |
|
| 1354 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1355 | + } else $data['registration'] = $line['aircraft']; |
|
| 1356 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1357 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1358 | + if (isset($line['aircraftname'])) { |
|
| 1359 | 1359 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1360 | 1360 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1361 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1362 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1363 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1364 | - else { |
|
| 1365 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1366 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1367 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1368 | - } |
|
| 1369 | - } |
|
| 1370 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1371 | - $data['id_source'] = $id_source; |
|
| 1372 | - $data['format_source'] = 'phpvmacars'; |
|
| 1373 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1374 | - $SI->add($data); |
|
| 1375 | - unset($data); |
|
| 1361 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1362 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1363 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1364 | + else { |
|
| 1365 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1366 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1367 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1368 | + } |
|
| 1369 | + } |
|
| 1370 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1371 | + $data['id_source'] = $id_source; |
|
| 1372 | + $data['format_source'] = 'phpvmacars'; |
|
| 1373 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1374 | + $SI->add($data); |
|
| 1375 | + unset($data); |
|
| 1376 | 1376 | } |
| 1377 | 1377 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1378 | 1378 | unset($buffer); |
| 1379 | 1379 | unset($all_data); |
| 1380 | - } |
|
| 1381 | - //$last_exec['phpvmacars'] = time(); |
|
| 1382 | - $last_exec[$id]['last'] = time(); |
|
| 1380 | + } |
|
| 1381 | + //$last_exec['phpvmacars'] = time(); |
|
| 1382 | + $last_exec[$id]['last'] = time(); |
|
| 1383 | 1383 | } elseif ($value['format'] === 'vaos' && |
| 1384 | - ( |
|
| 1384 | + ( |
|
| 1385 | 1385 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1386 | 1386 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1387 | - ) |
|
| 1387 | + ) |
|
| 1388 | 1388 | ) { |
| 1389 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1390 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1391 | - $buffer = $Common->getData($value['host']); |
|
| 1392 | - $all_data = json_decode($buffer,true); |
|
| 1393 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1389 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1390 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1391 | + $buffer = $Common->getData($value['host']); |
|
| 1392 | + $all_data = json_decode($buffer,true); |
|
| 1393 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1394 | 1394 | $reset = 0; |
| 1395 | 1395 | foreach ($all_data['ACARSData'] as $line) { |
| 1396 | - //print_r($line); |
|
| 1397 | - $data = array(); |
|
| 1398 | - //$data['id'] = $line['id']; // id not usable |
|
| 1399 | - $data['id'] = $line['id']; |
|
| 1400 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1401 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1402 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1403 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1404 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1405 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1406 | - $data['speed'] = $line['groundspeed']; // speed |
|
| 1407 | - $data['heading'] = $line['heading']; // heading |
|
| 1408 | - $data['latitude'] = $line['lat']; // lat |
|
| 1409 | - $data['longitude'] = $line['lon']; // long |
|
| 1410 | - //$data['verticalrate'] = ''; // verticale rate |
|
| 1411 | - //$data['squawk'] = ''; // squawk |
|
| 1412 | - //$data['emergency'] = ''; // emergency |
|
| 1413 | - if (isset($value['timezone'])) { |
|
| 1414 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1415 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1416 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1417 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1396 | + //print_r($line); |
|
| 1397 | + $data = array(); |
|
| 1398 | + //$data['id'] = $line['id']; // id not usable |
|
| 1399 | + $data['id'] = $line['id']; |
|
| 1400 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1401 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1402 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1403 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1404 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1405 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1406 | + $data['speed'] = $line['groundspeed']; // speed |
|
| 1407 | + $data['heading'] = $line['heading']; // heading |
|
| 1408 | + $data['latitude'] = $line['lat']; // lat |
|
| 1409 | + $data['longitude'] = $line['lon']; // long |
|
| 1410 | + //$data['verticalrate'] = ''; // verticale rate |
|
| 1411 | + //$data['squawk'] = ''; // squawk |
|
| 1412 | + //$data['emergency'] = ''; // emergency |
|
| 1413 | + if (isset($value['timezone'])) { |
|
| 1414 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1415 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1416 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1417 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1418 | 1418 | |
| 1419 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1420 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1421 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1422 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1423 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1419 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1420 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1421 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1422 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1423 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1424 | 1424 | |
| 1425 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1426 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1427 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1425 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1426 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1427 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1428 | 1428 | |
| 1429 | - $data['id_source'] = $id_source; |
|
| 1430 | - $data['format_source'] = 'vaos'; |
|
| 1431 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1432 | - $SI->add($data); |
|
| 1433 | - unset($data); |
|
| 1429 | + $data['id_source'] = $id_source; |
|
| 1430 | + $data['format_source'] = 'vaos'; |
|
| 1431 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1432 | + $SI->add($data); |
|
| 1433 | + unset($data); |
|
| 1434 | 1434 | } |
| 1435 | 1435 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1436 | 1436 | unset($buffer); |
| 1437 | 1437 | unset($all_data); |
| 1438 | - } |
|
| 1439 | - //$last_exec['phpvmacars'] = time(); |
|
| 1440 | - $last_exec[$id]['last'] = time(); |
|
| 1438 | + } |
|
| 1439 | + //$last_exec['phpvmacars'] = time(); |
|
| 1440 | + $last_exec[$id]['last'] = time(); |
|
| 1441 | 1441 | } elseif ($value['format'] === 'vam' && |
| 1442 | - ( |
|
| 1442 | + ( |
|
| 1443 | 1443 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1444 | 1444 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1445 | - ) |
|
| 1445 | + ) |
|
| 1446 | 1446 | ) { |
| 1447 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1448 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1449 | - $buffer = $Common->getData($value['host']); |
|
| 1450 | - $all_data = json_decode($buffer,true); |
|
| 1451 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1447 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1448 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1449 | + $buffer = $Common->getData($value['host']); |
|
| 1450 | + $all_data = json_decode($buffer,true); |
|
| 1451 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1452 | 1452 | $reset = 0; |
| 1453 | 1453 | foreach ($all_data as $line) { |
| 1454 | - $data = array(); |
|
| 1455 | - //$data['id'] = $line['id']; // id not usable |
|
| 1456 | - $data['id'] = trim($line['flight_id']); |
|
| 1457 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1458 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1459 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1460 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1461 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1462 | - $data['speed'] = $line['gs']; // speed |
|
| 1463 | - $data['heading'] = $line['heading']; // heading |
|
| 1464 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1465 | - $data['longitude'] = $line['longitude']; // long |
|
| 1466 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1467 | - $data['squawk'] = ''; // squawk |
|
| 1468 | - $data['emergency'] = ''; // emergency |
|
| 1469 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1470 | - $data['last_update'] = $line['last_update']; |
|
| 1471 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1472 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1473 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1474 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1475 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1476 | - //$data['registration'] = $line['aircraft']; |
|
| 1477 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1478 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1479 | - $data['id_source'] = $id_source; |
|
| 1480 | - $data['format_source'] = 'vam'; |
|
| 1481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1482 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1483 | - $SI->add($data); |
|
| 1484 | - unset($data); |
|
| 1454 | + $data = array(); |
|
| 1455 | + //$data['id'] = $line['id']; // id not usable |
|
| 1456 | + $data['id'] = trim($line['flight_id']); |
|
| 1457 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1458 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1459 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1460 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1461 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1462 | + $data['speed'] = $line['gs']; // speed |
|
| 1463 | + $data['heading'] = $line['heading']; // heading |
|
| 1464 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1465 | + $data['longitude'] = $line['longitude']; // long |
|
| 1466 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1467 | + $data['squawk'] = ''; // squawk |
|
| 1468 | + $data['emergency'] = ''; // emergency |
|
| 1469 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1470 | + $data['last_update'] = $line['last_update']; |
|
| 1471 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1472 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1473 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1474 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1475 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1476 | + //$data['registration'] = $line['aircraft']; |
|
| 1477 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1478 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1479 | + $data['id_source'] = $id_source; |
|
| 1480 | + $data['format_source'] = 'vam'; |
|
| 1481 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1482 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1483 | + $SI->add($data); |
|
| 1484 | + unset($data); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1487 | 1487 | unset($buffer); |
| 1488 | 1488 | unset($all_data); |
| 1489 | - } |
|
| 1490 | - //$last_exec['phpvmacars'] = time(); |
|
| 1491 | - $last_exec[$id]['last'] = time(); |
|
| 1489 | + } |
|
| 1490 | + //$last_exec['phpvmacars'] = time(); |
|
| 1491 | + $last_exec[$id]['last'] = time(); |
|
| 1492 | 1492 | } elseif ($value['format'] === 'blitzortung' && |
| 1493 | - ( |
|
| 1493 | + ( |
|
| 1494 | 1494 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1495 | 1495 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1496 | - ) |
|
| 1496 | + ) |
|
| 1497 | 1497 | ) { |
| 1498 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1499 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1500 | - $buffer = $Common->getData($value['host']); |
|
| 1501 | - $all_data = json_decode($buffer,true); |
|
| 1502 | - if ($buffer != '') { |
|
| 1498 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1499 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1500 | + $buffer = $Common->getData($value['host']); |
|
| 1501 | + $all_data = json_decode($buffer,true); |
|
| 1502 | + if ($buffer != '') { |
|
| 1503 | 1503 | $Source->deleteLocationBySource('blitzortung'); |
| 1504 | 1504 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1505 | 1505 | $buffer = explode('\n',$buffer); |
| 1506 | 1506 | foreach ($buffer as $buffer_line) { |
| 1507 | - $line = json_decode($buffer_line,true); |
|
| 1508 | - if (isset($line['time'])) { |
|
| 1507 | + $line = json_decode($buffer_line,true); |
|
| 1508 | + if (isset($line['time'])) { |
|
| 1509 | 1509 | $data = array(); |
| 1510 | 1510 | $data['altitude'] = $line['alt']; // altitude |
| 1511 | 1511 | $data['latitude'] = $line['lat']; // lat |
@@ -1517,94 +1517,94 @@ discard block |
||
| 1517 | 1517 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1518 | 1518 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1519 | 1519 | unset($data); |
| 1520 | - } |
|
| 1520 | + } |
|
| 1521 | 1521 | } |
| 1522 | 1522 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1523 | 1523 | unset($buffer); |
| 1524 | - } |
|
| 1525 | - $last_exec[$id]['last'] = time(); |
|
| 1524 | + } |
|
| 1525 | + $last_exec[$id]['last'] = time(); |
|
| 1526 | 1526 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
| 1527 | 1527 | } 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') { |
| 1528 | - //$last_exec[$id]['last'] = time(); |
|
| 1529 | - //$read = array( $sockets[$id] ); |
|
| 1530 | - $read = $sockets; |
|
| 1531 | - $write = NULL; |
|
| 1532 | - $e = NULL; |
|
| 1533 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1534 | - if ($e != NULL) var_dump($e); |
|
| 1535 | - if ($n > 0) { |
|
| 1528 | + //$last_exec[$id]['last'] = time(); |
|
| 1529 | + //$read = array( $sockets[$id] ); |
|
| 1530 | + $read = $sockets; |
|
| 1531 | + $write = NULL; |
|
| 1532 | + $e = NULL; |
|
| 1533 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1534 | + if ($e != NULL) var_dump($e); |
|
| 1535 | + if ($n > 0) { |
|
| 1536 | 1536 | $reset = 0; |
| 1537 | 1537 | foreach ($read as $nb => $r) { |
| 1538 | - //$value = $formats[$nb]; |
|
| 1539 | - $format = $globalSources[$nb]['format']; |
|
| 1540 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1538 | + //$value = $formats[$nb]; |
|
| 1539 | + $format = $globalSources[$nb]['format']; |
|
| 1540 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1541 | 1541 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1542 | - } elseif ($format === 'vrstcp') { |
|
| 1542 | + } elseif ($format === 'vrstcp') { |
|
| 1543 | 1543 | $buffer = @socket_read($r, 6000); |
| 1544 | - } else { |
|
| 1544 | + } else { |
|
| 1545 | 1545 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1546 | - } |
|
| 1547 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1548 | - //echo $buffer."\n"; |
|
| 1549 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1550 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1551 | - $error = false; |
|
| 1552 | - //$SI::del(); |
|
| 1553 | - if ($buffer !== FALSE) { |
|
| 1546 | + } |
|
| 1547 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1548 | + //echo $buffer."\n"; |
|
| 1549 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1550 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1551 | + $error = false; |
|
| 1552 | + //$SI::del(); |
|
| 1553 | + if ($buffer !== FALSE) { |
|
| 1554 | 1554 | if ($format === 'vrstcp') { |
| 1555 | - $buffer = explode('},{',$buffer); |
|
| 1555 | + $buffer = explode('},{',$buffer); |
|
| 1556 | 1556 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
| 1557 | - } |
|
| 1558 | - // SBS format is CSV format |
|
| 1559 | - if ($buffer !== FALSE && $buffer !== '') { |
|
| 1557 | + } |
|
| 1558 | + // SBS format is CSV format |
|
| 1559 | + if ($buffer !== FALSE && $buffer !== '') { |
|
| 1560 | 1560 | $tt[$format] = 0; |
| 1561 | 1561 | if ($format === 'acarssbs3') { |
| 1562 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1563 | - $ACARS->add(trim($buffer)); |
|
| 1564 | - $ACARS->deleteLiveAcarsData(); |
|
| 1562 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1563 | + $ACARS->add(trim($buffer)); |
|
| 1564 | + $ACARS->deleteLiveAcarsData(); |
|
| 1565 | 1565 | } elseif ($format === 'raw') { |
| 1566 | - // AVR format |
|
| 1567 | - $data = $SBS->parse($buffer); |
|
| 1568 | - if (is_array($data)) { |
|
| 1566 | + // AVR format |
|
| 1567 | + $data = $SBS->parse($buffer); |
|
| 1568 | + if (is_array($data)) { |
|
| 1569 | 1569 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1570 | 1570 | $data['format_source'] = 'raw'; |
| 1571 | 1571 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1572 | 1572 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1573 | 1573 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1574 | 1574 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1575 | - } |
|
| 1575 | + } |
|
| 1576 | 1576 | } elseif ($format === 'ais') { |
| 1577 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1578 | - $data = array(); |
|
| 1579 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1580 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1581 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1582 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1583 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1584 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1585 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1586 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1587 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1588 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1589 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1590 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1591 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1592 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1593 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1594 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1577 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1578 | + $data = array(); |
|
| 1579 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1580 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1581 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1582 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1583 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1584 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1585 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1586 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1587 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1588 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1589 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1590 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1591 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1592 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1593 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1594 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1595 | 1595 | |
| 1596 | - if (isset($ais_data['timestamp'])) { |
|
| 1596 | + if (isset($ais_data['timestamp'])) { |
|
| 1597 | 1597 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1598 | - } else { |
|
| 1598 | + } else { |
|
| 1599 | 1599 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1600 | - } |
|
| 1601 | - $data['format_source'] = 'aisnmea'; |
|
| 1602 | - $data['id_source'] = $id_source; |
|
| 1603 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1604 | - unset($data); |
|
| 1605 | - } elseif ($format === 'flightgearsp') { |
|
| 1606 | - //echo $buffer."\n"; |
|
| 1607 | - if (strlen($buffer) > 5) { |
|
| 1600 | + } |
|
| 1601 | + $data['format_source'] = 'aisnmea'; |
|
| 1602 | + $data['id_source'] = $id_source; |
|
| 1603 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1604 | + unset($data); |
|
| 1605 | + } elseif ($format === 'flightgearsp') { |
|
| 1606 | + //echo $buffer."\n"; |
|
| 1607 | + if (strlen($buffer) > 5) { |
|
| 1608 | 1608 | $line = explode(',',$buffer); |
| 1609 | 1609 | $data = array(); |
| 1610 | 1610 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1621,38 +1621,38 @@ discard block |
||
| 1621 | 1621 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1622 | 1622 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1623 | 1623 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1624 | - } |
|
| 1625 | - } elseif ($format === 'acars') { |
|
| 1626 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1627 | - $ACARS->add(trim($buffer)); |
|
| 1628 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1629 | - $ACARS->deleteLiveAcarsData(); |
|
| 1624 | + } |
|
| 1625 | + } elseif ($format === 'acars') { |
|
| 1626 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1627 | + $ACARS->add(trim($buffer)); |
|
| 1628 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1629 | + $ACARS->deleteLiveAcarsData(); |
|
| 1630 | 1630 | } elseif ($format === 'flightgearmp') { |
| 1631 | - if (substr($buffer,0,1) != '#') { |
|
| 1631 | + if (substr($buffer,0,1) != '#') { |
|
| 1632 | 1632 | $data = array(); |
| 1633 | 1633 | //echo $buffer."\n"; |
| 1634 | 1634 | $line = explode(' ',$buffer); |
| 1635 | 1635 | if (count($line) === 11) { |
| 1636 | - $userserver = explode('@',$line[0]); |
|
| 1637 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1638 | - $data['ident'] = $userserver[0]; |
|
| 1639 | - $data['registration'] = $userserver[0]; |
|
| 1640 | - $data['latitude'] = $line[4]; |
|
| 1641 | - $data['longitude'] = $line[5]; |
|
| 1642 | - $data['altitude'] = $line[6]; |
|
| 1643 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1644 | - $aircraft_type = $line[10]; |
|
| 1645 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1646 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1647 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1648 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1636 | + $userserver = explode('@',$line[0]); |
|
| 1637 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1638 | + $data['ident'] = $userserver[0]; |
|
| 1639 | + $data['registration'] = $userserver[0]; |
|
| 1640 | + $data['latitude'] = $line[4]; |
|
| 1641 | + $data['longitude'] = $line[5]; |
|
| 1642 | + $data['altitude'] = $line[6]; |
|
| 1643 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1644 | + $aircraft_type = $line[10]; |
|
| 1645 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1646 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1647 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1648 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1649 | + } |
|
| 1649 | 1650 | } |
| 1650 | - } |
|
| 1651 | 1651 | } elseif ($format === 'beast') { |
| 1652 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1653 | - die; |
|
| 1652 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1653 | + die; |
|
| 1654 | 1654 | } elseif ($format === 'vrstcp') { |
| 1655 | - foreach($buffer as $all_data) { |
|
| 1655 | + foreach($buffer as $all_data) { |
|
| 1656 | 1656 | $line = json_decode('{'.$all_data.'}',true); |
| 1657 | 1657 | $data = array(); |
| 1658 | 1658 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1672,158 +1672,158 @@ discard block |
||
| 1672 | 1672 | */ |
| 1673 | 1673 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1674 | 1674 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1675 | - $data['format_source'] = 'vrstcp'; |
|
| 1675 | + $data['format_source'] = 'vrstcp'; |
|
| 1676 | 1676 | $data['id_source'] = $id_source; |
| 1677 | 1677 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1678 | 1678 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1679 | 1679 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1680 | 1680 | unset($data); |
| 1681 | - } |
|
| 1681 | + } |
|
| 1682 | 1682 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
| 1683 | - $line = explode("\t", $buffer); |
|
| 1684 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1683 | + $line = explode("\t", $buffer); |
|
| 1684 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1685 | 1685 | $key = $line[$k]; |
| 1686 | - $lined[$key] = $line[$k+1]; |
|
| 1687 | - } |
|
| 1688 | - if (count($lined) > 3) { |
|
| 1689 | - $data['hex'] = $lined['hexid']; |
|
| 1690 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1691 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1692 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1693 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1694 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1695 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1696 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1697 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1698 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1699 | - $data['id_source'] = $id_source; |
|
| 1700 | - $data['format_source'] = 'tsv'; |
|
| 1701 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1702 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1686 | + $lined[$key] = $line[$k+1]; |
|
| 1687 | + } |
|
| 1688 | + if (count($lined) > 3) { |
|
| 1689 | + $data['hex'] = $lined['hexid']; |
|
| 1690 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1691 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1692 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1693 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1694 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1695 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1696 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1697 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1698 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1699 | + $data['id_source'] = $id_source; |
|
| 1700 | + $data['format_source'] = 'tsv'; |
|
| 1701 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1702 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1703 | 1703 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1704 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1705 | - unset($lined); |
|
| 1706 | - unset($data); |
|
| 1707 | - } else $error = true; |
|
| 1704 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1705 | + unset($lined); |
|
| 1706 | + unset($data); |
|
| 1707 | + } else $error = true; |
|
| 1708 | 1708 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1709 | - if ($aprs_connect === 0) { |
|
| 1709 | + if ($aprs_connect === 0) { |
|
| 1710 | 1710 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1711 | 1711 | $aprs_connect = 1; |
| 1712 | - } |
|
| 1712 | + } |
|
| 1713 | 1713 | |
| 1714 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1714 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1715 | 1715 | $aprs_last_tx = time(); |
| 1716 | 1716 | $data_aprs = "# Keep alive"; |
| 1717 | 1717 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1718 | - } |
|
| 1718 | + } |
|
| 1719 | 1719 | |
| 1720 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1721 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1722 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1723 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1724 | - //echo $buffer."\n"; |
|
| 1725 | - date_default_timezone_set('UTC'); |
|
| 1726 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1720 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1721 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1722 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1723 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1724 | + //echo $buffer."\n"; |
|
| 1725 | + date_default_timezone_set('UTC'); |
|
| 1726 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1727 | 1727 | $line = $APRS->parse($buffer); |
| 1728 | 1728 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1729 | 1729 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1730 | - $aprs_last_tx = time(); |
|
| 1731 | - $data = array(); |
|
| 1732 | - //print_r($line); |
|
| 1733 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1734 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1735 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1736 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1737 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1738 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1739 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1740 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1741 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1742 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1743 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1744 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1745 | - $data['latitude'] = $line['latitude']; |
|
| 1746 | - $data['longitude'] = $line['longitude']; |
|
| 1747 | - //$data['verticalrate'] = $line[16]; |
|
| 1748 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1749 | - //else $data['speed'] = 0; |
|
| 1750 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1751 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1752 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1753 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1730 | + $aprs_last_tx = time(); |
|
| 1731 | + $data = array(); |
|
| 1732 | + //print_r($line); |
|
| 1733 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1734 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1735 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1736 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1737 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1738 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1739 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1740 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1741 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1742 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1743 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1744 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1745 | + $data['latitude'] = $line['latitude']; |
|
| 1746 | + $data['longitude'] = $line['longitude']; |
|
| 1747 | + //$data['verticalrate'] = $line[16]; |
|
| 1748 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1749 | + //else $data['speed'] = 0; |
|
| 1750 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1751 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1752 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1753 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1754 | 1754 | |
| 1755 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1756 | - //else echo 'No heading...'."\n"; |
|
| 1757 | - //else $data['heading'] = 0; |
|
| 1758 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1759 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1760 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1761 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1762 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1763 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1764 | - $data['id_source'] = $id_source; |
|
| 1765 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1766 | - else $data['format_source'] = 'aprs'; |
|
| 1767 | - $data['source_name'] = $line['source']; |
|
| 1768 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1769 | - else $data['source_type'] = 'flarm'; |
|
| 1770 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1771 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1772 | - $aprsdate = strtotime($data['datetime']); |
|
| 1773 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1774 | - // Accept data if time <= system time + 20s |
|
| 1775 | - //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'])))) { |
|
| 1776 | - if ( |
|
| 1755 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1756 | + //else echo 'No heading...'."\n"; |
|
| 1757 | + //else $data['heading'] = 0; |
|
| 1758 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1759 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1760 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1761 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1762 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1763 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1764 | + $data['id_source'] = $id_source; |
|
| 1765 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1766 | + else $data['format_source'] = 'aprs'; |
|
| 1767 | + $data['source_name'] = $line['source']; |
|
| 1768 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1769 | + else $data['source_type'] = 'flarm'; |
|
| 1770 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1771 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1772 | + $aprsdate = strtotime($data['datetime']); |
|
| 1773 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1774 | + // Accept data if time <= system time + 20s |
|
| 1775 | + //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'])))) { |
|
| 1776 | + if ( |
|
| 1777 | 1777 | ($data['source_type'] === 'modes') || |
| 1778 | 1778 | isset($line['stealth']) && |
| 1779 | 1779 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
| 1780 | 1780 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
| 1781 | 1781 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1782 | 1782 | $send = $SI->add($data); |
| 1783 | - } elseif ($data['source_type'] === 'ais') { |
|
| 1783 | + } elseif ($data['source_type'] === 'ais') { |
|
| 1784 | 1784 | $data['type'] = ''; |
| 1785 | 1785 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1786 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1786 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1787 | 1787 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1788 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1789 | - //$line['symbol'] === 'Balloon' || |
|
| 1790 | - $line['symbol'] === 'Glider' || |
|
| 1791 | - $line['symbol'] === 'No. Plane' || |
|
| 1792 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1793 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1794 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1795 | - $send = $SI->add($data); |
|
| 1796 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1797 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1798 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1799 | - $send = $MI->add($data); |
|
| 1800 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1801 | - $line['symbol'] === 'Car' || |
|
| 1802 | - $line['symbol'] === 'Ambulance' || |
|
| 1803 | - $line['symbol'] === 'Van' || |
|
| 1804 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1805 | - $line['symbol'] === 'Motorcycle' || |
|
| 1806 | - $line['symbol'] === 'Tractor' || |
|
| 1807 | - $line['symbol'] === 'Police' || |
|
| 1808 | - $line['symbol'] === 'Bike' || |
|
| 1809 | - $line['symbol'] === 'Jogger' || |
|
| 1810 | - $line['symbol'] === 'Horse' || |
|
| 1811 | - $line['symbol'] === 'Bus' || |
|
| 1812 | - $line['symbol'] === 'Jeep' || |
|
| 1813 | - $line['symbol'] === 'Recreational Vehicle' || |
|
| 1814 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1815 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1816 | - $line['symbol'] === 'Firetruck' || |
|
| 1817 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1818 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1819 | - $line['symbol'] === 'SUV' || |
|
| 1820 | - $line['symbol'] === 'Snowmobile' || |
|
| 1821 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 1822 | - //} 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') { |
|
| 1788 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1789 | + //$line['symbol'] === 'Balloon' || |
|
| 1790 | + $line['symbol'] === 'Glider' || |
|
| 1791 | + $line['symbol'] === 'No. Plane' || |
|
| 1792 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1793 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1794 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1795 | + $send = $SI->add($data); |
|
| 1796 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1797 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1798 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1799 | + $send = $MI->add($data); |
|
| 1800 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1801 | + $line['symbol'] === 'Car' || |
|
| 1802 | + $line['symbol'] === 'Ambulance' || |
|
| 1803 | + $line['symbol'] === 'Van' || |
|
| 1804 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1805 | + $line['symbol'] === 'Motorcycle' || |
|
| 1806 | + $line['symbol'] === 'Tractor' || |
|
| 1807 | + $line['symbol'] === 'Police' || |
|
| 1808 | + $line['symbol'] === 'Bike' || |
|
| 1809 | + $line['symbol'] === 'Jogger' || |
|
| 1810 | + $line['symbol'] === 'Horse' || |
|
| 1811 | + $line['symbol'] === 'Bus' || |
|
| 1812 | + $line['symbol'] === 'Jeep' || |
|
| 1813 | + $line['symbol'] === 'Recreational Vehicle' || |
|
| 1814 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1815 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1816 | + $line['symbol'] === 'Firetruck' || |
|
| 1817 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1818 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1819 | + $line['symbol'] === 'SUV' || |
|
| 1820 | + $line['symbol'] === 'Snowmobile' || |
|
| 1821 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 1822 | + //} 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') { |
|
| 1823 | 1823 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') { |
| 1824 | 1824 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1825 | 1825 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1826 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1826 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1827 | 1827 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1828 | 1828 | $Source->deleteOldLocationByType('gs'); |
| 1829 | 1829 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1831,7 +1831,7 @@ discard block |
||
| 1831 | 1831 | } else { |
| 1832 | 1832 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1833 | 1833 | } |
| 1834 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 1834 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 1835 | 1835 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1836 | 1836 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 1837 | 1837 | $Source->deleteOldLocationByType('wx'); |
@@ -1841,7 +1841,7 @@ discard block |
||
| 1841 | 1841 | } else { |
| 1842 | 1842 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 1843 | 1843 | } |
| 1844 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 1844 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 1845 | 1845 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1846 | 1846 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1847 | 1847 | $Source->deleteOldLocationByType('lightning'); |
@@ -1850,11 +1850,11 @@ discard block |
||
| 1850 | 1850 | } else { |
| 1851 | 1851 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 1852 | 1852 | } |
| 1853 | - } elseif ($globalDebug) { |
|
| 1854 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 1855 | - print_r($line); |
|
| 1856 | - } |
|
| 1857 | - unset($data); |
|
| 1853 | + } elseif ($globalDebug) { |
|
| 1854 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 1855 | + print_r($line); |
|
| 1856 | + } |
|
| 1857 | + unset($data); |
|
| 1858 | 1858 | } |
| 1859 | 1859 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 1860 | 1860 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1873,12 +1873,12 @@ discard block |
||
| 1873 | 1873 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 1874 | 1874 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 1875 | 1875 | } |
| 1876 | - } |
|
| 1876 | + } |
|
| 1877 | 1877 | } else { |
| 1878 | - $line = explode(',', $buffer); |
|
| 1879 | - if (count($line) > 20) { |
|
| 1880 | - $data['hex'] = $line[4]; |
|
| 1881 | - /* |
|
| 1878 | + $line = explode(',', $buffer); |
|
| 1879 | + if (count($line) > 20) { |
|
| 1880 | + $data['hex'] = $line[4]; |
|
| 1881 | + /* |
|
| 1882 | 1882 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1883 | 1883 | date_default_timezone_set($globalTimezone); |
| 1884 | 1884 | $datetime = new DateTime($data['datetime']); |
@@ -1886,31 +1886,31 @@ discard block |
||
| 1886 | 1886 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1887 | 1887 | date_default_timezone_set('UTC'); |
| 1888 | 1888 | */ |
| 1889 | - // Force datetime to current UTC datetime |
|
| 1890 | - date_default_timezone_set('UTC'); |
|
| 1891 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1892 | - $data['ident'] = trim($line[10]); |
|
| 1893 | - $data['latitude'] = $line[14]; |
|
| 1894 | - $data['longitude'] = $line[15]; |
|
| 1895 | - $data['verticalrate'] = $line[16]; |
|
| 1896 | - $data['emergency'] = $line[20]; |
|
| 1897 | - $data['speed'] = $line[12]; |
|
| 1898 | - $data['squawk'] = $line[17]; |
|
| 1899 | - $data['altitude'] = $line[11]; |
|
| 1900 | - $data['heading'] = $line[13]; |
|
| 1901 | - $data['ground'] = $line[21]; |
|
| 1902 | - $data['emergency'] = $line[19]; |
|
| 1903 | - $data['format_source'] = 'sbs'; |
|
| 1889 | + // Force datetime to current UTC datetime |
|
| 1890 | + date_default_timezone_set('UTC'); |
|
| 1891 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1892 | + $data['ident'] = trim($line[10]); |
|
| 1893 | + $data['latitude'] = $line[14]; |
|
| 1894 | + $data['longitude'] = $line[15]; |
|
| 1895 | + $data['verticalrate'] = $line[16]; |
|
| 1896 | + $data['emergency'] = $line[20]; |
|
| 1897 | + $data['speed'] = $line[12]; |
|
| 1898 | + $data['squawk'] = $line[17]; |
|
| 1899 | + $data['altitude'] = $line[11]; |
|
| 1900 | + $data['heading'] = $line[13]; |
|
| 1901 | + $data['ground'] = $line[21]; |
|
| 1902 | + $data['emergency'] = $line[19]; |
|
| 1903 | + $data['format_source'] = 'sbs'; |
|
| 1904 | 1904 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1905 | 1905 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
| 1906 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1906 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1907 | 1907 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1908 | - $data['id_source'] = $id_source; |
|
| 1909 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1910 | - else $error = true; |
|
| 1911 | - unset($data); |
|
| 1912 | - } else $error = true; |
|
| 1913 | - if ($error) { |
|
| 1908 | + $data['id_source'] = $id_source; |
|
| 1909 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1910 | + else $error = true; |
|
| 1911 | + unset($data); |
|
| 1912 | + } else $error = true; |
|
| 1913 | + if ($error) { |
|
| 1914 | 1914 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 1915 | 1915 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1916 | 1916 | } else { |
@@ -1926,13 +1926,13 @@ discard block |
||
| 1926 | 1926 | connect_all($sourceer); |
| 1927 | 1927 | $sourceer = array(); |
| 1928 | 1928 | } |
| 1929 | - } |
|
| 1929 | + } |
|
| 1930 | 1930 | } |
| 1931 | 1931 | // Sleep for xxx microseconds |
| 1932 | 1932 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1933 | - } else { |
|
| 1933 | + } else { |
|
| 1934 | 1934 | if ($format === 'flightgearmp') { |
| 1935 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1935 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1936 | 1936 | //@socket_close($r); |
| 1937 | 1937 | sleep($globalMinFetch); |
| 1938 | 1938 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1941,9 +1941,9 @@ discard block |
||
| 1941 | 1941 | break; |
| 1942 | 1942 | |
| 1943 | 1943 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1944 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1945 | - else $tt[$format] = 0; |
|
| 1946 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 1944 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1945 | + else $tt[$format] = 0; |
|
| 1946 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 1947 | 1947 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1948 | 1948 | //@socket_close($r); |
| 1949 | 1949 | sleep(2); |
@@ -1954,24 +1954,24 @@ discard block |
||
| 1954 | 1954 | //connect_all($globalSources); |
| 1955 | 1955 | $tt[$format]=0; |
| 1956 | 1956 | break; |
| 1957 | - } |
|
| 1958 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 1957 | + } |
|
| 1958 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 1959 | + } |
|
| 1959 | 1960 | } |
| 1960 | - } |
|
| 1961 | 1961 | } |
| 1962 | - } else { |
|
| 1962 | + } else { |
|
| 1963 | 1963 | $error = socket_strerror(socket_last_error()); |
| 1964 | 1964 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1965 | 1965 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1966 | 1966 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1967 | 1967 | // Restart the script if possible |
| 1968 | 1968 | if (is_array($sockets)) { |
| 1969 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1969 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1970 | 1970 | |
| 1971 | - foreach ($sockets as $sock) { |
|
| 1971 | + foreach ($sockets as $sock) { |
|
| 1972 | 1972 | @socket_shutdown($sock,2); |
| 1973 | 1973 | @socket_close($sock); |
| 1974 | - } |
|
| 1974 | + } |
|
| 1975 | 1975 | |
| 1976 | 1976 | } |
| 1977 | 1977 | if ($globalDebug) echo "Waiting..."; |
@@ -1986,15 +1986,15 @@ discard block |
||
| 1986 | 1986 | if ($globalDebug) echo "Restart all connections..."; |
| 1987 | 1987 | connect_all($globalSources); |
| 1988 | 1988 | } |
| 1989 | - } |
|
| 1989 | + } |
|
| 1990 | 1990 | } |
| 1991 | 1991 | if ($globalDaemon === false) { |
| 1992 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1993 | - if (isset($SI)) $SI->checkAll(); |
|
| 1994 | - if (isset($TI)) $TI->checkAll(); |
|
| 1995 | - if (isset($MI)) $MI->checkAll(); |
|
| 1992 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1993 | + if (isset($SI)) $SI->checkAll(); |
|
| 1994 | + if (isset($TI)) $TI->checkAll(); |
|
| 1995 | + if (isset($MI)) $MI->checkAll(); |
|
| 1996 | + } |
|
| 1996 | 1997 | } |
| 1997 | - } |
|
| 1998 | 1998 | } |
| 1999 | 1999 | |
| 2000 | 2000 | ?> |
@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class MarineImport { |
| 16 | - private $all_tracked = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_tracked = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
| 27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 28 | - $Connection = new Connection($dbc); |
|
| 29 | - $this->db = $Connection->db(); |
|
| 30 | - date_default_timezone_set('UTC'); |
|
| 28 | + $Connection = new Connection($dbc); |
|
| 29 | + $this->db = $Connection->db(); |
|
| 30 | + date_default_timezone_set('UTC'); |
|
| 31 | 31 | } |
| 32 | 32 | // Get previous source stats |
| 33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | */ |
| 48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 49 | - $APRSMarine = new APRSMarine(); |
|
| 50 | - //$APRSSpotter->connect(); |
|
| 49 | + $APRSMarine = new APRSMarine(); |
|
| 50 | + //$APRSSpotter->connect(); |
|
| 51 | + } |
|
| 51 | 52 | } |
| 52 | - } |
|
| 53 | 53 | |
| 54 | - public function checkAll() { |
|
| 54 | + public function checkAll() { |
|
| 55 | 55 | global $globalDebug, $globalNoDB; |
| 56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 58 | - foreach ($this->all_tracked as $key => $flight) { |
|
| 57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 58 | + foreach ($this->all_tracked as $key => $flight) { |
|
| 59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
| 60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
| 61 | - $Marine = new Marine($this->db); |
|
| 62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
| 61 | + $Marine = new Marine($this->db); |
|
| 62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 63 | + } |
|
| 63 | 64 | } |
| 64 | - } |
|
| 65 | 65 | } |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function del() { |
|
| 68 | + public function del() { |
|
| 69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 70 | 70 | // Delete old infos |
| 71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
| 73 | - if (isset($flight['lastupdate'])) { |
|
| 74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 78 | - /* |
|
| 73 | + if (isset($flight['lastupdate'])) { |
|
| 74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 78 | + /* |
|
| 79 | 79 | $MarineLive = new MarineLive(); |
| 80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
| 81 | 81 | $MarineLive->db = null; |
| 82 | 82 | */ |
| 83 | - //$real_arrival = $this->arrival($key); |
|
| 84 | - $Marine = new Marine($this->db); |
|
| 85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 83 | + //$real_arrival = $this->arrival($key); |
|
| 84 | + $Marine = new Marine($this->db); |
|
| 85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 88 | - } |
|
| 89 | - // Put in archive |
|
| 88 | + } |
|
| 89 | + // Put in archive |
|
| 90 | 90 | // $Marine->db = null; |
| 91 | 91 | } |
| 92 | - } |
|
| 93 | - unset($this->all_tracked[$key]); |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 92 | + } |
|
| 93 | + unset($this->all_tracked[$key]); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function add($line) { |
|
| 99 | + public function add($line) { |
|
| 100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,104 +105,104 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // SBS format is CSV format |
| 107 | 107 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
| 108 | - //print_r($line); |
|
| 109 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 108 | + //print_r($line); |
|
| 109 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | // Increment message number |
| 113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 114 | - $current_date = date('Y-m-d'); |
|
| 115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 116 | - else $source = ''; |
|
| 117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 114 | + $current_date = date('Y-m-d'); |
|
| 115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 116 | + else $source = ''; |
|
| 117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | $Common = new Common(); |
| 126 | 126 | $AIS = new AIS(); |
| 127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 128 | - else $id = trim($line['id']); |
|
| 127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 128 | + else $id = trim($line['id']); |
|
| 129 | 129 | |
| 130 | 130 | if (!isset($this->all_tracked[$id])) { |
| 131 | - $this->all_tracked[$id] = array(); |
|
| 132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '')); |
|
| 134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 135 | - if (!isset($line['id'])) { |
|
| 131 | + $this->all_tracked[$id] = array(); |
|
| 132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '')); |
|
| 134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 135 | + if (!isset($line['id'])) { |
|
| 136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 145 | 145 | $Marine = new Marine($this->db); |
| 146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
| 147 | 147 | if (!empty($identity)) { |
| 148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 151 | 151 | } |
| 152 | 152 | //print_r($identity); |
| 153 | 153 | unset($Marine); |
| 154 | 154 | //$dataFound = true; |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | if (isset($line['type_id'])) { |
| 158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 160 | 160 | } |
| 161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
| 162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 167 | 167 | } |
| 168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 170 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 170 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 172 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 172 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 173 | 173 | $Marine = new Marine($this->db); |
| 174 | 174 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
| 175 | 175 | unset($Marine); |
| 176 | - } |
|
| 176 | + } |
|
| 177 | + } |
|
| 177 | 178 | } |
| 178 | - } |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 184 | 184 | } |
| 185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
| 186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 187 | 187 | } |
| 188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 190 | 190 | } |
| 191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 192 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 192 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 193 | 193 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 196 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 196 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 198 | - $Marine = new Marine($this->db); |
|
| 199 | - $fromsource = NULL; |
|
| 200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 201 | - $Marine->db = null; |
|
| 198 | + $Marine = new Marine($this->db); |
|
| 199 | + $fromsource = NULL; |
|
| 200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 201 | + $Marine->db = null; |
|
| 202 | + } |
|
| 202 | 203 | } |
| 203 | - } |
|
| 204 | 204 | } |
| 205 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 205 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 206 | 206 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 207 | 207 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 208 | 208 | if (!isset($line['id'])) { |
@@ -210,38 +210,38 @@ discard block |
||
| 210 | 210 | $this->all_tracked[$id]['forcenew'] = 1; |
| 211 | 211 | $this->all_tracked[$id]['addedMarine'] = 0; |
| 212 | 212 | } |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 217 | 217 | } |
| 218 | 218 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 220 | 220 | } |
| 221 | 221 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
| 222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 223 | 223 | } |
| 224 | 224 | if (isset($line['race_id']) && $line['race_id'] != '') { |
| 225 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 225 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 226 | 226 | } |
| 227 | 227 | if (isset($line['race_name']) && $line['race_name'] != '') { |
| 228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 232 | 232 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 233 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 233 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 234 | 234 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 235 | - $timeelapsed = microtime(true); |
|
| 236 | - $Marine = new Marine($this->db); |
|
| 237 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 238 | - $Marine->db = null; |
|
| 235 | + $timeelapsed = microtime(true); |
|
| 236 | + $Marine = new Marine($this->db); |
|
| 237 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 238 | + $Marine->db = null; |
|
| 239 | + } |
|
| 239 | 240 | } |
| 240 | - } |
|
| 241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 242 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 242 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 243 | 243 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 244 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 244 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 245 | 245 | $timeelapsed = microtime(true); |
| 246 | 246 | $Marine = new Marine($this->db); |
| 247 | 247 | $fromsource = NULL; |
@@ -249,20 +249,20 @@ discard block |
||
| 249 | 249 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 250 | 250 | $Marine->db = null; |
| 251 | 251 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 252 | - } |
|
| 252 | + } |
|
| 253 | + } |
|
| 253 | 254 | } |
| 254 | - } |
|
| 255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 255 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 259 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 259 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 260 | 260 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 261 | - } else { |
|
| 261 | + } else { |
|
| 262 | 262 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 263 | 263 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 264 | 264 | return ''; |
| 265 | - } |
|
| 265 | + } |
|
| 266 | 266 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 267 | 267 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 268 | 268 | return ''; |
@@ -279,24 +279,24 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | if (isset($line['speed'])) { |
| 282 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 283 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 282 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 283 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 284 | 284 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 285 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 286 | - if ($distance > 1000 && $distance < 10000) { |
|
| 285 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 286 | + if ($distance > 1000 && $distance < 10000) { |
|
| 287 | 287 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 288 | 288 | $speed = $speed*3.6; |
| 289 | 289 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
| 290 | 290 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 291 | - } |
|
| 291 | + } |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 296 | - else unset($timediff); |
|
| 297 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 294 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 295 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 296 | + else unset($timediff); |
|
| 297 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 298 | 298 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 299 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 299 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 300 | 300 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 301 | 301 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 302 | 302 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -304,192 +304,192 @@ discard block |
||
| 304 | 304 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 305 | 305 | $timeelapsed = microtime(true); |
| 306 | 306 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 307 | - $Marine = new Marine($this->db); |
|
| 308 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 309 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 310 | - $Marine->db = null; |
|
| 311 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 307 | + $Marine = new Marine($this->db); |
|
| 308 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 309 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 310 | + $Marine->db = null; |
|
| 311 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 312 | 312 | } |
| 313 | 313 | $this->tmd = 0; |
| 314 | 314 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 319 | 319 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 320 | 320 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 321 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 322 | - $dataFound = true; |
|
| 323 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 321 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 322 | + $dataFound = true; |
|
| 323 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 324 | 324 | } |
| 325 | 325 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 326 | 326 | } |
| 327 | 327 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 328 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 328 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 329 | 329 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 330 | 330 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 331 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 332 | - $dataFound = true; |
|
| 333 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 331 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 332 | + $dataFound = true; |
|
| 333 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 334 | 334 | } |
| 335 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - } else if ($globalDebug && $timediff > 20) { |
|
| 338 | + } else if ($globalDebug && $timediff > 20) { |
|
| 339 | 339 | $this->tmd = $this->tmd + 1; |
| 340 | 340 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 341 | 341 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 342 | 342 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 343 | 343 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 344 | - } |
|
| 344 | + } |
|
| 345 | 345 | } |
| 346 | 346 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 347 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 348 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 347 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 348 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 349 | 349 | } |
| 350 | 350 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 351 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 351 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 352 | 352 | } |
| 353 | 353 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 354 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 354 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 355 | 355 | } |
| 356 | 356 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | if (isset($line['heading']) && $line['heading'] != '') { |
| 361 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 362 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 363 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 364 | - //$dataFound = true; |
|
| 361 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 362 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 363 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 364 | + //$dataFound = true; |
|
| 365 | 365 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 366 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 367 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 368 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 369 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 366 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 367 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 368 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 369 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 370 | 370 | } |
| 371 | 371 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 372 | 372 | |
| 373 | 373 | |
| 374 | 374 | |
| 375 | 375 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
| 376 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 377 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 378 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 379 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 376 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 377 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 378 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 379 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 380 | 380 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 381 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 382 | - $timeelapsed = microtime(true); |
|
| 383 | - $MarineLive = new MarineLive($this->db); |
|
| 384 | - if (isset($line['id'])) { |
|
| 381 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 382 | + $timeelapsed = microtime(true); |
|
| 383 | + $MarineLive = new MarineLive($this->db); |
|
| 384 | + if (isset($line['id'])) { |
|
| 385 | 385 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 386 | 386 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 387 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 387 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 388 | 388 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 389 | 389 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 390 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 390 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 391 | 391 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 392 | 392 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 393 | - } else $recent_ident = ''; |
|
| 394 | - $MarineLive->db=null; |
|
| 395 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 396 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 393 | + } else $recent_ident = ''; |
|
| 394 | + $MarineLive->db=null; |
|
| 395 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 396 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 397 | 397 | } else $recent_ident = ''; |
| 398 | - } else { |
|
| 398 | + } else { |
|
| 399 | 399 | $recent_ident = ''; |
| 400 | 400 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 401 | - } |
|
| 402 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 403 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 404 | - { |
|
| 401 | + } |
|
| 402 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 403 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 404 | + { |
|
| 405 | 405 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 406 | 406 | //adds the spotter data for the archive |
| 407 | - $highlight = ''; |
|
| 408 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 409 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 407 | + $highlight = ''; |
|
| 408 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 409 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 410 | 410 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 411 | - $timeelapsed = microtime(true); |
|
| 412 | - $Marine = new Marine($this->db); |
|
| 413 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
|
| 414 | - $Marine->db = null; |
|
| 415 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 416 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 411 | + $timeelapsed = microtime(true); |
|
| 412 | + $Marine = new Marine($this->db); |
|
| 413 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
|
| 414 | + $Marine->db = null; |
|
| 415 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 416 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 417 | + } |
|
| 417 | 418 | } |
| 418 | - } |
|
| 419 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 419 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 420 | 420 | // Add source stat in DB |
| 421 | 421 | $Stats = new Stats($this->db); |
| 422 | 422 | if (!empty($this->stats)) { |
| 423 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 424 | - foreach($this->stats as $date => $data) { |
|
| 423 | + if ($globalDebug) echo 'Add source stats : '; |
|
| 424 | + foreach($this->stats as $date => $data) { |
|
| 425 | 425 | foreach($data as $source => $sourced) { |
| 426 | - //print_r($sourced); |
|
| 427 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 428 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 429 | - if (isset($sourced['msg'])) { |
|
| 430 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 431 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 432 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 433 | - unset($this->stats[$date][$source]['msg']); |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - if ($date != date('Y-m-d')) { |
|
| 438 | - unset($this->stats[$date]); |
|
| 439 | - } |
|
| 440 | - } |
|
| 441 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 426 | + //print_r($sourced); |
|
| 427 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 428 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 429 | + if (isset($sourced['msg'])) { |
|
| 430 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 431 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 432 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 433 | + unset($this->stats[$date][$source]['msg']); |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + if ($date != date('Y-m-d')) { |
|
| 438 | + unset($this->stats[$date]); |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 442 | 442 | } |
| 443 | 443 | $Stats->db = null; |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - $this->del(); |
|
| 446 | + $this->del(); |
|
| 447 | 447 | //$ignoreImport = false; |
| 448 | 448 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 449 | 449 | //print_r($this->all_tracked[$id]); |
| 450 | 450 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 451 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 452 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 453 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 451 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 452 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 453 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 454 | 454 | $MarineLive = new MarineLive($this->db); |
| 455 | 455 | $MarineLive->deleteLiveMarineData(); |
| 456 | 456 | $MarineLive->db=null; |
| 457 | 457 | if ($globalDebug) echo " Done\n"; |
| 458 | - } |
|
| 459 | - $this->last_delete = time(); |
|
| 458 | + } |
|
| 459 | + $this->last_delete = time(); |
|
| 460 | 460 | } |
| 461 | - } elseif ($recent_ident != '') { |
|
| 461 | + } elseif ($recent_ident != '') { |
|
| 462 | 462 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 463 | 463 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 464 | 464 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 465 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
| 465 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
| 466 | 466 | $Marine = new Marine($this->db); |
| 467 | 467 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
| 468 | 468 | $Marine->db = null; |
| 469 | - } |
|
| 469 | + } |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | } |
| 474 | - } |
|
| 475 | - //adds the spotter LIVE data |
|
| 476 | - if ($globalDebug) { |
|
| 474 | + } |
|
| 475 | + //adds the spotter LIVE data |
|
| 476 | + if ($globalDebug) { |
|
| 477 | 477 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 478 | - } |
|
| 479 | - $ignoreImport = false; |
|
| 478 | + } |
|
| 479 | + $ignoreImport = false; |
|
| 480 | 480 | |
| 481 | - if (!$ignoreImport) { |
|
| 481 | + if (!$ignoreImport) { |
|
| 482 | 482 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 483 | 483 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 484 | 484 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 485 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 485 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 486 | 486 | $timeelapsed = microtime(true); |
| 487 | 487 | $MarineLive = new MarineLive($this->db); |
| 488 | 488 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
| 489 | 489 | $MarineLive->db = null; |
| 490 | 490 | if ($globalDebug) echo $result."\n"; |
| 491 | 491 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 492 | - } |
|
| 492 | + } |
|
| 493 | 493 | } |
| 494 | 494 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 495 | 495 | $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | if ($stats_heading == 16) $stats_heading = 0; |
| 525 | 525 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 526 | 526 | for ($i=0;$i<=15;$i++) { |
| 527 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 527 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 528 | 528 | } |
| 529 | 529 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 530 | 530 | } else { |
@@ -537,11 +537,11 @@ discard block |
||
| 537 | 537 | //var_dump($this->stats); |
| 538 | 538 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 539 | 539 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 540 | - end($this->stats[$current_date][$source]['hist']); |
|
| 541 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 540 | + end($this->stats[$current_date][$source]['hist']); |
|
| 541 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 542 | 542 | } else $mini = 0; |
| 543 | 543 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 544 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 544 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 545 | 545 | } |
| 546 | 546 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 547 | 547 | } else { |
@@ -557,24 +557,24 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | |
| 559 | 559 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 560 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 560 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 561 | 561 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 562 | 562 | $MarineLive = new MarineLive($this->db); |
| 563 | 563 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 564 | 564 | $MarineLive->db = null; |
| 565 | 565 | //MarineLive->deleteLiveMarineData(); |
| 566 | 566 | if ($globalDebug) echo " Done\n"; |
| 567 | - } |
|
| 568 | - $this->last_delete_hourly = time(); |
|
| 567 | + } |
|
| 568 | + $this->last_delete_hourly = time(); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - } |
|
| 572 | - //$ignoreImport = false; |
|
| 571 | + } |
|
| 572 | + //$ignoreImport = false; |
|
| 573 | 573 | } |
| 574 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 575 | 575 | if ($send) return $this->all_tracked[$id]; |
| 576 | - } |
|
| 576 | + } |
|
| 577 | + } |
|
| 577 | 578 | } |
| 578 | - } |
|
| 579 | 579 | } |
| 580 | 580 | ?> |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?> |
| 51 | 51 | </tr></table></div> |
| 52 | 52 | <?php |
| 53 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
| 53 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
| 54 | 54 | ?> |
| 55 | 55 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script> |
| 56 | 56 | <?php |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
| 75 | 75 | <?php |
| 76 | 76 | } |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | ?> |
| 79 | 79 | |
| 80 | 80 | <div id="sidebar" class="sidebar collapsed"> |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | <li><a href="" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
| 86 | 86 | <li><a href="" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
| 87 | 87 | <?php |
| 88 | - //if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) { |
|
| 88 | + //if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) { |
|
| 89 | 89 | if (isset($globalArchive) && $globalArchive == TRUE && (!isset($globalAircraft) || $globalAircraft === TRUE)) { |
| 90 | 90 | ?> |
| 91 | 91 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
| 92 | 92 | <?php |
| 93 | 93 | } |
| 94 | - //} |
|
| 94 | + //} |
|
| 95 | 95 | ?> |
| 96 | 96 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
| 97 | 97 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | ?> |
| 106 | 106 | |
| 107 | 107 | <?php |
| 108 | - if (isset($globalMap3D) && $globalMap3D) { |
|
| 108 | + if (isset($globalMap3D) && $globalMap3D) { |
|
| 109 | 109 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
| 110 | 110 | ?> |
| 111 | 111 | <li><a href="" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | <li><a href="" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
| 116 | 116 | <?php |
| 117 | 117 | } |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | ?> |
| 120 | 120 | </ul> |
| 121 | 121 | |
@@ -264,15 +264,15 @@ discard block |
||
| 264 | 264 | </div> |
| 265 | 265 | </li> |
| 266 | 266 | <?php |
| 267 | - if (isset($globalDemo) && $globalDemo) { |
|
| 267 | + if (isset($globalDemo) && $globalDemo) { |
|
| 268 | 268 | ?> |
| 269 | 269 | <li><button type="button" class="btn btn-primary disabled"><?php echo _("Show archive"); ?></button> Disabled in Demo mode</li> |
| 270 | 270 | <?php |
| 271 | - } else { |
|
| 271 | + } else { |
|
| 272 | 272 | ?> |
| 273 | 273 | <li><button type="button" onclick="addarchive(begindate,enddate);" class="btn btn-primary"><?php echo _("Show archive"); ?></button></li> |
| 274 | 274 | <?php |
| 275 | - } |
|
| 275 | + } |
|
| 276 | 276 | ?> |
| 277 | 277 | </ul> |
| 278 | 278 | <ul> |
@@ -291,83 +291,83 @@ discard block |
||
| 291 | 291 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
| 292 | 292 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
| 293 | 293 | else $MapType = $_COOKIE['MapType']; |
| 294 | - ?> |
|
| 294 | + ?> |
|
| 295 | 295 | <select class="selectpicker" onchange="mapType(this);"> |
| 296 | 296 | <?php |
| 297 | 297 | } else { |
| 298 | 298 | if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider; |
| 299 | 299 | else $MapType = $_COOKIE['MapType3D']; |
| 300 | - ?> |
|
| 300 | + ?> |
|
| 301 | 301 | <select class="selectpicker" onchange="mapType3D(this);"> |
| 302 | 302 | <?php |
| 303 | 303 | } |
| 304 | - ?> |
|
| 304 | + ?> |
|
| 305 | 305 | <?php |
| 306 | 306 | if (isset($globalMapOffline) && $globalMapOffline === TRUE) { |
| 307 | - ?> |
|
| 307 | + ?> |
|
| 308 | 308 | <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option> |
| 309 | 309 | <?php |
| 310 | 310 | } else { |
| 311 | - if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) { |
|
| 312 | - ?> |
|
| 311 | + if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) { |
|
| 312 | + ?> |
|
| 313 | 313 | <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option> |
| 314 | 314 | <?php |
| 315 | - } |
|
| 316 | - ?> |
|
| 315 | + } |
|
| 316 | + ?> |
|
| 317 | 317 | <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option> |
| 318 | 318 | <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option> |
| 319 | 319 | <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') print ' selected'; ?>>ArcGIS Ocean</option> |
| 320 | 320 | <?php |
| 321 | - if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
|
| 322 | - ?> |
|
| 321 | + if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
|
| 322 | + ?> |
|
| 323 | 323 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
| 324 | 324 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
| 325 | 325 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
| 326 | 326 | <?php |
| 327 | - } |
|
| 328 | - ?> |
|
| 327 | + } |
|
| 328 | + ?> |
|
| 329 | 329 | <?php |
| 330 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
| 331 | - ?> |
|
| 330 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
| 331 | + ?> |
|
| 332 | 332 | <?php |
| 333 | 333 | if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
| 334 | - ?> |
|
| 334 | + ?> |
|
| 335 | 335 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
| 336 | 336 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
| 337 | 337 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
| 338 | 338 | <?php |
| 339 | 339 | } |
| 340 | - ?> |
|
| 340 | + ?> |
|
| 341 | 341 | <?php |
| 342 | 342 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
| 343 | - ?> |
|
| 343 | + ?> |
|
| 344 | 344 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
| 345 | 345 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
| 346 | 346 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
| 347 | 347 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
| 348 | 348 | <?php |
| 349 | 349 | } |
| 350 | - ?> |
|
| 350 | + ?> |
|
| 351 | 351 | <?php |
| 352 | 352 | if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
| 353 | - ?> |
|
| 353 | + ?> |
|
| 354 | 354 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
| 355 | 355 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
| 356 | 356 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
| 357 | 357 | <?php |
| 358 | 358 | } |
| 359 | - ?> |
|
| 359 | + ?> |
|
| 360 | 360 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
| 361 | 361 | <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option> |
| 362 | 362 | <?php |
| 363 | - } |
|
| 364 | - ?> |
|
| 363 | + } |
|
| 364 | + ?> |
|
| 365 | 365 | <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option> |
| 366 | 366 | <?php |
| 367 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
| 367 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
| 368 | 368 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
| 369 | 369 | else $MapBoxId = $_COOKIE['MapTypeId']; |
| 370 | - ?> |
|
| 370 | + ?> |
|
| 371 | 371 | <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option> |
| 372 | 372 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
| 373 | 373 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
@@ -382,17 +382,17 @@ discard block |
||
| 382 | 382 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
| 383 | 383 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
| 384 | 384 | <?php |
| 385 | - } |
|
| 386 | - ?> |
|
| 385 | + } |
|
| 386 | + ?> |
|
| 387 | 387 | <!--<option value="OpenSeaMap"<?php if ($MapType == 'OpenSeaMap') print ' selected'; ?>>OpenSeaMap</option>--> |
| 388 | 388 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
| 389 | 389 | <?php |
| 390 | 390 | } |
| 391 | - ?> |
|
| 391 | + ?> |
|
| 392 | 392 | </select> |
| 393 | 393 | </li> |
| 394 | 394 | <?php |
| 395 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) { |
|
| 395 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) { |
|
| 396 | 396 | ?> |
| 397 | 397 | <li><?php echo _("Type of Terrain:"); ?> |
| 398 | 398 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -403,18 +403,18 @@ discard block |
||
| 403 | 403 | </select> |
| 404 | 404 | </li> |
| 405 | 405 | <?php |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | ?> |
| 408 | 408 | |
| 409 | 409 | <?php |
| 410 | - if (isset($globalMap3D) && $globalMap3D) { |
|
| 410 | + if (isset($globalMap3D) && $globalMap3D) { |
|
| 411 | 411 | ?> |
| 412 | 412 | <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') print 'checked'; ?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li> |
| 413 | 413 | <?php |
| 414 | - } |
|
| 414 | + } |
|
| 415 | 415 | ?> |
| 416 | 416 | <?php |
| 417 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 417 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 418 | 418 | ?> |
| 419 | 419 | <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li> |
| 420 | 420 | |
@@ -437,17 +437,17 @@ discard block |
||
| 437 | 437 | <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li> |
| 438 | 438 | <?php |
| 439 | 439 | } |
| 440 | - } |
|
| 440 | + } |
|
| 441 | 441 | ?> |
| 442 | 442 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
| 443 | 443 | <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li> |
| 444 | 444 | <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li> |
| 445 | 445 | <?php |
| 446 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) { |
|
| 446 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) { |
|
| 447 | 447 | ?> |
| 448 | 448 | <li><div class="checkbox"><label><input type="checkbox" name="displayweather" value="1" onclick="clickDisplayWeather(this)" <?php if ((isset($_COOKIE['show_Weather']) && $_COOKIE['show_Weather'] == 'true') || (!isset($_COOKIE['show_Weather']) && (isset($globalMapWeather) && $globalMapWeather === TRUE))) print 'checked'; ?> ><?php echo _("Display weather on 3D map"); ?></label></div></li> |
| 449 | 449 | <?php |
| 450 | - } |
|
| 450 | + } |
|
| 451 | 451 | ?> |
| 452 | 452 | <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li> |
| 453 | 453 | <?php |
@@ -463,82 +463,82 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | ?> |
| 465 | 465 | <?php |
| 466 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 466 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 467 | 467 | ?> |
| 468 | 468 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
| 469 | 469 | <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) print 'checked'; ?> ><?php echo _("Use shadows"); ?></label></div></li> |
| 470 | 470 | <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li> |
| 471 | 471 | <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) print 'checked'; ?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li> |
| 472 | 472 | <?php |
| 473 | - } |
|
| 474 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
| 473 | + } |
|
| 474 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
| 475 | 475 | ?> |
| 476 | 476 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
| 477 | 477 | <?php |
| 478 | - } |
|
| 478 | + } |
|
| 479 | 479 | ?> |
| 480 | 480 | <?php |
| 481 | 481 | if (function_exists('array_column')) { |
| 482 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
| 483 | - ?> |
|
| 482 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
| 483 | + ?> |
|
| 484 | 484 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
| 485 | 485 | <?php |
| 486 | - } |
|
| 486 | + } |
|
| 487 | 487 | } elseif (isset($globalSources)) { |
| 488 | - $dispolar = false; |
|
| 489 | - foreach ($globalSources as $testsource) { |
|
| 490 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
| 491 | - } |
|
| 492 | - if ($dispolar) { |
|
| 493 | - ?> |
|
| 488 | + $dispolar = false; |
|
| 489 | + foreach ($globalSources as $testsource) { |
|
| 490 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
| 491 | + } |
|
| 492 | + if ($dispolar) { |
|
| 493 | + ?> |
|
| 494 | 494 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
| 495 | 495 | <?php |
| 496 | - } |
|
| 497 | - } |
|
| 498 | - ?> |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + ?> |
|
| 499 | 499 | <?php |
| 500 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 500 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 501 | 501 | ?> |
| 502 | 502 | |
| 503 | 503 | <?php |
| 504 | 504 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
| 505 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 506 | - ?> |
|
| 505 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 506 | + ?> |
|
| 507 | 507 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
| 508 | 508 | <?php |
| 509 | 509 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
| 510 | - ?> |
|
| 510 | + ?> |
|
| 511 | 511 | <li><?php echo _("Aircraft icon color:"); ?><input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"></li> |
| 512 | 512 | <?php |
| 513 | 513 | } |
| 514 | - } |
|
| 515 | - } |
|
| 516 | - ?> |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + ?> |
|
| 517 | 517 | <?php |
| 518 | 518 | if (isset($globalMarine) && $globalMarine === TRUE) { |
| 519 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 520 | - ?> |
|
| 519 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 520 | + ?> |
|
| 521 | 521 | <li><?php echo _("Marine icon color:"); ?> |
| 522 | 522 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
| 523 | 523 | </li> |
| 524 | 524 | <?php |
| 525 | - } |
|
| 526 | - } |
|
| 527 | - ?> |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + ?> |
|
| 528 | 528 | <?php |
| 529 | 529 | if (isset($globalTracker) && $globalTracker === TRUE) { |
| 530 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 531 | - ?> |
|
| 530 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 531 | + ?> |
|
| 532 | 532 | <li><?php echo _("Tracker icon color:"); ?> |
| 533 | 533 | <input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>"> |
| 534 | 534 | </li> |
| 535 | 535 | <?php |
| 536 | - } |
|
| 537 | - } |
|
| 538 | - ?> |
|
| 536 | + } |
|
| 537 | + } |
|
| 538 | + ?> |
|
| 539 | 539 | <?php |
| 540 | 540 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
| 541 | - ?> |
|
| 541 | + ?> |
|
| 542 | 542 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
| 543 | 543 | <div class="range"> |
| 544 | 544 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | </li> |
| 548 | 548 | <?php |
| 549 | 549 | } |
| 550 | - ?> |
|
| 550 | + ?> |
|
| 551 | 551 | <?php |
| 552 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
| 552 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
| 553 | 553 | ?> |
| 554 | 554 | <li><?php echo _("Set scaling factor for rendering resolution:"); ?> |
| 555 | 555 | <div class="range"> |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | </li> |
| 588 | 588 | <?php |
| 589 | 589 | } |
| 590 | - } |
|
| 590 | + } |
|
| 591 | 591 | ?> |
| 592 | 592 | <li><?php echo _("Distance unit:"); ?> |
| 593 | 593 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -620,19 +620,19 @@ discard block |
||
| 620 | 620 | <ul> |
| 621 | 621 | <?php |
| 622 | 622 | if (!isset($globalAircraft) || $globalAircraft) { |
| 623 | - ?> |
|
| 623 | + ?> |
|
| 624 | 624 | <?php |
| 625 | 625 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
| 626 | - ?> |
|
| 626 | + ?> |
|
| 627 | 627 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
| 628 | 628 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
| 629 | 629 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
| 630 | 630 | <?php |
| 631 | 631 | } |
| 632 | - ?> |
|
| 632 | + ?> |
|
| 633 | 633 | <?php |
| 634 | 634 | if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
| 635 | - ?> |
|
| 635 | + ?> |
|
| 636 | 636 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
| 637 | 637 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
| 638 | 638 | <?php } ?> |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | <?php } ?> |
| 642 | 642 | <?php |
| 643 | 643 | } |
| 644 | - ?> |
|
| 644 | + ?> |
|
| 645 | 645 | <li><?php echo _("Display airlines:"); ?> |
| 646 | 646 | <br/> |
| 647 | 647 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -661,14 +661,14 @@ discard block |
||
| 661 | 661 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | - ?> |
|
| 664 | + ?> |
|
| 665 | 665 | </select> |
| 666 | 666 | </li> |
| 667 | 667 | <?php |
| 668 | 668 | $Spotter = new Spotter(); |
| 669 | 669 | $allalliancenames = $Spotter->getAllAllianceNames(); |
| 670 | 670 | if (!empty($allalliancenames)) { |
| 671 | - ?> |
|
| 671 | + ?> |
|
| 672 | 672 | <li><?php echo _("Display alliance:"); ?> |
| 673 | 673 | <br/> |
| 674 | 674 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -682,18 +682,18 @@ discard block |
||
| 682 | 682 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | - ?> |
|
| 685 | + ?> |
|
| 686 | 686 | </select> |
| 687 | 687 | </li> |
| 688 | 688 | <?php |
| 689 | 689 | } |
| 690 | - ?> |
|
| 690 | + ?> |
|
| 691 | 691 | <?php |
| 692 | 692 | } |
| 693 | - ?> |
|
| 693 | + ?> |
|
| 694 | 694 | <?php |
| 695 | 695 | if (isset($globalAPRS) && $globalAPRS) { |
| 696 | - ?> |
|
| 696 | + ?> |
|
| 697 | 697 | <li><?php echo _("Display APRS sources name:"); ?> |
| 698 | 698 | <select class="selectpicker" multiple onchange="sources(this);"> |
| 699 | 699 | <?php |
@@ -717,18 +717,18 @@ discard block |
||
| 717 | 717 | echo '<option value="'.$src['name'].'">'.$src['name'].'</option>'; |
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | - ?> |
|
| 720 | + ?> |
|
| 721 | 721 | </select> |
| 722 | 722 | </li> |
| 723 | 723 | <?php |
| 724 | 724 | } |
| 725 | - ?> |
|
| 725 | + ?> |
|
| 726 | 726 | <?php |
| 727 | 727 | if (!isset($globalAircraft) || $globalAircraft) { |
| 728 | - ?> |
|
| 728 | + ?> |
|
| 729 | 729 | <?php |
| 730 | - if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
|
| 731 | - ?> |
|
| 730 | + if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
|
| 731 | + ?> |
|
| 732 | 732 | <li><?php echo _("Display airlines of type:"); ?><br/> |
| 733 | 733 | <select class="selectpicker" onchange="airlinestype(this);"> |
| 734 | 734 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -738,14 +738,14 @@ discard block |
||
| 738 | 738 | </select> |
| 739 | 739 | </li> |
| 740 | 740 | <?php |
| 741 | - } |
|
| 742 | - ?> |
|
| 741 | + } |
|
| 742 | + ?> |
|
| 743 | 743 | <?php |
| 744 | 744 | } |
| 745 | - ?> |
|
| 745 | + ?> |
|
| 746 | 746 | <?php |
| 747 | 747 | if (isset($globalMarine) && $globalMarine) { |
| 748 | - ?> |
|
| 748 | + ?> |
|
| 749 | 749 | <li> |
| 750 | 750 | <?php echo _("Display vessels with MMSI:"); ?> |
| 751 | 751 | <input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" /> |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | foreach ($races as $race) { |
| 765 | 765 | print '<option value="'.$race['race_id'].'">'.$race['race_name'].'</option>'; |
| 766 | 766 | } |
| 767 | - ?> |
|
| 767 | + ?> |
|
| 768 | 768 | </select> |
| 769 | 769 | </li> |
| 770 | 770 | |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | - ?> |
|
| 775 | + ?> |
|
| 776 | 776 | <li> |
| 777 | 777 | <?php echo _("Display with ident:"); ?> |
| 778 | 778 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | </form> |
| 786 | 786 | </div> |
| 787 | 787 | <?php |
| 788 | - if (isset($globalSatellite) && $globalSatellite) { |
|
| 788 | + if (isset($globalSatellite) && $globalSatellite) { |
|
| 789 | 789 | ?> |
| 790 | 790 | <div class="sidebar-pane" id="satellites"> |
| 791 | 791 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -825,14 +825,14 @@ discard block |
||
| 825 | 825 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
| 826 | 826 | } |
| 827 | 827 | } |
| 828 | - ?> |
|
| 828 | + ?> |
|
| 829 | 829 | </select> |
| 830 | 830 | </li> |
| 831 | 831 | </ul> |
| 832 | 832 | </form> |
| 833 | 833 | </div> |
| 834 | 834 | <?php |
| 835 | - } |
|
| 835 | + } |
|
| 836 | 836 | ?> |
| 837 | 837 | </div> |
| 838 | 838 | </div> |