Completed
Push — master ( 669803...3326da )
by Yannick
31:15
created
require/class.AIS.php 2 patches
Doc Comments   +25 added lines patch added patch discarded remove patch
@@ -68,6 +68,10 @@  discard block
 block discarded – undo
68 68
        't', 'u', 'v', 'w' // 119
69 69
     ); // char 64
70 70
     */
71
+
72
+	/**
73
+	 * @param integer $ascii
74
+	 */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73 77
 		if ($ascii < 48) { }
@@ -93,6 +97,10 @@  discard block
 block discarded – undo
93 97
 		return(substr($bin, -6)); 
94 98
 	}
95 99
 
100
+	/**
101
+	 * @param integer $_start
102
+	 * @param integer $_size
103
+	 */
96 104
 	private function binchar($_str, $_start, $_size) {
97 105
 		//  ' ' --- '?', // 0x20 - 0x3F
98 106
 		//  '@' --- '_', // 0x40 - 0x5F
@@ -118,6 +126,10 @@  discard block
 block discarded – undo
118 126
 	}
119 127
 
120 128
 	// function for decoding the AIS Message ITU Payload
129
+
130
+	/**
131
+	 * @param string $_aisdata
132
+	 */
121 133
 	private function decode_ais($_aisdata) {
122 134
 		$ro = new stdClass(); // return object
123 135
 		$ro->cls = 0; // AIS class undefined, also indicate unparsed msg
@@ -350,6 +362,12 @@  discard block
 block discarded – undo
350 362
 		elseif ($code == 99) return 'Other Type, no additional information';
351 363
 	}
352 364
 
365
+	/**
366
+	 * @param string $_itu
367
+	 * @param integer $_len
368
+	 * @param integer $_filler
369
+	 * @param string $aux
370
+	 */
353 371
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
354 372
 		global $port; // tcpip port...
355 373
 		static $debug_counter = 0;
@@ -369,6 +387,10 @@  discard block
 block discarded – undo
369 387
 
370 388
 	// char* - AIS \r terminated string
371 389
 	// TCP based streams which send messages in full can use this instead of calling process_ais_buf
390
+
391
+	/**
392
+	 * @param string $rawdata
393
+	 */
372 394
 	public function process_ais_raw($rawdata, $aux = '') { // return int
373 395
 		static $num_seq; // 1 to 9
374 396
 		static $seq; // 1 to 9
@@ -591,6 +613,9 @@  discard block
 block discarded – undo
591 613
 		return $result;
592 614
 	}
593 615
 
616
+	/**
617
+	 * @param string $mmsi
618
+	 */
594 619
 	public function mmsitype($mmsi) {
595 620
 		if (strlen($mmsi) == 9) {
596 621
 			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		return ($dec);
58 58
 	}
59 59
 	
60
-    /*
60
+	/*
61 61
     $ais_map64 = array(
62 62
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48
63 63
        ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C',
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		//  ' ' --- '?', // 0x20 - 0x3F
98 98
 		//  '@' --- '_', // 0x40 - 0x5F
99 99
 		$ais_chars = array(
100
-		    '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
-		    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
-		    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
-		    '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
-		    '(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
-		    '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
-		    '<', '=', '>', '?'
100
+			'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
+			'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
+			'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
+			'^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
+			'(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
+			'2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
+			'<', '=', '>', '?'
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 				}
422 422
 				if ($num_seq > 1) { // for multipart messages
423 423
 					if ($cmsg_sid != $msg_sid // different msg_sid
424
-					    || $msg_sid == -1 // invalid initial msg_sid
425
-					    || ($seq - $pseq) != 1 // not insequence
424
+						|| $msg_sid == -1 // invalid initial msg_sid
425
+						|| ($seq - $pseq) != 1 // not insequence
426 426
 					) {  // invalid for multipart message
427 427
 						$msg_sid = -1;
428 428
 						$cmsg_sid = -1;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 				$itu = $itu.$pcs[5]; // get itu message
436 436
 				$filler += (int)$pcs[6][0]; // get filler
437 437
 				if ($num_seq == 1 // valid single message
438
-				    || $num_seq == $pseq // valid multi-part message
438
+					|| $num_seq == $pseq // valid multi-part message
439 439
 				) {
440 440
 					if ($num_seq != 1) { // test
441 441
 						echo $rawdata;
@@ -518,13 +518,13 @@  discard block
 block discarded – undo
518 518
 		else $pad = '';
519 519
 		$rv = '';
520 520
 		$ais_chars = array(
521
-		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
522
-		    'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
523
-		    'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
524
-		    '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
525
-		    '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
526
-		    '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
527
-		    '<'=>60, '='=>61, '>'=>62, '?'=>63
521
+			'@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
522
+			'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
523
+			'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
524
+			'^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
525
+			'('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
526
+			'2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
527
+			'<'=>60, '='=>61, '>'=>62, '?'=>63
528 528
 		);
529 529
 		// "
530 530
 		$_a = str_split($name);
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
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;
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	/**
85
-	* Executes the SQL statements to get the spotter information
86
-	*
87
-	* @param String $query the SQL query
88
-	* @param Array $params parameter of the query
89
-	* @param String $limitQuery the limit query
90
-	* @return Array the spotter information
91
-	*
92
-	*/
85
+	 * Executes the SQL statements to get the spotter information
86
+	 *
87
+	 * @param String $query the SQL query
88
+	 * @param Array $params parameter of the query
89
+	 * @param String $limitQuery the limit query
90
+	 * @return Array the spotter information
91
+	 *
92
+	 */
93 93
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
94 94
 	{
95 95
 		date_default_timezone_set('UTC');
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 	
218 218
 	
219 219
 	/**
220
-	* Gets all the spotter information based on the latest data entry
221
-	*
222
-	* @return Array the spotter information
223
-	*
224
-	*/
220
+	 * Gets all the spotter information based on the latest data entry
221
+	 *
222
+	 * @return Array the spotter information
223
+	 *
224
+	 */
225 225
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
226 226
 	{
227 227
 		global $global_query;
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	}
271 271
 
272 272
 	/**
273
-	* Gets all the spotter information based on the callsign
274
-	*
275
-	* @return Array the spotter information
276
-	*
277
-	*/
273
+	 * Gets all the spotter information based on the callsign
274
+	 *
275
+	 * @return Array the spotter information
276
+	 *
277
+	 */
278 278
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
279 279
 	{
280 280
 		global $global_query;
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
 
386 386
 
387 387
 	/**
388
-	* Gets all source name
389
-	*
390
-	* @param String type format of source
391
-	* @return Array list of source name
392
-	*
393
-	*/
388
+	 * Gets all source name
389
+	 *
390
+	 * @param String type format of source
391
+	 * @return Array list of source name
392
+	 *
393
+	 */
394 394
 	public function getAllSourceName($type = '',$filters = array())
395 395
 	{
396 396
 		$filter_query = $this->getFilter($filters,true,true);
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 
421 421
 
422 422
 	/**
423
-	* Gets a list of all idents/callsigns
424
-	*
425
-	* @return Array list of ident/callsign names
426
-	*
427
-	*/
423
+	 * Gets a list of all idents/callsigns
424
+	 *
425
+	 * @return Array list of ident/callsign names
426
+	 *
427
+	 */
428 428
 	public function getAllIdents($filters = array())
429 429
 	{
430 430
 		$filter_query = $this->getFilter($filters,true,true);
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 	}
449 449
 
450 450
 	/**
451
-	* Gets all info from a mmsi
452
-	*
453
-	* @return Array ident
454
-	*
455
-	*/
451
+	 * Gets all info from a mmsi
452
+	 *
453
+	 * @return Array ident
454
+	 *
455
+	 */
456 456
 	public function getIdentity($mmsi)
457 457
 	{
458 458
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 	}
466 466
 
467 467
 	/**
468
-	* Add identity
469
-	*
470
-	*/
468
+	 * Add identity
469
+	 *
470
+	 */
471 471
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
472 472
 	{
473 473
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
 	}
534 534
 
535 535
 	/**
536
-	* Update ident tracker data
537
-	*
538
-	* @param String $fammarine_id the ID
539
-	* @param String $ident the marine ident
540
-	* @return String success or false
541
-	*
542
-	*/
536
+	 * Update ident tracker data
537
+	 *
538
+	 * @param String $fammarine_id the ID
539
+	 * @param String $ident the marine ident
540
+	 * @return String success or false
541
+	 *
542
+	 */
543 543
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
544 544
 	{
545 545
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -554,19 +554,19 @@  discard block
 block discarded – undo
554 554
 	}
555 555
 
556 556
 	/**
557
-	* Update Status data
558
-	*
559
-	* @param String $fammarine_id the ID
560
-	* @param String $status_id the marine status id
561
-	* @param String $status the marine status
562
-	* @return String success or false
563
-	*
564
-	*/
557
+	 * Update Status data
558
+	 *
559
+	 * @param String $fammarine_id the ID
560
+	 * @param String $status_id the marine status id
561
+	 * @param String $status the marine status
562
+	 * @return String success or false
563
+	 *
564
+	 */
565 565
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
566 566
 	{
567 567
 
568 568
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
569
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
569
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
570 570
 
571 571
 		try {
572 572
 			$sth = $this->db->prepare($query);
@@ -579,17 +579,17 @@  discard block
 block discarded – undo
579 579
 
580 580
 	}
581 581
 	/**
582
-	* Update latest marine data
583
-	*
584
-	* @param String $fammarine_id the ID
585
-	* @param String $ident the marine ident
586
-	* @return String success or false
587
-	*
588
-	*/	
582
+	 * Update latest marine data
583
+	 *
584
+	 * @param String $fammarine_id the ID
585
+	 * @param String $ident the marine ident
586
+	 * @return String success or false
587
+	 *
588
+	 */	
589 589
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
590 590
 	{
591 591
 		$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';
592
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
592
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
593 593
 
594 594
 		try {
595 595
 			$sth = $this->db->prepare($query);
@@ -603,30 +603,30 @@  discard block
 block discarded – undo
603 603
 	}
604 604
 
605 605
 	/**
606
-	* Adds a new spotter data
607
-	*
608
-	* @param String $fammarine_id the ID
609
-	* @param String $ident the marine ident
610
-	* @param String $departure_airport_icao the departure airport
611
-	* @param String $arrival_airport_icao the arrival airport
612
-	* @param String $latitude latitude of flight
613
-	* @param String $longitude latitude of flight
614
-	* @param String $waypoints waypoints of flight
615
-	* @param String $heading heading of flight
616
-	* @param String $groundspeed speed of flight
617
-	* @param String $date date of flight
618
-	* @param String $departure_airport_time departure time of flight
619
-	* @param String $arrival_airport_time arrival time of flight
620
-	* @param String $squawk squawk code of flight
621
-	* @param String $route_stop route stop of flight
622
-	* @param String $highlight highlight or not
623
-	* @param String $ModeS ModesS code of flight
624
-	* @param String $registration registration code of flight
625
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
626
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
627
-	* @param String $verticalrate vertival rate of flight
628
-	* @return String success or false
629
-	*/
606
+	 * Adds a new spotter data
607
+	 *
608
+	 * @param String $fammarine_id the ID
609
+	 * @param String $ident the marine ident
610
+	 * @param String $departure_airport_icao the departure airport
611
+	 * @param String $arrival_airport_icao the arrival airport
612
+	 * @param String $latitude latitude of flight
613
+	 * @param String $longitude latitude of flight
614
+	 * @param String $waypoints waypoints of flight
615
+	 * @param String $heading heading of flight
616
+	 * @param String $groundspeed speed of flight
617
+	 * @param String $date date of flight
618
+	 * @param String $departure_airport_time departure time of flight
619
+	 * @param String $arrival_airport_time arrival time of flight
620
+	 * @param String $squawk squawk code of flight
621
+	 * @param String $route_stop route stop of flight
622
+	 * @param String $highlight highlight or not
623
+	 * @param String $ModeS ModesS code of flight
624
+	 * @param String $registration registration code of flight
625
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
626
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
627
+	 * @param String $verticalrate vertival rate of flight
628
+	 * @return String success or false
629
+	 */
630 630
 	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 = '')
631 631
 	{
632 632
 		global $globalURL, $globalMarineImageFetch;
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 			$sth->execute($query_values);
738 738
 			$this->db = null;
739 739
 		} catch (PDOException $e) {
740
-		    return "error : ".$e->getMessage();
740
+			return "error : ".$e->getMessage();
741 741
 		}
742 742
 		
743 743
 		return "success";
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
 	
747 747
   
748 748
 	/**
749
-	* Gets the aircraft ident within the last hour
750
-	*
751
-	* @return String the ident
752
-	*
753
-	*/
749
+	 * Gets the aircraft ident within the last hour
750
+	 *
751
+	 * @return String the ident
752
+	 *
753
+	 */
754 754
 	public function getIdentFromLastHour($ident)
755 755
 	{
756 756
 		global $globalDBdriver, $globalTimezone;
@@ -766,11 +766,11 @@  discard block
 block discarded – undo
766 766
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
767 767
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
768 768
 			$query_data = array(':ident' => $ident);
769
-    		}
769
+			}
770 770
 		
771 771
 		$sth = $this->db->prepare($query);
772 772
 		$sth->execute($query_data);
773
-    		$ident_result='';
773
+			$ident_result='';
774 774
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
775 775
 		{
776 776
 			$ident_result = $row['ident'];
@@ -781,11 +781,11 @@  discard block
 block discarded – undo
781 781
 	
782 782
 	
783 783
 	/**
784
-	* Gets the aircraft data from the last 20 seconds
785
-	*
786
-	* @return Array the spotter data
787
-	*
788
-	*/
784
+	 * Gets the aircraft data from the last 20 seconds
785
+	 *
786
+	 * @return Array the spotter data
787
+	 *
788
+	 */
789 789
 	public function getRealTimeData($q = '')
790 790
 	{
791 791
 		global $globalDBdriver;
@@ -823,11 +823,11 @@  discard block
 block discarded – undo
823 823
 	
824 824
 
825 825
 	/**
826
-	* Gets all number of flight over countries
827
-	*
828
-	* @return Array the airline country list
829
-	*
830
-	*/
826
+	 * Gets all number of flight over countries
827
+	 *
828
+	 * @return Array the airline country list
829
+	 *
830
+	 */
831 831
 
832 832
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
833 833
 	{
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 	
901 901
 	
902 902
 	/**
903
-	* Gets all callsigns that have flown over
904
-	*
905
-	* @return Array the callsign list
906
-	*
907
-	*/
903
+	 * Gets all callsigns that have flown over
904
+	 *
905
+	 * @return Array the callsign list
906
+	 *
907
+	 */
908 908
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
909 909
 	{
910 910
 		global $globalDBdriver;
@@ -971,11 +971,11 @@  discard block
 block discarded – undo
971 971
 
972 972
 
973 973
 	/**
974
-	* Counts all dates
975
-	*
976
-	* @return Array the date list
977
-	*
978
-	*/
974
+	 * Counts all dates
975
+	 *
976
+	 * @return Array the date list
977
+	 *
978
+	 */
979 979
 	public function countAllDates($filters = array())
980 980
 	{
981 981
 		global $globalTimezone, $globalDBdriver;
@@ -1021,11 +1021,11 @@  discard block
 block discarded – undo
1021 1021
 	
1022 1022
 	
1023 1023
 	/**
1024
-	* Counts all dates during the last 7 days
1025
-	*
1026
-	* @return Array the date list
1027
-	*
1028
-	*/
1024
+	 * Counts all dates during the last 7 days
1025
+	 *
1026
+	 * @return Array the date list
1027
+	 *
1028
+	 */
1029 1029
 	public function countAllDatesLast7Days($filters = array())
1030 1030
 	{
1031 1031
 		global $globalTimezone, $globalDBdriver;
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 			$query .= " GROUP BY date_name 
1048 1048
 								ORDER BY date_name ASC";
1049 1049
 			$query_data = array(':offset' => $offset);
1050
-    		}
1050
+			}
1051 1051
 		
1052 1052
 		$sth = $this->db->prepare($query);
1053 1053
 		$sth->execute($query_data);
@@ -1067,11 +1067,11 @@  discard block
 block discarded – undo
1067 1067
 	}
1068 1068
 
1069 1069
 	/**
1070
-	* Counts all dates during the last month
1071
-	*
1072
-	* @return Array the date list
1073
-	*
1074
-	*/
1070
+	 * Counts all dates during the last month
1071
+	 *
1072
+	 * @return Array the date list
1073
+	 *
1074
+	 */
1075 1075
 	public function countAllDatesLastMonth($filters = array())
1076 1076
 	{
1077 1077
 		global $globalTimezone, $globalDBdriver;
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 			$query .= " GROUP BY date_name 
1094 1094
 								ORDER BY date_name ASC";
1095 1095
 			$query_data = array(':offset' => $offset);
1096
-    		}
1096
+			}
1097 1097
 		
1098 1098
 		$sth = $this->db->prepare($query);
1099 1099
 		$sth->execute($query_data);
@@ -1115,11 +1115,11 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 
1117 1117
 	/**
1118
-	* Counts all month
1119
-	*
1120
-	* @return Array the month list
1121
-	*
1122
-	*/
1118
+	 * Counts all month
1119
+	 *
1120
+	 * @return Array the month list
1121
+	 *
1122
+	 */
1123 1123
 	public function countAllMonths($filters = array())
1124 1124
 	{
1125 1125
 		global $globalTimezone, $globalDBdriver;
@@ -1164,11 +1164,11 @@  discard block
 block discarded – undo
1164 1164
 	
1165 1165
 
1166 1166
 	/**
1167
-	* Counts all dates during the last year
1168
-	*
1169
-	* @return Array the date list
1170
-	*
1171
-	*/
1167
+	 * Counts all dates during the last year
1168
+	 *
1169
+	 * @return Array the date list
1170
+	 *
1171
+	 */
1172 1172
 	public function countAllMonthsLastYear($filters)
1173 1173
 	{
1174 1174
 		global $globalTimezone, $globalDBdriver;
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 			$query .= " GROUP BY year_name, month_name
1191 1191
 								ORDER BY year_name, month_name ASC";
1192 1192
 			$query_data = array(':offset' => $offset);
1193
-    		}
1193
+			}
1194 1194
 		
1195 1195
 		$sth = $this->db->prepare($query);
1196 1196
 		$sth->execute($query_data);
@@ -1213,11 +1213,11 @@  discard block
 block discarded – undo
1213 1213
 	
1214 1214
 	
1215 1215
 	/**
1216
-	* Counts all hours
1217
-	*
1218
-	* @return Array the hour list
1219
-	*
1220
-	*/
1216
+	 * Counts all hours
1217
+	 *
1218
+	 * @return Array the hour list
1219
+	 *
1220
+	 */
1221 1221
 	public function countAllHours($orderby,$filters = array())
1222 1222
 	{
1223 1223
 		global $globalTimezone, $globalDBdriver;
@@ -1280,11 +1280,11 @@  discard block
 block discarded – undo
1280 1280
 	
1281 1281
 	
1282 1282
 	/**
1283
-	* Counts all hours by date
1284
-	*
1285
-	* @return Array the hour list
1286
-	*
1287
-	*/
1283
+	 * Counts all hours by date
1284
+	 *
1285
+	 * @return Array the hour list
1286
+	 *
1287
+	 */
1288 1288
 	public function countAllHoursByDate($date, $filters = array())
1289 1289
 	{
1290 1290
 		global $globalTimezone, $globalDBdriver;
@@ -1328,11 +1328,11 @@  discard block
 block discarded – undo
1328 1328
 	
1329 1329
 	
1330 1330
 	/**
1331
-	* Counts all hours by a ident/callsign
1332
-	*
1333
-	* @return Array the hour list
1334
-	*
1335
-	*/
1331
+	 * Counts all hours by a ident/callsign
1332
+	 *
1333
+	 * @return Array the hour list
1334
+	 *
1335
+	 */
1336 1336
 	public function countAllHoursByIdent($ident, $filters = array())
1337 1337
 	{
1338 1338
 		global $globalTimezone, $globalDBdriver;
@@ -1377,11 +1377,11 @@  discard block
 block discarded – undo
1377 1377
 	
1378 1378
 	
1379 1379
 	/**
1380
-	* Counts all vessels
1381
-	*
1382
-	* @return Integer the number of vessels
1383
-	*
1384
-	*/
1380
+	 * Counts all vessels
1381
+	 *
1382
+	 * @return Integer the number of vessels
1383
+	 *
1384
+	 */
1385 1385
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1386 1386
 	{
1387 1387
 		global $globalDBdriver;
@@ -1416,11 +1416,11 @@  discard block
 block discarded – undo
1416 1416
 	}
1417 1417
 	
1418 1418
 	/**
1419
-	* Counts all vessel type
1420
-	*
1421
-	* @return Integer the number of vessels
1422
-	*
1423
-	*/
1419
+	 * Counts all vessel type
1420
+	 *
1421
+	 * @return Integer the number of vessels
1422
+	 *
1423
+	 */
1424 1424
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1425 1425
 	{
1426 1426
 		global $globalDBdriver;
@@ -1455,11 +1455,11 @@  discard block
 block discarded – undo
1455 1455
 	
1456 1456
   
1457 1457
 	/**
1458
-	* Counts all hours of today
1459
-	*
1460
-	* @return Array the hour list
1461
-	*
1462
-	*/
1458
+	 * Counts all hours of today
1459
+	 *
1460
+	 * @return Array the hour list
1461
+	 *
1462
+	 */
1463 1463
 	public function countAllHoursFromToday($filters = array())
1464 1464
 	{
1465 1465
 		global $globalTimezone, $globalDBdriver;
@@ -1499,12 +1499,12 @@  discard block
 block discarded – undo
1499 1499
 	}
1500 1500
     
1501 1501
     
1502
-     /**
1503
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1504
-	*
1505
-	* @return Integer the Barrie Spotter ID
1502
+	 /**
1503
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1504
+	  *
1505
+	  * @return Integer the Barrie Spotter ID
1506 1506
 q	*
1507
-	*/
1507
+	  */
1508 1508
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1509 1509
 	{
1510 1510
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
   
1526 1526
  
1527 1527
 	/**
1528
-	* Parses a date string
1529
-	*
1530
-	* @param String $dateString the date string
1531
-	* @param String $timezone the timezone of a user
1532
-	* @return Array the time information
1533
-	*
1534
-	*/
1528
+	 * Parses a date string
1529
+	 *
1530
+	 * @param String $dateString the date string
1531
+	 * @param String $timezone the timezone of a user
1532
+	 * @return Array the time information
1533
+	 *
1534
+	 */
1535 1535
 	public function parseDateString($dateString, $timezone = '')
1536 1536
 	{
1537 1537
 		$time_array = array();
@@ -1564,12 +1564,12 @@  discard block
 block discarded – undo
1564 1564
 	}
1565 1565
 	
1566 1566
 	/**
1567
-	* Parses the direction degrees to working
1568
-	*
1569
-	* @param Float $direction the direction in degrees
1570
-	* @return Array the direction information
1571
-	*
1572
-	*/
1567
+	 * Parses the direction degrees to working
1568
+	 *
1569
+	 * @param Float $direction the direction in degrees
1570
+	 * @return Array the direction information
1571
+	 *
1572
+	 */
1573 1573
 	public function parseDirection($direction = 0)
1574 1574
 	{
1575 1575
 		if ($direction == '') $direction = 0;
@@ -1648,12 +1648,12 @@  discard block
 block discarded – undo
1648 1648
 	
1649 1649
 	
1650 1650
 	/**
1651
-	* Gets Country from latitude/longitude
1652
-	*
1653
-	* @param Float $latitude latitute of the flight
1654
-	* @param Float $longitude longitute of the flight
1655
-	* @return String the countrie
1656
-	*/
1651
+	 * Gets Country from latitude/longitude
1652
+	 *
1653
+	 * @param Float $latitude latitute of the flight
1654
+	 * @param Float $longitude longitute of the flight
1655
+	 * @return String the countrie
1656
+	 */
1657 1657
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1658 1658
 	{
1659 1659
 		global $globalDBdriver, $globalDebug;
@@ -1690,11 +1690,11 @@  discard block
 block discarded – undo
1690 1690
 	}
1691 1691
 
1692 1692
 	/**
1693
-	* Gets Country from iso2
1694
-	*
1695
-	* @param String $iso2 ISO2 country code
1696
-	* @return String the countrie
1697
-	*/
1693
+	 * Gets Country from iso2
1694
+	 *
1695
+	 * @param String $iso2 ISO2 country code
1696
+	 * @return String the countrie
1697
+	 */
1698 1698
 	public function getCountryFromISO2($iso2)
1699 1699
 	{
1700 1700
 		global $globalDBdriver, $globalDebug;
@@ -1723,12 +1723,12 @@  discard block
 block discarded – undo
1723 1723
 
1724 1724
 	
1725 1725
 	/**
1726
-	* Gets the short url from bit.ly
1727
-	*
1728
-	* @param String $url the full url
1729
-	* @return String the bit.ly url
1730
-	*
1731
-	*/
1726
+	 * Gets the short url from bit.ly
1727
+	 *
1728
+	 * @param String $url the full url
1729
+	 * @return String the bit.ly url
1730
+	 *
1731
+	 */
1732 1732
 	public function getBitlyURL($url)
1733 1733
 	{
1734 1734
 		global $globalBitlyAccessToken;
@@ -1755,11 +1755,11 @@  discard block
 block discarded – undo
1755 1755
 
1756 1756
 	
1757 1757
 	/**
1758
-	* Gets all vessels types that have flown over
1759
-	*
1760
-	* @return Array the vessel type list
1761
-	*
1762
-	*/
1758
+	 * Gets all vessels types that have flown over
1759
+	 *
1760
+	 * @return Array the vessel type list
1761
+	 *
1762
+	 */
1763 1763
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1764 1764
 	{
1765 1765
 		global $globalDBdriver;
@@ -1824,11 +1824,11 @@  discard block
 block discarded – undo
1824 1824
 	}
1825 1825
 
1826 1826
 	/**
1827
-	* Gets all the tracker information
1828
-	*
1829
-	* @return Array the tracker information
1830
-	*
1831
-	*/
1827
+	 * Gets all the tracker information
1828
+	 *
1829
+	 * @return Array the tracker information
1830
+	 *
1831
+	 */
1832 1832
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1833 1833
 	{
1834 1834
 		global $globalTimezone, $globalDBdriver;
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,83 +105,83 @@  discard block
 block discarded – undo
105 105
 	
106 106
 	// SBS format is CSV format
107 107
 	if(is_array($line) && isset($line['mmsi'])) {
108
-	    //print_r($line);
109
-  	    if (isset($line['mmsi'])) {
108
+		//print_r($line);
109
+  		if (isset($line['mmsi'])) {
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' => ''));
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' => ''));
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'];
148
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
+				$this->all_tracked[$id]['type'] = $identity['type'];
150 150
 			}
151 151
 			//print_r($identity);
152 152
 			unset($Marine);
153 153
 			//$dataFound = true;
154
-		    }
154
+			}
155 155
 		}
156 156
 		if (isset($line['type_id'])) {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
157
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
159 159
 		}
160 160
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
161
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
162 162
 		}
163 163
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
165 165
 		}
166 166
 		if (isset($line['imo']) && $line['imo'] != '') {
167
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
167
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
168 168
 		}
169 169
 		if (isset($line['callsign']) && $line['callsign'] != '') {
170
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
170
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
171 171
 		}
172 172
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
173
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
173
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
174 174
 		}
175 175
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
176
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
176
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
177 177
 		}
178 178
 
179 179
 		//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'])) {
180 180
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
181
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
182
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
181
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
182
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
183 183
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
184
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
184
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
185 185
 				$timeelapsed = microtime(true);
186 186
 				$Marine = new Marine($this->db);
187 187
 				$fromsource = NULL;
@@ -190,20 +190,20 @@  discard block
 block discarded – undo
190 190
 				$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']);
191 191
 				$Marine->db = null;
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193
-			    }
193
+				}
194 194
 			}
195
-		    }
196
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
195
+			}
196
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
197 197
 		}
198 198
 
199 199
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
200
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
200
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
201 201
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
202
-		    } else {
202
+			} else {
203 203
 				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";
204 204
 				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";
205 205
 				return '';
206
-		    }
206
+			}
207 207
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
208 208
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
209 209
 			return '';
@@ -220,24 +220,24 @@  discard block
 block discarded – undo
220 220
 
221 221
 
222 222
 		if (isset($line['speed'])) {
223
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
224
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
223
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
224
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
225 225
 		} 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'])) {
226
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
227
-		    if ($distance > 1000 && $distance < 10000) {
226
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
227
+			if ($distance > 1000 && $distance < 10000) {
228 228
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
229 229
 			$speed = $speed*3.6;
230 230
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
231 231
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
232
-		    }
232
+			}
233 233
 		}
234 234
 
235
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
236
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
237
-	    	    else unset($timediff);
238
-	    	    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')))) {
235
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
236
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
237
+				else unset($timediff);
238
+				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')))) {
239 239
 			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'])) {
240
-			    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'])) {
240
+				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'])) {
241 241
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
242 242
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
243 243
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -245,211 +245,211 @@  discard block
 block discarded – undo
245 245
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
246 246
 				$timeelapsed = microtime(true);
247 247
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
248
-				    $Marine = new Marine($this->db);
249
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
250
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
251
-				    $Marine->db = null;
252
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
248
+					$Marine = new Marine($this->db);
249
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
250
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
251
+					$Marine->db = null;
252
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
253 253
 				}
254 254
 				$this->tmd = 0;
255 255
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
256
-			    }
256
+				}
257 257
 			}
258 258
 
259 259
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
260 260
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
261 261
 				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') {
262
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
263
-				    $dataFound = true;
264
-				    $this->all_tracked[$id]['time_last_coord'] = time();
262
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
263
+					$dataFound = true;
264
+					$this->all_tracked[$id]['time_last_coord'] = time();
265 265
 				}
266 266
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
267 267
 			}
268 268
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
269
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
269
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
270 270
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271 271
 				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') {
272
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
273
-				    $dataFound = true;
274
-				    $this->all_tracked[$id]['time_last_coord'] = time();
272
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
273
+					$dataFound = true;
274
+					$this->all_tracked[$id]['time_last_coord'] = time();
275 275
 				}
276 276
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
277 277
 			}
278 278
 
279
-		    } else if ($globalDebug && $timediff > 20) {
279
+			} else if ($globalDebug && $timediff > 20) {
280 280
 			$this->tmd = $this->tmd + 1;
281 281
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
282 282
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
283 283
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
284 284
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
285
-		    }
285
+			}
286 286
 		}
287 287
 		if (isset($line['last_update']) && $line['last_update'] != '') {
288
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
289
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
288
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
289
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
290 290
 		}
291 291
 		if (isset($line['format_source']) && $line['format_source'] != '') {
292
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
292
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
293 293
 		}
294 294
 		if (isset($line['source_name']) && $line['source_name'] != '') {
295
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
295
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
296 296
 		}
297 297
 		if (isset($line['status']) && $line['status'] != '') {
298
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
298
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
299 299
 		}
300 300
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
301
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
302
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
301
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
302
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
303 303
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
304
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
304
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 				$Marine = new Marine($this->db);
306 306
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
307 307
 				unset($Marine);
308
-			    }
308
+				}
309
+			}
309 310
 			}
310
-		    }
311 311
 		}
312 312
 
313 313
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
314
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
314
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
315 315
 		}
316 316
 		
317 317
 		if (isset($line['heading']) && $line['heading'] != '') {
318
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
320
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
321
-		    //$dataFound = true;
318
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
320
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
321
+			//$dataFound = true;
322 322
   		} 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']) {
323
-  		    $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']);
324
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
325
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
326
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
323
+  			$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']);
324
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
325
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
326
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
327 327
   		}
328 328
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
329 329
 
330 330
 
331 331
 
332 332
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
333
-		    $this->all_tracked[$id]['lastupdate'] = time();
334
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
335
-		        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'])) {
336
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
333
+			$this->all_tracked[$id]['lastupdate'] = time();
334
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
335
+				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'])) {
336
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
337 337
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
338
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
339
-				    $timeelapsed = microtime(true);
340
-				    $MarineLive = new MarineLive($this->db);
341
-				    if (isset($line['id'])) {
338
+					if ($globalDebug) echo "Check if vessel is already in DB...";
339
+					$timeelapsed = microtime(true);
340
+					$MarineLive = new MarineLive($this->db);
341
+					if (isset($line['id'])) {
342 342
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
343 343
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
344
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
344
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
345 345
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
346 346
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
347
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
347
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
348 348
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
349 349
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
350
-				    } else $recent_ident = '';
351
-				    $MarineLive->db=null;
352
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
353
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
350
+					} else $recent_ident = '';
351
+					$MarineLive->db=null;
352
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
353
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
354 354
 				} else $recent_ident = '';
355
-			    } else {
355
+				} else {
356 356
 				$recent_ident = '';
357 357
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
358
-			    }
359
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
360
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
361
-			    {
358
+				}
359
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
360
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
361
+				{
362 362
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
363 363
 				//adds the spotter data for the archive
364
-				    $highlight = '';
365
-				    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')));
366
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
364
+					$highlight = '';
365
+					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')));
366
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
367 367
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
368
-					    $timeelapsed = microtime(true);
369
-					    $Marine = new Marine($this->db);
370
-					    $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']);
371
-					    $Marine->db = null;
372
-					    if ($globalDebug && isset($result)) echo $result."\n";
373
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
368
+						$timeelapsed = microtime(true);
369
+						$Marine = new Marine($this->db);
370
+						$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']);
371
+						$Marine->db = null;
372
+						if ($globalDebug && isset($result)) echo $result."\n";
373
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
374
+					}
374 375
 					}
375
-				    }
376
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
376
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
377 377
 					// Add source stat in DB
378 378
 					$Stats = new Stats($this->db);
379 379
 					if (!empty($this->stats)) {
380
-					    if ($globalDebug) echo 'Add source stats : ';
381
-				    	    foreach($this->stats as $date => $data) {
380
+						if ($globalDebug) echo 'Add source stats : ';
381
+							foreach($this->stats as $date => $data) {
382 382
 						foreach($data as $source => $sourced) {
383
-					    	    //print_r($sourced);
384
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
385
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
386
-				    		    if (isset($sourced['msg'])) {
387
-				    			if (time() - $sourced['msg']['date'] > 10) {
388
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
389
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
390
-			    			    	    unset($this->stats[$date][$source]['msg']);
391
-			    				}
392
-			    			    }
393
-			    			}
394
-			    			if ($date != date('Y-m-d')) {
395
-			    			    unset($this->stats[$date]);
396
-			    			}
397
-				    	    }
398
-				    	    if ($globalDebug) echo 'Done'."\n";
383
+								//print_r($sourced);
384
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
385
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
386
+								if (isset($sourced['msg'])) {
387
+								if (time() - $sourced['msg']['date'] > 10) {
388
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
389
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
390
+										unset($this->stats[$date][$source]['msg']);
391
+								}
392
+								}
393
+							}
394
+							if ($date != date('Y-m-d')) {
395
+								unset($this->stats[$date]);
396
+							}
397
+							}
398
+							if ($globalDebug) echo 'Done'."\n";
399 399
 					}
400 400
 					$Stats->db = null;
401
-				    }
401
+					}
402 402
 				    
403
-				    $this->del();
403
+					$this->del();
404 404
 				//$ignoreImport = false;
405 405
 				$this->all_tracked[$id]['addedMarine'] = 1;
406 406
 				//print_r($this->all_tracked[$id]);
407 407
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
408
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
409
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
410
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
408
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
409
+					//MarineLive->deleteLiveMarineDataNotUpdated();
410
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
411 411
 					$MarineLive = new MarineLive($this->db);
412 412
 					$MarineLive->deleteLiveMarineData();
413 413
 					$MarineLive->db=null;
414 414
 					if ($globalDebug) echo " Done\n";
415
-				    }
416
-				    $this->last_delete = time();
415
+					}
416
+					$this->last_delete = time();
417 417
 				}
418
-			    } elseif ($recent_ident != '') {
418
+				} elseif ($recent_ident != '') {
419 419
 				$this->all_tracked[$id]['id'] = $recent_ident;
420 420
 				$this->all_tracked[$id]['addedMarine'] = 1;
421 421
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
422
-				    if (isset($globalDaemon) && !$globalDaemon) {
422
+					if (isset($globalDaemon) && !$globalDaemon) {
423 423
 					$Marine = new Marine($this->db);
424 424
 					$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']);
425 425
 					$Marine->db = null;
426
-				    }
426
+					}
427 427
 				}
428 428
 				
429
-			    }
429
+				}
430
+			}
430 431
 			}
431
-		    }
432
-		    //adds the spotter LIVE data
433
-		    if ($globalDebug) {
432
+			//adds the spotter LIVE data
433
+			if ($globalDebug) {
434 434
 			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";
435
-		    }
436
-		    $ignoreImport = false;
435
+			}
436
+			$ignoreImport = false;
437 437
 
438
-		    if (!$ignoreImport) {
438
+			if (!$ignoreImport) {
439 439
 			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'])) {
440 440
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
441 441
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
442
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
443 443
 					$timeelapsed = microtime(true);
444 444
 					$MarineLive = new MarineLive($this->db);
445 445
 					$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']);
446 446
 					$MarineLive->db = null;
447 447
 					if ($globalDebug) echo $result."\n";
448 448
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
-				    }
449
+					}
450 450
 				}
451 451
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
452
-				    $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']);
452
+					$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']);
453 453
 				}
454 454
 				$this->all_tracked[$id]['putinarchive'] = false;
455 455
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 					if ($stats_heading == 16) $stats_heading = 0;
482 482
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
483 483
 						for ($i=0;$i<=15;$i++) {
484
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
484
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
485 485
 						}
486 486
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
487 487
 					} else {
@@ -494,11 +494,11 @@  discard block
 block discarded – undo
494 494
 					//var_dump($this->stats);
495 495
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
496 496
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
497
-						    end($this->stats[$current_date][$source]['hist']);
498
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
497
+							end($this->stats[$current_date][$source]['hist']);
498
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
499 499
 						} else $mini = 0;
500 500
 						for ($i=$mini;$i<=$distance;$i+=10) {
501
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
501
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
502 502
 						}
503 503
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
504 504
 					} else {
@@ -514,24 +514,24 @@  discard block
 block discarded – undo
514 514
 			
515 515
 			
516 516
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
517
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
517
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
519 519
 				$MarineLive = new MarineLive($this->db);
520 520
 				$MarineLive->deleteLiveMarineDataNotUpdated();
521 521
 				$MarineLive->db = null;
522 522
 				//MarineLive->deleteLiveMarineData();
523 523
 				if ($globalDebug) echo " Done\n";
524
-			    }
525
-			    $this->last_delete_hourly = time();
524
+				}
525
+				$this->last_delete_hourly = time();
526 526
 			}
527 527
 			
528
-		    }
529
-		    //$ignoreImport = false;
528
+			}
529
+			//$ignoreImport = false;
530 530
 		}
531 531
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
532 532
 		if ($send) return $this->all_tracked[$id];
533
-	    }
533
+		}
534
+	}
534 535
 	}
535
-    }
536 536
 }
537 537
 ?>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +1020 added lines, -1020 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,36 +149,36 @@  discard block
 block discarded – undo
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('/opensky/i',$host)) {
177
-        	//$formats[$id] = 'aircraftlistjson';
178
-        	$globalSources[$id]['format'] = 'opensky';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
-    	    /*
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('/opensky/i',$host)) {
177
+			//$formats[$id] = 'aircraftlistjson';
178
+			$globalSources[$id]['format'] = 'opensky';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
+			/*
182 182
     	    // Disabled for now, site change source format
183 183
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
184 184
         	//$formats[$id] = 'radarvirtueljson';
@@ -190,125 +190,125 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
-        	//$formats[$id] = 'planeupdatefaa';
195
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
196
-        	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
-        	    exit(0);
201
-        	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
-        	//$formats[$id] = 'phpvmacars';
204
-        	$globalSources[$id]['format'] = 'phpvmacars';
205
-        	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'vaos';
210
-        	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'vam';
215
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
-            } else if (preg_match('/whazzup/i',$host)) {
217
-        	//$formats[$id] = 'whazzup';
218
-        	$globalSources[$id]['format'] = 'whazzup';
219
-        	//$last_exec['whazzup'] = 0;
220
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
-            } else if (preg_match('/blitzortung/i',$host)) {
222
-        	$globalSources[$id]['format'] = 'blitzortung';
223
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
-            } else if (preg_match('/airwhere/i',$host)) {
225
-        	$globalSources[$id]['format'] = 'airwhere';
226
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
-            } else if (preg_match('/recentpireps/i',$host)) {
228
-        	//$formats[$id] = 'pirepsjson';
229
-        	$globalSources[$id]['format'] = 'pirepsjson';
230
-        	//$last_exec['pirepsjson'] = 0;
231
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233
-        	//$formats[$id] = 'fr24json';
234
-        	$globalSources[$id]['format'] = 'fr24json';
235
-        	//$last_exec['fr24json'] = 0;
236
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
237
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239
-        	    exit(0);
240
-        	}
241
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
242
-        	//$formats[$id] = 'fr24json';
243
-        	$globalSources[$id]['format'] = 'myshiptracking';
244
-        	//$last_exec['fr24json'] = 0;
245
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
246
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248
-        	    exit(0);
249
-        	}
250
-            //} else if (preg_match('/10001/',$host)) {
251
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252
-        	//$formats[$id] = 'tsv';
253
-        	$globalSources[$id]['format'] = 'tsv';
254
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255
-            }
256
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
259
-    		    if ($idf !== false) {
260
-    			$httpfeeds[$id] = $idf;
261
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
-	    $hostport = explode(':',$host);
266
-	    if (isset($hostport[1])) {
193
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
+			//$formats[$id] = 'planeupdatefaa';
195
+			$globalSources[$id]['format'] = 'planeupdatefaa';
196
+			//$last_exec['planeupdatefaa'] = 0;
197
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
+				exit(0);
201
+			}
202
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
+			//$formats[$id] = 'phpvmacars';
204
+			$globalSources[$id]['format'] = 'phpvmacars';
205
+			//$last_exec['phpvmacars'] = 0;
206
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'vaos';
210
+			//$last_exec['phpvmacars'] = 0;
211
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'vam';
215
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
+			} else if (preg_match('/whazzup/i',$host)) {
217
+			//$formats[$id] = 'whazzup';
218
+			$globalSources[$id]['format'] = 'whazzup';
219
+			//$last_exec['whazzup'] = 0;
220
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
+			} else if (preg_match('/blitzortung/i',$host)) {
222
+			$globalSources[$id]['format'] = 'blitzortung';
223
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
+			} else if (preg_match('/airwhere/i',$host)) {
225
+			$globalSources[$id]['format'] = 'airwhere';
226
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
+			} else if (preg_match('/recentpireps/i',$host)) {
228
+			//$formats[$id] = 'pirepsjson';
229
+			$globalSources[$id]['format'] = 'pirepsjson';
230
+			//$last_exec['pirepsjson'] = 0;
231
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233
+			//$formats[$id] = 'fr24json';
234
+			$globalSources[$id]['format'] = 'fr24json';
235
+			//$last_exec['fr24json'] = 0;
236
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
237
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239
+				exit(0);
240
+			}
241
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
242
+			//$formats[$id] = 'fr24json';
243
+			$globalSources[$id]['format'] = 'myshiptracking';
244
+			//$last_exec['fr24json'] = 0;
245
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
246
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248
+				exit(0);
249
+			}
250
+			//} else if (preg_match('/10001/',$host)) {
251
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252
+			//$formats[$id] = 'tsv';
253
+			$globalSources[$id]['format'] = 'tsv';
254
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255
+			}
256
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
259
+				if ($idf !== false) {
260
+				$httpfeeds[$id] = $idf;
261
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
+		$hostport = explode(':',$host);
266
+		if (isset($hostport[1])) {
267 267
 		$port = $hostport[1];
268 268
 		$hostn = $hostport[0];
269
-	    } else {
269
+		} else {
270 270
 		$port = $globalSources[$id]['port'];
271 271
 		$hostn = $globalSources[$id]['host'];
272
-	    }
273
-	    $Common = new Common();
274
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
276
-    	    } else {
277
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
278
-	    }
279
-	    if ($s) {
280
-    	        $sockets[$id] = $s;
281
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
272
+		}
273
+		$Common = new Common();
274
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
276
+			} else {
277
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
278
+		}
279
+		if ($s) {
280
+				$sockets[$id] = $s;
281
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283 283
 			//$formats[$id] = 'aprs';
284 284
 			$globalSources[$id]['format'] = 'aprs';
285 285
 			//$aprs_connect = 0;
286 286
 			//$use_aprs = true;
287
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
287
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
288 288
 			$globalSources[$id]['format'] = 'vrstcp';
289
-    		    } elseif ($port == '10001') {
290
-        		//$formats[$id] = 'tsv';
291
-        		$globalSources[$id]['format'] = 'tsv';
292
-		    } elseif ($port == '30002') {
293
-        		//$formats[$id] = 'raw';
294
-        		$globalSources[$id]['format'] = 'raw';
295
-		    } elseif ($port == '5001') {
296
-        		//$formats[$id] = 'raw';
297
-        		$globalSources[$id]['format'] = 'flightgearmp';
298
-		    } elseif ($port == '30005') {
289
+				} elseif ($port == '10001') {
290
+				//$formats[$id] = 'tsv';
291
+				$globalSources[$id]['format'] = 'tsv';
292
+			} elseif ($port == '30002') {
293
+				//$formats[$id] = 'raw';
294
+				$globalSources[$id]['format'] = 'raw';
295
+			} elseif ($port == '5001') {
296
+				//$formats[$id] = 'raw';
297
+				$globalSources[$id]['format'] = 'flightgearmp';
298
+			} elseif ($port == '30005') {
299 299
 			// Not yet supported
300
-        		//$formats[$id] = 'beast';
301
-        		$globalSources[$id]['format'] = 'beast';
302
-		    //} else $formats[$id] = 'sbs';
303
-		    } else $globalSources[$id]['format'] = 'sbs';
304
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
300
+				//$formats[$id] = 'beast';
301
+				$globalSources[$id]['format'] = 'beast';
302
+			//} else $formats[$id] = 'sbs';
303
+			} else $globalSources[$id]['format'] = 'sbs';
304
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
305 305
 		}
306 306
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
307
-            } else {
307
+			} else {
308 308
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
309
-    	    }
310
-        }
311
-    }
309
+			}
310
+		}
311
+	}
312 312
 }
313 313
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
314 314
 
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 //connect_all($globalSources);
332 332
 
333 333
 if (isset($globalProxy) && $globalProxy) {
334
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
334
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
335 335
 } else {
336
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
336
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
337 337
 }
338 338
 
339 339
 // APRS Configuration
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 	die;
343 343
 }
344 344
 foreach ($globalSources as $key => $source) {
345
-    if (!isset($source['format'])) {
346
-        $globalSources[$key]['format'] = 'auto';
347
-    }
348
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
349
-        unset($globalSources[$key]);
350
-    }
345
+	if (!isset($source['format'])) {
346
+		$globalSources[$key]['format'] = 'auto';
347
+	}
348
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
349
+		unset($globalSources[$key]);
350
+	}
351 351
 }
352 352
 connect_all($globalSources);
353 353
 foreach ($globalSources as $key => $source) {
354
-    if (isset($source['format']) && $source['format'] == 'aprs') {
354
+	if (isset($source['format']) && $source['format'] == 'aprs') {
355 355
 	$aprs_connect = 0;
356 356
 	$use_aprs = true;
357 357
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
358 358
 	break;
359
-    }
359
+	}
360 360
 }
361 361
 
362 362
 if ($use_aprs) {
@@ -397,129 +397,129 @@  discard block
 block discarded – undo
397 397
 
398 398
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
399 399
 while ($i > 0) {
400
-    if (!$globalDaemon) $i = $endtime-time();
401
-    // Delete old ATC
402
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
400
+	if (!$globalDaemon) $i = $endtime-time();
401
+	// Delete old ATC
402
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
403 403
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
404
-        $ATC->deleteOldATC();
405
-    }
404
+		$ATC->deleteOldATC();
405
+	}
406 406
     
407
-    if (count($last_exec) == count($globalSources)) {
407
+	if (count($last_exec) == count($globalSources)) {
408 408
 	$max = $globalMinFetch;
409 409
 	foreach ($last_exec as $last) {
410
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
410
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
411 411
 	}
412 412
 	if ($max != $globalMinFetch) {
413
-	    if ($globalDebug) echo 'Sleeping...'."\n";
414
-	    sleep($globalMinFetch-$max+2);
413
+		if ($globalDebug) echo 'Sleeping...'."\n";
414
+		sleep($globalMinFetch-$max+2);
415
+	}
415 416
 	}
416
-    }
417 417
 
418 418
     
419
-    //foreach ($formats as $id => $value) {
420
-    foreach ($globalSources as $id => $value) {
419
+	//foreach ($formats as $id => $value) {
420
+	foreach ($globalSources as $id => $value) {
421 421
 	date_default_timezone_set('UTC');
422 422
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
423 423
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
424 424
 	if ($value['format'] == 'deltadbtxt' && 
425
-	    (
425
+		(
426 426
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
427 427
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
428
-	    )
428
+		)
429 429
 	) {
430
-	    //$buffer = $Common->getData($hosts[$id]);
431
-	    $buffer = $Common->getData($value['host']);
432
-	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
435
-	    foreach ($buffer as $line) {
436
-    		if ($line != '' && count($line) > 7) {
437
-    		    $line = explode(',', $line);
438
-	            $data = array();
439
-	            $data['hex'] = $line[1]; // hex
440
-	            $data['ident'] = $line[2]; // ident
441
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
-	            $data['verticalrate'] = ''; // vertical rate
447
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448
-	            $data['emergency'] = ''; // emergency
449
-		    $data['datetime'] = date('Y-m-d H:i:s');
450
-		    $data['format_source'] = 'deltadbtxt';
451
-    		    $data['id_source'] = $id_source;
452
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
455
-    		    $SI->add($data);
456
-		    unset($data);
457
-    		}
458
-    	    }
459
-    	    $last_exec[$id]['last'] = time();
430
+		//$buffer = $Common->getData($hosts[$id]);
431
+		$buffer = $Common->getData($value['host']);
432
+		if ($buffer != '') $reset = 0;
433
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
+		$buffer = explode('\n',$buffer);
435
+		foreach ($buffer as $line) {
436
+			if ($line != '' && count($line) > 7) {
437
+				$line = explode(',', $line);
438
+				$data = array();
439
+				$data['hex'] = $line[1]; // hex
440
+				$data['ident'] = $line[2]; // ident
441
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
+				$data['verticalrate'] = ''; // vertical rate
447
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448
+				$data['emergency'] = ''; // emergency
449
+			$data['datetime'] = date('Y-m-d H:i:s');
450
+			$data['format_source'] = 'deltadbtxt';
451
+				$data['id_source'] = $id_source;
452
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
455
+				$SI->add($data);
456
+			unset($data);
457
+			}
458
+			}
459
+			$last_exec[$id]['last'] = time();
460 460
 	} elseif ($value['format'] == 'aisnmeatxt' && 
461
-	    (
461
+		(
462 462
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
463 463
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
464
-	    )
464
+		)
465 465
 	) {
466
-	    date_default_timezone_set('CET');
467
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468
-	    date_default_timezone_set('UTC');
469
-	    if ($buffer != '') $reset = 0;
470
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
-	    $buffer = explode('\n',$buffer);
472
-	    foreach ($buffer as $line) {
466
+		date_default_timezone_set('CET');
467
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468
+		date_default_timezone_set('UTC');
469
+		if ($buffer != '') $reset = 0;
470
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
+		$buffer = explode('\n',$buffer);
472
+		foreach ($buffer as $line) {
473 473
 		if ($line != '') {
474
-		    //echo "'".$line."'\n";
475
-		    $add = false;
476
-		    $ais_data = $AIS->parse_line(trim($line));
477
-		    $data = array();
478
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
480
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488
-		    if (isset($ais_data['timestamp'])) {
474
+			//echo "'".$line."'\n";
475
+			$add = false;
476
+			$ais_data = $AIS->parse_line(trim($line));
477
+			$data = array();
478
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
480
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488
+			if (isset($ais_data['timestamp'])) {
489 489
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
490 490
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
491
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492
-			    $add = true;
491
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492
+				$add = true;
493 493
 			}
494
-		    } else {
494
+			} else {
495 495
 			$data['datetime'] = date('Y-m-d H:i:s');
496 496
 			$add = true;
497
-		    }
498
-		    $data['format_source'] = 'aisnmeatxt';
499
-    		    $data['id_source'] = $id_source;
500
-		    //print_r($data);
501
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
503
-		    unset($data);
497
+			}
498
+			$data['format_source'] = 'aisnmeatxt';
499
+				$data['id_source'] = $id_source;
500
+			//print_r($data);
501
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
503
+			unset($data);
504 504
 		}
505
-    	    }
506
-    	    $last_exec[$id]['last'] = time();
505
+			}
506
+			$last_exec[$id]['last'] = time();
507 507
 	} elseif ($value['format'] == 'aisnmeahttp') {
508
-	    $arr = $httpfeeds;
509
-	    $w = $e = null;
508
+		$arr = $httpfeeds;
509
+		$w = $e = null;
510 510
 	    
511
-	    if (isset($arr[$id])) {
511
+		if (isset($arr[$id])) {
512 512
 		$nn = stream_select($arr,$w,$e,$timeout);
513 513
 		if ($nn > 0) {
514
-		    foreach ($httpfeeds as $feed) {
514
+			foreach ($httpfeeds as $feed) {
515 515
 			$buffer = stream_get_line($feed,2000,"\n");
516 516
 			if ($buffer === FALSE) {
517
-			    connect_all($globalSources);
517
+				connect_all($globalSources);
518 518
 			}
519 519
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
520 520
 			$buffer = explode('\n',$buffer);
521 521
 			foreach ($buffer as $line) {
522
-			    if ($line != '') {
522
+				if ($line != '') {
523 523
 				$ais_data = $AIS->parse_line(trim($line));
524 524
 				$data = array();
525 525
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -537,117 +537,117 @@  discard block
 block discarded – undo
537 537
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
538 538
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
539 539
 				if (isset($ais_data['timestamp'])) {
540
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
540
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
541 541
 				} else {
542
-				    $data['datetime'] = date('Y-m-d H:i:s');
542
+					$data['datetime'] = date('Y-m-d H:i:s');
543 543
 				}
544 544
 				$data['format_source'] = 'aisnmeahttp';
545 545
 				$data['id_source'] = $id_source;
546 546
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
547 547
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
548 548
 				unset($data);
549
-			    }
549
+				}
550
+			}
550 551
 			}
551
-		    }
552 552
 		} else {
553
-		    $format = $value['format'];
554
-		    if (isset($tt[$format])) $tt[$format]++;
555
-		    else $tt[$format] = 0;
556
-		    if ($tt[$format] > 30) {
553
+			$format = $value['format'];
554
+			if (isset($tt[$format])) $tt[$format]++;
555
+			else $tt[$format] = 0;
556
+			if ($tt[$format] > 30) {
557 557
 			if ($globalDebug) echo 'Reconnect...'."\n";
558 558
 			sleep(2);
559 559
 			//$sourceeen[] = $value;
560 560
 			//connect_all($sourceeen);
561 561
 			//$sourceeen = array();
562 562
 			connect_all($globalSources);
563
-		    }
563
+			}
564
+		}
564 565
 		}
565
-	    }
566 566
 	} elseif ($value['format'] == 'myshiptracking' && 
567
-	    (
567
+		(
568 568
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
569 569
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
570
-	    )
570
+		)
571 571
 	) {
572
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
573
-	    if ($buffer != '') {
572
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
573
+		if ($buffer != '') {
574 574
 		//echo $buffer;
575 575
 		$all_data = json_decode($buffer,true);
576 576
 		//print_r($all_data);
577 577
 		if (isset($all_data[0]['DATA'])) {
578
-		    foreach ($all_data[0]['DATA'] as $line) {
578
+			foreach ($all_data[0]['DATA'] as $line) {
579 579
 			if ($line != '') {
580
-			    $data = array();
581
-			    $data['ident'] = $line['NAME'];
582
-			    $data['mmsi'] = $line['MMSI'];
583
-			    if (strlen($data['mmsi']) > 9) {
580
+				$data = array();
581
+				$data['ident'] = $line['NAME'];
582
+				$data['mmsi'] = $line['MMSI'];
583
+				if (strlen($data['mmsi']) > 9) {
584 584
 				$data['mmsi'] = substr($data['mmsi'],-9);
585
-			    }
586
-			    $data['speed'] = $line['SOG'];
587
-			    $data['heading'] = $line['COG'];
588
-			    $data['latitude'] = $line['LAT'];
589
-			    $data['longitude'] = $line['LNG'];
590
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591
-			    $data['type_id'] = $line['TYPE'];
592
-			    $data['imo'] = $line['IMO'];
593
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
594
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
595
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
596
-			    $data['format_source'] = 'myshiptracking';
597
-			    $data['id_source'] = $id_source;
598
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
599
-			    $MI->add($data);
600
-			    unset($data);
585
+				}
586
+				$data['speed'] = $line['SOG'];
587
+				$data['heading'] = $line['COG'];
588
+				$data['latitude'] = $line['LAT'];
589
+				$data['longitude'] = $line['LNG'];
590
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591
+				$data['type_id'] = $line['TYPE'];
592
+				$data['imo'] = $line['IMO'];
593
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
594
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
595
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
596
+				$data['format_source'] = 'myshiptracking';
597
+				$data['id_source'] = $id_source;
598
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
599
+				$MI->add($data);
600
+				unset($data);
601
+			}
601 602
 			}
602
-		    }
603 603
 		}
604
-	    }
605
-	    $last_exec[$id]['last'] = time();
604
+		}
605
+		$last_exec[$id]['last'] = time();
606 606
 	} elseif ($value['format'] == 'boatbeaconapp' && 
607
-	    (
607
+		(
608 608
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
609 609
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
610
-	    )
610
+		)
611 611
 	) {
612
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
613
-	    if ($buffer != '') {
612
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
613
+		if ($buffer != '') {
614 614
 		$all_data = json_decode($buffer,true);
615 615
 		if (isset($all_data[0]['mmsi'])) {
616
-		    foreach ($all_data as $line) {
616
+			foreach ($all_data as $line) {
617 617
 			if ($line != '') {
618
-			    $data = array();
619
-			    $data['ident'] = $line['shipname'];
620
-			    $data['callsign'] = $line['callsign'];
621
-			    $data['mmsi'] = substr($line['mmsi'],-9);
622
-			    $data['speed'] = $line['sog'];
623
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
624
-			    $data['latitude'] = $line['latitude'];
625
-			    $data['longitude'] = $line['longitude'];
626
-			    $data['type_id'] = $line['shiptype'];
627
-			    $data['arrival_code'] = $line['destination'];
628
-			    $data['datetime'] = $line['time'];
629
-			    $data['format_source'] = 'boatbeaconapp';
630
-			    $data['id_source'] = $id_source;
631
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
632
-			    $MI->add($data);
633
-			    unset($data);
618
+				$data = array();
619
+				$data['ident'] = $line['shipname'];
620
+				$data['callsign'] = $line['callsign'];
621
+				$data['mmsi'] = substr($line['mmsi'],-9);
622
+				$data['speed'] = $line['sog'];
623
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
624
+				$data['latitude'] = $line['latitude'];
625
+				$data['longitude'] = $line['longitude'];
626
+				$data['type_id'] = $line['shiptype'];
627
+				$data['arrival_code'] = $line['destination'];
628
+				$data['datetime'] = $line['time'];
629
+				$data['format_source'] = 'boatbeaconapp';
630
+				$data['id_source'] = $id_source;
631
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
632
+				$MI->add($data);
633
+				unset($data);
634
+			}
634 635
 			}
635
-		    }
636 636
 		}
637 637
 		
638
-	    }
639
-    	    $last_exec[$id]['last'] = time();
638
+		}
639
+			$last_exec[$id]['last'] = time();
640 640
 	} elseif ($value['format'] == 'boatnerd' && 
641
-	    (
641
+		(
642 642
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
643 643
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
644
-	    )
644
+		)
645 645
 	) {
646
-	    $buffer = $Common->getData($value['host']);
647
-	    if ($buffer != '') {
646
+		$buffer = $Common->getData($value['host']);
647
+		if ($buffer != '') {
648 648
 		$all_data = json_decode($buffer,true);
649 649
 		if (isset($all_data['features'][0]['id'])) {
650
-		    foreach ($all_data['features'] as $line) {
650
+			foreach ($all_data['features'] as $line) {
651 651
 			print_r($line);
652 652
 			$data = array();
653 653
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -667,80 +667,80 @@  discard block
 block discarded – undo
667 667
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668 668
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
669 669
 			unset($data);
670
-		    }
670
+			}
671 671
 		}
672 672
 		
673
-	    }
674
-    	    $last_exec[$id]['last'] = time();
673
+		}
674
+			$last_exec[$id]['last'] = time();
675 675
 	} elseif ($value['format'] == 'shipplotter' && 
676
-	    (
676
+		(
677 677
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679
-	    )
679
+		)
680 680
 	) {
681
-	    echo 'download...';
682
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
683
-	    echo 'done !'."\n";
684
-	    // FIXME: Need more work
685
-	    if ($buffer != '') $reset = 0;
686
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
687
-	    $buffer = explode('\n',$buffer);
688
-	    foreach ($buffer as $line) {
681
+		echo 'download...';
682
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
683
+		echo 'done !'."\n";
684
+		// FIXME: Need more work
685
+		if ($buffer != '') $reset = 0;
686
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
687
+		$buffer = explode('\n',$buffer);
688
+		foreach ($buffer as $line) {
689 689
 		if ($line != '') {
690
-		    $data = array();
691
-		    echo $line."\n";
692
-		    $data['mmsi'] = (int)substr($line,0,9);
693
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
694
-		    $data['status_id'] = substr($line,21,2);
695
-		    $data['type_id'] = substr($line,24,3);
696
-		    $data['latitude'] = substr($line,29,9);
697
-		    $data['longitude'] = substr($line,41,9);
698
-		    $data['speed'] = round(substr($line,51,5));
699
-		    //$data['course'] = substr($line,57,5);
700
-		    $data['heading'] = round(substr($line,63,3));
701
-		    //$data['draft'] = substr($line,67,4);
702
-		    //$data['length'] = substr($line,72,3);
703
-		    //$data['beam'] = substr($line,76,2);
704
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
705
-		    //$data['callsign'] = trim(substr($line,100,7);
706
-		    $data['arrival_code'] = substr($line,108,20);
707
-		    //$data['etaDate'] = substr($line,129,5);
708
-		    //$data['etaTime'] = substr($line,135,5);
709
-		    $data['format_source'] = 'shipplotter';
710
-    		    $data['id_source'] = $id_source;
711
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
712
-		    //print_r($data);
713
-		    echo 'Add...'."\n";
714
-		    $MI->add($data);
715
-		    unset($data);
690
+			$data = array();
691
+			echo $line."\n";
692
+			$data['mmsi'] = (int)substr($line,0,9);
693
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
694
+			$data['status_id'] = substr($line,21,2);
695
+			$data['type_id'] = substr($line,24,3);
696
+			$data['latitude'] = substr($line,29,9);
697
+			$data['longitude'] = substr($line,41,9);
698
+			$data['speed'] = round(substr($line,51,5));
699
+			//$data['course'] = substr($line,57,5);
700
+			$data['heading'] = round(substr($line,63,3));
701
+			//$data['draft'] = substr($line,67,4);
702
+			//$data['length'] = substr($line,72,3);
703
+			//$data['beam'] = substr($line,76,2);
704
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
705
+			//$data['callsign'] = trim(substr($line,100,7);
706
+			$data['arrival_code'] = substr($line,108,20);
707
+			//$data['etaDate'] = substr($line,129,5);
708
+			//$data['etaTime'] = substr($line,135,5);
709
+			$data['format_source'] = 'shipplotter';
710
+				$data['id_source'] = $id_source;
711
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
712
+			//print_r($data);
713
+			echo 'Add...'."\n";
714
+			$MI->add($data);
715
+			unset($data);
716 716
 		}
717
-    	    }
718
-    	    $last_exec[$id]['last'] = time();
717
+			}
718
+			$last_exec[$id]['last'] = time();
719 719
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
720 720
 	} elseif (
721
-	    (
721
+		(
722 722
 		$value['format'] == 'whazzup' && 
723 723
 		(
724
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
725
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
724
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
725
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
726 726
 		)
727
-	    ) || (
727
+		) || (
728 728
 		$value['format'] == 'vatsimtxt' && 
729 729
 		(
730
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
731
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
730
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
731
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
732
+		)
732 733
 		)
733
-	    )
734 734
 	) {
735
-	    //$buffer = $Common->getData($hosts[$id]);
736
-	    $buffer = $Common->getData($value['host']);
737
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
738
-	    $buffer = explode('\n',$buffer);
739
-	    $reset = 0;
740
-	    foreach ($buffer as $line) {
741
-    		if ($line != '') {
742
-    		    $line = explode(':', $line);
743
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
735
+		//$buffer = $Common->getData($hosts[$id]);
736
+		$buffer = $Common->getData($value['host']);
737
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
738
+		$buffer = explode('\n',$buffer);
739
+		$reset = 0;
740
+		foreach ($buffer as $line) {
741
+			if ($line != '') {
742
+				$line = explode(':', $line);
743
+				if (count($line) > 30 && $line[0] != 'callsign') {
744 744
 			$data = array();
745 745
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
746 746
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -753,37 +753,37 @@  discard block
 block discarded – undo
753 753
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
754 754
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
755 755
 			$data['latitude'] = $line[5]; // lat
756
-	        	$data['longitude'] = $line[6]; // long
757
-	        	$data['verticalrate'] = ''; // vertical rate
758
-	        	$data['squawk'] = ''; // squawk
759
-	        	$data['emergency'] = ''; // emergency
760
-	        	$data['waypoints'] = $line[30];
756
+				$data['longitude'] = $line[6]; // long
757
+				$data['verticalrate'] = ''; // vertical rate
758
+				$data['squawk'] = ''; // squawk
759
+				$data['emergency'] = ''; // emergency
760
+				$data['waypoints'] = $line[30];
761 761
 			$data['datetime'] = date('Y-m-d H:i:s');
762 762
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
763 763
 			//if (isset($line[37])) $data['last_update'] = $line[37];
764
-		        $data['departure_airport_icao'] = $line[11];
765
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
766
-		        $data['arrival_airport_icao'] = $line[13];
764
+				$data['departure_airport_icao'] = $line[11];
765
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
766
+				$data['arrival_airport_icao'] = $line[13];
767 767
 			$data['frequency'] = $line[4];
768 768
 			$data['type'] = $line[18];
769 769
 			$data['range'] = $line[19];
770 770
 			if (isset($line[35])) $data['info'] = $line[35];
771
-    			$data['id_source'] = $id_source;
772
-	    		//$data['arrival_airport_time'] = ;
773
-	    		if ($line[9] != '') {
774
-	    		    $aircraft_data = explode('/',$line[9]);
775
-	    		    if (isset($aircraft_data[1])) {
776
-	    			$data['aircraft_icao'] = $aircraft_data[1];
777
-	    		    }
778
-        		}
779
-	    		/*
771
+				$data['id_source'] = $id_source;
772
+				//$data['arrival_airport_time'] = ;
773
+				if ($line[9] != '') {
774
+					$aircraft_data = explode('/',$line[9]);
775
+					if (isset($aircraft_data[1])) {
776
+					$data['aircraft_icao'] = $aircraft_data[1];
777
+					}
778
+				}
779
+				/*
780 780
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
781 781
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
782 782
 	    		*/
783
-	    		$data['format_source'] = $value['format'];
783
+				$data['format_source'] = $value['format'];
784 784
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
785 785
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
786
-    			if ($line[3] == 'PILOT') $SI->add($data);
786
+				if ($line[3] == 'PILOT') $SI->add($data);
787 787
 			elseif ($line[3] == 'ATC') {
788 788
 				//print_r($data);
789 789
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -804,21 +804,21 @@  discard block
 block discarded – undo
804 804
 					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']);
805 805
 				}
806 806
 			}
807
-    			unset($data);
808
-    		    }
809
-    		}
810
-    	    }
811
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
812
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
813
-    	    $last_exec[$id]['last'] = time();
814
-    	} elseif ($value['format'] == 'airwhere' && 
815
-    	    (
816
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
817
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
818
-    	    )
819
-    	) {
820
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
821
-	    if ($buffer != '') {
807
+				unset($data);
808
+				}
809
+			}
810
+			}
811
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
812
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
813
+			$last_exec[$id]['last'] = time();
814
+		} elseif ($value['format'] == 'airwhere' && 
815
+			(
816
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
817
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
818
+			)
819
+		) {
820
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
821
+		if ($buffer != '') {
822 822
 		$all_data = simplexml_load_string($buffer);
823 823
 		foreach($all_data->children() as $childdata) {
824 824
 			$data = array();
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
 			$SI->add($data);
841 841
 			unset($data);
842 842
 		}
843
-	    }
844
-	    $Source->deleteOldLocationByType('gs');
845
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
846
-	    if ($buffer != '') {
843
+		}
844
+		$Source->deleteOldLocationByType('gs');
845
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
846
+		if ($buffer != '') {
847 847
 		$all_data = simplexml_load_string($buffer);
848 848
 		foreach($all_data->children() as $childdata) {
849 849
 			$data = array();
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 			}
862 862
 			unset($data);
863 863
 		}
864
-	    }
865
-	    $last_exec[$id]['last'] = time();
864
+		}
865
+		$last_exec[$id]['last'] = time();
866 866
 	/*
867 867
 	} if ($value['format'] == 'aircraftlistjson') {
868 868
 	    print_r($globalSources);
@@ -870,17 +870,17 @@  discard block
 block discarded – undo
870 870
 	    echo $globalMinFetch;
871 871
 	*/
872 872
 	} elseif ($value['format'] == 'aircraftlistjson' && 
873
-	    (
873
+		(
874 874
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
875 875
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
876
-	    )
876
+		)
877 877
 	) {
878
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
879
-	    if ($buffer != '') {
880
-	        $all_data = json_decode($buffer,true);
878
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
879
+		if ($buffer != '') {
880
+			$all_data = json_decode($buffer,true);
881 881
 		if (isset($all_data['acList'])) {
882
-		    $reset = 0;
883
-		    foreach ($all_data['acList'] as $line) {
882
+			$reset = 0;
883
+			foreach ($all_data['acList'] as $line) {
884 884
 			$data = array();
885 885
 			$data['hex'] = $line['Icao']; // hex
886 886
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -903,10 +903,10 @@  discard block
 block discarded – undo
903 903
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
904 904
 			if (isset($data['latitude'])) $SI->add($data);
905 905
 			unset($data);
906
-		    }
906
+			}
907 907
 		} elseif (is_array($all_data)) {
908
-		    $reset = 0;
909
-		    foreach ($all_data as $line) {
908
+			$reset = 0;
909
+			foreach ($all_data as $line) {
910 910
 			$data = array();
911 911
 			$data['hex'] = $line['hex']; // hex
912 912
 			$data['ident'] = $line['flight']; // ident
@@ -926,218 +926,218 @@  discard block
 block discarded – undo
926 926
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
927 927
 			$SI->add($data);
928 928
 			unset($data);
929
-		    }
929
+			}
930 930
 		}
931
-	    } elseif ($globalDebug) echo 'No data'."\n";
932
-    	    //$last_exec['aircraftlistjson'] = time();
933
-    	    $last_exec[$id]['last'] = time();
934
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
935
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
936
-    	    (
937
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
938
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
939
-    	    )
940
-    	) {
941
-	    $buffer = $Common->getData($value['host']);
942
-	    $all_data = json_decode($buffer,true);
943
-	    if (isset($all_data['planes'])) {
931
+		} elseif ($globalDebug) echo 'No data'."\n";
932
+			//$last_exec['aircraftlistjson'] = time();
933
+			$last_exec[$id]['last'] = time();
934
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
935
+		} elseif ($value['format'] == 'planeupdatefaa' && 
936
+			(
937
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
938
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
939
+			)
940
+		) {
941
+		$buffer = $Common->getData($value['host']);
942
+		$all_data = json_decode($buffer,true);
943
+		if (isset($all_data['planes'])) {
944 944
 		$reset = 0;
945 945
 		foreach ($all_data['planes'] as $key => $line) {
946
-		    $data = array();
947
-		    $data['hex'] = $key; // hex
948
-		    $data['ident'] = $line[3]; // ident
949
-		    $data['altitude'] = $line[6]; // altitude
950
-		    $data['speed'] = $line[8]; // speed
951
-		    $data['heading'] = $line[7]; // heading
952
-		    $data['latitude'] = $line[4]; // lat
953
-		    $data['longitude'] = $line[5]; // long
954
-		    //$data['verticalrate'] = $line[]; // verticale rate
955
-		    $data['squawk'] = $line[10]; // squawk
956
-		    $data['emergency'] = ''; // emergency
957
-		    $data['registration'] = $line[2];
958
-		    $data['aircraft_icao'] = $line[0];
959
-		    $deparr = explode('-',$line[1]);
960
-		    if (count($deparr) == 2) {
946
+			$data = array();
947
+			$data['hex'] = $key; // hex
948
+			$data['ident'] = $line[3]; // ident
949
+			$data['altitude'] = $line[6]; // altitude
950
+			$data['speed'] = $line[8]; // speed
951
+			$data['heading'] = $line[7]; // heading
952
+			$data['latitude'] = $line[4]; // lat
953
+			$data['longitude'] = $line[5]; // long
954
+			//$data['verticalrate'] = $line[]; // verticale rate
955
+			$data['squawk'] = $line[10]; // squawk
956
+			$data['emergency'] = ''; // emergency
957
+			$data['registration'] = $line[2];
958
+			$data['aircraft_icao'] = $line[0];
959
+			$deparr = explode('-',$line[1]);
960
+			if (count($deparr) == 2) {
961 961
 			$data['departure_airport_icao'] = $deparr[0];
962 962
 			$data['arrival_airport_icao'] = $deparr[1];
963
-		    }
964
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
965
-	    	    $data['format_source'] = 'planeupdatefaa';
966
-    		    $data['id_source'] = $id_source;
967
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
968
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
969
-		    $SI->add($data);
970
-		    unset($data);
963
+			}
964
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
965
+				$data['format_source'] = 'planeupdatefaa';
966
+				$data['id_source'] = $id_source;
967
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
968
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
969
+			$SI->add($data);
970
+			unset($data);
971
+		}
971 972
 		}
972
-	    }
973
-	    //$last_exec['planeupdatefaa'] = time();
974
-	    $last_exec[$id]['last'] = time();
973
+		//$last_exec['planeupdatefaa'] = time();
974
+		$last_exec[$id]['last'] = time();
975 975
 	} elseif ($value['format'] == 'opensky' && 
976
-	    (
976
+		(
977 977
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
978 978
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
979
-	    )
979
+		)
980 980
 	) {
981
-	    $buffer = $Common->getData($value['host']);
982
-	    $all_data = json_decode($buffer,true);
983
-	    if (isset($all_data['states'])) {
981
+		$buffer = $Common->getData($value['host']);
982
+		$all_data = json_decode($buffer,true);
983
+		if (isset($all_data['states'])) {
984 984
 		$reset = 0;
985 985
 		foreach ($all_data['states'] as $key => $line) {
986
-		    $data = array();
987
-		    $data['hex'] = $line[0]; // hex
988
-		    $data['ident'] = trim($line[1]); // ident
989
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
990
-		    $data['speed'] = round($line[9]*1.94384); // speed
991
-		    $data['heading'] = round($line[10]); // heading
992
-		    $data['latitude'] = $line[6]; // lat
993
-		    $data['longitude'] = $line[5]; // long
994
-		    $data['verticalrate'] = $line[11]; // verticale rate
995
-		    //$data['squawk'] = $line[10]; // squawk
996
-		    //$data['emergency'] = ''; // emergency
997
-		    //$data['registration'] = $line[2];
998
-		    //$data['aircraft_icao'] = $line[0];
999
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1000
-		    $data['format_source'] = 'opensky';
1001
-		    $data['id_source'] = $id_source;
1002
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1003
-		    $SI->add($data);
1004
-		    unset($data);
986
+			$data = array();
987
+			$data['hex'] = $line[0]; // hex
988
+			$data['ident'] = trim($line[1]); // ident
989
+			$data['altitude'] = round($line[7]*3.28084); // altitude
990
+			$data['speed'] = round($line[9]*1.94384); // speed
991
+			$data['heading'] = round($line[10]); // heading
992
+			$data['latitude'] = $line[6]; // lat
993
+			$data['longitude'] = $line[5]; // long
994
+			$data['verticalrate'] = $line[11]; // verticale rate
995
+			//$data['squawk'] = $line[10]; // squawk
996
+			//$data['emergency'] = ''; // emergency
997
+			//$data['registration'] = $line[2];
998
+			//$data['aircraft_icao'] = $line[0];
999
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1000
+			$data['format_source'] = 'opensky';
1001
+			$data['id_source'] = $id_source;
1002
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1003
+			$SI->add($data);
1004
+			unset($data);
1005
+		}
1005 1006
 		}
1006
-	    }
1007
-	    //$last_exec['planeupdatefaa'] = time();
1008
-	    $last_exec[$id]['last'] = time();
1007
+		//$last_exec['planeupdatefaa'] = time();
1008
+		$last_exec[$id]['last'] = time();
1009 1009
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1010 1010
 	} elseif ($value['format'] == 'fr24json' && 
1011
-	    (
1011
+		(
1012 1012
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1013 1013
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1014
-	    )
1014
+		)
1015 1015
 	) {
1016
-	    //$buffer = $Common->getData($hosts[$id]);
1017
-	    $buffer = $Common->getData($value['host']);
1018
-	    $all_data = json_decode($buffer,true);
1019
-	    if (!empty($all_data)) $reset = 0;
1020
-	    foreach ($all_data as $key => $line) {
1016
+		//$buffer = $Common->getData($hosts[$id]);
1017
+		$buffer = $Common->getData($value['host']);
1018
+		$all_data = json_decode($buffer,true);
1019
+		if (!empty($all_data)) $reset = 0;
1020
+		foreach ($all_data as $key => $line) {
1021 1021
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1022
-		    $data = array();
1023
-		    $data['hex'] = $line[0];
1024
-		    $data['ident'] = $line[16]; //$line[13]
1025
-	    	    $data['altitude'] = $line[4]; // altitude
1026
-	    	    $data['speed'] = $line[5]; // speed
1027
-	    	    $data['heading'] = $line[3]; // heading
1028
-	    	    $data['latitude'] = $line[1]; // lat
1029
-	    	    $data['longitude'] = $line[2]; // long
1030
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1031
-	    	    $data['squawk'] = $line[6]; // squawk
1032
-	    	    $data['aircraft_icao'] = $line[8];
1033
-	    	    $data['registration'] = $line[9];
1034
-		    $data['departure_airport_iata'] = $line[11];
1035
-		    $data['arrival_airport_iata'] = $line[12];
1036
-	    	    $data['emergency'] = ''; // emergency
1037
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1038
-	    	    $data['format_source'] = 'fr24json';
1039
-    		    $data['id_source'] = $id_source;
1040
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1041
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1042
-		    $SI->add($data);
1043
-		    unset($data);
1022
+			$data = array();
1023
+			$data['hex'] = $line[0];
1024
+			$data['ident'] = $line[16]; //$line[13]
1025
+				$data['altitude'] = $line[4]; // altitude
1026
+				$data['speed'] = $line[5]; // speed
1027
+				$data['heading'] = $line[3]; // heading
1028
+				$data['latitude'] = $line[1]; // lat
1029
+				$data['longitude'] = $line[2]; // long
1030
+				$data['verticalrate'] = $line[15]; // verticale rate
1031
+				$data['squawk'] = $line[6]; // squawk
1032
+				$data['aircraft_icao'] = $line[8];
1033
+				$data['registration'] = $line[9];
1034
+			$data['departure_airport_iata'] = $line[11];
1035
+			$data['arrival_airport_iata'] = $line[12];
1036
+				$data['emergency'] = ''; // emergency
1037
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1038
+				$data['format_source'] = 'fr24json';
1039
+				$data['id_source'] = $id_source;
1040
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1041
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1042
+			$SI->add($data);
1043
+			unset($data);
1044 1044
 		}
1045
-	    }
1046
-	    //$last_exec['fr24json'] = time();
1047
-	    $last_exec[$id]['last'] = time();
1045
+		}
1046
+		//$last_exec['fr24json'] = time();
1047
+		$last_exec[$id]['last'] = time();
1048 1048
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1049 1049
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1050
-	    (
1050
+		(
1051 1051
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1052 1052
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1053
-	    )
1053
+		)
1054 1054
 	) {
1055
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1056
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1057
-	    //echo $buffer;
1058
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1059
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1060
-	    $all_data = json_decode($buffer,true);
1061
-	    if (json_last_error() != JSON_ERROR_NONE) {
1055
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1056
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1057
+		//echo $buffer;
1058
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1059
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1060
+		$all_data = json_decode($buffer,true);
1061
+		if (json_last_error() != JSON_ERROR_NONE) {
1062 1062
 		die(json_last_error_msg());
1063
-	    }
1064
-	    if (isset($all_data['mrkrs'])) {
1063
+		}
1064
+		if (isset($all_data['mrkrs'])) {
1065 1065
 		$reset = 0;
1066 1066
 		foreach ($all_data['mrkrs'] as $key => $line) {
1067
-		    if (isset($line['inf'])) {
1067
+			if (isset($line['inf'])) {
1068 1068
 			$data = array();
1069 1069
 			$data['hex'] = $line['inf']['ia'];
1070 1070
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1071
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1072
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1073
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1074
-	    		$data['latitude'] = $line['pt'][0]; // lat
1075
-	    		$data['longitude'] = $line['pt'][1]; // long
1076
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1077
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1078
-	    		//$data['aircraft_icao'] = $line[8];
1079
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1071
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1072
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1073
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1074
+				$data['latitude'] = $line['pt'][0]; // lat
1075
+				$data['longitude'] = $line['pt'][1]; // long
1076
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1077
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1078
+				//$data['aircraft_icao'] = $line[8];
1079
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1080 1080
 			//$data['departure_airport_iata'] = $line[11];
1081 1081
 			//$data['arrival_airport_iata'] = $line[12];
1082
-	    		//$data['emergency'] = ''; // emergency
1082
+				//$data['emergency'] = ''; // emergency
1083 1083
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1084
-	    		$data['format_source'] = 'radarvirtueljson';
1085
-    			$data['id_source'] = $id_source;
1084
+				$data['format_source'] = 'radarvirtueljson';
1085
+				$data['id_source'] = $id_source;
1086 1086
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087 1087
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088 1088
 			$SI->add($data);
1089 1089
 			unset($data);
1090
-		    }
1090
+			}
1091 1091
 		}
1092
-	    }
1093
-	    //$last_exec['radarvirtueljson'] = time();
1094
-	    $last_exec[$id]['last'] = time();
1092
+		}
1093
+		//$last_exec['radarvirtueljson'] = time();
1094
+		$last_exec[$id]['last'] = time();
1095 1095
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1096 1096
 	} elseif ($value['format'] == 'pirepsjson' && 
1097
-	    (
1097
+		(
1098 1098
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1099 1099
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1100
-	    )
1100
+		)
1101 1101
 	) {
1102
-	    //$buffer = $Common->getData($hosts[$id]);
1103
-	    $buffer = $Common->getData($value['host'].'?'.time());
1104
-	    $all_data = json_decode(utf8_encode($buffer),true);
1102
+		//$buffer = $Common->getData($hosts[$id]);
1103
+		$buffer = $Common->getData($value['host'].'?'.time());
1104
+		$all_data = json_decode(utf8_encode($buffer),true);
1105 1105
 	    
1106
-	    if (isset($all_data['pireps'])) {
1106
+		if (isset($all_data['pireps'])) {
1107 1107
 		$reset = 0;
1108
-	        foreach ($all_data['pireps'] as $line) {
1109
-		    $data = array();
1110
-		    $data['id'] = $line['id'];
1111
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1112
-		    $data['ident'] = $line['callsign']; // ident
1113
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1114
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1115
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1116
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1117
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1118
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1119
-		    $data['latitude'] = $line['lat']; // lat
1120
-		    $data['longitude'] = $line['lon']; // long
1121
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1122
-		    //$data['squawk'] = $line['squawk']; // squawk
1123
-		    //$data['emergency'] = ''; // emergency
1124
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1125
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1126
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1127
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1128
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1129
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1130
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1131
-		    else $data['info'] = '';
1132
-		    $data['format_source'] = 'pireps';
1133
-    		    $data['id_source'] = $id_source;
1134
-		    $data['datetime'] = date('Y-m-d H:i:s');
1135
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1136
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1137
-		    if ($line['icon'] == 'plane') {
1108
+			foreach ($all_data['pireps'] as $line) {
1109
+			$data = array();
1110
+			$data['id'] = $line['id'];
1111
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1112
+			$data['ident'] = $line['callsign']; // ident
1113
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1114
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1115
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1116
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1117
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1118
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1119
+			$data['latitude'] = $line['lat']; // lat
1120
+			$data['longitude'] = $line['lon']; // long
1121
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1122
+			//$data['squawk'] = $line['squawk']; // squawk
1123
+			//$data['emergency'] = ''; // emergency
1124
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1125
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1126
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1127
+			//$data['arrival_airport_time'] = $line['arrtime'];
1128
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1129
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1130
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1131
+			else $data['info'] = '';
1132
+			$data['format_source'] = 'pireps';
1133
+				$data['id_source'] = $id_source;
1134
+			$data['datetime'] = date('Y-m-d H:i:s');
1135
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1136
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1137
+			if ($line['icon'] == 'plane') {
1138 1138
 			$SI->add($data);
1139
-		    //    print_r($data);
1140
-    		    } elseif ($line['icon'] == 'ct') {
1139
+			//    print_r($data);
1140
+				} elseif ($line['icon'] == 'ct') {
1141 1141
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1142 1142
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1143 1143
 			$typec = substr($data['ident'],-3);
@@ -1152,209 +1152,209 @@  discard block
 block discarded – undo
1152 1152
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1153 1153
 			else $data['type'] = 'Observer';
1154 1154
 			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']);
1155
-		    }
1156
-		    unset($data);
1155
+			}
1156
+			unset($data);
1157
+		}
1157 1158
 		}
1158
-	    }
1159
-	    //$last_exec['pirepsjson'] = time();
1160
-	    $last_exec[$id]['last'] = time();
1159
+		//$last_exec['pirepsjson'] = time();
1160
+		$last_exec[$id]['last'] = time();
1161 1161
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1162 1162
 	} elseif ($value['format'] == 'phpvmacars' && 
1163
-	    (
1163
+		(
1164 1164
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1165 1165
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1166
-	    )
1166
+		)
1167 1167
 	) {
1168
-	    //$buffer = $Common->getData($hosts[$id]);
1169
-	    if ($globalDebug) echo 'Get Data...'."\n";
1170
-	    $buffer = $Common->getData($value['host']);
1171
-	    $all_data = json_decode($buffer,true);
1172
-	    if ($buffer != '' && is_array($all_data)) {
1168
+		//$buffer = $Common->getData($hosts[$id]);
1169
+		if ($globalDebug) echo 'Get Data...'."\n";
1170
+		$buffer = $Common->getData($value['host']);
1171
+		$all_data = json_decode($buffer,true);
1172
+		if ($buffer != '' && is_array($all_data)) {
1173 1173
 		$reset = 0;
1174 1174
 		foreach ($all_data as $line) {
1175
-	    	    $data = array();
1176
-	    	    //$data['id'] = $line['id']; // id not usable
1177
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1178
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1179
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1180
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1181
-	    	    $data['ident'] = $line['flightnum']; // ident
1182
-	    	    $data['altitude'] = $line['alt']; // altitude
1183
-	    	    $data['speed'] = $line['gs']; // speed
1184
-	    	    $data['heading'] = $line['heading']; // heading
1185
-	    	    $data['latitude'] = $line['lat']; // lat
1186
-	    	    $data['longitude'] = $line['lng']; // long
1187
-	    	    $data['verticalrate'] = ''; // verticale rate
1188
-	    	    $data['squawk'] = ''; // squawk
1189
-	    	    $data['emergency'] = ''; // emergency
1190
-	    	    //$data['datetime'] = $line['lastupdate'];
1191
-	    	    //$data['last_update'] = $line['lastupdate'];
1192
-	    	    if (isset($value['timezone'])) {
1193
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1194
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1195
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1196
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1197
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1198
-	    	    $data['departure_airport_time'] = $line['deptime'];
1199
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1200
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1201
-    		    if (isset($line['registration'])) {
1202
-    			$data['registration'] = $line['registration'];
1203
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1204
-    		    } else $data['registration'] = $line['aircraft'];
1205
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1206
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1207
-		    if (isset($line['aircraftname'])) {
1175
+				$data = array();
1176
+				//$data['id'] = $line['id']; // id not usable
1177
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1178
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1179
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1180
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1181
+				$data['ident'] = $line['flightnum']; // ident
1182
+				$data['altitude'] = $line['alt']; // altitude
1183
+				$data['speed'] = $line['gs']; // speed
1184
+				$data['heading'] = $line['heading']; // heading
1185
+				$data['latitude'] = $line['lat']; // lat
1186
+				$data['longitude'] = $line['lng']; // long
1187
+				$data['verticalrate'] = ''; // verticale rate
1188
+				$data['squawk'] = ''; // squawk
1189
+				$data['emergency'] = ''; // emergency
1190
+				//$data['datetime'] = $line['lastupdate'];
1191
+				//$data['last_update'] = $line['lastupdate'];
1192
+				if (isset($value['timezone'])) {
1193
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1194
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1195
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1196
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1197
+				$data['departure_airport_icao'] = $line['depicao'];
1198
+				$data['departure_airport_time'] = $line['deptime'];
1199
+				$data['arrival_airport_icao'] = $line['arricao'];
1200
+				$data['arrival_airport_time'] = $line['arrtime'];
1201
+				if (isset($line['registration'])) {
1202
+				$data['registration'] = $line['registration'];
1203
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1204
+				} else $data['registration'] = $line['aircraft'];
1205
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1206
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1207
+			if (isset($line['aircraftname'])) {
1208 1208
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1209 1209
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1210
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1211
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1212
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1213
-	    		else {
1214
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1215
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1216
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1217
-	    		}
1218
-	    	    }
1219
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1220
-    		    $data['id_source'] = $id_source;
1221
-	    	    $data['format_source'] = 'phpvmacars';
1222
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1223
-		    $SI->add($data);
1224
-		    unset($data);
1210
+				$aircraft_data = explode('-',$line['aircraftname']);
1211
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1212
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1213
+				else {
1214
+					$aircraft_data = explode(' ',$line['aircraftname']);
1215
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1216
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1217
+				}
1218
+				}
1219
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1220
+				$data['id_source'] = $id_source;
1221
+				$data['format_source'] = 'phpvmacars';
1222
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1223
+			$SI->add($data);
1224
+			unset($data);
1225 1225
 		}
1226 1226
 		if ($globalDebug) echo 'No more data...'."\n";
1227 1227
 		unset($buffer);
1228 1228
 		unset($all_data);
1229
-	    }
1230
-	    //$last_exec['phpvmacars'] = time();
1231
-	    $last_exec[$id]['last'] = time();
1229
+		}
1230
+		//$last_exec['phpvmacars'] = time();
1231
+		$last_exec[$id]['last'] = time();
1232 1232
 	} elseif ($value['format'] == 'vaos' && 
1233
-	    (
1233
+		(
1234 1234
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1235 1235
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1236
-	    )
1236
+		)
1237 1237
 	) {
1238
-	    //$buffer = $Common->getData($hosts[$id]);
1239
-	    if ($globalDebug) echo 'Get Data...'."\n";
1240
-	    $buffer = $Common->getData($value['host']);
1241
-	    $all_data = json_decode($buffer,true);
1242
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1238
+		//$buffer = $Common->getData($hosts[$id]);
1239
+		if ($globalDebug) echo 'Get Data...'."\n";
1240
+		$buffer = $Common->getData($value['host']);
1241
+		$all_data = json_decode($buffer,true);
1242
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1243 1243
 		$reset = 0;
1244 1244
 		foreach ($all_data['ACARSData'] as $line) {
1245
-		    //print_r($line);
1246
-	    	    $data = array();
1247
-	    	    //$data['id'] = $line['id']; // id not usable
1248
-	    	    $data['id'] = $line['id'];
1249
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1250
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1251
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1252
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1253
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1254
-	    	    $data['altitude'] = $line['altitude']; // altitude
1255
-	    	    $data['speed'] = $line['groundspeed']; // speed
1256
-	    	    $data['heading'] = $line['heading']; // heading
1257
-	    	    $data['latitude'] = $line['lat']; // lat
1258
-	    	    $data['longitude'] = $line['lon']; // long
1259
-	    	    //$data['verticalrate'] = ''; // verticale rate
1260
-	    	    //$data['squawk'] = ''; // squawk
1261
-	    	    //$data['emergency'] = ''; // emergency
1262
-	    	    if (isset($value['timezone'])) {
1263
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1264
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1265
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1266
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1245
+			//print_r($line);
1246
+				$data = array();
1247
+				//$data['id'] = $line['id']; // id not usable
1248
+				$data['id'] = $line['id'];
1249
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1250
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1251
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1252
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1253
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1254
+				$data['altitude'] = $line['altitude']; // altitude
1255
+				$data['speed'] = $line['groundspeed']; // speed
1256
+				$data['heading'] = $line['heading']; // heading
1257
+				$data['latitude'] = $line['lat']; // lat
1258
+				$data['longitude'] = $line['lon']; // long
1259
+				//$data['verticalrate'] = ''; // verticale rate
1260
+				//$data['squawk'] = ''; // squawk
1261
+				//$data['emergency'] = ''; // emergency
1262
+				if (isset($value['timezone'])) {
1263
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1264
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1265
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1266
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1267 1267
 	    	    
1268
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1269
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1270
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1271
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1272
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1268
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1269
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1270
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1271
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1272
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1273 1273
 
1274
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1275
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1276
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1274
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1275
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1276
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1277 1277
 
1278
-    		    $data['id_source'] = $id_source;
1279
-	    	    $data['format_source'] = 'vaos';
1280
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1281
-		    $SI->add($data);
1282
-		    unset($data);
1278
+				$data['id_source'] = $id_source;
1279
+				$data['format_source'] = 'vaos';
1280
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1281
+			$SI->add($data);
1282
+			unset($data);
1283 1283
 		}
1284 1284
 		if ($globalDebug) echo 'No more data...'."\n";
1285 1285
 		unset($buffer);
1286 1286
 		unset($all_data);
1287
-	    }
1288
-	    //$last_exec['phpvmacars'] = time();
1289
-	    $last_exec[$id]['last'] = time();
1287
+		}
1288
+		//$last_exec['phpvmacars'] = time();
1289
+		$last_exec[$id]['last'] = time();
1290 1290
 	} elseif ($value['format'] == 'vam' && 
1291
-	    (
1291
+		(
1292 1292
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1293 1293
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1294
-	    )
1294
+		)
1295 1295
 	) {
1296
-	    //$buffer = $Common->getData($hosts[$id]);
1297
-	    if ($globalDebug) echo 'Get Data...'."\n";
1298
-	    $buffer = $Common->getData($value['host']);
1299
-	    $all_data = json_decode($buffer,true);
1300
-	    if ($buffer != '' && is_array($all_data)) {
1296
+		//$buffer = $Common->getData($hosts[$id]);
1297
+		if ($globalDebug) echo 'Get Data...'."\n";
1298
+		$buffer = $Common->getData($value['host']);
1299
+		$all_data = json_decode($buffer,true);
1300
+		if ($buffer != '' && is_array($all_data)) {
1301 1301
 		$reset = 0;
1302 1302
 		foreach ($all_data as $line) {
1303
-	    	    $data = array();
1304
-	    	    //$data['id'] = $line['id']; // id not usable
1305
-	    	    $data['id'] = trim($line['flight_id']);
1306
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1307
-	    	    $data['pilot_name'] = $line['pilot_name'];
1308
-	    	    $data['pilot_id'] = $line['pilot_id'];
1309
-	    	    $data['ident'] = trim($line['callsign']); // ident
1310
-	    	    $data['altitude'] = $line['altitude']; // altitude
1311
-	    	    $data['speed'] = $line['gs']; // speed
1312
-	    	    $data['heading'] = $line['heading']; // heading
1313
-	    	    $data['latitude'] = $line['latitude']; // lat
1314
-	    	    $data['longitude'] = $line['longitude']; // long
1315
-	    	    $data['verticalrate'] = ''; // verticale rate
1316
-	    	    $data['squawk'] = ''; // squawk
1317
-	    	    $data['emergency'] = ''; // emergency
1318
-	    	    //$data['datetime'] = $line['lastupdate'];
1319
-	    	    $data['last_update'] = $line['last_update'];
1320
-		    $data['datetime'] = date('Y-m-d H:i:s');
1321
-	    	    $data['departure_airport_icao'] = $line['departure'];
1322
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1323
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1324
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1325
-    		    //$data['registration'] = $line['aircraft'];
1326
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1327
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1328
-    		    $data['id_source'] = $id_source;
1329
-	    	    $data['format_source'] = 'vam';
1330
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1331
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1332
-		    $SI->add($data);
1333
-		    unset($data);
1303
+				$data = array();
1304
+				//$data['id'] = $line['id']; // id not usable
1305
+				$data['id'] = trim($line['flight_id']);
1306
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1307
+				$data['pilot_name'] = $line['pilot_name'];
1308
+				$data['pilot_id'] = $line['pilot_id'];
1309
+				$data['ident'] = trim($line['callsign']); // ident
1310
+				$data['altitude'] = $line['altitude']; // altitude
1311
+				$data['speed'] = $line['gs']; // speed
1312
+				$data['heading'] = $line['heading']; // heading
1313
+				$data['latitude'] = $line['latitude']; // lat
1314
+				$data['longitude'] = $line['longitude']; // long
1315
+				$data['verticalrate'] = ''; // verticale rate
1316
+				$data['squawk'] = ''; // squawk
1317
+				$data['emergency'] = ''; // emergency
1318
+				//$data['datetime'] = $line['lastupdate'];
1319
+				$data['last_update'] = $line['last_update'];
1320
+			$data['datetime'] = date('Y-m-d H:i:s');
1321
+				$data['departure_airport_icao'] = $line['departure'];
1322
+				//$data['departure_airport_time'] = $line['departure_time'];
1323
+				$data['arrival_airport_icao'] = $line['arrival'];
1324
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1325
+				//$data['registration'] = $line['aircraft'];
1326
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1327
+				$data['aircraft_icao'] = $line['plane_type'];
1328
+				$data['id_source'] = $id_source;
1329
+				$data['format_source'] = 'vam';
1330
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1331
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1332
+			$SI->add($data);
1333
+			unset($data);
1334 1334
 		}
1335 1335
 		if ($globalDebug) echo 'No more data...'."\n";
1336 1336
 		unset($buffer);
1337 1337
 		unset($all_data);
1338
-	    }
1339
-	    //$last_exec['phpvmacars'] = time();
1340
-	    $last_exec[$id]['last'] = time();
1338
+		}
1339
+		//$last_exec['phpvmacars'] = time();
1340
+		$last_exec[$id]['last'] = time();
1341 1341
 	} elseif ($value['format'] == 'blitzortung' && 
1342
-	    (
1342
+		(
1343 1343
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1344 1344
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1345
-	    )
1345
+		)
1346 1346
 	) {
1347
-	    //$buffer = $Common->getData($hosts[$id]);
1348
-	    if ($globalDebug) echo 'Get Data...'."\n";
1349
-	    $buffer = $Common->getData($value['host']);
1350
-	    $all_data = json_decode($buffer,true);
1351
-	    if ($buffer != '') {
1347
+		//$buffer = $Common->getData($hosts[$id]);
1348
+		if ($globalDebug) echo 'Get Data...'."\n";
1349
+		$buffer = $Common->getData($value['host']);
1350
+		$all_data = json_decode($buffer,true);
1351
+		if ($buffer != '') {
1352 1352
 		$Source->deleteLocationBySource('blitzortung');
1353 1353
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1354 1354
 		$buffer = explode('\n',$buffer);
1355 1355
 		foreach ($buffer as $buffer_line) {
1356
-		    $line = json_decode($buffer_line,true);
1357
-		    if (isset($line['time'])) {
1356
+			$line = json_decode($buffer_line,true);
1357
+			if (isset($line['time'])) {
1358 1358
 			$data = array();
1359 1359
 			$data['altitude'] = $line['alt']; // altitude
1360 1360
 			$data['latitude'] = $line['lat']; // lat
@@ -1366,96 +1366,96 @@  discard block
 block discarded – undo
1366 1366
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1367 1367
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1368 1368
 			unset($data);
1369
-		    }
1369
+			}
1370 1370
 		}
1371 1371
 		if ($globalDebug) echo 'No more data...'."\n";
1372 1372
 		unset($buffer);
1373
-	    }
1374
-	    $last_exec[$id]['last'] = time();
1373
+		}
1374
+		$last_exec[$id]['last'] = time();
1375 1375
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1376 1376
 	} 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') {
1377
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1378
-    	    //$last_exec[$id]['last'] = time();
1377
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1378
+			//$last_exec[$id]['last'] = time();
1379 1379
 
1380
-	    //$read = array( $sockets[$id] );
1381
-	    $read = $sockets;
1382
-	    $write = NULL;
1383
-	    $e = NULL;
1384
-	    $n = socket_select($read, $write, $e, $timeout);
1385
-	    if ($e != NULL) var_dump($e);
1386
-	    if ($n > 0) {
1380
+		//$read = array( $sockets[$id] );
1381
+		$read = $sockets;
1382
+		$write = NULL;
1383
+		$e = NULL;
1384
+		$n = socket_select($read, $write, $e, $timeout);
1385
+		if ($e != NULL) var_dump($e);
1386
+		if ($n > 0) {
1387 1387
 		$reset = 0;
1388 1388
 		foreach ($read as $nb => $r) {
1389
-		    //$value = $formats[$nb];
1390
-		    $format = $globalSources[$nb]['format'];
1391
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1389
+			//$value = $formats[$nb];
1390
+			$format = $globalSources[$nb]['format'];
1391
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1392 1392
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1393
-		    } elseif ($format == 'vrstcp') {
1393
+			} elseif ($format == 'vrstcp') {
1394 1394
 			$buffer = @socket_read($r, 6000);
1395
-		    } else {
1395
+			} else {
1396 1396
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1397
-		    }
1398
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1399
-		    //echo $buffer."\n";
1400
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1401
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1402
-		    $error = false;
1403
-		    //$SI::del();
1404
-		    if ($buffer !== FALSE) {
1397
+			}
1398
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1399
+			//echo $buffer."\n";
1400
+			// lets play nice and handle signals such as ctrl-c/kill properly
1401
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1402
+			$error = false;
1403
+			//$SI::del();
1404
+			if ($buffer !== FALSE) {
1405 1405
 			if ($format == 'vrstcp') {
1406
-			    $buffer = explode('},{',$buffer);
1406
+				$buffer = explode('},{',$buffer);
1407 1407
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1408
-		    }
1409
-		    // SBS format is CSV format
1410
-		    if ($buffer !== FALSE && $buffer !== '') {
1408
+			}
1409
+			// SBS format is CSV format
1410
+			if ($buffer !== FALSE && $buffer !== '') {
1411 1411
 			$tt[$format] = 0;
1412 1412
 			if ($format == 'acarssbs3') {
1413
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1414
-			    $ACARS->add(trim($buffer));
1415
-			    $ACARS->deleteLiveAcarsData();
1413
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1414
+				$ACARS->add(trim($buffer));
1415
+				$ACARS->deleteLiveAcarsData();
1416 1416
 			} elseif ($format == 'raw') {
1417
-			    // AVR format
1418
-			    $data = $SBS->parse($buffer);
1419
-			    if (is_array($data)) {
1417
+				// AVR format
1418
+				$data = $SBS->parse($buffer);
1419
+				if (is_array($data)) {
1420 1420
 				$data['datetime'] = date('Y-m-d H:i:s');
1421 1421
 				$data['format_source'] = 'raw';
1422 1422
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1423 1423
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1424 1424
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1425 1425
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1426
-			    }
1426
+				}
1427 1427
 			} elseif ($format == 'ais') {
1428
-			    $ais_data = $AIS->parse_line(trim($buffer));
1429
-			    $data = array();
1430
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1431
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1432
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1433
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1434
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1435
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1436
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1437
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1438
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1439
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1440
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1441
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1442
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1443
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1444
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1445
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1428
+				$ais_data = $AIS->parse_line(trim($buffer));
1429
+				$data = array();
1430
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1431
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1432
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1433
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1434
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1435
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1436
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1437
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1438
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1439
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1440
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1441
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1442
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1443
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1444
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1445
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1446 1446
 
1447
-			    if (isset($ais_data['timestamp'])) {
1447
+				if (isset($ais_data['timestamp'])) {
1448 1448
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1449
-			    } else {
1449
+				} else {
1450 1450
 				$data['datetime'] = date('Y-m-d H:i:s');
1451
-			    }
1452
-			    $data['format_source'] = 'aisnmea';
1453
-    			    $data['id_source'] = $id_source;
1454
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1455
-			    unset($data);
1456
-                        } elseif ($format == 'flightgearsp') {
1457
-                    	    //echo $buffer."\n";
1458
-                    	    if (strlen($buffer) > 5) {
1451
+				}
1452
+				$data['format_source'] = 'aisnmea';
1453
+					$data['id_source'] = $id_source;
1454
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1455
+				unset($data);
1456
+						} elseif ($format == 'flightgearsp') {
1457
+							//echo $buffer."\n";
1458
+							if (strlen($buffer) > 5) {
1459 1459
 				$line = explode(',',$buffer);
1460 1460
 				$data = array();
1461 1461
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1472,38 +1472,38 @@  discard block
 block discarded – undo
1472 1472
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1473 1473
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1474 1474
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1475
-			    }
1476
-                        } elseif ($format == 'acars') {
1477
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1478
-			    $ACARS->add(trim($buffer));
1479
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1480
-			    $ACARS->deleteLiveAcarsData();
1475
+				}
1476
+						} elseif ($format == 'acars') {
1477
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1478
+				$ACARS->add(trim($buffer));
1479
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1480
+				$ACARS->deleteLiveAcarsData();
1481 1481
 			} elseif ($format == 'flightgearmp') {
1482
-			    if (substr($buffer,0,1) != '#') {
1482
+				if (substr($buffer,0,1) != '#') {
1483 1483
 				$data = array();
1484 1484
 				//echo $buffer."\n";
1485 1485
 				$line = explode(' ',$buffer);
1486 1486
 				if (count($line) == 11) {
1487
-				    $userserver = explode('@',$line[0]);
1488
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1489
-				    $data['ident'] = $userserver[0];
1490
-				    $data['registration'] = $userserver[0];
1491
-				    $data['latitude'] = $line[4];
1492
-				    $data['longitude'] = $line[5];
1493
-				    $data['altitude'] = $line[6];
1494
-				    $data['datetime'] = date('Y-m-d H:i:s');
1495
-				    $aircraft_type = $line[10];
1496
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1497
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1498
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1499
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1487
+					$userserver = explode('@',$line[0]);
1488
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1489
+					$data['ident'] = $userserver[0];
1490
+					$data['registration'] = $userserver[0];
1491
+					$data['latitude'] = $line[4];
1492
+					$data['longitude'] = $line[5];
1493
+					$data['altitude'] = $line[6];
1494
+					$data['datetime'] = date('Y-m-d H:i:s');
1495
+					$aircraft_type = $line[10];
1496
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1497
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1498
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1499
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1500
+				}
1500 1501
 				}
1501
-			    }
1502 1502
 			} elseif ($format == 'beast') {
1503
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1504
-			    die;
1503
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1504
+				die;
1505 1505
 			} elseif ($format == 'vrstcp') {
1506
-			    foreach($buffer as $all_data) {
1506
+				foreach($buffer as $all_data) {
1507 1507
 				$line = json_decode('{'.$all_data.'}',true);
1508 1508
 				$data = array();
1509 1509
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1523,153 +1523,153 @@  discard block
 block discarded – undo
1523 1523
 				*/
1524 1524
 				$data['datetime'] = date('Y-m-d H:i:s');
1525 1525
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1526
-		    		$data['format_source'] = 'vrstcp';
1526
+					$data['format_source'] = 'vrstcp';
1527 1527
 				$data['id_source'] = $id_source;
1528 1528
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1529 1529
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1530 1530
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1531 1531
 				unset($data);
1532
-			    }
1532
+				}
1533 1533
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1534
-			    $line = explode("\t", $buffer);
1535
-			    for($k = 0; $k < count($line); $k=$k+2) {
1534
+				$line = explode("\t", $buffer);
1535
+				for($k = 0; $k < count($line); $k=$k+2) {
1536 1536
 				$key = $line[$k];
1537
-			        $lined[$key] = $line[$k+1];
1538
-			    }
1539
-    			    if (count($lined) > 3) {
1540
-    				$data['hex'] = $lined['hexid'];
1541
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1542
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1543
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1544
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1545
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1546
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1547
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1548
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1549
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1550
-    				$data['id_source'] = $id_source;
1551
-    				$data['format_source'] = 'tsv';
1552
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1553
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1537
+					$lined[$key] = $line[$k+1];
1538
+				}
1539
+					if (count($lined) > 3) {
1540
+					$data['hex'] = $lined['hexid'];
1541
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1542
+					$data['datetime'] = date('Y-m-d H:i:s');;
1543
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1544
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1545
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1546
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1547
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1548
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1549
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1550
+					$data['id_source'] = $id_source;
1551
+					$data['format_source'] = 'tsv';
1552
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1553
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1554 1554
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1555
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1556
-    				unset($lined);
1557
-    				unset($data);
1558
-    			    } else $error = true;
1555
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1556
+					unset($lined);
1557
+					unset($data);
1558
+					} else $error = true;
1559 1559
 			} elseif ($format == 'aprs' && $use_aprs) {
1560
-			    if ($aprs_connect == 0) {
1560
+				if ($aprs_connect == 0) {
1561 1561
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1562 1562
 				$aprs_connect = 1;
1563
-			    }
1563
+				}
1564 1564
 			    
1565
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1565
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1566 1566
 				$aprs_last_tx = time();
1567 1567
 				$data_aprs = "# Keep alive";
1568 1568
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1569
-			    }
1569
+				}
1570 1570
 			    
1571
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1572
-			    //echo 'APRS data : '.$buffer."\n";
1573
-			    $buffer = str_replace('APRS <- ','',$buffer);
1574
-			    $buffer = str_replace('APRS -> ','',$buffer);
1575
-			    //echo $buffer."\n";
1576
-			    date_default_timezone_set('UTC');
1577
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1571
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1572
+				//echo 'APRS data : '.$buffer."\n";
1573
+				$buffer = str_replace('APRS <- ','',$buffer);
1574
+				$buffer = str_replace('APRS -> ','',$buffer);
1575
+				//echo $buffer."\n";
1576
+				date_default_timezone_set('UTC');
1577
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1578 1578
 				$line = $APRS->parse($buffer);
1579 1579
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1580 1580
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1581
-				    $aprs_last_tx = time();
1582
-				    $data = array();
1583
-				    //print_r($line);
1584
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1585
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1586
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1587
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1588
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1589
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1590
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1591
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1592
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1593
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1594
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1595
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1596
-				    $data['latitude'] = $line['latitude'];
1597
-				    $data['longitude'] = $line['longitude'];
1598
-				    //$data['verticalrate'] = $line[16];
1599
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1600
-				    //else $data['speed'] = 0;
1601
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1602
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1603
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1604
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1581
+					$aprs_last_tx = time();
1582
+					$data = array();
1583
+					//print_r($line);
1584
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1585
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1586
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1587
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1588
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1589
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1590
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1591
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1592
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1593
+					else $data['datetime'] = date('Y-m-d H:i:s');
1594
+					//$data['datetime'] = date('Y-m-d H:i:s');
1595
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1596
+					$data['latitude'] = $line['latitude'];
1597
+					$data['longitude'] = $line['longitude'];
1598
+					//$data['verticalrate'] = $line[16];
1599
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1600
+					//else $data['speed'] = 0;
1601
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1602
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1603
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1604
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1605 1605
 				    
1606
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1607
-				    //else echo 'No heading...'."\n";
1608
-				    //else $data['heading'] = 0;
1609
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1610
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1611
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1612
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1613
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1614
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1615
-    				    $data['id_source'] = $id_source;
1616
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1617
-				    else $data['format_source'] = 'aprs';
1618
-				    $data['source_name'] = $line['source'];
1619
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1620
-				    else $data['source_type'] = 'flarm';
1621
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1622
-				    $currentdate = date('Y-m-d H:i:s');
1623
-				    $aprsdate = strtotime($data['datetime']);
1624
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1625
-				    // Accept data if time <= system time + 20s
1626
-				    //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'])))) {
1627
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1606
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1607
+					//else echo 'No heading...'."\n";
1608
+					//else $data['heading'] = 0;
1609
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1610
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1611
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1612
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1613
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1614
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1615
+						$data['id_source'] = $id_source;
1616
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1617
+					else $data['format_source'] = 'aprs';
1618
+					$data['source_name'] = $line['source'];
1619
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1620
+					else $data['source_type'] = 'flarm';
1621
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1622
+					$currentdate = date('Y-m-d H:i:s');
1623
+					$aprsdate = strtotime($data['datetime']);
1624
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1625
+					// Accept data if time <= system time + 20s
1626
+					//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'])))) {
1627
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1628 1628
 					$send = $SI->add($data);
1629
-				    } elseif ($data['source_type'] == 'ais') {
1629
+					} elseif ($data['source_type'] == 'ais') {
1630 1630
 					$data['type'] = '';
1631 1631
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1632
-				    } elseif (isset($line['stealth'])) {
1632
+					} elseif (isset($line['stealth'])) {
1633 1633
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1634 1634
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1635
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1636
-					    //$line['symbol'] == 'Balloon' ||
1637
-					    $line['symbol'] == 'Glider' || 
1638
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1639
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1640
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1641
-					    $send = $SI->add($data);
1642
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1643
-					    $line['symbol'] == 'Yacht (Sail)' || 
1644
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1645
-					    $send = $MI->add($data);
1646
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1647
-					    $line['symbol'] == 'Car' || 
1648
-					    $line['symbol'] == 'Ambulance' || 
1649
-					    $line['symbol'] == 'Van' || 
1650
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1651
-					    $line['symbol'] == 'Motorcycle' || 
1652
-					    $line['symbol'] == 'Tractor' || 
1653
-					    $line['symbol'] == 'Police' || 
1654
-					    $line['symbol'] == 'Bike' || 
1655
-					    $line['symbol'] == 'Jogger' || 
1656
-					    $line['symbol'] == 'Horse' || 
1657
-					    $line['symbol'] == 'Bus' || 
1658
-					    $line['symbol'] == 'Jeep' || 
1659
-					    $line['symbol'] == 'Recreational Vehicle' || 
1660
-					    $line['symbol'] == 'Yacht (Sail)' || 
1661
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1662
-					    $line['symbol'] == 'Firetruck' || 
1663
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1664
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1665
-					    $line['symbol'] == 'SUV' ||
1666
-					    $line['symbol'] == 'Snowmobile' ||
1667
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1668
-				    //} 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') {
1635
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1636
+						//$line['symbol'] == 'Balloon' ||
1637
+						$line['symbol'] == 'Glider' || 
1638
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1639
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1640
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1641
+						$send = $SI->add($data);
1642
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1643
+						$line['symbol'] == 'Yacht (Sail)' || 
1644
+						$line['symbol'] == 'Ship (Power Boat)')) {
1645
+						$send = $MI->add($data);
1646
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1647
+						$line['symbol'] == 'Car' || 
1648
+						$line['symbol'] == 'Ambulance' || 
1649
+						$line['symbol'] == 'Van' || 
1650
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1651
+						$line['symbol'] == 'Motorcycle' || 
1652
+						$line['symbol'] == 'Tractor' || 
1653
+						$line['symbol'] == 'Police' || 
1654
+						$line['symbol'] == 'Bike' || 
1655
+						$line['symbol'] == 'Jogger' || 
1656
+						$line['symbol'] == 'Horse' || 
1657
+						$line['symbol'] == 'Bus' || 
1658
+						$line['symbol'] == 'Jeep' || 
1659
+						$line['symbol'] == 'Recreational Vehicle' || 
1660
+						$line['symbol'] == 'Yacht (Sail)' || 
1661
+						$line['symbol'] == 'Ship (Power Boat)' || 
1662
+						$line['symbol'] == 'Firetruck' || 
1663
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1664
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1665
+						$line['symbol'] == 'SUV' ||
1666
+						$line['symbol'] == 'Snowmobile' ||
1667
+						$line['symbol'] == 'Mobile Satellite Station')) {
1668
+					//} 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') {
1669 1669
 				//    } 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') {
1670 1670
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1671 1671
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1672
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1672
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1673 1673
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1674 1674
 					$Source->deleteOldLocationByType('gs');
1675 1675
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 					} else {
1678 1678
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1679 1679
 					}
1680
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1680
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1681 1681
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1682 1682
 					if ($globalDebug) echo '# Weather Station added'."\n";
1683 1683
 					$Source->deleteOldLocationByType('wx');
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 					} else {
1688 1688
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1689 1689
 					}
1690
-				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1690
+					} elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1691 1691
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1692 1692
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1693 1693
 					$Source->deleteOldLocationByType('lightning');
@@ -1696,11 +1696,11 @@  discard block
 block discarded – undo
1696 1696
 					} else {
1697 1697
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1698 1698
 					}
1699
-				    } elseif ($globalDebug) {
1700
-				    	echo '/!\ Not added: '.$buffer."\n";
1701
-				    	print_r($line);
1702
-				    }
1703
-				    unset($data);
1699
+					} elseif ($globalDebug) {
1700
+						echo '/!\ Not added: '.$buffer."\n";
1701
+						print_r($line);
1702
+					}
1703
+					unset($data);
1704 1704
 				}
1705 1705
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1706 1706
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1719,12 +1719,12 @@  discard block
 block discarded – undo
1719 1719
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1720 1720
 					$globalSources[$nb]['last_weather_clean'] = time();
1721 1721
 				}
1722
-			    }
1722
+				}
1723 1723
 			} else {
1724
-			    $line = explode(',', $buffer);
1725
-    			    if (count($line) > 20) {
1726
-    			    	$data['hex'] = $line[4];
1727
-    				/*
1724
+				$line = explode(',', $buffer);
1725
+					if (count($line) > 20) {
1726
+						$data['hex'] = $line[4];
1727
+					/*
1728 1728
     				$data['datetime'] = $line[6].' '.$line[7];
1729 1729
     					date_default_timezone_set($globalTimezone);
1730 1730
     					$datetime = new DateTime($data['datetime']);
@@ -1732,30 +1732,30 @@  discard block
 block discarded – undo
1732 1732
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1733 1733
     					date_default_timezone_set('UTC');
1734 1734
     				*/
1735
-    				// Force datetime to current UTC datetime
1736
-    				date_default_timezone_set('UTC');
1737
-    				$data['datetime'] = date('Y-m-d H:i:s');
1738
-    				$data['ident'] = trim($line[10]);
1739
-    				$data['latitude'] = $line[14];
1740
-    				$data['longitude'] = $line[15];
1741
-    				$data['verticalrate'] = $line[16];
1742
-    				$data['emergency'] = $line[20];
1743
-    				$data['speed'] = $line[12];
1744
-    				$data['squawk'] = $line[17];
1745
-    				$data['altitude'] = $line[11];
1746
-    				$data['heading'] = $line[13];
1747
-    				$data['ground'] = $line[21];
1748
-    				$data['emergency'] = $line[19];
1749
-    				$data['format_source'] = 'sbs';
1735
+					// Force datetime to current UTC datetime
1736
+					date_default_timezone_set('UTC');
1737
+					$data['datetime'] = date('Y-m-d H:i:s');
1738
+					$data['ident'] = trim($line[10]);
1739
+					$data['latitude'] = $line[14];
1740
+					$data['longitude'] = $line[15];
1741
+					$data['verticalrate'] = $line[16];
1742
+					$data['emergency'] = $line[20];
1743
+					$data['speed'] = $line[12];
1744
+					$data['squawk'] = $line[17];
1745
+					$data['altitude'] = $line[11];
1746
+					$data['heading'] = $line[13];
1747
+					$data['ground'] = $line[21];
1748
+					$data['emergency'] = $line[19];
1749
+					$data['format_source'] = 'sbs';
1750 1750
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1751
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1751
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1752 1752
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1753
-    				$data['id_source'] = $id_source;
1754
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1755
-    				else $error = true;
1756
-    				unset($data);
1757
-    			    } else $error = true;
1758
-			    if ($error) {
1753
+					$data['id_source'] = $id_source;
1754
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1755
+					else $error = true;
1756
+					unset($data);
1757
+					} else $error = true;
1758
+				if ($error) {
1759 1759
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1760 1760
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1761 1761
 				} else {
@@ -1771,13 +1771,13 @@  discard block
 block discarded – undo
1771 1771
 					connect_all($sourceer);
1772 1772
 					$sourceer = array();
1773 1773
 				}
1774
-			    }
1774
+				}
1775 1775
 			}
1776 1776
 			// Sleep for xxx microseconds
1777 1777
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1778
-		    } else {
1778
+			} else {
1779 1779
 			if ($format == 'flightgearmp') {
1780
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1780
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1781 1781
 				//@socket_close($r);
1782 1782
 				sleep($globalMinFetch);
1783 1783
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1786,9 +1786,9 @@  discard block
 block discarded – undo
1786 1786
 				break;
1787 1787
 				
1788 1788
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1789
-			    if (isset($tt[$format])) $tt[$format]++;
1790
-			    else $tt[$format] = 0;
1791
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1789
+				if (isset($tt[$format])) $tt[$format]++;
1790
+				else $tt[$format] = 0;
1791
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1792 1792
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1793 1793
 				//@socket_close($r);
1794 1794
 				sleep(2);
@@ -1799,24 +1799,24 @@  discard block
 block discarded – undo
1799 1799
 				//connect_all($globalSources);
1800 1800
 				$tt[$format]=0;
1801 1801
 				break;
1802
-			    } 
1803
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1802
+				} 
1803
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1804
+			}
1804 1805
 			}
1805
-		    }
1806 1806
 		}
1807
-	    } else {
1807
+		} else {
1808 1808
 		$error = socket_strerror(socket_last_error());
1809 1809
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1810 1810
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1811 1811
 			if (isset($globalDebug)) echo "Restarting...\n";
1812 1812
 			// Restart the script if possible
1813 1813
 			if (is_array($sockets)) {
1814
-			    if ($globalDebug) echo "Shutdown all sockets...";
1814
+				if ($globalDebug) echo "Shutdown all sockets...";
1815 1815
 			    
1816
-			    foreach ($sockets as $sock) {
1816
+				foreach ($sockets as $sock) {
1817 1817
 				@socket_shutdown($sock,2);
1818 1818
 				@socket_close($sock);
1819
-			    }
1819
+				}
1820 1820
 			    
1821 1821
 			}
1822 1822
 			if ($globalDebug) echo "Waiting...";
@@ -1831,15 +1831,15 @@  discard block
 block discarded – undo
1831 1831
 			if ($globalDebug) echo "Restart all connections...";
1832 1832
 			connect_all($globalSources);
1833 1833
 		}
1834
-	    }
1834
+		}
1835 1835
 	}
1836 1836
 	if ($globalDaemon === false) {
1837
-	    if ($globalDebug) echo 'Check all...'."\n";
1838
-	    if (isset($SI)) $SI->checkAll();
1839
-	    if (isset($TI)) $TI->checkAll();
1840
-	    if (isset($MI)) $MI->checkAll();
1837
+		if ($globalDebug) echo 'Check all...'."\n";
1838
+		if (isset($SI)) $SI->checkAll();
1839
+		if (isset($TI)) $TI->checkAll();
1840
+		if (isset($MI)) $MI->checkAll();
1841
+	}
1841 1842
 	}
1842
-    }
1843 1843
 }
1844 1844
 
1845 1845
 ?>
Please login to merge, or discard this patch.