Completed
Push — master ( 46434e...ad133e )
by Yannick
32:08 queued 16:03
created
search-rss.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,52 +5,52 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
 	//for the date manipulation into the query
8
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
10
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
8
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
10
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
11 11
 		$sql_date = $start_date.",".$end_date;
12
-	} else if($_GET['start_date'] != ""){
13
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
12
+	} else if ($_GET['start_date'] != "") {
13
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
14 14
 		$sql_date = $start_date;
15
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
15
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18 18
 	} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
 	//for altitude manipulation
23
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
25
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
23
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
25
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
26 26
 		$sql_altitude = $start_altitude.",".$end_altitude;
27
-	} else if($_GET['highest_altitude'] != ""){
28
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
27
+	} else if ($_GET['highest_altitude'] != "") {
28
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
29 29
 		$sql_altitude = $end_altitude;
30
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
30
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
32 32
 		$sql_altitude = $start_altitude;
33 33
 	} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit'])) {
37
+if (!isset($_GET['limit'])) {
38 38
 	if (!isset($_GET['number_results'])) {
39 39
 		$limit_start = 0;
40 40
 		$limit_end = 25;
41 41
 		$absolute_difference = 25;
42 42
 	} else {
43
-		if ($_GET['number_results'] > 1000){
43
+		if ($_GET['number_results'] > 1000) {
44 44
 			$_GET['number_results'] = 1000;
45 45
 		}
46 46
 		$limit_start = 0;
47
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
47
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
48
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
49 49
 	}
50
-}  else {
50
+} else {
51 51
 	$limit_explode = explode(",", $_GET['limit']);
52
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
52
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
53
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
54 54
 }
55 55
 
56 56
 $absolute_difference = abs($limit_start - $limit_end);
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 $date = date("D, d M Y H:i:s T", time());
69 69
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
70 70
 else $sort = '';
71
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
72
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
73
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
74
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
75
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
76
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
77
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
78
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
79
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
80
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
81
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
82
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
83
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
84
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
85
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
86
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
87
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
71
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
72
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
73
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
74
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
75
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
76
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
77
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
78
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
79
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
80
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
81
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
82
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
83
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
84
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
85
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
86
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
87
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
88 88
 if ($id != '') {
89 89
 	$spotter_array = $Spotter->getSpotterDataByID($id);
90 90
 } else {
91
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
91
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
92 92
 } 
93 93
 print '<?xml version="1.0" encoding="UTF-8" ?>';
94 94
 print '<rss xmlns:flightairmap="http://'.$_SERVER['HTTP_HOST'].''.htmlentities($_SERVER['REQUEST_URI']).'" version="2.0">';
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 print '<lastBuildDate>'.$date.'</lastBuildDate>';
102 102
 
103 103
 if (!empty($spotter_array)) {
104
-	foreach($spotter_array as $spotter_item) {
104
+	foreach ($spotter_array as $spotter_item) {
105 105
 		print '<item>';
106 106
 		print '<title>'.$spotter_item['ident'].' '.$spotter_item['airline_name'].' | '.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].') | '.$spotter_item['departure_airport'].' - '.$spotter_item['arrival_airport'].'</title>';
107 107
 		print '<link>http://www.flightairmap.fr/flightid/'.$spotter_item['spotter_id'].'</link>';
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,12 @@  discard block
 block discarded – undo
15 15
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16 16
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18
-	} else $sql_date = '';
19
-} else $sql_date = '';
18
+	} else {
19
+		$sql_date = '';
20
+	}
21
+	} else {
22
+	$sql_date = '';
23
+}
20 24
 
21 25
 if (isset($_GET['highest_altitude'])) {
22 26
 	//for altitude manipulation
@@ -30,8 +34,12 @@  discard block
 block discarded – undo
30 34
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31 35
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
32 36
 		$sql_altitude = $start_altitude;
33
-	} else $sql_altitude = '';
34
-} else $sql_altitude = '';
37
+	} else {
38
+		$sql_altitude = '';
39
+	}
40
+	} else {
41
+	$sql_altitude = '';
42
+}
35 43
 
36 44
 //calculuation for the pagination
37 45
 if(!isset($_GET['limit'])) {
@@ -47,7 +55,7 @@  discard block
 block discarded – undo
47 55
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48 56
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49 57
 	}
50
-}  else {
58
+} else {
51 59
 	$limit_explode = explode(",", $_GET['limit']);
52 60
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53 61
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -66,8 +74,11 @@  discard block
 block discarded – undo
66 74
 header('Content-Type: application/rss+xml; charset=utf-8');
67 75
 
68 76
 $date = date("D, d M Y H:i:s T", time());
69
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
70
-else $sort = '';
77
+if (isset($_GET['sort'])) {
78
+	$sort = $_GET['sort'];
79
+} else {
80
+	$sort = '';
81
+}
71 82
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
72 83
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
73 84
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-yaml.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,52 +5,52 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
 	//for the date manipulation into the query
8
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
10
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
8
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
10
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
11 11
 		$sql_date = $start_date.",".$end_date;
12
-	} else if($_GET['start_date'] != ""){
13
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
12
+	} else if ($_GET['start_date'] != "") {
13
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
14 14
 		$sql_date = $start_date;
15
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
15
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18 18
 	} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
 	//for altitude manipulation
23
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
25
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
23
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
25
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
26 26
 		$sql_altitude = $start_altitude.",".$end_altitude;
27
-	} else if($_GET['highest_altitude'] != ""){
28
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
27
+	} else if ($_GET['highest_altitude'] != "") {
28
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
29 29
 		$sql_altitude = $end_altitude;
30
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
30
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
32 32
 		$sql_altitude = $start_altitude;
33 33
 	} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit'])) {
37
+if (!isset($_GET['limit'])) {
38 38
 	if (!isset($_GET['number_results'])) {
39 39
 		$limit_start = 0;
40 40
 		$limit_end = 25;
41 41
 		$absolute_difference = 25;
42 42
 	} else {
43
-		if ($_GET['number_results'] > 1000){
43
+		if ($_GET['number_results'] > 1000) {
44 44
 			$_GET['number_results'] = 1000;
45 45
 		}
46 46
 		$limit_start = 0;
47
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
47
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
48
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
49 49
 	}
50
-}  else {
50
+} else {
51 51
 	$limit_explode = explode(",", $_GET['limit']);
52
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
52
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
53
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
54 54
 }
55 55
 
56 56
 $absolute_difference = abs($limit_start - $limit_end);
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 
68 68
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
69 69
 else $sort = '';
70
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
71
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
72
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
73
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
74
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
75
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
76
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
77
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
78
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
79
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
80
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
81
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
82
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
83
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
84
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
85
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
86
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
70
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
71
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
72
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
73
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
74
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
75
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
76
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
77
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
78
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
79
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
80
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
81
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
82
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
83
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
84
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
85
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
86
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
87 87
 if ($id != '') {
88 88
 	$spotter_array = $Spotter->getSpotterDataByID($id);
89 89
 } else {
90
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
90
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
91 91
 }
92 92
 $output = "-flights:\n";
93 93
 if (!empty($spotter_array)) {
94
-	foreach($spotter_array as $spotter_item) {
94
+	foreach ($spotter_array as $spotter_item) {
95 95
 		$output .= ' - id: '.$spotter_item['spotter_id'];
96 96
 		$output .= "\n";
97 97
 		$output .= ' - ident: '.$spotter_item['ident'];
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,12 @@  discard block
 block discarded – undo
15 15
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16 16
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18
-	} else $sql_date = '';
19
-} else $sql_date = '';
18
+	} else {
19
+		$sql_date = '';
20
+	}
21
+	} else {
22
+	$sql_date = '';
23
+}
20 24
 
21 25
 if (isset($_GET['highest_altitude'])) {
22 26
 	//for altitude manipulation
@@ -30,8 +34,12 @@  discard block
 block discarded – undo
30 34
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31 35
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
32 36
 		$sql_altitude = $start_altitude;
33
-	} else $sql_altitude = '';
34
-} else $sql_altitude = '';
37
+	} else {
38
+		$sql_altitude = '';
39
+	}
40
+	} else {
41
+	$sql_altitude = '';
42
+}
35 43
 
36 44
 //calculuation for the pagination
37 45
 if(!isset($_GET['limit'])) {
@@ -47,7 +55,7 @@  discard block
 block discarded – undo
47 55
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48 56
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49 57
 	}
50
-}  else {
58
+} else {
51 59
 	$limit_explode = explode(",", $_GET['limit']);
52 60
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53 61
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -65,8 +73,11 @@  discard block
 block discarded – undo
65 73
 
66 74
 header("Content-type: text/yaml");
67 75
 
68
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
69
-else $sort = '';
76
+if (isset($_GET['sort'])) {
77
+	$sort = $_GET['sort'];
78
+} else {
79
+	$sort = '';
80
+}
70 81
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
71 82
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
72 83
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-georss.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,36 +6,36 @@  discard block
 block discarded – undo
6 6
 $Spotter = new Spotter();
7 7
 if (isset($_GET['start_date'])) {
8 8
 	//for the date manipulation into the query
9
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
10
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
11
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
9
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
10
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
11
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
12 12
 		$sql_date = $start_date.",".$end_date;
13
-	} else if($_GET['start_date'] != ""){
14
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
13
+	} else if ($_GET['start_date'] != "") {
14
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
15 15
 		$sql_date = $start_date;
16
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
16
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
17
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19 19
 	} else $sql_date = '';
20 20
 } else $sql_date = '';
21 21
 
22 22
 if (isset($_GET['highest_altitude'])) {
23 23
 	//for altitude manipulation
24
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
25
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
26
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
24
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
25
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
26
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
27 27
 		$sql_altitude = $start_altitude.",".$end_altitude;
28
-	} else if($_GET['highest_altitude'] != ""){
29
-		$end_altitude = filter_input(iNPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
28
+	} else if ($_GET['highest_altitude'] != "") {
29
+		$end_altitude = filter_input(iNPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
30 30
 		$sql_altitude = $end_altitude;
31
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
31
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
32
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
33 33
 		$sql_altitude = $start_altitude;
34 34
 	} else $sql_altitude = '';
35 35
 } else $sql_altitude = '';
36 36
 
37 37
 //calculuation for the pagination
38
-if(!isset($_GET['limit']))
38
+if (!isset($_GET['limit']))
39 39
 {
40 40
 	if (!isset($_GET['number_results']))
41 41
 	{
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 		$limit_end = 25;
44 44
 		$absolute_difference = 25;
45 45
 	} else {
46
-		if ($_GET['number_results'] > 1000){
46
+		if ($_GET['number_results'] > 1000) {
47 47
 			$_GET['number_results'] = 1000;
48 48
 		}
49 49
 		$limit_start = 0;
50
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
51
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
52 52
 	}
53
-}  else {
53
+} else {
54 54
 	$limit_explode = explode(",", $_GET['limit']);
55
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
56
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
55
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
56
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
57 57
 }
58 58
 
59 59
 $absolute_difference = abs($limit_start - $limit_end);
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
75 75
 else $sort = '';
76
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
77
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_STRING);
78
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
79
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
80
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
81
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
82
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
83
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
84
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
85
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
86
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
87
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
88
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
89
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
90
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
91
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
92
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
76
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
77
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
78
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
79
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
80
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
81
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
82
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
83
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
84
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
85
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
86
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
87
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
88
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
89
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
90
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
91
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
92
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
93 93
 if ($id != '') {
94 94
 	$spotter_array = $Spotter->getSpotterDataByID($id);
95 95
 } else {
96
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
96
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
97 97
 }
98 98
  
99 99
 print '<?xml version="1.0" encoding="UTF-8" ?>';
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 print '</author>';
110 110
 print '<id>FlightAirMap</id>';
111 111
 if (!empty($spotter_array)) {
112
-	foreach($spotter_array as $spotter_item) {
112
+	foreach ($spotter_array as $spotter_item) {
113 113
 		print '<entry>';
114 114
 		print '<title>'.$spotter_item['ident'].' '.$spotter_item['airline_name'].' | '.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].') | '.$spotter_item['departure_airport'].' - '.$spotter_item['arrival_airport'].'</title>';
115 115
 		print '<link href="http://www.flightairmap.fr/flightid/'.$spotter_item['spotter_id'].'"/>';
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@  discard block
 block discarded – undo
16 16
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17 17
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19
-	} else $sql_date = '';
20
-} else $sql_date = '';
19
+	} else {
20
+		$sql_date = '';
21
+	}
22
+	} else {
23
+	$sql_date = '';
24
+}
21 25
 
22 26
 if (isset($_GET['highest_altitude'])) {
23 27
 	//for altitude manipulation
@@ -31,8 +35,12 @@  discard block
 block discarded – undo
31 35
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32 36
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
33 37
 		$sql_altitude = $start_altitude;
34
-	} else $sql_altitude = '';
35
-} else $sql_altitude = '';
38
+	} else {
39
+		$sql_altitude = '';
40
+	}
41
+	} else {
42
+	$sql_altitude = '';
43
+}
36 44
 
37 45
 //calculuation for the pagination
38 46
 if(!isset($_GET['limit']))
@@ -50,7 +58,7 @@  discard block
 block discarded – undo
50 58
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51 59
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
52 60
 	}
53
-}  else {
61
+} else {
54 62
 	$limit_explode = explode(",", $_GET['limit']);
55 63
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
56 64
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -71,8 +79,11 @@  discard block
 block discarded – undo
71 79
 
72 80
 $date = date("c", time());
73 81
 
74
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
75
-else $sort = '';
82
+if (isset($_GET['sort'])) {
83
+	$sort = $_GET['sort'];
84
+} else {
85
+	$sort = '';
86
+}
76 87
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
77 88
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_STRING);
78 89
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-json.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,53 +5,53 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
 	//for the date manipulation into the query
8
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
10
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
8
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
10
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
11 11
 		$sql_date = $start_date.",".$end_date;
12
-	} else if($_GET['start_date'] != ""){
13
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
12
+	} else if ($_GET['start_date'] != "") {
13
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
14 14
 		$sql_date = $start_date;
15
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
15
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18 18
 	} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
 	//for altitude manipulation
23
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
25
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
23
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
25
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
26 26
 		$sql_altitude = $start_altitude.",".$end_altitude;
27
-	} else if($_GET['highest_altitude'] != ""){
28
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
27
+	} else if ($_GET['highest_altitude'] != "") {
28
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
29 29
 		$sql_altitude = $end_altitude;
30
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
30
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
32 32
 		$sql_altitude = $start_altitude;
33 33
 	} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit']))
37
+if (!isset($_GET['limit']))
38 38
 {
39 39
 	if (!isset($_GET['number_results'])) {
40 40
 		$limit_start = 0;
41 41
 		$limit_end = 25;
42 42
 		$absolute_difference = 25;
43 43
 	} else {
44
-		if ($_GET['number_results'] > 1000){
44
+		if ($_GET['number_results'] > 1000) {
45 45
 			$_GET['number_results'] = 1000;
46 46
 		}
47 47
 		$limit_start = 0;
48
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
49
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
50 50
 	}
51
-}  else {
51
+} else {
52 52
 	$limit_explode = explode(",", $_GET['limit']);
53
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
54
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
53
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
54
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
55 55
 }
56 56
 
57 57
 $absolute_difference = abs($limit_start - $limit_end);
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 
69 69
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
70 70
 else $sort = '';
71
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
72
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
73
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
74
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
75
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
76
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
77
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
78
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
79
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
80
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
81
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
82
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
83
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
84
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
85
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
86
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
87
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
71
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
72
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
73
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
74
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
75
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
76
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
77
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
78
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
79
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
80
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
81
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
82
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
83
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
84
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
85
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
86
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
87
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
88 88
 if ($id != '') {
89 89
 	$spotter_array = $Spotter->getSpotterDataByID($id);
90 90
 } else {
91
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
91
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
92 92
 }
93 93
 $output = '{';
94 94
 $output .= '"flightairmap": {';
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 $output .= '"aircraft": [';
98 98
 
99 99
 if (!empty($spotter_array)) {
100
-	foreach($spotter_array as $spotter_item) {
100
+	foreach ($spotter_array as $spotter_item) {
101 101
 		$output .= '{';    	
102 102
 		$output .= '"id": "'.$spotter_item['spotter_id'].'",';
103 103
 		$output .= '"ident": "'.$spotter_item['ident'].'",';
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@  discard block
 block discarded – undo
16 16
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17 17
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19
-	} else $sql_date = '';
20
-} else $sql_date = '';
19
+	} else {
20
+		$sql_date = '';
21
+	}
22
+	} else {
23
+	$sql_date = '';
24
+}
21 25
 
22 26
 if (isset($_GET['highest_altitude'])) {
23 27
 	//for altitude manipulation
@@ -31,8 +35,12 @@  discard block
 block discarded – undo
31 35
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32 36
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
33 37
 		$sql_altitude = $start_altitude;
34
-	} else $sql_altitude = '';
35
-} else $sql_altitude = '';
38
+	} else {
39
+		$sql_altitude = '';
40
+	}
41
+	} else {
42
+	$sql_altitude = '';
43
+}
36 44
 
37 45
 //calculuation for the pagination
38 46
 if(!isset($_GET['limit']))
@@ -50,7 +58,7 @@  discard block
 block discarded – undo
50 58
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51 59
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
52 60
 	}
53
-}  else {
61
+} else {
54 62
 	$limit_explode = explode(",", $_GET['limit']);
55 63
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
56 64
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -68,8 +76,11 @@  discard block
 block discarded – undo
68 76
 
69 77
 header('Content-Type: application/json');
70 78
 
71
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
72
-else $sort = '';
79
+if (isset($_GET['sort'])) {
80
+	$sort = $_GET['sort'];
81
+} else {
82
+	$sort = '';
83
+}
73 84
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
74 85
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
75 86
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-wkt.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,52 +5,52 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
 	//for the date manipulation into the query
8
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
10
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
8
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
10
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
11 11
 		$sql_date = $start_date.",".$end_date;
12
-	} else if($_GET['start_date'] != ""){
13
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
12
+	} else if ($_GET['start_date'] != "") {
13
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
14 14
 		$sql_date = $start_date;
15
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
15
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18 18
 	} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
 	//for altitude manipulation
23
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
25
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
23
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
25
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
26 26
 		$sql_altitude = $start_altitude.",".$end_altitude;
27
-	} else if($_GET['highest_altitude'] != ""){
28
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
27
+	} else if ($_GET['highest_altitude'] != "") {
28
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
29 29
 		$sql_altitude = $end_altitude;
30
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
30
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
32 32
 		$sql_altitude = $start_altitude;
33 33
 	} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit'])) {
37
+if (!isset($_GET['limit'])) {
38 38
 	if (!isset($_GET['number_results'])) {
39 39
 		$limit_start = 0;
40 40
 		$limit_end = 25;
41 41
 		$absolute_difference = 25;
42 42
 	} else {
43
-		if ($_GET['number_results'] > 1000){
43
+		if ($_GET['number_results'] > 1000) {
44 44
 			$_GET['number_results'] = 1000;
45 45
 		}
46 46
 		$limit_start = 0;
47
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
47
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
48
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
49 49
 	}
50
-}  else {
50
+} else {
51 51
 	$limit_explode = explode(",", $_GET['limit']);
52
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
52
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
53
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
54 54
 }
55 55
 
56 56
 $absolute_difference = abs($limit_start - $limit_end);
@@ -67,34 +67,34 @@  discard block
 block discarded – undo
67 67
 
68 68
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
69 69
 else $sort = '';
70
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
71
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
72
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
73
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
74
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
75
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
76
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
77
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
78
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
79
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
80
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
81
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
82
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
83
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
84
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
85
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
86
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
70
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
71
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
72
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
73
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
74
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
75
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
76
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
77
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
78
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
79
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
80
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
81
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
82
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
83
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
84
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
85
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
86
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
87 87
 if ($id != '') {
88 88
 	$spotter_array = $Spotter->getSpotterDataByID($id);
89 89
 } else {
90
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
90
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
91 91
 }
92 92
 $i = 1;
93 93
 //$output .= "oid;Line\n";
94 94
 $output = '';
95 95
 if (!empty($spotter_array))
96 96
 {
97
-	foreach($spotter_array as $spotter_item)
97
+	foreach ($spotter_array as $spotter_item)
98 98
 	{
99 99
 		if ($spotter_item['waypoints'] != '') {
100 100
 			$waypoint_pieces = explode(' ', $spotter_item['waypoints']);
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,12 @@  discard block
 block discarded – undo
15 15
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16 16
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18
-	} else $sql_date = '';
19
-} else $sql_date = '';
18
+	} else {
19
+		$sql_date = '';
20
+	}
21
+	} else {
22
+	$sql_date = '';
23
+}
20 24
 
21 25
 if (isset($_GET['highest_altitude'])) {
22 26
 	//for altitude manipulation
@@ -30,8 +34,12 @@  discard block
 block discarded – undo
30 34
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31 35
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
32 36
 		$sql_altitude = $start_altitude;
33
-	} else $sql_altitude = '';
34
-} else $sql_altitude = '';
37
+	} else {
38
+		$sql_altitude = '';
39
+	}
40
+	} else {
41
+	$sql_altitude = '';
42
+}
35 43
 
36 44
 //calculuation for the pagination
37 45
 if(!isset($_GET['limit'])) {
@@ -47,7 +55,7 @@  discard block
 block discarded – undo
47 55
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48 56
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49 57
 	}
50
-}  else {
58
+} else {
51 59
 	$limit_explode = explode(",", $_GET['limit']);
52 60
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53 61
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -65,8 +73,11 @@  discard block
 block discarded – undo
65 73
 
66 74
 header("Content-type: text/csv");
67 75
 
68
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
69
-else $sort = '';
76
+if (isset($_GET['sort'])) {
77
+	$sort = $_GET['sort'];
78
+} else {
79
+	$sort = '';
80
+}
70 81
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
71 82
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
72 83
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-csv.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,53 +6,53 @@  discard block
 block discarded – undo
6 6
 
7 7
 if (isset($_GET['start_date'])) {
8 8
 	//for the date manipulation into the query
9
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
10
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
11
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
9
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
10
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
11
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
12 12
 		$sql_date = $start_date.",".$end_date;
13
-	} else if($_GET['start_date'] != ""){
14
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
13
+	} else if ($_GET['start_date'] != "") {
14
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
15 15
 		$sql_date = $start_date;
16
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
16
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
17
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19 19
 	} else $sql_date = '';
20 20
 } else $sql_date = '';
21 21
 
22 22
 if (isset($_GET['highest_altitude'])) {
23 23
 	//for altitude manipulation
24
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
25 25
 		$end_altitude = $_GET['highest_altitude'];
26 26
 		$start_altitude = $_GET['lowest_altitude'];
27 27
 		$sql_altitude = $start_altitude.",".$end_altitude;
28
-	} else if($_GET['highest_altitude'] != ""){
28
+	} else if ($_GET['highest_altitude'] != "") {
29 29
 		$end_altitude = $_GET['highest_altitude'];
30 30
 		$sql_altitude = $end_altitude;
31
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
32 32
 		$start_altitude = $_GET['lowest_altitude'].",60000";
33 33
 		$sql_altitude = $start_altitude;
34 34
 	} else $sql_altitude = '';
35 35
 } else $sql_altitude = '';
36 36
 
37 37
 //calculuation for the pagination
38
-if(!isset($_GET['limit']))
38
+if (!isset($_GET['limit']))
39 39
 {
40 40
 	if (!isset($_GET['number_results'])) {
41 41
 		$limit_start = 0;
42 42
 		$limit_end = 25;
43 43
 		$absolute_difference = 25;
44 44
 	} else {
45
-		if ($_GET['number_results'] > 1000){
45
+		if ($_GET['number_results'] > 1000) {
46 46
 			$_GET['number_results'] = 1000;
47 47
 		}
48 48
 		$limit_start = 0;
49
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
50
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
51 51
 	}
52
-}  else {
52
+} else {
53 53
 	$limit_explode = explode(",", $_GET['limit']);
54
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
55
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
54
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
55
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
56 56
 }
57 57
 $absolute_difference = abs($limit_start - $limit_end);
58 58
 $limit_next = $limit_end + $absolute_difference;
@@ -69,33 +69,33 @@  discard block
 block discarded – undo
69 69
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
70 70
 else $sort = '';
71 71
 
72
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
74
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
75
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
76
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
77
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
78
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
79
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
80
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
81
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
82
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
83
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
84
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
85
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
86
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
87
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
88
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
72
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
73
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
74
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
75
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
76
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
77
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
78
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
79
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
80
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
81
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
82
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
83
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
84
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
85
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
86
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
87
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
88
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
89 89
 if ($id != '') {
90 90
 	$spotter_array = $Spotter->getSpotterDataByID($id);
91 91
 } else {
92
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
92
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
93 93
 } 
94 94
 
95 95
 $output = "id,ident,registration,aircraft_icao,aircraft_name,aircraft_manufacturer,airline,airline_icao,airline_iata,airline_country,airline_callsign,airline_type,departure_airport_city,departure_airport_country,departure_airport_iata,departure_airport_icao,departure_airport_latitude,departure_airport_longitude,departure_airport_altitude,arrival_airport_city,arrival_airport_country,arrival_airport_iata,arrival_airport_icao,arrival_airport_latitude,arrival_airport_longitude,arrival_airport_altitude,latitude,longitude,altitude,ground_speed,heading,heading_name,waypoints,date\n";
96 96
 
97 97
 if (!empty($spotter_array)) {
98
-	foreach($spotter_array as $spotter_item) {
98
+	foreach ($spotter_array as $spotter_item) {
99 99
 		$output .= $spotter_item['spotter_id'].',';
100 100
 		$output .= $spotter_item['ident'].',';
101 101
 		$output .= $spotter_item['registration'].',';
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@  discard block
 block discarded – undo
16 16
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17 17
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19
-	} else $sql_date = '';
20
-} else $sql_date = '';
19
+	} else {
20
+		$sql_date = '';
21
+	}
22
+	} else {
23
+	$sql_date = '';
24
+}
21 25
 
22 26
 if (isset($_GET['highest_altitude'])) {
23 27
 	//for altitude manipulation
@@ -31,8 +35,12 @@  discard block
 block discarded – undo
31 35
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32 36
 		$start_altitude = $_GET['lowest_altitude'].",60000";
33 37
 		$sql_altitude = $start_altitude;
34
-	} else $sql_altitude = '';
35
-} else $sql_altitude = '';
38
+	} else {
39
+		$sql_altitude = '';
40
+	}
41
+	} else {
42
+	$sql_altitude = '';
43
+}
36 44
 
37 45
 //calculuation for the pagination
38 46
 if(!isset($_GET['limit']))
@@ -49,7 +57,7 @@  discard block
 block discarded – undo
49 57
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50 58
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51 59
 	}
52
-}  else {
60
+} else {
53 61
 	$limit_explode = explode(",", $_GET['limit']);
54 62
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
55 63
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -66,8 +74,11 @@  discard block
 block discarded – undo
66 74
 
67 75
 header("Content-type: text/csv");
68 76
 
69
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
70
-else $sort = '';
77
+if (isset($_GET['sort'])) {
78
+	$sort = $_GET['sort'];
79
+} else {
80
+	$sort = '';
81
+}
71 82
 
72 83
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73 84
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
registration-sub-menu.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 </span>
16 16
 <div class="sub-menu sub-menu-container">
17 17
 	<ul class="nav nav-pills">
18
-		<li><a href="<?php print $globalURL; ?>/registration/<?php print $registration; ?>" <?php if (strtolower($current_page) == "registration-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
18
+		<li><a href="<?php print $globalURL; ?>/registration/<?php print $registration; ?>" <?php if (strtolower($current_page) == "registration-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
19 19
 		<li class="dropdown">
20
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "registration-statistics-departure-airport" || strtolower($current_page) == "registration-statistics-departure-airport-country" || strtolower($current_page) == "registration-statistics-arrival-airport" || strtolower($current_page) == "registration-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
20
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "registration-statistics-departure-airport" || strtolower($current_page) == "registration-statistics-departure-airport-country" || strtolower($current_page) == "registration-statistics-arrival-airport" || strtolower($current_page) == "registration-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
21 21
 		      <?php _("Airport"); ?> <span class="caret"></span>
22 22
 		    </a>
23 23
 		    <ul class="dropdown-menu" role="menu">
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 			  <li><a href="<?php print $globalURL; ?>/registration/statistics/arrival-airport-country/<?php print $registration; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
28 28
 		    </ul>
29 29
 		</li>
30
-		<li><a href="<?php print $globalURL; ?>/registration/statistics/route/<?php print $registration; ?>" <?php if (strtolower($current_page) == "registration-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
31
-		<li><a href="<?php print $globalURL; ?>/registration/statistics/time/<?php print $registration; ?>" <?php if (strtolower($current_page) == "registration-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
30
+		<li><a href="<?php print $globalURL; ?>/registration/statistics/route/<?php print $registration; ?>" <?php if (strtolower($current_page) == "registration-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
31
+		<li><a href="<?php print $globalURL; ?>/registration/statistics/time/<?php print $registration; ?>" <?php if (strtolower($current_page) == "registration-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
32 32
 	</ul>
33 33
 </div>
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +1215 added lines, -1215 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
26 26
 
27 27
 if ($globalInstalled === FALSE) {
28
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
-    sleep(5);
30
-    die();
28
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
+	sleep(5);
30
+	die();
31 31
 }
32 32
 
33 33
 
34 34
 // Check if schema is at latest version
35 35
 $Connection = new Connection();
36 36
 if ($Connection->connectionExists() === false) {
37
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
-    exit();
37
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
+	exit();
39 39
 }
40 40
 if ($Connection->latest() === false) {
41
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
-    exit();
41
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
+	exit();
43 43
 }
44 44
 if (PHP_SAPI != 'cli') {
45
-    echo "This script MUST be called from console, not a web browser.";
45
+	echo "This script MUST be called from console, not a web browser.";
46 46
 //    exit();
47 47
 }
48 48
 
49 49
 // This is to be compatible with old version of settings.php
50 50
 if (!isset($globalSources)) {
51
-    if (isset($globalSBS1Hosts)) {
52
-        //$hosts = $globalSBS1Hosts;
53
-        foreach ($globalSBS1Hosts as $host) {
54
-	    $globalSources[] = array('host' => $host);
55
-    	}
56
-    } else {
57
-        if (!isset($globalSBS1Host)) {
58
-	    echo '$globalSources MUST be defined !';
59
-	    die;
51
+	if (isset($globalSBS1Hosts)) {
52
+		//$hosts = $globalSBS1Hosts;
53
+		foreach ($globalSBS1Hosts as $host) {
54
+		$globalSources[] = array('host' => $host);
55
+		}
56
+	} else {
57
+		if (!isset($globalSBS1Host)) {
58
+		echo '$globalSources MUST be defined !';
59
+		die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62 62
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
63
-    }
63
+	}
64 64
 }
65 65
 
66 66
 $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'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70
-    $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
70
+	$globalSources = array();
71
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+	else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74
-    $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
74
+	$globalSources = array();
75
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
+	else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
79 79
 	$globalServerAPRS = TRUE;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 if (isset($options['idsource'])) $id_source = $options['idsource'];
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
115
+	if ($globalDebug) echo "Using Server Mode\n";
116
+	$SI=new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
126
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
126
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 128
 }
129 129
 
130 130
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
131 131
 if (isset($globalMarine) && $globalMarine) {
132
-    $AIS = new AIS();
133
-    $MI = new MarineImport($Connection->db);
132
+	$AIS = new AIS();
133
+	$MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136 136
 $SBS=new SBS();
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
147
-        global $sockets;
148
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
-        die("Bye!\n");
150
-    });
151
-    pcntl_signal_dispatch();
146
+	pcntl_signal(SIGINT,  function() {
147
+		global $sockets;
148
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
+		die("Bye!\n");
150
+	});
151
+	pcntl_signal_dispatch();
152 152
 }
153 153
 
154 154
 // let's try and connect
@@ -158,47 +158,47 @@  discard block
 block discarded – undo
158 158
 $reset = 0;
159 159
 
160 160
 function connect_all($hosts) {
161
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
-    $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
165
-    foreach ($hosts as $id => $value) {
161
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
+	$reset++;
164
+	if ($globalDebug) echo 'Connect to all...'."\n";
165
+	foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170 170
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
172
-        	//$formats[$id] = 'deltadbtxt';
173
-        	$globalSources[$id]['format'] = 'deltadbtxt';
174
-        	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
-        	//$formats[$id] = 'vatsimtxt';
178
-        	$globalSources[$id]['format'] = 'vatsimtxt';
179
-        	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
187
-        	//$formats[$id] = 'aircraftjson';
188
-        	$globalSources[$id]['format'] = 'aircraftjson';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
192
-        	//$formats[$id] = 'planefinderclient';
193
-        	$globalSources[$id]['format'] = 'planefinderclient';
194
-        	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
197
-        	//$formats[$id] = 'aircraftlistjson';
198
-        	$globalSources[$id]['format'] = 'opensky';
199
-        	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
-    	    /*
171
+			if (preg_match('/deltadb.txt$/i',$host)) {
172
+			//$formats[$id] = 'deltadbtxt';
173
+			$globalSources[$id]['format'] = 'deltadbtxt';
174
+			//$last_exec['deltadbtxt'] = 0;
175
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
+			//$formats[$id] = 'vatsimtxt';
178
+			$globalSources[$id]['format'] = 'vatsimtxt';
179
+			//$last_exec['vatsimtxt'] = 0;
180
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'aircraftlistjson';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
+			} else if (preg_match('/aircraft.json$/i',$host)) {
187
+			//$formats[$id] = 'aircraftjson';
188
+			$globalSources[$id]['format'] = 'aircraftjson';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
+			} else if (preg_match('/aircraft$/i',$host)) {
192
+			//$formats[$id] = 'planefinderclient';
193
+			$globalSources[$id]['format'] = 'planefinderclient';
194
+			//$last_exec['aircraftlistjson'] = 0;
195
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
+			} else if (preg_match('/opensky/i',$host)) {
197
+			//$formats[$id] = 'aircraftlistjson';
198
+			$globalSources[$id]['format'] = 'opensky';
199
+			//$last_exec['aircraftlistjson'] = 0;
200
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
+			/*
202 202
     	    // Disabled for now, site change source format
203 203
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
204 204
         	//$formats[$id] = 'radarvirtueljson';
@@ -210,131 +210,131 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
-        	//$formats[$id] = 'planeupdatefaa';
215
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
216
-        	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
-        	    exit(0);
221
-        	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'phpvmacars';
225
-        	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
-        	//$formats[$id] = 'phpvmacars';
229
-        	$globalSources[$id]['format'] = 'vaos';
230
-        	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
233
-        	//$formats[$id] = 'phpvmacars';
234
-        	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
237
-        	//$formats[$id] = 'whazzup';
238
-        	$globalSources[$id]['format'] = 'whazzup';
239
-        	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
242
-        	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
245
-        	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
248
-        	//$formats[$id] = 'pirepsjson';
249
-        	$globalSources[$id]['format'] = 'pirepsjson';
250
-        	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
-        	//$formats[$id] = 'fr24json';
254
-        	$globalSources[$id]['format'] = 'fr24json';
255
-        	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
-        	    exit(0);
260
-        	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
262
-        	//$formats[$id] = 'fr24json';
263
-        	$globalSources[$id]['format'] = 'myshiptracking';
264
-        	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
-        	    exit(0);
269
-        	}
270
-            //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
-        	//$formats[$id] = 'tsv';
273
-        	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
-            }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
-    		    if ($idf !== false) {
280
-    			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
-	    $hostport = explode(':',$host);
288
-	    if (isset($hostport[1])) {
213
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
+			//$formats[$id] = 'planeupdatefaa';
215
+			$globalSources[$id]['format'] = 'planeupdatefaa';
216
+			//$last_exec['planeupdatefaa'] = 0;
217
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
+				exit(0);
221
+			}
222
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'phpvmacars';
225
+			//$last_exec['phpvmacars'] = 0;
226
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
+			//$formats[$id] = 'phpvmacars';
229
+			$globalSources[$id]['format'] = 'vaos';
230
+			//$last_exec['phpvmacars'] = 0;
231
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
233
+			//$formats[$id] = 'phpvmacars';
234
+			$globalSources[$id]['format'] = 'vam';
235
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
+			} else if (preg_match('/whazzup/i',$host)) {
237
+			//$formats[$id] = 'whazzup';
238
+			$globalSources[$id]['format'] = 'whazzup';
239
+			//$last_exec['whazzup'] = 0;
240
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
+			} else if (preg_match('/blitzortung/i',$host)) {
242
+			$globalSources[$id]['format'] = 'blitzortung';
243
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
+			} else if (preg_match('/airwhere/i',$host)) {
245
+			$globalSources[$id]['format'] = 'airwhere';
246
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
+			} else if (preg_match('/recentpireps/i',$host)) {
248
+			//$formats[$id] = 'pirepsjson';
249
+			$globalSources[$id]['format'] = 'pirepsjson';
250
+			//$last_exec['pirepsjson'] = 0;
251
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
+			//$formats[$id] = 'fr24json';
254
+			$globalSources[$id]['format'] = 'fr24json';
255
+			//$last_exec['fr24json'] = 0;
256
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
+				exit(0);
260
+			}
261
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
262
+			//$formats[$id] = 'fr24json';
263
+			$globalSources[$id]['format'] = 'myshiptracking';
264
+			//$last_exec['fr24json'] = 0;
265
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
+				exit(0);
269
+			}
270
+			//} else if (preg_match('/10001/',$host)) {
271
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
+			//$formats[$id] = 'tsv';
273
+			$globalSources[$id]['format'] = 'tsv';
274
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
+			}
276
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
+			if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
+				if ($idf !== false) {
280
+				$httpfeeds[$id] = $idf;
281
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
+			elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
+		$hostport = explode(':',$host);
288
+		if (isset($hostport[1])) {
289 289
 		$port = $hostport[1];
290 290
 		$hostn = $hostport[0];
291
-	    } else {
291
+		} else {
292 292
 		$port = $globalSources[$id]['port'];
293 293
 		$hostn = $globalSources[$id]['host'];
294
-	    }
295
-	    $Common = new Common();
296
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
298
-    	    } else {
299
-    		$udp = true;
300
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
301
-	    }
302
-	    if ($s) {
303
-    	        $sockets[$id] = $s;
304
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
294
+		}
295
+		$Common = new Common();
296
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
298
+			} else {
299
+			$udp = true;
300
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
301
+		}
302
+		if ($s) {
303
+				$sockets[$id] = $s;
304
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
306 306
 			//$formats[$id] = 'aprs';
307 307
 			$globalSources[$id]['format'] = 'aprs';
308 308
 			//$aprs_connect = 0;
309 309
 			//$use_aprs = true;
310
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
311 311
 			$globalSources[$id]['format'] = 'vrstcp';
312
-    		    } elseif ($port == '10001') {
313
-        		//$formats[$id] = 'tsv';
314
-        		$globalSources[$id]['format'] = 'tsv';
315
-		    } elseif ($port == '30002') {
316
-        		//$formats[$id] = 'raw';
317
-        		$globalSources[$id]['format'] = 'raw';
318
-		    } elseif ($port == '5001') {
319
-        		//$formats[$id] = 'raw';
320
-        		$globalSources[$id]['format'] = 'flightgearmp';
321
-		    } elseif ($port == '30005') {
312
+				} elseif ($port == '10001') {
313
+				//$formats[$id] = 'tsv';
314
+				$globalSources[$id]['format'] = 'tsv';
315
+			} elseif ($port == '30002') {
316
+				//$formats[$id] = 'raw';
317
+				$globalSources[$id]['format'] = 'raw';
318
+			} elseif ($port == '5001') {
319
+				//$formats[$id] = 'raw';
320
+				$globalSources[$id]['format'] = 'flightgearmp';
321
+			} elseif ($port == '30005') {
322 322
 			// Not yet supported
323
-        		//$formats[$id] = 'beast';
324
-        		$globalSources[$id]['format'] = 'beast';
325
-		    //} else $formats[$id] = 'sbs';
326
-		    } else $globalSources[$id]['format'] = 'sbs';
327
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
323
+				//$formats[$id] = 'beast';
324
+				$globalSources[$id]['format'] = 'beast';
325
+			//} else $formats[$id] = 'sbs';
326
+			} else $globalSources[$id]['format'] = 'sbs';
327
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
328 328
 		}
329 329
 		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330 330
 		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
331
-            } else {
331
+			} else {
332 332
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
333 333
 		sleep(10);
334 334
 		connect_all($hosts);
335
-    	    }
336
-        }
337
-    }
335
+			}
336
+		}
337
+	}
338 338
 }
339 339
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
340 340
 
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 //connect_all($globalSources);
358 358
 
359 359
 if (isset($globalProxy) && $globalProxy) {
360
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
361 361
 } else {
362
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
362
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
363 363
 }
364 364
 
365 365
 // APRS Configuration
@@ -368,21 +368,21 @@  discard block
 block discarded – undo
368 368
 	die;
369 369
 }
370 370
 foreach ($globalSources as $key => $source) {
371
-    if (!isset($source['format'])) {
372
-        $globalSources[$key]['format'] = 'auto';
373
-    }
374
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
375
-        unset($globalSources[$key]);
376
-    }
371
+	if (!isset($source['format'])) {
372
+		$globalSources[$key]['format'] = 'auto';
373
+	}
374
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
375
+		unset($globalSources[$key]);
376
+	}
377 377
 }
378 378
 connect_all($globalSources);
379 379
 foreach ($globalSources as $key => $source) {
380
-    if (isset($source['format']) && $source['format'] == 'aprs') {
380
+	if (isset($source['format']) && $source['format'] == 'aprs') {
381 381
 	$aprs_connect = 0;
382 382
 	$use_aprs = true;
383 383
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
384 384
 	break;
385
-    }
385
+	}
386 386
 }
387 387
 
388 388
 if ($use_aprs) {
@@ -423,173 +423,173 @@  discard block
 block discarded – undo
423 423
 
424 424
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
425 425
 while ($i > 0) {
426
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
427 427
 
428
-    if (!$globalDaemon) $i = $endtime-time();
429
-    // Delete old ATC
430
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
428
+	if (!$globalDaemon) $i = $endtime-time();
429
+	// Delete old ATC
430
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431 431
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
432
-        $ATC->deleteOldATC();
433
-    }
432
+		$ATC->deleteOldATC();
433
+	}
434 434
     
435
-    if (count($last_exec) == count($globalSources)) {
435
+	if (count($last_exec) == count($globalSources)) {
436 436
 	$max = $globalMinFetch;
437 437
 	foreach ($last_exec as $last) {
438
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
438
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
439 439
 	}
440 440
 	if ($max < $globalMinFetch) {
441
-	    if ($globalDebug) echo 'Sleeping...'."\n";
442
-	    sleep($globalMinFetch-$max+2);
441
+		if ($globalDebug) echo 'Sleeping...'."\n";
442
+		sleep($globalMinFetch-$max+2);
443
+	}
443 444
 	}
444
-    }
445 445
 
446 446
     
447
-    //foreach ($formats as $id => $value) {
448
-    foreach ($globalSources as $id => $value) {
447
+	//foreach ($formats as $id => $value) {
448
+	foreach ($globalSources as $id => $value) {
449 449
 	date_default_timezone_set('UTC');
450 450
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
451 451
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
452 452
 	if ($value['format'] === 'deltadbtxt' && 
453
-	    (
453
+		(
454 454
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
455 455
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
456
-	    )
456
+		)
457 457
 	) {
458
-        //$buffer = $Common->getData($hosts[$id]);
459
-        $buffer = $Common->getData($value['host']);
460
-        if ($buffer != '') $reset = 0;
461
-        $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462
-        $buffer = explode('\n', $buffer);
463
-        foreach ($buffer as $line) {
464
-            if ($line != '' && count($line) > 7) {
465
-                $line = explode(',', $line);
466
-                $data = array();
467
-                $data['hex'] = $line[1]; // hex
468
-                $data['ident'] = $line[2]; // ident
469
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
474
-                $data['verticalrate'] = ''; // vertical rate
475
-                //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476
-                $data['emergency'] = ''; // emergency
477
-                $data['datetime'] = date('Y-m-d H:i:s');
478
-                $data['format_source'] = 'deltadbtxt';
479
-                $data['id_source'] = $id_source;
480
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
483
-                $SI->add($data);
484
-                unset($data);
485
-            }
486
-        }
487
-        $last_exec[$id]['last'] = time();
488
-    } elseif ($value['format'] === 'radarcapejson' &&
489
-            (
490
-                (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
491
-                (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
492
-            )
493
-        ) {
494
-            //$buffer = $Common->getData($hosts[$id]);
495
-            $buffer = $Common->getData($value['host']);
496
-            if ($buffer != '') {
497
-                $all_data = json_decode($buffer,true);
498
-                foreach ($all_data as $line) {
499
-                    $data = array();
500
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
501
-                    $data['hex'] = $line['hex']; // hex
502
-                    $data['ident'] = $line['fli']; // ident
503
-                    $data['altitude'] = $line['alt']; // altitude
504
-                    $data['speed'] = $line['spd']; // speed
505
-                    $data['heading'] = $line['trk']; // heading
506
-                    $data['latitude'] = $line['lat']; // lat
507
-                    $data['longitude'] = $line['lon']; // long
508
-                    $data['verticalrate'] = $line['vrt']; // vertical rate
509
-                    $data['squawk'] = $line['squ']; // squawk
510
-                    $data['ground'] = $line['gda']; // ground
511
-                    $data['registration'] = $line['reg'];
512
-                    //$data['emergency'] = ''; // emergency
513
-                    $data['datetime'] = date('Y-m-d H:i:s');
514
-                    $data['format_source'] = 'radarcapejson';
515
-                    $data['id_source'] = $id_source;
516
-                    if (isset($value['name']) && $value['name'] != '') {
517
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
-                        else $data['source_name'] = $value['name'];
519
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
458
+		//$buffer = $Common->getData($hosts[$id]);
459
+		$buffer = $Common->getData($value['host']);
460
+		if ($buffer != '') $reset = 0;
461
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462
+		$buffer = explode('\n', $buffer);
463
+		foreach ($buffer as $line) {
464
+			if ($line != '' && count($line) > 7) {
465
+				$line = explode(',', $line);
466
+				$data = array();
467
+				$data['hex'] = $line[1]; // hex
468
+				$data['ident'] = $line[2]; // ident
469
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
474
+				$data['verticalrate'] = ''; // vertical rate
475
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476
+				$data['emergency'] = ''; // emergency
477
+				$data['datetime'] = date('Y-m-d H:i:s');
478
+				$data['format_source'] = 'deltadbtxt';
479
+				$data['id_source'] = $id_source;
480
+				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
+				if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
483
+				$SI->add($data);
484
+				unset($data);
485
+			}
486
+		}
487
+		$last_exec[$id]['last'] = time();
488
+	} elseif ($value['format'] === 'radarcapejson' &&
489
+			(
490
+				(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
491
+				(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
492
+			)
493
+		) {
494
+			//$buffer = $Common->getData($hosts[$id]);
495
+			$buffer = $Common->getData($value['host']);
496
+			if ($buffer != '') {
497
+				$all_data = json_decode($buffer,true);
498
+				foreach ($all_data as $line) {
499
+					$data = array();
500
+					$data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
501
+					$data['hex'] = $line['hex']; // hex
502
+					$data['ident'] = $line['fli']; // ident
503
+					$data['altitude'] = $line['alt']; // altitude
504
+					$data['speed'] = $line['spd']; // speed
505
+					$data['heading'] = $line['trk']; // heading
506
+					$data['latitude'] = $line['lat']; // lat
507
+					$data['longitude'] = $line['lon']; // long
508
+					$data['verticalrate'] = $line['vrt']; // vertical rate
509
+					$data['squawk'] = $line['squ']; // squawk
510
+					$data['ground'] = $line['gda']; // ground
511
+					$data['registration'] = $line['reg'];
512
+					//$data['emergency'] = ''; // emergency
513
+					$data['datetime'] = date('Y-m-d H:i:s');
514
+					$data['format_source'] = 'radarcapejson';
515
+					$data['id_source'] = $id_source;
516
+					if (isset($value['name']) && $value['name'] != '') {
517
+						if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
+						else $data['source_name'] = $value['name'];
519
+					} elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
+					if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
+					if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
522 522
 
523
-                    $SI->add($data);
524
-                    unset($data);
525
-                }
526
-            }
527
-            $last_exec[$id]['last'] = time();
523
+					$SI->add($data);
524
+					unset($data);
525
+				}
526
+			}
527
+			$last_exec[$id]['last'] = time();
528 528
 	} elseif ($value['format'] === 'aisnmeatxt' && 
529
-	    (
529
+		(
530 530
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
531 531
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
532
-	    )
532
+		)
533 533
 	) {
534
-	    date_default_timezone_set('CET');
535
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536
-	    date_default_timezone_set('UTC');
537
-	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
540
-	    foreach ($buffer as $line) {
534
+		date_default_timezone_set('CET');
535
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536
+		date_default_timezone_set('UTC');
537
+		if ($buffer != '') $reset = 0;
538
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
+		$buffer = explode('\n',$buffer);
540
+		foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542
-		    //echo "'".$line."'\n";
543
-		    $add = false;
544
-		    $ais_data = $AIS->parse_line(trim($line));
545
-		    $data = array();
546
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558
-		    if (isset($ais_data['timestamp'])) {
542
+			//echo "'".$line."'\n";
543
+			$add = false;
544
+			$ais_data = $AIS->parse_line(trim($line));
545
+			$data = array();
546
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558
+			if (isset($ais_data['timestamp'])) {
559 559
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
560 560
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
561
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562
-			    $add = true;
561
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562
+				$add = true;
563 563
 			}
564
-		    } else {
564
+			} else {
565 565
 			$data['datetime'] = date('Y-m-d H:i:s');
566 566
 			$add = true;
567
-		    }
568
-		    $data['format_source'] = 'aisnmeatxt';
569
-    		    $data['id_source'] = $id_source;
570
-		    //print_r($data);
571
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
573
-		    unset($data);
567
+			}
568
+			$data['format_source'] = 'aisnmeatxt';
569
+				$data['id_source'] = $id_source;
570
+			//print_r($data);
571
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
573
+			unset($data);
574 574
 		}
575
-    	    }
576
-    	    $last_exec[$id]['last'] = time();
575
+			}
576
+			$last_exec[$id]['last'] = time();
577 577
 	} elseif ($value['format'] === 'aisnmeahttp') {
578
-	    $arr = $httpfeeds;
579
-	    $w = $e = null;
578
+		$arr = $httpfeeds;
579
+		$w = $e = null;
580 580
 	    
581
-	    if (isset($arr[$id])) {
581
+		if (isset($arr[$id])) {
582 582
 		$nn = stream_select($arr,$w,$e,$timeout);
583 583
 		if ($nn > 0) {
584
-		    foreach ($httpfeeds as $feed) {
584
+			foreach ($httpfeeds as $feed) {
585 585
 			$buffer = stream_get_line($feed,2000,"\n");
586 586
 			if ($buffer === FALSE) {
587
-			    connect_all($globalSources);
587
+				connect_all($globalSources);
588 588
 			}
589 589
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
590 590
 			$buffer = explode('\n',$buffer);
591 591
 			foreach ($buffer as $line) {
592
-			    if ($line != '') {
592
+				if ($line != '') {
593 593
 				$ais_data = $AIS->parse_line(trim($line));
594 594
 				$data = array();
595 595
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -607,117 +607,117 @@  discard block
 block discarded – undo
607 607
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608 608
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
609 609
 				if (isset($ais_data['timestamp'])) {
610
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
611 611
 				} else {
612
-				    $data['datetime'] = date('Y-m-d H:i:s');
612
+					$data['datetime'] = date('Y-m-d H:i:s');
613 613
 				}
614 614
 				$data['format_source'] = 'aisnmeahttp';
615 615
 				$data['id_source'] = $id_source;
616 616
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
617 617
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
618 618
 				unset($data);
619
-			    }
619
+				}
620
+			}
620 621
 			}
621
-		    }
622 622
 		} else {
623
-		    $format = $value['format'];
624
-		    if (isset($tt[$format])) $tt[$format]++;
625
-		    else $tt[$format] = 0;
626
-		    if ($tt[$format] > 30) {
623
+			$format = $value['format'];
624
+			if (isset($tt[$format])) $tt[$format]++;
625
+			else $tt[$format] = 0;
626
+			if ($tt[$format] > 30) {
627 627
 			if ($globalDebug) echo 'Reconnect...'."\n";
628 628
 			sleep(2);
629 629
 			//$sourceeen[] = $value;
630 630
 			//connect_all($sourceeen);
631 631
 			//$sourceeen = array();
632 632
 			connect_all($globalSources);
633
-		    }
633
+			}
634
+		}
634 635
 		}
635
-	    }
636 636
 	} elseif ($value['format'] === 'myshiptracking' && 
637
-	    (
637
+		(
638 638
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
639 639
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
640
-	    )
640
+		)
641 641
 	) {
642
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
643
-	    if ($buffer != '') {
642
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
643
+		if ($buffer != '') {
644 644
 		//echo $buffer;
645 645
 		$all_data = json_decode($buffer,true);
646 646
 		//print_r($all_data);
647 647
 		if (isset($all_data[0]['DATA'])) {
648
-		    foreach ($all_data[0]['DATA'] as $line) {
648
+			foreach ($all_data[0]['DATA'] as $line) {
649 649
 			if ($line != '') {
650
-			    $data = array();
651
-			    $data['ident'] = $line['NAME'];
652
-			    $data['mmsi'] = $line['MMSI'];
653
-			    if (strlen($data['mmsi']) > 9) {
650
+				$data = array();
651
+				$data['ident'] = $line['NAME'];
652
+				$data['mmsi'] = $line['MMSI'];
653
+				if (strlen($data['mmsi']) > 9) {
654 654
 				$data['mmsi'] = substr($data['mmsi'],-9);
655
-			    }
656
-			    $data['speed'] = $line['SOG'];
657
-			    $data['heading'] = $line['COG'];
658
-			    $data['latitude'] = $line['LAT'];
659
-			    $data['longitude'] = $line['LNG'];
660
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661
-			    //$data['type_id'] = $line['TYPE'];
662
-			    $data['imo'] = $line['IMO'];
663
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666
-			    $data['format_source'] = 'myshiptracking';
667
-			    $data['id_source'] = $id_source;
668
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
669
-			    $MI->add($data);
670
-			    unset($data);
655
+				}
656
+				$data['speed'] = $line['SOG'];
657
+				$data['heading'] = $line['COG'];
658
+				$data['latitude'] = $line['LAT'];
659
+				$data['longitude'] = $line['LNG'];
660
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661
+				//$data['type_id'] = $line['TYPE'];
662
+				$data['imo'] = $line['IMO'];
663
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666
+				$data['format_source'] = 'myshiptracking';
667
+				$data['id_source'] = $id_source;
668
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
669
+				$MI->add($data);
670
+				unset($data);
671
+			}
671 672
 			}
672
-		    }
673 673
 		}
674
-	    }
675
-	    $last_exec[$id]['last'] = time();
674
+		}
675
+		$last_exec[$id]['last'] = time();
676 676
 	} elseif ($value['format'] === 'boatbeaconapp' && 
677
-	    (
677
+		(
678 678
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
679 679
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
680
-	    )
680
+		)
681 681
 	) {
682
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
683
-	    if ($buffer != '') {
682
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
683
+		if ($buffer != '') {
684 684
 		$all_data = json_decode($buffer,true);
685 685
 		if (isset($all_data[0]['mmsi'])) {
686
-		    foreach ($all_data as $line) {
686
+			foreach ($all_data as $line) {
687 687
 			if ($line != '') {
688
-			    $data = array();
689
-			    $data['ident'] = $line['shipname'];
690
-			    $data['callsign'] = $line['callsign'];
691
-			    $data['mmsi'] = substr($line['mmsi'],-9);
692
-			    $data['speed'] = $line['sog'];
693
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694
-			    $data['latitude'] = $line['latitude'];
695
-			    $data['longitude'] = $line['longitude'];
696
-			    $data['type_id'] = $line['shiptype'];
697
-			    $data['arrival_code'] = $line['destination'];
698
-			    $data['datetime'] = $line['time'];
699
-			    $data['format_source'] = 'boatbeaconapp';
700
-			    $data['id_source'] = $id_source;
701
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
-			    $MI->add($data);
703
-			    unset($data);
688
+				$data = array();
689
+				$data['ident'] = $line['shipname'];
690
+				$data['callsign'] = $line['callsign'];
691
+				$data['mmsi'] = substr($line['mmsi'],-9);
692
+				$data['speed'] = $line['sog'];
693
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694
+				$data['latitude'] = $line['latitude'];
695
+				$data['longitude'] = $line['longitude'];
696
+				$data['type_id'] = $line['shiptype'];
697
+				$data['arrival_code'] = $line['destination'];
698
+				$data['datetime'] = $line['time'];
699
+				$data['format_source'] = 'boatbeaconapp';
700
+				$data['id_source'] = $id_source;
701
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
+				$MI->add($data);
703
+				unset($data);
704
+			}
704 705
 			}
705
-		    }
706 706
 		}
707 707
 		
708
-	    }
709
-    	    $last_exec[$id]['last'] = time();
708
+		}
709
+			$last_exec[$id]['last'] = time();
710 710
 	} elseif ($value['format'] === 'boatnerd' && 
711
-	    (
711
+		(
712 712
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
713 713
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
714
-	    )
714
+		)
715 715
 	) {
716
-	    $buffer = $Common->getData($value['host']);
717
-	    if ($buffer != '') {
716
+		$buffer = $Common->getData($value['host']);
717
+		if ($buffer != '') {
718 718
 		$all_data = json_decode($buffer,true);
719 719
 		if (isset($all_data['features'][0]['id'])) {
720
-		    foreach ($all_data['features'] as $line) {
720
+			foreach ($all_data['features'] as $line) {
721 721
 			print_r($line);
722 722
 			$data = array();
723 723
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -737,75 +737,75 @@  discard block
 block discarded – undo
737 737
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738 738
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
739 739
 			unset($data);
740
-		    }
740
+			}
741 741
 		}
742 742
 		
743
-	    }
744
-    	    $last_exec[$id]['last'] = time();
743
+		}
744
+			$last_exec[$id]['last'] = time();
745 745
 	} elseif ($value['format'] === 'shipplotter' && 
746
-	    (
746
+		(
747 747
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
748 748
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
749
-	    )
749
+		)
750 750
 	) {
751
-	    if ($globalDebug) echo 'download...';
752
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
-	    if ($globalDebug) echo 'done !'."\n";
754
-	    // FIXME: Need more work
755
-	    if ($buffer != '') $reset = 0;
756
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
-	    $buffer = explode('\n',$buffer);
758
-	    foreach ($buffer as $line) {
751
+		if ($globalDebug) echo 'download...';
752
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
+		if ($globalDebug) echo 'done !'."\n";
754
+		// FIXME: Need more work
755
+		if ($buffer != '') $reset = 0;
756
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
+		$buffer = explode('\n',$buffer);
758
+		foreach ($buffer as $line) {
759 759
 		if ($line != '') {
760
-		    $data = array();
761
-		    //echo $line."\n";
762
-		    $data['mmsi'] = (int)substr($line,0,9);
763
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
-		    $data['status_id'] = substr($line,21,2);
765
-		    $data['type_id'] = substr($line,24,3);
766
-		    $data['latitude'] = substr($line,29,9);
767
-		    $data['longitude'] = substr($line,41,9);
768
-		    $data['speed'] = round(substr($line,51,5));
769
-		    //$data['course'] = substr($line,57,5);
770
-		    $data['heading'] = round(substr($line,63,3));
771
-		    //$data['draft'] = substr($line,67,4);
772
-		    //$data['length'] = substr($line,72,3);
773
-		    //$data['beam'] = substr($line,76,2);
774
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
775
-		    //$data['callsign'] = trim(substr($line,100,7);
776
-		    $data['arrival_code'] = substr($line,108,20);
777
-		    //$data['etaDate'] = substr($line,129,5);
778
-		    //$data['etaTime'] = substr($line,135,5);
779
-		    $data['format_source'] = 'shipplotter';
780
-    		    $data['id_source'] = $id_source;
781
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
782
-		    //print_r($data);
783
-		    //echo 'Add...'."\n";
784
-		    $MI->add($data);
785
-		    unset($data);
760
+			$data = array();
761
+			//echo $line."\n";
762
+			$data['mmsi'] = (int)substr($line,0,9);
763
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
+			$data['status_id'] = substr($line,21,2);
765
+			$data['type_id'] = substr($line,24,3);
766
+			$data['latitude'] = substr($line,29,9);
767
+			$data['longitude'] = substr($line,41,9);
768
+			$data['speed'] = round(substr($line,51,5));
769
+			//$data['course'] = substr($line,57,5);
770
+			$data['heading'] = round(substr($line,63,3));
771
+			//$data['draft'] = substr($line,67,4);
772
+			//$data['length'] = substr($line,72,3);
773
+			//$data['beam'] = substr($line,76,2);
774
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
775
+			//$data['callsign'] = trim(substr($line,100,7);
776
+			$data['arrival_code'] = substr($line,108,20);
777
+			//$data['etaDate'] = substr($line,129,5);
778
+			//$data['etaTime'] = substr($line,135,5);
779
+			$data['format_source'] = 'shipplotter';
780
+				$data['id_source'] = $id_source;
781
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
782
+			//print_r($data);
783
+			//echo 'Add...'."\n";
784
+			$MI->add($data);
785
+			unset($data);
786 786
 		}
787
-    	    }
788
-    	    $last_exec[$id]['last'] = time();
787
+			}
788
+			$last_exec[$id]['last'] = time();
789 789
 	} elseif ($value['format'] === 'sailawayfull' && 
790
-	    (
790
+		(
791 791
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 10*60))
792
-	    )
792
+		)
793 793
 	) {
794
-	    if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') {
794
+		if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') {
795 795
 		echo 'Sailaway API key MUST be defined';
796 796
 		exit(0);
797
-	    }
798
-	    $sailawayoption = array('key' => $globalSailaway['key']);
799
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
800
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
797
+		}
798
+		$sailawayoption = array('key' => $globalSailaway['key']);
799
+		if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
800
+		if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
801 801
 
802
-	    for ($i = 0; $i <= 1; $i++) {
802
+		for ($i = 0; $i <= 1; $i++) {
803 803
 		if ($globalDebug) echo '! Download... ';
804 804
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30);
805 805
 		if ($globalDebug) echo 'done'."\n";
806 806
 		if ($buffer != '') {
807
-		    $all_data = json_decode($buffer,true);
808
-		    if (isset($all_data['missions'])) {
807
+			$all_data = json_decode($buffer,true);
808
+			if (isset($all_data['missions'])) {
809 809
 			foreach ($all_data['missions'] as $mission) {
810 810
 				$mission_user = $mission['usrname'];
811 811
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
@@ -832,17 +832,17 @@  discard block
 block discarded – undo
832 832
 					unset($datar);
833 833
 				}
834 834
 			}
835
-		    }
835
+			}
836 836
 		}
837 837
 		if ($globalDebug) echo '=== Wait... ===';
838 838
 		sleep(10*60);
839
-	    }
840
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
841
-	    if ($buffer != '') {
839
+		}
840
+		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
841
+		if ($buffer != '') {
842 842
 		$data = json_decode($buffer,true);
843 843
 		//print_r($data);
844 844
 		if (isset($data['boats'])) {
845
-		    foreach ($data['boats'] as $sail) {
845
+			foreach ($data['boats'] as $sail) {
846 846
 			$data = array();
847 847
 			$data['id'] = $sail['ubtnr'];
848 848
 			$data['datetime'] = date('Y-m-d H:i:s');
@@ -862,17 +862,17 @@  discard block
 block discarded – undo
862 862
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
863 863
 			$MI->add($data);
864 864
 			unset($data);
865
-		    }
865
+			}
866 866
 		} elseif ($globalDebug) echo 'Error in JSON parsing';
867
-	    } elseif ($globalDebug) echo 'Empty result !'."\n";
867
+		} elseif ($globalDebug) echo 'Empty result !'."\n";
868 868
 
869
-    	    $last_exec[$id]['last'] = time();
869
+			$last_exec[$id]['last'] = time();
870 870
 	} elseif ($value['format'] === 'sailaway' && 
871
-	    (
871
+		(
872 872
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 10*60))
873
-	    )
873
+		)
874 874
 	) {
875
-	    /*
875
+		/*
876 876
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
877 877
 		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
878 878
 		//echo $authsailaway;
@@ -883,20 +883,20 @@  discard block
 block discarded – undo
883 883
 		}
884 884
 	    }
885 885
 	    */
886
-	    if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') {
886
+		if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') {
887 887
 		echo 'Sailaway API key MUST be defined';
888 888
 		exit(0);
889
-	    }
890
-	    if ($globalDebug) echo '! Download... ';
891
-	    $sailawayoption = array('key' => $globalSailaway['key']);
892
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
893
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
894
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
895
-	    if ($buffer != '') {
889
+		}
890
+		if ($globalDebug) echo '! Download... ';
891
+		$sailawayoption = array('key' => $globalSailaway['key']);
892
+		if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
893
+		if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
894
+		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
895
+		if ($buffer != '') {
896 896
 		$data = json_decode($buffer,true);
897 897
 		//print_r($data);
898 898
 		if (isset($data['boats'])) {
899
-		    foreach ($data['boats'] as $sail) {
899
+			foreach ($data['boats'] as $sail) {
900 900
 			$data = array();
901 901
 			$data['id'] = $sail['ubtnr'];
902 902
 			$data['datetime'] = date('Y-m-d H:i:s');
@@ -916,35 +916,35 @@  discard block
 block discarded – undo
916 916
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
917 917
 			$MI->add($data);
918 918
 			unset($data);
919
-		    }
919
+			}
920 920
 		} elseif ($globalDebug) echo 'Error in JSON parsing';
921
-	    } elseif ($globalDebug) echo 'Empty result !'."\n";
922
-    	    $last_exec[$id]['last'] = time();
921
+		} elseif ($globalDebug) echo 'Empty result !'."\n";
922
+			$last_exec[$id]['last'] = time();
923 923
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
924 924
 	} elseif (
925
-	    (
925
+		(
926 926
 		$value['format'] === 'whazzup' && 
927 927
 		(
928
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
929
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
928
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
929
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
930 930
 		)
931
-	    ) || (
931
+		) || (
932 932
 		$value['format'] === 'vatsimtxt' && 
933 933
 		(
934
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
935
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
934
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
935
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
936
+		)
936 937
 		)
937
-	    )
938 938
 	) {
939
-	    //$buffer = $Common->getData($hosts[$id]);
940
-	    $buffer = $Common->getData($value['host']);
941
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
942
-	    $buffer = explode('\n',$buffer);
943
-	    $reset = 0;
944
-	    foreach ($buffer as $line) {
945
-    		if ($line != '') {
946
-    		    $line = explode(':', $line);
947
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
939
+		//$buffer = $Common->getData($hosts[$id]);
940
+		$buffer = $Common->getData($value['host']);
941
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
942
+		$buffer = explode('\n',$buffer);
943
+		$reset = 0;
944
+		foreach ($buffer as $line) {
945
+			if ($line != '') {
946
+				$line = explode(':', $line);
947
+				if (count($line) > 30 && $line[0] != 'callsign') {
948 948
 			$data = array();
949 949
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
950 950
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -957,37 +957,37 @@  discard block
 block discarded – undo
957 957
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
958 958
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
959 959
 			$data['latitude'] = $line[5]; // lat
960
-	        	$data['longitude'] = $line[6]; // long
961
-	        	$data['verticalrate'] = ''; // vertical rate
962
-	        	$data['squawk'] = ''; // squawk
963
-	        	$data['emergency'] = ''; // emergency
964
-	        	$data['waypoints'] = $line[30];
960
+				$data['longitude'] = $line[6]; // long
961
+				$data['verticalrate'] = ''; // vertical rate
962
+				$data['squawk'] = ''; // squawk
963
+				$data['emergency'] = ''; // emergency
964
+				$data['waypoints'] = $line[30];
965 965
 			$data['datetime'] = date('Y-m-d H:i:s');
966 966
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
967 967
 			//if (isset($line[37])) $data['last_update'] = $line[37];
968
-		        $data['departure_airport_icao'] = $line[11];
969
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
970
-		        $data['arrival_airport_icao'] = $line[13];
968
+				$data['departure_airport_icao'] = $line[11];
969
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
970
+				$data['arrival_airport_icao'] = $line[13];
971 971
 			$data['frequency'] = $line[4];
972 972
 			$data['type'] = $line[18];
973 973
 			$data['range'] = $line[19];
974 974
 			if (isset($line[35])) $data['info'] = $line[35];
975
-    			$data['id_source'] = $id_source;
976
-	    		//$data['arrival_airport_time'] = ;
977
-	    		if ($line[9] != '') {
978
-	    		    $aircraft_data = explode('/',$line[9]);
979
-	    		    if (isset($aircraft_data[1])) {
980
-	    			$data['aircraft_icao'] = $aircraft_data[1];
981
-	    		    }
982
-        		}
983
-	    		/*
975
+				$data['id_source'] = $id_source;
976
+				//$data['arrival_airport_time'] = ;
977
+				if ($line[9] != '') {
978
+					$aircraft_data = explode('/',$line[9]);
979
+					if (isset($aircraft_data[1])) {
980
+					$data['aircraft_icao'] = $aircraft_data[1];
981
+					}
982
+				}
983
+				/*
984 984
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
985 985
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
986 986
 	    		*/
987
-	    		$data['format_source'] = $value['format'];
987
+				$data['format_source'] = $value['format'];
988 988
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
989 989
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
990
-    			if ($line[3] === 'PILOT') $SI->add($data);
990
+				if ($line[3] === 'PILOT') $SI->add($data);
991 991
 			elseif ($line[3] === 'ATC') {
992 992
 				//print_r($data);
993 993
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -1008,21 +1008,21 @@  discard block
 block discarded – undo
1008 1008
 					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']);
1009 1009
 				}
1010 1010
 			}
1011
-    			unset($data);
1012
-    		    }
1013
-    		}
1014
-    	    }
1015
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
1016
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1017
-    	    $last_exec[$id]['last'] = time();
1018
-    	} elseif ($value['format'] === 'airwhere' && 
1019
-    	    (
1020
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1021
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1022
-    	    )
1023
-    	) {
1024
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1025
-	    if ($buffer != '') {
1011
+				unset($data);
1012
+				}
1013
+			}
1014
+			}
1015
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
1016
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1017
+			$last_exec[$id]['last'] = time();
1018
+		} elseif ($value['format'] === 'airwhere' && 
1019
+			(
1020
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1021
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1022
+			)
1023
+		) {
1024
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1025
+		if ($buffer != '') {
1026 1026
 		$all_data = simplexml_load_string($buffer);
1027 1027
 		foreach($all_data->children() as $childdata) {
1028 1028
 			$data = array();
@@ -1044,10 +1044,10 @@  discard block
 block discarded – undo
1044 1044
 			$SI->add($data);
1045 1045
 			unset($data);
1046 1046
 		}
1047
-	    }
1048
-	    $Source->deleteOldLocationByType('gs');
1049
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1050
-	    if ($buffer != '') {
1047
+		}
1048
+		$Source->deleteOldLocationByType('gs');
1049
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1050
+		if ($buffer != '') {
1051 1051
 		$all_data = simplexml_load_string($buffer);
1052 1052
 		foreach($all_data->children() as $childdata) {
1053 1053
 			$data = array();
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 			}
1066 1066
 			unset($data);
1067 1067
 		}
1068
-	    }
1069
-	    $last_exec[$id]['last'] = time();
1068
+		}
1069
+		$last_exec[$id]['last'] = time();
1070 1070
 	/*
1071 1071
 	} if ($value['format'] === 'aircraftlistjson') {
1072 1072
 	    print_r($globalSources);
@@ -1074,17 +1074,17 @@  discard block
 block discarded – undo
1074 1074
 	    echo $globalMinFetch;
1075 1075
 	*/
1076 1076
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1077
-	    (
1077
+		(
1078 1078
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1079 1079
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1080
-	    )
1080
+		)
1081 1081
 	) {
1082
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1083
-	    if ($buffer != '') {
1084
-	        $all_data = json_decode($buffer,true);
1082
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1083
+		if ($buffer != '') {
1084
+			$all_data = json_decode($buffer,true);
1085 1085
 		if (isset($all_data['acList'])) {
1086
-		    $reset = 0;
1087
-		    foreach ($all_data['acList'] as $line) {
1086
+			$reset = 0;
1087
+			foreach ($all_data['acList'] as $line) {
1088 1088
 			$data = array();
1089 1089
 			$data['hex'] = $line['Icao']; // hex
1090 1090
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1107,10 +1107,10 @@  discard block
 block discarded – undo
1107 1107
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1108 1108
 			if (isset($data['latitude'])) $SI->add($data);
1109 1109
 			unset($data);
1110
-		    }
1110
+			}
1111 1111
 		} elseif (is_array($all_data)) {
1112
-		    $reset = 0;
1113
-		    foreach ($all_data as $line) {
1112
+			$reset = 0;
1113
+			foreach ($all_data as $line) {
1114 1114
 			$data = array();
1115 1115
 			$data['hex'] = $line['hex']; // hex
1116 1116
 			$data['ident'] = $line['flight']; // ident
@@ -1130,291 +1130,291 @@  discard block
 block discarded – undo
1130 1130
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131 1131
 			$SI->add($data);
1132 1132
 			unset($data);
1133
-		    }
1133
+			}
1134 1134
 		}
1135
-	    } elseif ($globalDebug) echo 'No data'."\n";
1136
-    	    //$last_exec['aircraftlistjson'] = time();
1137
-    	    $last_exec[$id]['last'] = time();
1138
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1139
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1140
-    	    (
1141
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1142
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1143
-    	    )
1144
-    	) {
1145
-	    $buffer = $Common->getData($value['host']);
1146
-	    $all_data = json_decode($buffer,true);
1147
-	    if (isset($all_data['planes'])) {
1135
+		} elseif ($globalDebug) echo 'No data'."\n";
1136
+			//$last_exec['aircraftlistjson'] = time();
1137
+			$last_exec[$id]['last'] = time();
1138
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1139
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1140
+			(
1141
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1142
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1143
+			)
1144
+		) {
1145
+		$buffer = $Common->getData($value['host']);
1146
+		$all_data = json_decode($buffer,true);
1147
+		if (isset($all_data['planes'])) {
1148 1148
 		$reset = 0;
1149 1149
 		foreach ($all_data['planes'] as $key => $line) {
1150
-		    $data = array();
1151
-		    $data['hex'] = $key; // hex
1152
-		    $data['ident'] = $line[3]; // ident
1153
-		    $data['altitude'] = $line[6]; // altitude
1154
-		    $data['speed'] = $line[8]; // speed
1155
-		    $data['heading'] = $line[7]; // heading
1156
-		    $data['latitude'] = $line[4]; // lat
1157
-		    $data['longitude'] = $line[5]; // long
1158
-		    //$data['verticalrate'] = $line[]; // verticale rate
1159
-		    $data['squawk'] = $line[10]; // squawk
1160
-		    $data['emergency'] = ''; // emergency
1161
-		    $data['registration'] = $line[2];
1162
-		    $data['aircraft_icao'] = $line[0];
1163
-		    $deparr = explode('-',$line[1]);
1164
-		    if (count($deparr) === 2) {
1150
+			$data = array();
1151
+			$data['hex'] = $key; // hex
1152
+			$data['ident'] = $line[3]; // ident
1153
+			$data['altitude'] = $line[6]; // altitude
1154
+			$data['speed'] = $line[8]; // speed
1155
+			$data['heading'] = $line[7]; // heading
1156
+			$data['latitude'] = $line[4]; // lat
1157
+			$data['longitude'] = $line[5]; // long
1158
+			//$data['verticalrate'] = $line[]; // verticale rate
1159
+			$data['squawk'] = $line[10]; // squawk
1160
+			$data['emergency'] = ''; // emergency
1161
+			$data['registration'] = $line[2];
1162
+			$data['aircraft_icao'] = $line[0];
1163
+			$deparr = explode('-',$line[1]);
1164
+			if (count($deparr) === 2) {
1165 1165
 			$data['departure_airport_icao'] = $deparr[0];
1166 1166
 			$data['arrival_airport_icao'] = $deparr[1];
1167
-		    }
1168
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1169
-	    	    $data['format_source'] = 'planeupdatefaa';
1170
-    		    $data['id_source'] = $id_source;
1171
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1172
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1173
-		    $SI->add($data);
1174
-		    unset($data);
1167
+			}
1168
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1169
+				$data['format_source'] = 'planeupdatefaa';
1170
+				$data['id_source'] = $id_source;
1171
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1172
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1173
+			$SI->add($data);
1174
+			unset($data);
1175 1175
 		}
1176
-	    }
1177
-	    //$last_exec['planeupdatefaa'] = time();
1178
-	    $last_exec[$id]['last'] = time();
1176
+		}
1177
+		//$last_exec['planeupdatefaa'] = time();
1178
+		$last_exec[$id]['last'] = time();
1179 1179
 	} elseif ($value['format'] === 'opensky' && 
1180
-	    (
1180
+		(
1181 1181
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1182 1182
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1183
-	    )
1183
+		)
1184 1184
 	) {
1185
-	    $buffer = $Common->getData($value['host']);
1186
-	    $all_data = json_decode($buffer,true);
1187
-	    if (isset($all_data['states'])) {
1185
+		$buffer = $Common->getData($value['host']);
1186
+		$all_data = json_decode($buffer,true);
1187
+		if (isset($all_data['states'])) {
1188 1188
 		$reset = 0;
1189 1189
 		foreach ($all_data['states'] as $key => $line) {
1190
-		    $data = array();
1191
-		    $data['hex'] = $line[0]; // hex
1192
-		    $data['ident'] = trim($line[1]); // ident
1193
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1194
-		    $data['speed'] = round($line[9]*1.94384); // speed
1195
-		    $data['heading'] = round($line[10]); // heading
1196
-		    $data['latitude'] = $line[6]; // lat
1197
-		    $data['longitude'] = $line[5]; // long
1198
-		    $data['verticalrate'] = $line[11]; // verticale rate
1199
-		    //$data['squawk'] = $line[10]; // squawk
1200
-		    //$data['emergency'] = ''; // emergency
1201
-		    //$data['registration'] = $line[2];
1202
-		    //$data['aircraft_icao'] = $line[0];
1203
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1204
-		    $data['format_source'] = 'opensky';
1205
-		    $data['id_source'] = $id_source;
1206
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1207
-		    $SI->add($data);
1208
-		    unset($data);
1190
+			$data = array();
1191
+			$data['hex'] = $line[0]; // hex
1192
+			$data['ident'] = trim($line[1]); // ident
1193
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1194
+			$data['speed'] = round($line[9]*1.94384); // speed
1195
+			$data['heading'] = round($line[10]); // heading
1196
+			$data['latitude'] = $line[6]; // lat
1197
+			$data['longitude'] = $line[5]; // long
1198
+			$data['verticalrate'] = $line[11]; // verticale rate
1199
+			//$data['squawk'] = $line[10]; // squawk
1200
+			//$data['emergency'] = ''; // emergency
1201
+			//$data['registration'] = $line[2];
1202
+			//$data['aircraft_icao'] = $line[0];
1203
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1204
+			$data['format_source'] = 'opensky';
1205
+			$data['id_source'] = $id_source;
1206
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1207
+			$SI->add($data);
1208
+			unset($data);
1209 1209
 		}
1210
-	    }
1211
-	    //$last_exec['planeupdatefaa'] = time();
1212
-	    $last_exec[$id]['last'] = time();
1210
+		}
1211
+		//$last_exec['planeupdatefaa'] = time();
1212
+		$last_exec[$id]['last'] = time();
1213 1213
 	} elseif ($value['format'] === 'aircraftjson' && 
1214
-	    (
1214
+		(
1215 1215
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1216 1216
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1217
-	    )
1217
+		)
1218 1218
 	) {
1219
-	    $buffer = $Common->getData($value['host']);
1220
-	    $all_data = json_decode($buffer,true);
1221
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1219
+		$buffer = $Common->getData($value['host']);
1220
+		$all_data = json_decode($buffer,true);
1221
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1222 1222
 		$reset = 0;
1223 1223
 		foreach ($all_data['aircraft'] as $key => $line) {
1224
-		    $data = array();
1225
-		    // add support for ground vehicule with ~ in front of hex
1226
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1227
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1228
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1229
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1230
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1231
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1232
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1233
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1234
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1235
-		    //$data['emergency'] = ''; // emergency
1236
-		    //$data['registration'] = $line[2];
1237
-		    //$data['aircraft_icao'] = $line[0];
1238
-		    $data['datetime'] = date('Y-m-d H:i:s');
1239
-		    $data['format_source'] = 'aircraftjson';
1240
-		    $data['id_source'] = $id_source;
1241
-		    if (isset($value['name']) && $value['name'] != '') {
1242
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1243
-			    else $data['source_name'] = $value['name'];
1244
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1245
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1246
-		    $SI->add($data);
1247
-		    unset($data);
1224
+			$data = array();
1225
+			// add support for ground vehicule with ~ in front of hex
1226
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1227
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1228
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1229
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1230
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1231
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1232
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1233
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1234
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1235
+			//$data['emergency'] = ''; // emergency
1236
+			//$data['registration'] = $line[2];
1237
+			//$data['aircraft_icao'] = $line[0];
1238
+			$data['datetime'] = date('Y-m-d H:i:s');
1239
+			$data['format_source'] = 'aircraftjson';
1240
+			$data['id_source'] = $id_source;
1241
+			if (isset($value['name']) && $value['name'] != '') {
1242
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1243
+				else $data['source_name'] = $value['name'];
1244
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1245
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1246
+			$SI->add($data);
1247
+			unset($data);
1248 1248
 		}
1249
-	    }
1250
-	    //$last_exec['planeupdatefaa'] = time();
1251
-	    $last_exec[$id]['last'] = time();
1249
+		}
1250
+		//$last_exec['planeupdatefaa'] = time();
1251
+		$last_exec[$id]['last'] = time();
1252 1252
 	} elseif ($value['format'] === 'planefinderclient' && 
1253
-	    (
1253
+		(
1254 1254
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1255 1255
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1256
-	    )
1256
+		)
1257 1257
 	) {
1258
-	    $buffer = $Common->getData($value['host']);
1259
-	    $all_data = json_decode($buffer,true);
1260
-	    if (isset($all_data['aircraft'])) {
1258
+		$buffer = $Common->getData($value['host']);
1259
+		$all_data = json_decode($buffer,true);
1260
+		if (isset($all_data['aircraft'])) {
1261 1261
 		$reset = 0;
1262 1262
 		foreach ($all_data['aircraft'] as $key => $line) {
1263
-		    $data = array();
1264
-		    $data['hex'] = $key; // hex
1265
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1266
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1267
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1268
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1269
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1270
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1271
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1272
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1273
-		    //$data['emergency'] = ''; // emergency
1274
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1275
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1276
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1277
-		    $data['format_source'] = 'planefinderclient';
1278
-		    $data['id_source'] = $id_source;
1279
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1281
-		    $SI->add($data);
1282
-		    unset($data);
1263
+			$data = array();
1264
+			$data['hex'] = $key; // hex
1265
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1266
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1267
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1268
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1269
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1270
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1271
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1272
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1273
+			//$data['emergency'] = ''; // emergency
1274
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1275
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1276
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1277
+			$data['format_source'] = 'planefinderclient';
1278
+			$data['id_source'] = $id_source;
1279
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1281
+			$SI->add($data);
1282
+			unset($data);
1283 1283
 		}
1284
-	    }
1285
-	    $last_exec[$id]['last'] = time();
1284
+		}
1285
+		$last_exec[$id]['last'] = time();
1286 1286
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1287 1287
 	} elseif ($value['format'] === 'fr24json' && 
1288
-	    (
1288
+		(
1289 1289
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1290 1290
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1291
-	    )
1291
+		)
1292 1292
 	) {
1293
-	    //$buffer = $Common->getData($hosts[$id]);
1294
-	    $buffer = $Common->getData($value['host']);
1295
-	    $all_data = json_decode($buffer,true);
1296
-	    if (!empty($all_data)) $reset = 0;
1297
-	    foreach ($all_data as $key => $line) {
1293
+		//$buffer = $Common->getData($hosts[$id]);
1294
+		$buffer = $Common->getData($value['host']);
1295
+		$all_data = json_decode($buffer,true);
1296
+		if (!empty($all_data)) $reset = 0;
1297
+		foreach ($all_data as $key => $line) {
1298 1298
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1299
-		    $data = array();
1300
-		    $data['hex'] = $line[0];
1301
-		    $data['ident'] = $line[16]; //$line[13]
1302
-	    	    $data['altitude'] = $line[4]; // altitude
1303
-	    	    $data['speed'] = $line[5]; // speed
1304
-	    	    $data['heading'] = $line[3]; // heading
1305
-	    	    $data['latitude'] = $line[1]; // lat
1306
-	    	    $data['longitude'] = $line[2]; // long
1307
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1308
-	    	    $data['squawk'] = $line[6]; // squawk
1309
-	    	    $data['aircraft_icao'] = $line[8];
1310
-	    	    $data['registration'] = $line[9];
1311
-		    $data['departure_airport_iata'] = $line[11];
1312
-		    $data['arrival_airport_iata'] = $line[12];
1313
-	    	    $data['emergency'] = ''; // emergency
1314
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1315
-	    	    $data['format_source'] = 'fr24json';
1316
-    		    $data['id_source'] = $id_source;
1317
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1319
-		    $SI->add($data);
1320
-		    unset($data);
1299
+			$data = array();
1300
+			$data['hex'] = $line[0];
1301
+			$data['ident'] = $line[16]; //$line[13]
1302
+				$data['altitude'] = $line[4]; // altitude
1303
+				$data['speed'] = $line[5]; // speed
1304
+				$data['heading'] = $line[3]; // heading
1305
+				$data['latitude'] = $line[1]; // lat
1306
+				$data['longitude'] = $line[2]; // long
1307
+				$data['verticalrate'] = $line[15]; // verticale rate
1308
+				$data['squawk'] = $line[6]; // squawk
1309
+				$data['aircraft_icao'] = $line[8];
1310
+				$data['registration'] = $line[9];
1311
+			$data['departure_airport_iata'] = $line[11];
1312
+			$data['arrival_airport_iata'] = $line[12];
1313
+				$data['emergency'] = ''; // emergency
1314
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1315
+				$data['format_source'] = 'fr24json';
1316
+				$data['id_source'] = $id_source;
1317
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1319
+			$SI->add($data);
1320
+			unset($data);
1321 1321
 		}
1322
-	    }
1323
-	    //$last_exec['fr24json'] = time();
1324
-	    $last_exec[$id]['last'] = time();
1322
+		}
1323
+		//$last_exec['fr24json'] = time();
1324
+		$last_exec[$id]['last'] = time();
1325 1325
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1326 1326
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1327
-	    (
1327
+		(
1328 1328
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1329 1329
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1330
-	    )
1330
+		)
1331 1331
 	) {
1332
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1333
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1334
-	    //echo $buffer;
1335
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1336
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1337
-	    $all_data = json_decode($buffer,true);
1338
-	    if (json_last_error() != JSON_ERROR_NONE) {
1332
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1333
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1334
+		//echo $buffer;
1335
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1336
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1337
+		$all_data = json_decode($buffer,true);
1338
+		if (json_last_error() != JSON_ERROR_NONE) {
1339 1339
 		die(json_last_error_msg());
1340
-	    }
1341
-	    if (isset($all_data['mrkrs'])) {
1340
+		}
1341
+		if (isset($all_data['mrkrs'])) {
1342 1342
 		$reset = 0;
1343 1343
 		foreach ($all_data['mrkrs'] as $key => $line) {
1344
-		    if (isset($line['inf'])) {
1344
+			if (isset($line['inf'])) {
1345 1345
 			$data = array();
1346 1346
 			$data['hex'] = $line['inf']['ia'];
1347 1347
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1348
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1349
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1350
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1351
-	    		$data['latitude'] = $line['pt'][0]; // lat
1352
-	    		$data['longitude'] = $line['pt'][1]; // long
1353
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1354
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1355
-	    		//$data['aircraft_icao'] = $line[8];
1356
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1348
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1349
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1350
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1351
+				$data['latitude'] = $line['pt'][0]; // lat
1352
+				$data['longitude'] = $line['pt'][1]; // long
1353
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1354
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1355
+				//$data['aircraft_icao'] = $line[8];
1356
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1357 1357
 			//$data['departure_airport_iata'] = $line[11];
1358 1358
 			//$data['arrival_airport_iata'] = $line[12];
1359
-	    		//$data['emergency'] = ''; // emergency
1359
+				//$data['emergency'] = ''; // emergency
1360 1360
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1361
-	    		$data['format_source'] = 'radarvirtueljson';
1362
-    			$data['id_source'] = $id_source;
1361
+				$data['format_source'] = 'radarvirtueljson';
1362
+				$data['id_source'] = $id_source;
1363 1363
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364 1364
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1365 1365
 			$SI->add($data);
1366 1366
 			unset($data);
1367
-		    }
1367
+			}
1368 1368
 		}
1369
-	    }
1370
-	    //$last_exec['radarvirtueljson'] = time();
1371
-	    $last_exec[$id]['last'] = time();
1369
+		}
1370
+		//$last_exec['radarvirtueljson'] = time();
1371
+		$last_exec[$id]['last'] = time();
1372 1372
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1373 1373
 	} elseif ($value['format'] === 'pirepsjson' && 
1374
-	    (
1374
+		(
1375 1375
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1376 1376
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1377
-	    )
1377
+		)
1378 1378
 	) {
1379
-	    //$buffer = $Common->getData($hosts[$id]);
1380
-	    $buffer = $Common->getData($value['host'].'?'.time());
1381
-	    $all_data = json_decode(utf8_encode($buffer),true);
1379
+		//$buffer = $Common->getData($hosts[$id]);
1380
+		$buffer = $Common->getData($value['host'].'?'.time());
1381
+		$all_data = json_decode(utf8_encode($buffer),true);
1382 1382
 	    
1383
-	    if (isset($all_data['pireps'])) {
1383
+		if (isset($all_data['pireps'])) {
1384 1384
 		$reset = 0;
1385
-	        foreach ($all_data['pireps'] as $line) {
1386
-		    $data = array();
1387
-		    $data['id'] = $line['id'];
1388
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1389
-		    $data['ident'] = $line['callsign']; // ident
1390
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1391
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1392
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1393
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1394
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1395
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1396
-		    $data['latitude'] = $line['lat']; // lat
1397
-		    $data['longitude'] = $line['lon']; // long
1398
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1399
-		    //$data['squawk'] = $line['squawk']; // squawk
1400
-		    //$data['emergency'] = ''; // emergency
1401
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1402
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1403
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1404
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1405
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1406
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1407
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1408
-		    else $data['info'] = '';
1409
-		    $data['format_source'] = 'pireps';
1410
-    		    $data['id_source'] = $id_source;
1411
-		    $data['datetime'] = date('Y-m-d H:i:s');
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1414
-		    if ($line['icon'] === 'plane') {
1385
+			foreach ($all_data['pireps'] as $line) {
1386
+			$data = array();
1387
+			$data['id'] = $line['id'];
1388
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1389
+			$data['ident'] = $line['callsign']; // ident
1390
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1391
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1392
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1393
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1394
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1395
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1396
+			$data['latitude'] = $line['lat']; // lat
1397
+			$data['longitude'] = $line['lon']; // long
1398
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1399
+			//$data['squawk'] = $line['squawk']; // squawk
1400
+			//$data['emergency'] = ''; // emergency
1401
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1402
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1403
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1404
+			//$data['arrival_airport_time'] = $line['arrtime'];
1405
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1406
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1407
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1408
+			else $data['info'] = '';
1409
+			$data['format_source'] = 'pireps';
1410
+				$data['id_source'] = $id_source;
1411
+			$data['datetime'] = date('Y-m-d H:i:s');
1412
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1414
+			if ($line['icon'] === 'plane') {
1415 1415
 			$SI->add($data);
1416
-		    //    print_r($data);
1417
-    		    } elseif ($line['icon'] === 'ct') {
1416
+			//    print_r($data);
1417
+				} elseif ($line['icon'] === 'ct') {
1418 1418
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1419 1419
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1420 1420
 			$typec = substr($data['ident'],-3);
@@ -1429,210 +1429,210 @@  discard block
 block discarded – undo
1429 1429
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1430 1430
 			else $data['type'] = 'Observer';
1431 1431
 			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']);
1432
-		    }
1433
-		    unset($data);
1432
+			}
1433
+			unset($data);
1434 1434
 		}
1435
-	    }
1436
-	    //$last_exec['pirepsjson'] = time();
1437
-	    $last_exec[$id]['last'] = time();
1435
+		}
1436
+		//$last_exec['pirepsjson'] = time();
1437
+		$last_exec[$id]['last'] = time();
1438 1438
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1439 1439
 	} elseif ($value['format'] === 'phpvmacars' && 
1440
-	    (
1440
+		(
1441 1441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1442 1442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1443
-	    )
1443
+		)
1444 1444
 	) {
1445
-	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1447
-	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1449
-	    if ($buffer != '' && is_array($all_data)) {
1445
+		//$buffer = $Common->getData($hosts[$id]);
1446
+		if ($globalDebug) echo 'Get Data...'."\n";
1447
+		$buffer = $Common->getData($value['host']);
1448
+		$all_data = json_decode($buffer,true);
1449
+		if ($buffer != '' && is_array($all_data)) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data as $line) {
1452
-	    	    $data = array();
1453
-	    	    //$data['id'] = $line['id']; // id not usable
1454
-	    	    if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
1455
-	    	    elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1456
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1458
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1459
-	    	    $data['ident'] = $line['flightnum']; // ident
1460
-	    	    $data['altitude'] = $line['alt']; // altitude
1461
-	    	    $data['speed'] = $line['gs']; // speed
1462
-	    	    $data['heading'] = $line['heading']; // heading
1463
-	    	    $data['latitude'] = $line['lat']; // lat
1464
-	    	    $data['longitude'] = $line['lng']; // long
1465
-	    	    $data['verticalrate'] = ''; // verticale rate
1466
-	    	    $data['squawk'] = ''; // squawk
1467
-	    	    $data['emergency'] = ''; // emergency
1468
-	    	    //$data['datetime'] = $line['lastupdate'];
1469
-	    	    //$data['last_update'] = $line['lastupdate'];
1470
-	    	    if (isset($value['timezone'])) {
1471
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1472
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1473
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1474
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1475
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1476
-	    	    $data['departure_airport_time'] = $line['deptime'];
1477
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1478
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1479
-    		    if (isset($line['registration'])) {
1480
-    			$data['registration'] = trim($line['registration']);
1481
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1482
-    		    } else $data['registration'] = $line['aircraft'];
1483
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1484
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1485
-		    if (isset($line['aircraftname'])) {
1452
+				$data = array();
1453
+				//$data['id'] = $line['id']; // id not usable
1454
+				if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
1455
+				elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1456
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1458
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1459
+				$data['ident'] = $line['flightnum']; // ident
1460
+				$data['altitude'] = $line['alt']; // altitude
1461
+				$data['speed'] = $line['gs']; // speed
1462
+				$data['heading'] = $line['heading']; // heading
1463
+				$data['latitude'] = $line['lat']; // lat
1464
+				$data['longitude'] = $line['lng']; // long
1465
+				$data['verticalrate'] = ''; // verticale rate
1466
+				$data['squawk'] = ''; // squawk
1467
+				$data['emergency'] = ''; // emergency
1468
+				//$data['datetime'] = $line['lastupdate'];
1469
+				//$data['last_update'] = $line['lastupdate'];
1470
+				if (isset($value['timezone'])) {
1471
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1472
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1473
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1474
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1475
+				$data['departure_airport_icao'] = $line['depicao'];
1476
+				$data['departure_airport_time'] = $line['deptime'];
1477
+				$data['arrival_airport_icao'] = $line['arricao'];
1478
+				$data['arrival_airport_time'] = $line['arrtime'];
1479
+				if (isset($line['registration'])) {
1480
+				$data['registration'] = trim($line['registration']);
1481
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1482
+				} else $data['registration'] = $line['aircraft'];
1483
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1484
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1485
+			if (isset($line['aircraftname'])) {
1486 1486
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1487 1487
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1488
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1489
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1490
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1491
-	    		else {
1492
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1493
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1494
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1495
-	    		}
1496
-	    	    }
1497
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1498
-    		    $data['id_source'] = $id_source;
1499
-	    	    $data['format_source'] = 'phpvmacars';
1500
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1501
-		    $SI->add($data);
1502
-		    unset($data);
1488
+				$aircraft_data = explode('-',$line['aircraftname']);
1489
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1490
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1491
+				else {
1492
+					$aircraft_data = explode(' ',$line['aircraftname']);
1493
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1494
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1495
+				}
1496
+				}
1497
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1498
+				$data['id_source'] = $id_source;
1499
+				$data['format_source'] = 'phpvmacars';
1500
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1501
+			$SI->add($data);
1502
+			unset($data);
1503 1503
 		}
1504 1504
 		if ($globalDebug) echo 'No more data...'."\n";
1505 1505
 		unset($buffer);
1506 1506
 		unset($all_data);
1507
-	    }
1508
-	    //$last_exec['phpvmacars'] = time();
1509
-	    $last_exec[$id]['last'] = time();
1507
+		}
1508
+		//$last_exec['phpvmacars'] = time();
1509
+		$last_exec[$id]['last'] = time();
1510 1510
 	} elseif ($value['format'] === 'vaos' && 
1511
-	    (
1511
+		(
1512 1512
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1513 1513
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1514
-	    )
1514
+		)
1515 1515
 	) {
1516
-	    //$buffer = $Common->getData($hosts[$id]);
1517
-	    if ($globalDebug) echo 'Get Data...'."\n";
1518
-	    $buffer = $Common->getData($value['host']);
1519
-	    $all_data = json_decode($buffer,true);
1520
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1516
+		//$buffer = $Common->getData($hosts[$id]);
1517
+		if ($globalDebug) echo 'Get Data...'."\n";
1518
+		$buffer = $Common->getData($value['host']);
1519
+		$all_data = json_decode($buffer,true);
1520
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1521 1521
 		$reset = 0;
1522 1522
 		foreach ($all_data['ACARSData'] as $line) {
1523
-		    //print_r($line);
1524
-	    	    $data = array();
1525
-	    	    //$data['id'] = $line['id']; // id not usable
1526
-	    	    $data['id'] = $line['id'];
1527
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1528
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1529
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1530
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1531
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1532
-	    	    $data['altitude'] = $line['altitude']; // altitude
1533
-	    	    $data['speed'] = $line['groundspeed']; // speed
1534
-	    	    $data['heading'] = $line['heading']; // heading
1535
-	    	    $data['latitude'] = $line['lat']; // lat
1536
-	    	    $data['longitude'] = $line['lon']; // long
1537
-	    	    //$data['verticalrate'] = ''; // verticale rate
1538
-	    	    //$data['squawk'] = ''; // squawk
1539
-	    	    //$data['emergency'] = ''; // emergency
1540
-	    	    if (isset($value['timezone'])) {
1541
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1542
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1543
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1544
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1523
+			//print_r($line);
1524
+				$data = array();
1525
+				//$data['id'] = $line['id']; // id not usable
1526
+				$data['id'] = $line['id'];
1527
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1528
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1529
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1530
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1531
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1532
+				$data['altitude'] = $line['altitude']; // altitude
1533
+				$data['speed'] = $line['groundspeed']; // speed
1534
+				$data['heading'] = $line['heading']; // heading
1535
+				$data['latitude'] = $line['lat']; // lat
1536
+				$data['longitude'] = $line['lon']; // long
1537
+				//$data['verticalrate'] = ''; // verticale rate
1538
+				//$data['squawk'] = ''; // squawk
1539
+				//$data['emergency'] = ''; // emergency
1540
+				if (isset($value['timezone'])) {
1541
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1542
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1543
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1544
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1545 1545
 	    	    
1546
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1547
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1548
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1549
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1550
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1546
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1547
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1548
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1549
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1550
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1551 1551
 
1552
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1553
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1554
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1552
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1553
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1554
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1555 1555
 
1556
-    		    $data['id_source'] = $id_source;
1557
-	    	    $data['format_source'] = 'vaos';
1558
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1559
-		    $SI->add($data);
1560
-		    unset($data);
1556
+				$data['id_source'] = $id_source;
1557
+				$data['format_source'] = 'vaos';
1558
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1559
+			$SI->add($data);
1560
+			unset($data);
1561 1561
 		}
1562 1562
 		if ($globalDebug) echo 'No more data...'."\n";
1563 1563
 		unset($buffer);
1564 1564
 		unset($all_data);
1565
-	    }
1566
-	    //$last_exec['phpvmacars'] = time();
1567
-	    $last_exec[$id]['last'] = time();
1565
+		}
1566
+		//$last_exec['phpvmacars'] = time();
1567
+		$last_exec[$id]['last'] = time();
1568 1568
 	} elseif ($value['format'] === 'vam' && 
1569
-	    (
1569
+		(
1570 1570
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1571 1571
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1572
-	    )
1572
+		)
1573 1573
 	) {
1574
-	    //$buffer = $Common->getData($hosts[$id]);
1575
-	    if ($globalDebug) echo 'Get Data...'."\n";
1576
-	    $buffer = $Common->getData($value['host']);
1577
-	    $all_data = json_decode($buffer,true);
1578
-	    if ($buffer != '' && is_array($all_data)) {
1574
+		//$buffer = $Common->getData($hosts[$id]);
1575
+		if ($globalDebug) echo 'Get Data...'."\n";
1576
+		$buffer = $Common->getData($value['host']);
1577
+		$all_data = json_decode($buffer,true);
1578
+		if ($buffer != '' && is_array($all_data)) {
1579 1579
 		$reset = 0;
1580 1580
 		foreach ($all_data as $line) {
1581
-	    	    $data = array();
1582
-	    	    //$data['id'] = $line['id']; // id not usable
1583
-	    	    $data['id'] = trim($line['flight_id']);
1584
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1585
-	    	    $data['pilot_name'] = $line['pilot_name'];
1586
-	    	    $data['pilot_id'] = $line['pilot_id'];
1587
-	    	    $data['ident'] = trim($line['callsign']); // ident
1588
-	    	    $data['altitude'] = $line['altitude']; // altitude
1589
-	    	    $data['speed'] = $line['gs']; // speed
1590
-	    	    $data['heading'] = $line['heading']; // heading
1591
-	    	    $data['latitude'] = $line['latitude']; // lat
1592
-	    	    $data['longitude'] = $line['longitude']; // long
1593
-	    	    $data['verticalrate'] = ''; // verticale rate
1594
-	    	    $data['squawk'] = ''; // squawk
1595
-	    	    $data['emergency'] = ''; // emergency
1596
-	    	    //$data['datetime'] = $line['lastupdate'];
1597
-	    	    $data['last_update'] = $line['last_update'];
1598
-		    $data['datetime'] = date('Y-m-d H:i:s');
1599
-	    	    $data['departure_airport_icao'] = $line['departure'];
1600
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1601
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1602
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1603
-    		    //$data['registration'] = $line['aircraft'];
1604
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1605
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1606
-    		    $data['id_source'] = $id_source;
1607
-	    	    $data['format_source'] = 'vam';
1608
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1609
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1610
-		    $SI->add($data);
1611
-		    unset($data);
1581
+				$data = array();
1582
+				//$data['id'] = $line['id']; // id not usable
1583
+				$data['id'] = trim($line['flight_id']);
1584
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1585
+				$data['pilot_name'] = $line['pilot_name'];
1586
+				$data['pilot_id'] = $line['pilot_id'];
1587
+				$data['ident'] = trim($line['callsign']); // ident
1588
+				$data['altitude'] = $line['altitude']; // altitude
1589
+				$data['speed'] = $line['gs']; // speed
1590
+				$data['heading'] = $line['heading']; // heading
1591
+				$data['latitude'] = $line['latitude']; // lat
1592
+				$data['longitude'] = $line['longitude']; // long
1593
+				$data['verticalrate'] = ''; // verticale rate
1594
+				$data['squawk'] = ''; // squawk
1595
+				$data['emergency'] = ''; // emergency
1596
+				//$data['datetime'] = $line['lastupdate'];
1597
+				$data['last_update'] = $line['last_update'];
1598
+			$data['datetime'] = date('Y-m-d H:i:s');
1599
+				$data['departure_airport_icao'] = $line['departure'];
1600
+				//$data['departure_airport_time'] = $line['departure_time'];
1601
+				$data['arrival_airport_icao'] = $line['arrival'];
1602
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1603
+				//$data['registration'] = $line['aircraft'];
1604
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1605
+				$data['aircraft_icao'] = $line['plane_type'];
1606
+				$data['id_source'] = $id_source;
1607
+				$data['format_source'] = 'vam';
1608
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1609
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1610
+			$SI->add($data);
1611
+			unset($data);
1612 1612
 		}
1613 1613
 		if ($globalDebug) echo 'No more data...'."\n";
1614 1614
 		unset($buffer);
1615 1615
 		unset($all_data);
1616
-	    }
1617
-	    //$last_exec['phpvmacars'] = time();
1618
-	    $last_exec[$id]['last'] = time();
1616
+		}
1617
+		//$last_exec['phpvmacars'] = time();
1618
+		$last_exec[$id]['last'] = time();
1619 1619
 	} elseif ($value['format'] === 'blitzortung' && 
1620
-	    (
1620
+		(
1621 1621
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1622 1622
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1623
-	    )
1623
+		)
1624 1624
 	) {
1625
-	    //$buffer = $Common->getData($hosts[$id]);
1626
-	    if ($globalDebug) echo 'Get Data...'."\n";
1627
-	    $buffer = $Common->getData($value['host']);
1628
-	    $all_data = json_decode($buffer,true);
1629
-	    if ($buffer != '') {
1625
+		//$buffer = $Common->getData($hosts[$id]);
1626
+		if ($globalDebug) echo 'Get Data...'."\n";
1627
+		$buffer = $Common->getData($value['host']);
1628
+		$all_data = json_decode($buffer,true);
1629
+		if ($buffer != '') {
1630 1630
 		$Source->deleteLocationBySource('blitzortung');
1631 1631
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1632 1632
 		$buffer = explode('\n',$buffer);
1633 1633
 		foreach ($buffer as $buffer_line) {
1634
-		    $line = json_decode($buffer_line,true);
1635
-		    if (isset($line['time'])) {
1634
+			$line = json_decode($buffer_line,true);
1635
+			if (isset($line['time'])) {
1636 1636
 			$data = array();
1637 1637
 			$data['altitude'] = $line['alt']; // altitude
1638 1638
 			$data['latitude'] = $line['lat']; // lat
@@ -1644,92 +1644,92 @@  discard block
 block discarded – undo
1644 1644
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1645 1645
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1646 1646
 			unset($data);
1647
-		    }
1647
+			}
1648 1648
 		}
1649 1649
 		if ($globalDebug) echo 'No more data...'."\n";
1650 1650
 		unset($buffer);
1651
-	    }
1652
-	    $last_exec[$id]['last'] = time();
1651
+		}
1652
+		$last_exec[$id]['last'] = time();
1653 1653
 	} elseif ($value['format'] === 'acarsjson') {
1654
-        $arr = $httpfeeds;
1655
-        $w = $e = null;
1656
-        if (isset($arr[$id])) {
1657
-            $nn = stream_select($arr,$w,$e,$timeout);
1658
-            if ($nn > 0) {
1659
-                foreach ($httpfeeds as $feed) {
1660
-                    $buffer = stream_get_line($feed,2000,"\n");
1661
-                    if ($buffer === FALSE) {
1662
-                        connect_all($globalSources);
1663
-                    }
1664
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1665
-                    $buffer = explode('\n',$buffer);
1666
-                    foreach ($buffer as $line) {
1667
-                        if ($line != '') {
1668
-                            $line = json_decode($line, true);
1669
-                            if (!empty($line)) {
1670
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1671
-                                $ACARS->deleteLiveAcarsData();
1672
-                            }
1673
-                        }
1674
-                    }
1675
-                }
1676
-            } else {
1677
-                $format = $value['format'];
1678
-                if (isset($tt[$format])) $tt[$format]++;
1679
-                else $tt[$format] = 0;
1680
-                if ($tt[$format] > 30) {
1681
-                    if ($globalDebug) echo 'Reconnect...'."\n";
1682
-                    sleep(2);
1683
-                    //$sourceeen[] = $value;
1684
-                    //connect_all($sourceeen);
1685
-                    //$sourceeen = array();
1686
-                    connect_all($globalSources);
1687
-                }
1688
-            }
1689
-        }
1654
+		$arr = $httpfeeds;
1655
+		$w = $e = null;
1656
+		if (isset($arr[$id])) {
1657
+			$nn = stream_select($arr,$w,$e,$timeout);
1658
+			if ($nn > 0) {
1659
+				foreach ($httpfeeds as $feed) {
1660
+					$buffer = stream_get_line($feed,2000,"\n");
1661
+					if ($buffer === FALSE) {
1662
+						connect_all($globalSources);
1663
+					}
1664
+					$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1665
+					$buffer = explode('\n',$buffer);
1666
+					foreach ($buffer as $line) {
1667
+						if ($line != '') {
1668
+							$line = json_decode($line, true);
1669
+							if (!empty($line)) {
1670
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1671
+								$ACARS->deleteLiveAcarsData();
1672
+							}
1673
+						}
1674
+					}
1675
+				}
1676
+			} else {
1677
+				$format = $value['format'];
1678
+				if (isset($tt[$format])) $tt[$format]++;
1679
+				else $tt[$format] = 0;
1680
+				if ($tt[$format] > 30) {
1681
+					if ($globalDebug) echo 'Reconnect...'."\n";
1682
+					sleep(2);
1683
+					//$sourceeen[] = $value;
1684
+					//connect_all($sourceeen);
1685
+					//$sourceeen = array();
1686
+					connect_all($globalSources);
1687
+				}
1688
+			}
1689
+		}
1690 1690
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1691 1691
 	} 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'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1692
-	    //$last_exec[$id]['last'] = time();
1693
-	    //$read = array( $sockets[$id] );
1694
-	    $read = $sockets;
1695
-	    $write = NULL;
1696
-	    $e = NULL;
1697
-	    $n = socket_select($read, $write, $e, $timeout);
1698
-	    if ($e != NULL) var_dump($e);
1699
-	    if ($n > 0) {
1692
+		//$last_exec[$id]['last'] = time();
1693
+		//$read = array( $sockets[$id] );
1694
+		$read = $sockets;
1695
+		$write = NULL;
1696
+		$e = NULL;
1697
+		$n = socket_select($read, $write, $e, $timeout);
1698
+		if ($e != NULL) var_dump($e);
1699
+		if ($n > 0) {
1700 1700
 		$reset = 0;
1701 1701
 		foreach ($read as $nb => $r) {
1702
-		    //$value = $formats[$nb];
1703
-		    $format = $globalSources[$nb]['format'];
1704
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1702
+			//$value = $formats[$nb];
1703
+			$format = $globalSources[$nb]['format'];
1704
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1705 1705
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1706
-		    } elseif ($format === 'vrstcp') {
1706
+			} elseif ($format === 'vrstcp') {
1707 1707
 			$buffer = @socket_read($r, 6000);
1708
-		    } else {
1708
+			} else {
1709 1709
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1710
-		    }
1711
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1712
-		    //echo $buffer."\n";
1713
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1714
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1715
-		    $error = false;
1716
-		    //$SI::del();
1717
-		    if ($buffer !== FALSE) {
1710
+			}
1711
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1712
+			//echo $buffer."\n";
1713
+			// lets play nice and handle signals such as ctrl-c/kill properly
1714
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1715
+			$error = false;
1716
+			//$SI::del();
1717
+			if ($buffer !== FALSE) {
1718 1718
 			if ($format === 'vrstcp') {
1719
-			    $buffer = explode('},{',$buffer);
1719
+				$buffer = explode('},{',$buffer);
1720 1720
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1721
-		    }
1722
-		    // SBS format is CSV format
1723
-		    if ($buffer !== FALSE && $buffer !== '') {
1721
+			}
1722
+			// SBS format is CSV format
1723
+			if ($buffer !== FALSE && $buffer !== '') {
1724 1724
 			$tt[$format] = 0;
1725 1725
 			if ($format === 'acarssbs3') {
1726
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1727
-			    $ACARS->add(trim($buffer));
1728
-			    $ACARS->deleteLiveAcarsData();
1726
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1727
+				$ACARS->add(trim($buffer));
1728
+				$ACARS->deleteLiveAcarsData();
1729 1729
 			} elseif ($format === 'raw') {
1730
-			    // AVR format
1731
-			    $data = $SBS->parse($buffer);
1732
-			    if (is_array($data)) {
1730
+				// AVR format
1731
+				$data = $SBS->parse($buffer);
1732
+				if (is_array($data)) {
1733 1733
 				//if (!empty($data)) print_r($data);
1734 1734
 				$data['datetime'] = date('Y-m-d H:i:s');
1735 1735
 				$data['format_source'] = 'raw';
@@ -1739,39 +1739,39 @@  discard block
 block discarded – undo
1739 1739
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1740 1740
 				$SI->add($data);
1741 1741
 				unset($data);
1742
-			    }
1742
+				}
1743 1743
 			} elseif ($format === 'ais') {
1744
-			    $ais_data = $AIS->parse_line(trim($buffer));
1745
-			    $data = array();
1746
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1747
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1748
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1749
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1750
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1751
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1752
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1753
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1754
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1755
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1756
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1757
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1758
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1759
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1761
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1744
+				$ais_data = $AIS->parse_line(trim($buffer));
1745
+				$data = array();
1746
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1747
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1748
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1749
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1750
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1751
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1752
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1753
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1754
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1755
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1756
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1757
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1758
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1759
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1761
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1762 1762
 
1763
-			    if (isset($ais_data['timestamp'])) {
1763
+				if (isset($ais_data['timestamp'])) {
1764 1764
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1765
-			    } else {
1765
+				} else {
1766 1766
 				$data['datetime'] = date('Y-m-d H:i:s');
1767
-			    }
1768
-			    $data['format_source'] = 'aisnmea';
1769
-    			    $data['id_source'] = $id_source;
1770
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1771
-			    unset($data);
1772
-                        } elseif ($format === 'flightgearsp') {
1773
-                    	    //echo $buffer."\n";
1774
-                    	    if (strlen($buffer) > 5) {
1767
+				}
1768
+				$data['format_source'] = 'aisnmea';
1769
+					$data['id_source'] = $id_source;
1770
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1771
+				unset($data);
1772
+						} elseif ($format === 'flightgearsp') {
1773
+							//echo $buffer."\n";
1774
+							if (strlen($buffer) > 5) {
1775 1775
 				$line = explode(',',$buffer);
1776 1776
 				$data = array();
1777 1777
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1788,47 +1788,47 @@  discard block
 block discarded – undo
1788 1788
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1789 1789
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1790 1790
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1791
-			    }
1792
-                        } elseif ($format === 'acars') {
1793
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1794
-			    $ACARS->add(trim($buffer));
1795
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1796
-			    $ACARS->deleteLiveAcarsData();
1791
+				}
1792
+						} elseif ($format === 'acars') {
1793
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1794
+				$ACARS->add(trim($buffer));
1795
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1796
+				$ACARS->deleteLiveAcarsData();
1797 1797
 			} elseif ($format === 'acarsjsonudp') {
1798
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1799
-                            $line = json_decode(trim($buffer), true);
1800
-                            if (!empty($line)) {
1798
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1799
+							$line = json_decode(trim($buffer), true);
1800
+							if (!empty($line)) {
1801 1801
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1802
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1803
-                                $ACARS->deleteLiveAcarsData();
1804
-                            }
1805
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1802
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1803
+								$ACARS->deleteLiveAcarsData();
1804
+							}
1805
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1806 1806
 			} elseif ($format === 'flightgearmp') {
1807
-			    if (substr($buffer,0,1) != '#') {
1807
+				if (substr($buffer,0,1) != '#') {
1808 1808
 				$data = array();
1809 1809
 				//echo $buffer."\n";
1810 1810
 				$line = explode(' ',$buffer);
1811 1811
 				if (count($line) === 11) {
1812
-				    $userserver = explode('@',$line[0]);
1813
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1814
-				    $data['ident'] = $userserver[0];
1815
-				    $data['registration'] = $userserver[0];
1816
-				    $data['latitude'] = $line[4];
1817
-				    $data['longitude'] = $line[5];
1818
-				    $data['altitude'] = $line[6];
1819
-				    $data['datetime'] = date('Y-m-d H:i:s');
1820
-				    $aircraft_type = $line[10];
1821
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1822
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1823
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1824
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1812
+					$userserver = explode('@',$line[0]);
1813
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1814
+					$data['ident'] = $userserver[0];
1815
+					$data['registration'] = $userserver[0];
1816
+					$data['latitude'] = $line[4];
1817
+					$data['longitude'] = $line[5];
1818
+					$data['altitude'] = $line[6];
1819
+					$data['datetime'] = date('Y-m-d H:i:s');
1820
+					$aircraft_type = $line[10];
1821
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1822
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1823
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1824
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1825
+				}
1825 1826
 				}
1826
-			    }
1827 1827
 			} elseif ($format === 'beast') {
1828
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1829
-			    die;
1828
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1829
+				die;
1830 1830
 			} elseif ($format === 'vrstcp') {
1831
-			    foreach($buffer as $all_data) {
1831
+				foreach($buffer as $all_data) {
1832 1832
 				$line = json_decode('{'.$all_data.'}',true);
1833 1833
 				$data = array();
1834 1834
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1848,158 +1848,158 @@  discard block
 block discarded – undo
1848 1848
 				*/
1849 1849
 				$data['datetime'] = date('Y-m-d H:i:s');
1850 1850
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1851
-		    		$data['format_source'] = 'vrstcp';
1851
+					$data['format_source'] = 'vrstcp';
1852 1852
 				$data['id_source'] = $id_source;
1853 1853
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1854 1854
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1855 1855
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1856 1856
 				unset($data);
1857
-			    }
1857
+				}
1858 1858
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1859
-			    $line = explode("\t", $buffer);
1860
-			    for($k = 0; $k < count($line); $k=$k+2) {
1859
+				$line = explode("\t", $buffer);
1860
+				for($k = 0; $k < count($line); $k=$k+2) {
1861 1861
 				$key = $line[$k];
1862
-			        $lined[$key] = $line[$k+1];
1863
-			    }
1864
-    			    if (count($lined) > 3) {
1865
-    				$data['hex'] = $lined['hexid'];
1866
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1867
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1868
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1869
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1870
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1871
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1872
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1873
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1874
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1875
-    				$data['id_source'] = $id_source;
1876
-    				$data['format_source'] = 'tsv';
1877
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1878
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1862
+					$lined[$key] = $line[$k+1];
1863
+				}
1864
+					if (count($lined) > 3) {
1865
+					$data['hex'] = $lined['hexid'];
1866
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1867
+					$data['datetime'] = date('Y-m-d H:i:s');;
1868
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1869
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1870
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1871
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1872
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1873
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1874
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1875
+					$data['id_source'] = $id_source;
1876
+					$data['format_source'] = 'tsv';
1877
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1878
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1879 1879
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1880
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1881
-    				unset($lined);
1882
-    				unset($data);
1883
-    			    } else $error = true;
1880
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1881
+					unset($lined);
1882
+					unset($data);
1883
+					} else $error = true;
1884 1884
 			} elseif ($format === 'aprs' && $use_aprs) {
1885
-			    if ($aprs_connect === 0) {
1885
+				if ($aprs_connect === 0) {
1886 1886
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1887 1887
 				$aprs_connect = 1;
1888
-			    }
1888
+				}
1889 1889
 			    
1890
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1890
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1891 1891
 				$aprs_last_tx = time();
1892 1892
 				$data_aprs = "# Keep alive";
1893 1893
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1894
-			    }
1894
+				}
1895 1895
 			    
1896
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1897
-			    //echo 'APRS data : '.$buffer."\n";
1898
-			    $buffer = str_replace('APRS <- ','',$buffer);
1899
-			    $buffer = str_replace('APRS -> ','',$buffer);
1900
-			    //echo $buffer."\n";
1901
-			    date_default_timezone_set('UTC');
1902
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1896
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1897
+				//echo 'APRS data : '.$buffer."\n";
1898
+				$buffer = str_replace('APRS <- ','',$buffer);
1899
+				$buffer = str_replace('APRS -> ','',$buffer);
1900
+				//echo $buffer."\n";
1901
+				date_default_timezone_set('UTC');
1902
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1903 1903
 				$line = $APRS->parse($buffer);
1904 1904
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1905 1905
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1906
-				    $aprs_last_tx = time();
1907
-				    $data = array();
1908
-				    //print_r($line);
1909
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1910
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1911
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1912
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1913
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1914
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1915
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1916
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1917
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1918
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1919
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1920
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1921
-				    $data['latitude'] = $line['latitude'];
1922
-				    $data['longitude'] = $line['longitude'];
1923
-				    //$data['verticalrate'] = $line[16];
1924
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1925
-				    //else $data['speed'] = 0;
1926
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1927
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1928
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1929
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1906
+					$aprs_last_tx = time();
1907
+					$data = array();
1908
+					//print_r($line);
1909
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1910
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1911
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1912
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1913
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1914
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1915
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1916
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1917
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1918
+					else $data['datetime'] = date('Y-m-d H:i:s');
1919
+					//$data['datetime'] = date('Y-m-d H:i:s');
1920
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1921
+					$data['latitude'] = $line['latitude'];
1922
+					$data['longitude'] = $line['longitude'];
1923
+					//$data['verticalrate'] = $line[16];
1924
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1925
+					//else $data['speed'] = 0;
1926
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1927
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1928
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1929
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1930 1930
 				    
1931
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1932
-				    //else echo 'No heading...'."\n";
1933
-				    //else $data['heading'] = 0;
1934
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1935
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1936
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1937
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1938
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1939
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1940
-    				    $data['id_source'] = $id_source;
1941
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1942
-				    else $data['format_source'] = 'aprs';
1943
-				    $data['source_name'] = $line['source'];
1944
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1945
-				    else $data['source_type'] = 'flarm';
1946
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1947
-				    $currentdate = date('Y-m-d H:i:s');
1948
-				    $aprsdate = strtotime($data['datetime']);
1949
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1950
-				    // Accept data if time <= system time + 20s
1951
-				    //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'])))) {
1952
-				    if (
1931
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1932
+					//else echo 'No heading...'."\n";
1933
+					//else $data['heading'] = 0;
1934
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1935
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1936
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1937
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1938
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1939
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1940
+						$data['id_source'] = $id_source;
1941
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1942
+					else $data['format_source'] = 'aprs';
1943
+					$data['source_name'] = $line['source'];
1944
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1945
+					else $data['source_type'] = 'flarm';
1946
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1947
+					$currentdate = date('Y-m-d H:i:s');
1948
+					$aprsdate = strtotime($data['datetime']);
1949
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1950
+					// Accept data if time <= system time + 20s
1951
+					//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'])))) {
1952
+					if (
1953 1953
 					($data['source_type'] === 'modes') || 
1954 1954
 					isset($line['stealth']) && 
1955 1955
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1956 1956
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1957 1957
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1958 1958
 					$send = $SI->add($data);
1959
-				    } elseif ($data['source_type'] === 'ais') {
1959
+					} elseif ($data['source_type'] === 'ais') {
1960 1960
 					$data['type'] = '';
1961 1961
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1962
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1962
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1963 1963
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1964
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1965
-					    //$line['symbol'] === 'Balloon' ||
1966
-					    $line['symbol'] === 'Glider' || 
1967
-					    $line['symbol'] === 'No. Plane' || 
1968
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1969
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1970
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1971
-					    $send = $SI->add($data);
1972
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1973
-					    $line['symbol'] === 'Yacht (Sail)' || 
1974
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1975
-					    $send = $MI->add($data);
1976
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1977
-					    $line['symbol'] === 'Car' || 
1978
-					    $line['symbol'] === 'Ambulance' || 
1979
-					    $line['symbol'] === 'Van' || 
1980
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1981
-					    $line['symbol'] === 'Motorcycle' || 
1982
-					    $line['symbol'] === 'Tractor' || 
1983
-					    $line['symbol'] === 'Police' || 
1984
-					    $line['symbol'] === 'Bike' || 
1985
-					    $line['symbol'] === 'Jogger' || 
1986
-					    $line['symbol'] === 'Horse' || 
1987
-					    $line['symbol'] === 'Bus' || 
1988
-					    $line['symbol'] === 'Jeep' || 
1989
-					    $line['symbol'] === 'Recreational Vehicle' || 
1990
-					    $line['symbol'] === 'Yacht (Sail)' || 
1991
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1992
-					    $line['symbol'] === 'Firetruck' || 
1993
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1994
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1995
-					    $line['symbol'] === 'SUV' ||
1996
-					    $line['symbol'] === 'Snowmobile' ||
1997
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1998
-				    //} 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') {
1964
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1965
+						//$line['symbol'] === 'Balloon' ||
1966
+						$line['symbol'] === 'Glider' || 
1967
+						$line['symbol'] === 'No. Plane' || 
1968
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1969
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1970
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1971
+						$send = $SI->add($data);
1972
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1973
+						$line['symbol'] === 'Yacht (Sail)' || 
1974
+						$line['symbol'] === 'Ship (Power Boat)')) {
1975
+						$send = $MI->add($data);
1976
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1977
+						$line['symbol'] === 'Car' || 
1978
+						$line['symbol'] === 'Ambulance' || 
1979
+						$line['symbol'] === 'Van' || 
1980
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1981
+						$line['symbol'] === 'Motorcycle' || 
1982
+						$line['symbol'] === 'Tractor' || 
1983
+						$line['symbol'] === 'Police' || 
1984
+						$line['symbol'] === 'Bike' || 
1985
+						$line['symbol'] === 'Jogger' || 
1986
+						$line['symbol'] === 'Horse' || 
1987
+						$line['symbol'] === 'Bus' || 
1988
+						$line['symbol'] === 'Jeep' || 
1989
+						$line['symbol'] === 'Recreational Vehicle' || 
1990
+						$line['symbol'] === 'Yacht (Sail)' || 
1991
+						$line['symbol'] === 'Ship (Power Boat)' || 
1992
+						$line['symbol'] === 'Firetruck' || 
1993
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1994
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1995
+						$line['symbol'] === 'SUV' ||
1996
+						$line['symbol'] === 'Snowmobile' ||
1997
+						$line['symbol'] === 'Mobile Satellite Station')) {
1998
+					//} 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') {
1999 1999
 				//    } 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') {
2000 2000
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
2001 2001
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2002
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2002
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2003 2003
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2004 2004
 					$Source->deleteOldLocationByType('gs');
2005 2005
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
 					} else {
2008 2008
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2009 2009
 					}
2010
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2010
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2011 2011
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2012 2012
 					if ($globalDebug) echo '# Weather Station added'."\n";
2013 2013
 					$Source->deleteOldLocationByType('wx');
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 					} else {
2018 2018
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2019 2019
 					}
2020
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2020
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2021 2021
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2022 2022
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2023 2023
 					$Source->deleteOldLocationByType('lightning');
@@ -2026,11 +2026,11 @@  discard block
 block discarded – undo
2026 2026
 					} else {
2027 2027
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2028 2028
 					}
2029
-				    } elseif ($globalDebug) {
2030
-				    	echo '/!\ Not added: '.$buffer."\n";
2031
-				    	print_r($line);
2032
-				    }
2033
-				    unset($data);
2029
+					} elseif ($globalDebug) {
2030
+						echo '/!\ Not added: '.$buffer."\n";
2031
+						print_r($line);
2032
+					}
2033
+					unset($data);
2034 2034
 				}
2035 2035
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2036 2036
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -2049,13 +2049,13 @@  discard block
 block discarded – undo
2049 2049
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
2050 2050
 					$globalSources[$nb]['last_weather_clean'] = time();
2051 2051
 				}
2052
-			    }
2052
+				}
2053 2053
 			} else {
2054
-			    $line = explode(',', $buffer);
2055
-			    //print_r($line);
2056
-    			    if (count($line) > 20) {
2057
-    			    	$data['hex'] = $line[4];
2058
-    				/*
2054
+				$line = explode(',', $buffer);
2055
+				//print_r($line);
2056
+					if (count($line) > 20) {
2057
+						$data['hex'] = $line[4];
2058
+					/*
2059 2059
     				$data['datetime'] = $line[6].' '.$line[7];
2060 2060
     					date_default_timezone_set($globalTimezone);
2061 2061
     					$datetime = new DateTime($data['datetime']);
@@ -2063,31 +2063,31 @@  discard block
 block discarded – undo
2063 2063
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
2064 2064
     					date_default_timezone_set('UTC');
2065 2065
     				*/
2066
-    				// Force datetime to current UTC datetime
2067
-    				date_default_timezone_set('UTC');
2068
-    				$data['datetime'] = date('Y-m-d H:i:s');
2069
-    				$data['ident'] = trim($line[10]);
2070
-    				$data['latitude'] = $line[14];
2071
-    				$data['longitude'] = $line[15];
2072
-    				$data['verticalrate'] = $line[16];
2073
-    				$data['emergency'] = $line[20];
2074
-    				$data['speed'] = $line[12];
2075
-    				$data['squawk'] = $line[17];
2076
-    				$data['altitude'] = $line[11];
2077
-    				$data['heading'] = $line[13];
2078
-    				$data['ground'] = $line[21];
2079
-    				$data['emergency'] = $line[19];
2080
-    				$data['format_source'] = 'sbs';
2066
+					// Force datetime to current UTC datetime
2067
+					date_default_timezone_set('UTC');
2068
+					$data['datetime'] = date('Y-m-d H:i:s');
2069
+					$data['ident'] = trim($line[10]);
2070
+					$data['latitude'] = $line[14];
2071
+					$data['longitude'] = $line[15];
2072
+					$data['verticalrate'] = $line[16];
2073
+					$data['emergency'] = $line[20];
2074
+					$data['speed'] = $line[12];
2075
+					$data['squawk'] = $line[17];
2076
+					$data['altitude'] = $line[11];
2077
+					$data['heading'] = $line[13];
2078
+					$data['ground'] = $line[21];
2079
+					$data['emergency'] = $line[19];
2080
+					$data['format_source'] = 'sbs';
2081 2081
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2082 2082
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2083 2083
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2084 2084
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2085
-    				$data['id_source'] = $id_source;
2086
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2087
-    				else $error = true;
2088
-    				unset($data);
2089
-    			    } else $error = true;
2090
-			    if ($error) {
2085
+					$data['id_source'] = $id_source;
2086
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2087
+					else $error = true;
2088
+					unset($data);
2089
+					} else $error = true;
2090
+				if ($error) {
2091 2091
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2092 2092
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
2093 2093
 				} else {
@@ -2103,13 +2103,13 @@  discard block
 block discarded – undo
2103 2103
 					connect_all($sourceer);
2104 2104
 					$sourceer = array();
2105 2105
 				}
2106
-			    }
2106
+				}
2107 2107
 			}
2108 2108
 			// Sleep for xxx microseconds
2109 2109
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2110
-		    } else {
2110
+			} else {
2111 2111
 			if ($format === 'flightgearmp') {
2112
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2112
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2113 2113
 				//@socket_close($r);
2114 2114
 				sleep($globalMinFetch);
2115 2115
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2118,9 +2118,9 @@  discard block
 block discarded – undo
2118 2118
 				break;
2119 2119
 				
2120 2120
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2121
-			    if (isset($tt[$format])) $tt[$format]++;
2122
-			    else $tt[$format] = 0;
2123
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2121
+				if (isset($tt[$format])) $tt[$format]++;
2122
+				else $tt[$format] = 0;
2123
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2124 2124
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2125 2125
 				//@socket_close($r);
2126 2126
 				sleep(2);
@@ -2131,24 +2131,24 @@  discard block
 block discarded – undo
2131 2131
 				//connect_all($globalSources);
2132 2132
 				$tt[$format]=0;
2133 2133
 				break;
2134
-			    } 
2135
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2134
+				} 
2135
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2136
+			}
2136 2137
 			}
2137
-		    }
2138 2138
 		}
2139
-	    } else {
2139
+		} else {
2140 2140
 		$error = socket_strerror(socket_last_error());
2141 2141
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2142 2142
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2143 2143
 			if (isset($globalDebug)) echo "Restarting...\n";
2144 2144
 			// Restart the script if possible
2145 2145
 			if (is_array($sockets)) {
2146
-			    if ($globalDebug) echo "Shutdown all sockets...";
2146
+				if ($globalDebug) echo "Shutdown all sockets...";
2147 2147
 			    
2148
-			    foreach ($sockets as $sock) {
2148
+				foreach ($sockets as $sock) {
2149 2149
 				@socket_shutdown($sock,2);
2150 2150
 				@socket_close($sock);
2151
-			    }
2151
+				}
2152 2152
 			    
2153 2153
 			}
2154 2154
 			if ($globalDebug) echo "Waiting...";
@@ -2163,15 +2163,15 @@  discard block
 block discarded – undo
2163 2163
 			if ($globalDebug) echo "Restart all connections...";
2164 2164
 			connect_all($globalSources);
2165 2165
 		}
2166
-	    }
2166
+		}
2167 2167
 	}
2168 2168
 	if ($globalDaemon === false) {
2169
-	    if ($globalDebug) echo 'Check all...'."\n";
2170
-	    if (isset($SI)) $SI->checkAll();
2171
-	    if (isset($TI)) $TI->checkAll();
2172
-	    if (isset($MI)) $MI->checkAll();
2169
+		if ($globalDebug) echo 'Check all...'."\n";
2170
+		if (isset($SI)) $SI->checkAll();
2171
+		if (isset($TI)) $TI->checkAll();
2172
+		if (isset($MI)) $MI->checkAll();
2173
+	}
2173 2174
 	}
2174
-    }
2175 2175
 }
2176 2176
 
2177 2177
 ?>
Please login to merge, or discard this patch.
Spacing   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$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'));
66
+$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'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285 285
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
-	    $hostport = explode(':',$host);
286
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
287
+	    $hostport = explode(':', $host);
288 288
 	    if (isset($hostport[1])) {
289 289
 		$port = $hostport[1];
290 290
 		$hostn = $hostport[0];
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	    }
295 295
 	    $Common = new Common();
296 296
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
298 298
     	    } else {
299 299
     		$udp = true;
300
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
301 301
 	    }
302 302
 	    if ($s) {
303 303
     	        $sockets[$id] = $s;
304 304
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
306 306
 			//$formats[$id] = 'aprs';
307 307
 			$globalSources[$id]['format'] = 'aprs';
308 308
 			//$aprs_connect = 0;
309 309
 			//$use_aprs = true;
310
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
311 311
 			$globalSources[$id]['format'] = 'vrstcp';
312 312
     		    } elseif ($port == '10001') {
313 313
         		//$formats[$id] = 'tsv';
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350 350
 else $timeout = 20;
351 351
 $errno = '';
352
-$errstr='';
352
+$errstr = '';
353 353
 
354 354
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
355 355
 /* Initiate connections to all the hosts simultaneously */
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 //connect_all($globalSources);
358 358
 
359 359
 if (isset($globalProxy) && $globalProxy) {
360
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
361 361
 } else {
362 362
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
363 363
 }
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 
388 388
 if ($use_aprs) {
389 389
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
390
-	$APRS=new APRS();
390
+	$APRS = new APRS();
391 391
 	$aprs_connect = 0;
392 392
 	$aprs_keep = 120;
393 393
 	$aprs_last_tx = time();
394 394
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
395
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
396 396
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
397
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
398 398
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400 400
 	if ($aprs_full) $aprs_filter = '';
401 401
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402 402
 	else $aprs_pass = '-1';
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 sleep(1);
411 411
 if ($globalDebug) echo "SCAN MODE \n\n";
412 412
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
413
-$endtime = time()+$globalCronEnd;
413
+$endtime = time() + $globalCronEnd;
414 414
 $i = 1;
415 415
 $tt = array();
416 416
 // Delete all ATC
417 417
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
418
-	$ATC=new ATC($Connection->db);
418
+	$ATC = new ATC($Connection->db);
419 419
 }
420 420
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
421 421
 	$ATC->deleteAll();
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 while ($i > 0) {
426 426
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
427 427
 
428
-    if (!$globalDaemon) $i = $endtime-time();
428
+    if (!$globalDaemon) $i = $endtime - time();
429 429
     // Delete old ATC
430 430
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431 431
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 	if ($max < $globalMinFetch) {
441 441
 	    if ($globalDebug) echo 'Sleeping...'."\n";
442
-	    sleep($globalMinFetch-$max+2);
442
+	    sleep($globalMinFetch - $max + 2);
443 443
 	}
444 444
     }
445 445
 
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
             //$buffer = $Common->getData($hosts[$id]);
495 495
             $buffer = $Common->getData($value['host']);
496 496
             if ($buffer != '') {
497
-                $all_data = json_decode($buffer,true);
497
+                $all_data = json_decode($buffer, true);
498 498
                 foreach ($all_data as $line) {
499 499
                     $data = array();
500
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
501 501
                     $data['hex'] = $line['hex']; // hex
502 502
                     $data['ident'] = $line['fli']; // ident
503 503
                     $data['altitude'] = $line['alt']; // altitude
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	    )
533 533
 	) {
534 534
 	    date_default_timezone_set('CET');
535
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
536 536
 	    date_default_timezone_set('UTC');
537 537
 	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
538
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
539
+	    $buffer = explode('\n', $buffer);
540 540
 	    foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542 542
 		    //echo "'".$line."'\n";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		    $ais_data = $AIS->parse_line(trim($line));
545 545
 		    $data = array();
546 546
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
548 548
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549 549
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550 550
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557 557
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558 558
 		    if (isset($ais_data['timestamp'])) {
559
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
560 560
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
561 561
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562 562
 			    $add = true;
@@ -579,21 +579,21 @@  discard block
 block discarded – undo
579 579
 	    $w = $e = null;
580 580
 	    
581 581
 	    if (isset($arr[$id])) {
582
-		$nn = stream_select($arr,$w,$e,$timeout);
582
+		$nn = stream_select($arr, $w, $e, $timeout);
583 583
 		if ($nn > 0) {
584 584
 		    foreach ($httpfeeds as $feed) {
585
-			$buffer = stream_get_line($feed,2000,"\n");
585
+			$buffer = stream_get_line($feed, 2000, "\n");
586 586
 			if ($buffer === FALSE) {
587 587
 			    connect_all($globalSources);
588 588
 			}
589
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
590
-			$buffer = explode('\n',$buffer);
589
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
590
+			$buffer = explode('\n', $buffer);
591 591
 			foreach ($buffer as $line) {
592 592
 			    if ($line != '') {
593 593
 				$ais_data = $AIS->parse_line(trim($line));
594 594
 				$data = array();
595 595
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
596
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
597 597
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598 598
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599 599
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606 606
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607 607
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
609 609
 				if (isset($ais_data['timestamp'])) {
610
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
611 611
 				} else {
612 612
 				    $data['datetime'] = date('Y-m-d H:i:s');
613 613
 				}
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
640 640
 	    )
641 641
 	) {
642
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
643 643
 	    if ($buffer != '') {
644 644
 		//echo $buffer;
645
-		$all_data = json_decode($buffer,true);
645
+		$all_data = json_decode($buffer, true);
646 646
 		//print_r($all_data);
647 647
 		if (isset($all_data[0]['DATA'])) {
648 648
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			    $data['ident'] = $line['NAME'];
652 652
 			    $data['mmsi'] = $line['MMSI'];
653 653
 			    if (strlen($data['mmsi']) > 9) {
654
-				$data['mmsi'] = substr($data['mmsi'],-9);
654
+				$data['mmsi'] = substr($data['mmsi'], -9);
655 655
 			    }
656 656
 			    $data['speed'] = $line['SOG'];
657 657
 			    $data['heading'] = $line['COG'];
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 			    //$data['type_id'] = $line['TYPE'];
662 662
 			    $data['imo'] = $line['IMO'];
663 663
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
664
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
665
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
666 666
 			    $data['format_source'] = 'myshiptracking';
667 667
 			    $data['id_source'] = $id_source;
668 668
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
680 680
 	    )
681 681
 	) {
682
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
683 683
 	    if ($buffer != '') {
684
-		$all_data = json_decode($buffer,true);
684
+		$all_data = json_decode($buffer, true);
685 685
 		if (isset($all_data[0]['mmsi'])) {
686 686
 		    foreach ($all_data as $line) {
687 687
 			if ($line != '') {
688 688
 			    $data = array();
689 689
 			    $data['ident'] = $line['shipname'];
690 690
 			    $data['callsign'] = $line['callsign'];
691
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
+			    $data['mmsi'] = substr($line['mmsi'], -9);
692 692
 			    $data['speed'] = $line['sog'];
693 693
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694 694
 			    $data['latitude'] = $line['latitude'];
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 	) {
716 716
 	    $buffer = $Common->getData($value['host']);
717 717
 	    if ($buffer != '') {
718
-		$all_data = json_decode($buffer,true);
718
+		$all_data = json_decode($buffer, true);
719 719
 		if (isset($all_data['features'][0]['id'])) {
720 720
 		    foreach ($all_data['features'] as $line) {
721 721
 			print_r($line);
722 722
 			$data = array();
723 723
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724 724
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
725
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
726 726
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727 727
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728 728
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -749,31 +749,31 @@  discard block
 block discarded – undo
749 749
 	    )
750 750
 	) {
751 751
 	    if ($globalDebug) echo 'download...';
752
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
753 753
 	    if ($globalDebug) echo 'done !'."\n";
754 754
 	    // FIXME: Need more work
755 755
 	    if ($buffer != '') $reset = 0;
756
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
-	    $buffer = explode('\n',$buffer);
756
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
757
+	    $buffer = explode('\n', $buffer);
758 758
 	    foreach ($buffer as $line) {
759 759
 		if ($line != '') {
760 760
 		    $data = array();
761 761
 		    //echo $line."\n";
762
-		    $data['mmsi'] = (int)substr($line,0,9);
763
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
-		    $data['status_id'] = substr($line,21,2);
765
-		    $data['type_id'] = substr($line,24,3);
766
-		    $data['latitude'] = substr($line,29,9);
767
-		    $data['longitude'] = substr($line,41,9);
768
-		    $data['speed'] = round(substr($line,51,5));
762
+		    $data['mmsi'] = (int) substr($line, 0, 9);
763
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
764
+		    $data['status_id'] = substr($line, 21, 2);
765
+		    $data['type_id'] = substr($line, 24, 3);
766
+		    $data['latitude'] = substr($line, 29, 9);
767
+		    $data['longitude'] = substr($line, 41, 9);
768
+		    $data['speed'] = round(substr($line, 51, 5));
769 769
 		    //$data['course'] = substr($line,57,5);
770
-		    $data['heading'] = round(substr($line,63,3));
770
+		    $data['heading'] = round(substr($line, 63, 3));
771 771
 		    //$data['draft'] = substr($line,67,4);
772 772
 		    //$data['length'] = substr($line,72,3);
773 773
 		    //$data['beam'] = substr($line,76,2);
774
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
775 775
 		    //$data['callsign'] = trim(substr($line,100,7);
776
-		    $data['arrival_code'] = substr($line,108,20);
776
+		    $data['arrival_code'] = substr($line, 108, 20);
777 777
 		    //$data['etaDate'] = substr($line,129,5);
778 778
 		    //$data['etaTime'] = substr($line,135,5);
779 779
 		    $data['format_source'] = 'shipplotter';
@@ -796,28 +796,28 @@  discard block
 block discarded – undo
796 796
 		exit(0);
797 797
 	    }
798 798
 	    $sailawayoption = array('key' => $globalSailaway['key']);
799
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
800
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
799
+	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr']));
800
+	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr']));
801 801
 
802 802
 	    for ($i = 0; $i <= 1; $i++) {
803 803
 		if ($globalDebug) echo '! Download... ';
804
-		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30);
804
+		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2', 'get', '', '', '', '', 30);
805 805
 		if ($globalDebug) echo 'done'."\n";
806 806
 		if ($buffer != '') {
807
-		    $all_data = json_decode($buffer,true);
807
+		    $all_data = json_decode($buffer, true);
808 808
 		    if (isset($all_data['missions'])) {
809 809
 			foreach ($all_data['missions'] as $mission) {
810 810
 				$mission_user = $mission['usrname'];
811
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
812
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
811
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
812
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
813 813
 					//print_r($mission);
814 814
 					$datar = array();
815 815
 					$datar['id'] = $mission['misnr'];
816 816
 					$datar['desc'] = $mission['misdescr'];
817 817
 					//$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname'])));
818 818
 					$datar['creator'] = '';
819
-					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])));
820
-					if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart']));
819
+					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])));
820
+					if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s', strtotime($mission['misstart']));
821 821
 					else $datar['startdate'] = '1970-01-01 00:00:00';
822 822
 					/*
823 823
 					$markers = array();
@@ -837,9 +837,9 @@  discard block
 block discarded – undo
837 837
 		if ($globalDebug) echo '=== Wait... ===';
838 838
 		sleep(10*60);
839 839
 	    }
840
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
840
+	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30);
841 841
 	    if ($buffer != '') {
842
-		$data = json_decode($buffer,true);
842
+		$data = json_decode($buffer, true);
843 843
 		//print_r($data);
844 844
 		if (isset($data['boats'])) {
845 845
 		    foreach ($data['boats'] as $sail) {
@@ -851,12 +851,12 @@  discard block
 block discarded – undo
851 851
 			$data['longitude'] = $sail['ubtlon'];
852 852
 			$data['type_id'] = 36;
853 853
 			$data['heading'] = $sail['ubtheading'];
854
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
854
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
855 855
 			$data['captain_name'] = $sail['usrname'];
856
-			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
856
+			$allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52&#39; Cruising Cat', '50&#39; Performance Cruiser', 'Nordic Folkboat', '32&#39; Offshore Racer');
857 857
 			$boattype = $sail['ubtbtpnr'];
858
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
859
-			$data['speed'] = round($sail['ubtspeed']*3.6,2);
858
+			if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1];
859
+			$data['speed'] = round($sail['ubtspeed']*3.6, 2);
860 860
 			$data['format_source'] = 'sailaway';
861 861
 			$data['id_source'] = $id_source;
862 862
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -889,11 +889,11 @@  discard block
 block discarded – undo
889 889
 	    }
890 890
 	    if ($globalDebug) echo '! Download... ';
891 891
 	    $sailawayoption = array('key' => $globalSailaway['key']);
892
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
893
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
894
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
892
+	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr']));
893
+	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr']));
894
+	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30);
895 895
 	    if ($buffer != '') {
896
-		$data = json_decode($buffer,true);
896
+		$data = json_decode($buffer, true);
897 897
 		//print_r($data);
898 898
 		if (isset($data['boats'])) {
899 899
 		    foreach ($data['boats'] as $sail) {
@@ -905,12 +905,12 @@  discard block
 block discarded – undo
905 905
 			$data['longitude'] = $sail['ubtlon'];
906 906
 			$data['type_id'] = 36;
907 907
 			$data['heading'] = $sail['ubtheading'];
908
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
908
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
909 909
 			$data['captain_name'] = $sail['usrname'];
910
-			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
910
+			$allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52&#39; Cruising Cat', '50&#39; Performance Cruiser', 'Nordic Folkboat', '32&#39; Offshore Racer');
911 911
 			$boattype = $sail['ubtbtpnr'];
912
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
913
-			$data['speed'] = round($sail['ubtspeed']*3.6,2);
912
+			if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1];
913
+			$data['speed'] = round($sail['ubtspeed']*3.6, 2);
914 914
 			$data['format_source'] = 'sailaway';
915 915
 			$data['id_source'] = $id_source;
916 916
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -938,8 +938,8 @@  discard block
 block discarded – undo
938 938
 	) {
939 939
 	    //$buffer = $Common->getData($hosts[$id]);
940 940
 	    $buffer = $Common->getData($value['host']);
941
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
942
-	    $buffer = explode('\n',$buffer);
941
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
942
+	    $buffer = explode('\n', $buffer);
943 943
 	    $reset = 0;
944 944
 	    foreach ($buffer as $line) {
945 945
     		if ($line != '') {
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
951 951
 			$data['pilot_id'] = $line[1];
952 952
 			$data['pilot_name'] = $line[2];
953
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
953
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
954 954
 			$data['ident'] = $line[0]; // ident
955 955
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
956 956
 			$data['speed'] = $line[8]; // speed
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
967 967
 			//if (isset($line[37])) $data['last_update'] = $line[37];
968 968
 		        $data['departure_airport_icao'] = $line[11];
969
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
969
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
970 970
 		        $data['arrival_airport_icao'] = $line[13];
971 971
 			$data['frequency'] = $line[4];
972 972
 			$data['type'] = $line[18];
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
     			$data['id_source'] = $id_source;
976 976
 	    		//$data['arrival_airport_time'] = ;
977 977
 	    		if ($line[9] != '') {
978
-	    		    $aircraft_data = explode('/',$line[9]);
978
+	    		    $aircraft_data = explode('/', $line[9]);
979 979
 	    		    if (isset($aircraft_data[1])) {
980 980
 	    			$data['aircraft_icao'] = $aircraft_data[1];
981 981
 	    		    }
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
     			if ($line[3] === 'PILOT') $SI->add($data);
991 991
 			elseif ($line[3] === 'ATC') {
992 992
 				//print_r($data);
993
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
994
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
995
-				$typec = substr($data['ident'],-3);
993
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
994
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
995
+				$typec = substr($data['ident'], -3);
996 996
 				if ($typec === 'APP') $data['type'] = 'Approach';
997 997
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
998 998
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
1005 1005
 				if (!isset($data['source_name'])) $data['source_name'] = '';
1006 1006
 				if (isset($ATC)) {
1007
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1008
-					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']);
1007
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
1008
+					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']);
1009 1009
 				}
1010 1010
 			}
1011 1011
     			unset($data);
@@ -1021,24 +1021,24 @@  discard block
 block discarded – undo
1021 1021
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1022 1022
     	    )
1023 1023
     	) {
1024
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1024
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1025 1025
 	    if ($buffer != '') {
1026 1026
 		$all_data = simplexml_load_string($buffer);
1027
-		foreach($all_data->children() as $childdata) {
1027
+		foreach ($all_data->children() as $childdata) {
1028 1028
 			$data = array();
1029 1029
 			$line = $childdata;
1030 1030
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1031
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1032
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1033
-			$data['latitude'] = (float)$line['pktLatitude'];
1034
-			$data['longitude'] = (float)$line['pktLongitude'];
1035
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1036
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1037
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1031
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1032
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1033
+			$data['latitude'] = (float) $line['pktLatitude'];
1034
+			$data['longitude'] = (float) $line['pktLongitude'];
1035
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1036
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1037
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1038 1038
 			$data['altitude_relative'] = 'AMSL';
1039
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1039
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1040 1040
 			$data['aircraft_icao'] = 'PARAGLIDER';
1041
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1041
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1042 1042
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1043 1043
 			$data['format_source'] = $value['format'];
1044 1044
 			$SI->add($data);
@@ -1046,22 +1046,22 @@  discard block
 block discarded – undo
1046 1046
 		}
1047 1047
 	    }
1048 1048
 	    $Source->deleteOldLocationByType('gs');
1049
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1049
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1050 1050
 	    if ($buffer != '') {
1051 1051
 		$all_data = simplexml_load_string($buffer);
1052
-		foreach($all_data->children() as $childdata) {
1052
+		foreach ($all_data->children() as $childdata) {
1053 1053
 			$data = array();
1054 1054
 			$line = $childdata;
1055
-			$data['id'] = (int)$line['gsID'];
1056
-			$data['latitude'] = (float)$line['gsLatitude'];
1057
-			$data['longitude'] = (float)$line['gsLongitude'];
1058
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1055
+			$data['id'] = (int) $line['gsID'];
1056
+			$data['latitude'] = (float) $line['gsLatitude'];
1057
+			$data['longitude'] = (float) $line['gsLongitude'];
1058
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1059 1059
 			$data['altitude_relative'] = 'AMSL';
1060
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1060
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1061 1061
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1062
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1062
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1063 1063
 			} else {
1064
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1064
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1065 1065
 			}
1066 1066
 			unset($data);
1067 1067
 		}
@@ -1079,9 +1079,9 @@  discard block
 block discarded – undo
1079 1079
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1080 1080
 	    )
1081 1081
 	) {
1082
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1082
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1083 1083
 	    if ($buffer != '') {
1084
-	        $all_data = json_decode($buffer,true);
1084
+	        $all_data = json_decode($buffer, true);
1085 1085
 		if (isset($all_data['acList'])) {
1086 1086
 		    $reset = 0;
1087 1087
 		    foreach ($all_data['acList'] as $line) {
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1098 1098
 			$data['emergency'] = ''; // emergency
1099 1099
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1100
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1100
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1101 1101
 			else $data['datetime'] = date('Y-m-d H:i:s');
1102 1102
 			//$data['datetime'] = date('Y-m-d H:i:s');
1103 1103
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1123 1123
 			$data['squawk'] = $line['squawk']; // squawk
1124 1124
 			$data['emergency'] = ''; // emergency
1125
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1125
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1126 1126
 			else $data['datetime'] = date('Y-m-d H:i:s');
1127 1127
 			$data['format_source'] = 'aircraftlistjson';
1128 1128
 			$data['id_source'] = $id_source;
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
     	    )
1144 1144
     	) {
1145 1145
 	    $buffer = $Common->getData($value['host']);
1146
-	    $all_data = json_decode($buffer,true);
1146
+	    $all_data = json_decode($buffer, true);
1147 1147
 	    if (isset($all_data['planes'])) {
1148 1148
 		$reset = 0;
1149 1149
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1160,12 +1160,12 @@  discard block
 block discarded – undo
1160 1160
 		    $data['emergency'] = ''; // emergency
1161 1161
 		    $data['registration'] = $line[2];
1162 1162
 		    $data['aircraft_icao'] = $line[0];
1163
-		    $deparr = explode('-',$line[1]);
1163
+		    $deparr = explode('-', $line[1]);
1164 1164
 		    if (count($deparr) === 2) {
1165 1165
 			$data['departure_airport_icao'] = $deparr[0];
1166 1166
 			$data['arrival_airport_icao'] = $deparr[1];
1167 1167
 		    }
1168
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1168
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1169 1169
 	    	    $data['format_source'] = 'planeupdatefaa';
1170 1170
     		    $data['id_source'] = $id_source;
1171 1171
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 	    )
1184 1184
 	) {
1185 1185
 	    $buffer = $Common->getData($value['host']);
1186
-	    $all_data = json_decode($buffer,true);
1186
+	    $all_data = json_decode($buffer, true);
1187 1187
 	    if (isset($all_data['states'])) {
1188 1188
 		$reset = 0;
1189 1189
 		foreach ($all_data['states'] as $key => $line) {
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 		    //$data['emergency'] = ''; // emergency
1201 1201
 		    //$data['registration'] = $line[2];
1202 1202
 		    //$data['aircraft_icao'] = $line[0];
1203
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1203
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1204 1204
 		    $data['format_source'] = 'opensky';
1205 1205
 		    $data['id_source'] = $id_source;
1206 1206
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1217,8 +1217,8 @@  discard block
 block discarded – undo
1217 1217
 	    )
1218 1218
 	) {
1219 1219
 	    $buffer = $Common->getData($value['host']);
1220
-	    $all_data = json_decode($buffer,true);
1221
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1220
+	    $all_data = json_decode($buffer, true);
1221
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1222 1222
 		$reset = 0;
1223 1223
 		foreach ($all_data['aircraft'] as $key => $line) {
1224 1224
 		    $data = array();
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 	    )
1257 1257
 	) {
1258 1258
 	    $buffer = $Common->getData($value['host']);
1259
-	    $all_data = json_decode($buffer,true);
1259
+	    $all_data = json_decode($buffer, true);
1260 1260
 	    if (isset($all_data['aircraft'])) {
1261 1261
 		$reset = 0;
1262 1262
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 		    //$data['emergency'] = ''; // emergency
1274 1274
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1275 1275
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1276
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1276
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1277 1277
 		    $data['format_source'] = 'planefinderclient';
1278 1278
 		    $data['id_source'] = $id_source;
1279 1279
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 	) {
1293 1293
 	    //$buffer = $Common->getData($hosts[$id]);
1294 1294
 	    $buffer = $Common->getData($value['host']);
1295
-	    $all_data = json_decode($buffer,true);
1295
+	    $all_data = json_decode($buffer, true);
1296 1296
 	    if (!empty($all_data)) $reset = 0;
1297 1297
 	    foreach ($all_data as $key => $line) {
1298 1298
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1330,11 +1330,11 @@  discard block
 block discarded – undo
1330 1330
 	    )
1331 1331
 	) {
1332 1332
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1333
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1333
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1334 1334
 	    //echo $buffer;
1335
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1336
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1337
-	    $all_data = json_decode($buffer,true);
1335
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1336
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1337
+	    $all_data = json_decode($buffer, true);
1338 1338
 	    if (json_last_error() != JSON_ERROR_NONE) {
1339 1339
 		die(json_last_error_msg());
1340 1340
 	    }
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
 			//$data['departure_airport_iata'] = $line[11];
1358 1358
 			//$data['arrival_airport_iata'] = $line[12];
1359 1359
 	    		//$data['emergency'] = ''; // emergency
1360
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1360
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1361 1361
 	    		$data['format_source'] = 'radarvirtueljson';
1362 1362
     			$data['id_source'] = $id_source;
1363 1363
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1378,14 +1378,14 @@  discard block
 block discarded – undo
1378 1378
 	) {
1379 1379
 	    //$buffer = $Common->getData($hosts[$id]);
1380 1380
 	    $buffer = $Common->getData($value['host'].'?'.time());
1381
-	    $all_data = json_decode(utf8_encode($buffer),true);
1381
+	    $all_data = json_decode(utf8_encode($buffer), true);
1382 1382
 	    
1383 1383
 	    if (isset($all_data['pireps'])) {
1384 1384
 		$reset = 0;
1385 1385
 	        foreach ($all_data['pireps'] as $line) {
1386 1386
 		    $data = array();
1387 1387
 		    $data['id'] = $line['id'];
1388
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1388
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1389 1389
 		    $data['ident'] = $line['callsign']; // ident
1390 1390
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1391 1391
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1415,9 +1415,9 @@  discard block
 block discarded – undo
1415 1415
 			$SI->add($data);
1416 1416
 		    //    print_r($data);
1417 1417
     		    } elseif ($line['icon'] === 'ct') {
1418
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1419
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1420
-			$typec = substr($data['ident'],-3);
1418
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1419
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1420
+			$typec = substr($data['ident'], -3);
1421 1421
 			$data['type'] = '';
1422 1422
 			if ($typec === 'APP') $data['type'] = 'Approach';
1423 1423
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1429 1429
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1430 1430
 			else $data['type'] = 'Observer';
1431
-			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']);
1431
+			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']);
1432 1432
 		    }
1433 1433
 		    unset($data);
1434 1434
 		}
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 	    //$buffer = $Common->getData($hosts[$id]);
1446 1446
 	    if ($globalDebug) echo 'Get Data...'."\n";
1447 1447
 	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1448
+	    $all_data = json_decode($buffer, true);
1449 1449
 	    if ($buffer != '' && is_array($all_data)) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data as $line) {
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
 	    	    //$data['id'] = $line['id']; // id not usable
1454 1454
 	    	    if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
1455 1455
 	    	    elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1456
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1456
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1457 1457
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1458 1458
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1459 1459
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
 	    	    //$data['datetime'] = $line['lastupdate'];
1469 1469
 	    	    //$data['last_update'] = $line['lastupdate'];
1470 1470
 	    	    if (isset($value['timezone'])) {
1471
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1471
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1472 1472
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1473 1473
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1474 1474
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1484,14 +1484,14 @@  discard block
 block discarded – undo
1484 1484
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1485 1485
 		    if (isset($line['aircraftname'])) {
1486 1486
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1487
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1488
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1487
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1488
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1489 1489
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1490 1490
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1491 1491
 	    		else {
1492
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1493
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1494
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1492
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1493
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1494
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1495 1495
 	    		}
1496 1496
 	    	    }
1497 1497
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 	    //$buffer = $Common->getData($hosts[$id]);
1517 1517
 	    if ($globalDebug) echo 'Get Data...'."\n";
1518 1518
 	    $buffer = $Common->getData($value['host']);
1519
-	    $all_data = json_decode($buffer,true);
1519
+	    $all_data = json_decode($buffer, true);
1520 1520
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1521 1521
 		$reset = 0;
1522 1522
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1528 1528
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1529 1529
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1530
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1530
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1531 1531
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1532 1532
 	    	    $data['altitude'] = $line['altitude']; // altitude
1533 1533
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
 	    	    //$data['squawk'] = ''; // squawk
1539 1539
 	    	    //$data['emergency'] = ''; // emergency
1540 1540
 	    	    if (isset($value['timezone'])) {
1541
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1541
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1542 1542
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1543 1543
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1544 1544
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1574,14 +1574,14 @@  discard block
 block discarded – undo
1574 1574
 	    //$buffer = $Common->getData($hosts[$id]);
1575 1575
 	    if ($globalDebug) echo 'Get Data...'."\n";
1576 1576
 	    $buffer = $Common->getData($value['host']);
1577
-	    $all_data = json_decode($buffer,true);
1577
+	    $all_data = json_decode($buffer, true);
1578 1578
 	    if ($buffer != '' && is_array($all_data)) {
1579 1579
 		$reset = 0;
1580 1580
 		foreach ($all_data as $line) {
1581 1581
 	    	    $data = array();
1582 1582
 	    	    //$data['id'] = $line['id']; // id not usable
1583 1583
 	    	    $data['id'] = trim($line['flight_id']);
1584
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1584
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1585 1585
 	    	    $data['pilot_name'] = $line['pilot_name'];
1586 1586
 	    	    $data['pilot_id'] = $line['pilot_id'];
1587 1587
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1625,24 +1625,24 @@  discard block
 block discarded – undo
1625 1625
 	    //$buffer = $Common->getData($hosts[$id]);
1626 1626
 	    if ($globalDebug) echo 'Get Data...'."\n";
1627 1627
 	    $buffer = $Common->getData($value['host']);
1628
-	    $all_data = json_decode($buffer,true);
1628
+	    $all_data = json_decode($buffer, true);
1629 1629
 	    if ($buffer != '') {
1630 1630
 		$Source->deleteLocationBySource('blitzortung');
1631
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1632
-		$buffer = explode('\n',$buffer);
1631
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1632
+		$buffer = explode('\n', $buffer);
1633 1633
 		foreach ($buffer as $buffer_line) {
1634
-		    $line = json_decode($buffer_line,true);
1634
+		    $line = json_decode($buffer_line, true);
1635 1635
 		    if (isset($line['time'])) {
1636 1636
 			$data = array();
1637 1637
 			$data['altitude'] = $line['alt']; // altitude
1638 1638
 			$data['latitude'] = $line['lat']; // lat
1639 1639
 			$data['longitude'] = $line['lon']; // long
1640
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1640
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1641 1641
 			$data['id_source'] = $id_source;
1642 1642
 			$data['format_source'] = 'blitzortung';
1643 1643
 			$SI->add($data);
1644 1644
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1645
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1645
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1646 1646
 			unset($data);
1647 1647
 		    }
1648 1648
 		}
@@ -1654,15 +1654,15 @@  discard block
 block discarded – undo
1654 1654
         $arr = $httpfeeds;
1655 1655
         $w = $e = null;
1656 1656
         if (isset($arr[$id])) {
1657
-            $nn = stream_select($arr,$w,$e,$timeout);
1657
+            $nn = stream_select($arr, $w, $e, $timeout);
1658 1658
             if ($nn > 0) {
1659 1659
                 foreach ($httpfeeds as $feed) {
1660
-                    $buffer = stream_get_line($feed,2000,"\n");
1660
+                    $buffer = stream_get_line($feed, 2000, "\n");
1661 1661
                     if ($buffer === FALSE) {
1662 1662
                         connect_all($globalSources);
1663 1663
                     }
1664
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1665
-                    $buffer = explode('\n',$buffer);
1664
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1665
+                    $buffer = explode('\n', $buffer);
1666 1666
                     foreach ($buffer as $line) {
1667 1667
                         if ($line != '') {
1668 1668
                             $line = json_decode($line, true);
@@ -1702,11 +1702,11 @@  discard block
 block discarded – undo
1702 1702
 		    //$value = $formats[$nb];
1703 1703
 		    $format = $globalSources[$nb]['format'];
1704 1704
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1705
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1705
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1706 1706
 		    } elseif ($format === 'vrstcp') {
1707 1707
 			$buffer = @socket_read($r, 6000);
1708 1708
 		    } else {
1709
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1709
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1710 1710
 		    }
1711 1711
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1712 1712
 		    //echo $buffer."\n";
@@ -1716,8 +1716,8 @@  discard block
 block discarded – undo
1716 1716
 		    //$SI::del();
1717 1717
 		    if ($buffer !== FALSE) {
1718 1718
 			if ($format === 'vrstcp') {
1719
-			    $buffer = explode('},{',$buffer);
1720
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1719
+			    $buffer = explode('},{', $buffer);
1720
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1721 1721
 		    }
1722 1722
 		    // SBS format is CSV format
1723 1723
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			    $ais_data = $AIS->parse_line(trim($buffer));
1745 1745
 			    $data = array();
1746 1746
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1747
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1747
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1748 1748
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1749 1749
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1750 1750
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1755,13 +1755,13 @@  discard block
 block discarded – undo
1755 1755
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1756 1756
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1757 1757
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1758
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1758
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1759 1759
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760 1760
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1761 1761
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1762 1762
 
1763 1763
 			    if (isset($ais_data['timestamp'])) {
1764
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1764
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1765 1765
 			    } else {
1766 1766
 				$data['datetime'] = date('Y-m-d H:i:s');
1767 1767
 			    }
@@ -1772,10 +1772,10 @@  discard block
 block discarded – undo
1772 1772
                         } elseif ($format === 'flightgearsp') {
1773 1773
                     	    //echo $buffer."\n";
1774 1774
                     	    if (strlen($buffer) > 5) {
1775
-				$line = explode(',',$buffer);
1775
+				$line = explode(',', $buffer);
1776 1776
 				$data = array();
1777 1777
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1778
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1778
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1779 1779
 				$data['ident'] = $line[6];
1780 1780
 				$data['aircraft_name'] = $line[7];
1781 1781
 				$data['longitude'] = $line[1];
@@ -1792,25 +1792,25 @@  discard block
 block discarded – undo
1792 1792
                         } elseif ($format === 'acars') {
1793 1793
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1794 1794
 			    $ACARS->add(trim($buffer));
1795
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1795
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1796 1796
 			    $ACARS->deleteLiveAcarsData();
1797 1797
 			} elseif ($format === 'acarsjsonudp') {
1798 1798
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1799 1799
                             $line = json_decode(trim($buffer), true);
1800 1800
                             if (!empty($line)) {
1801
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1801
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1802 1802
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1803 1803
                                 $ACARS->deleteLiveAcarsData();
1804 1804
                             }
1805
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1805
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1806 1806
 			} elseif ($format === 'flightgearmp') {
1807
-			    if (substr($buffer,0,1) != '#') {
1807
+			    if (substr($buffer, 0, 1) != '#') {
1808 1808
 				$data = array();
1809 1809
 				//echo $buffer."\n";
1810
-				$line = explode(' ',$buffer);
1810
+				$line = explode(' ', $buffer);
1811 1811
 				if (count($line) === 11) {
1812
-				    $userserver = explode('@',$line[0]);
1813
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1812
+				    $userserver = explode('@', $line[0]);
1813
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1814 1814
 				    $data['ident'] = $userserver[0];
1815 1815
 				    $data['registration'] = $userserver[0];
1816 1816
 				    $data['latitude'] = $line[4];
@@ -1818,8 +1818,8 @@  discard block
 block discarded – undo
1818 1818
 				    $data['altitude'] = $line[6];
1819 1819
 				    $data['datetime'] = date('Y-m-d H:i:s');
1820 1820
 				    $aircraft_type = $line[10];
1821
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1822
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1821
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1822
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1823 1823
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1824 1824
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1825 1825
 				}
@@ -1828,8 +1828,8 @@  discard block
 block discarded – undo
1828 1828
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1829 1829
 			    die;
1830 1830
 			} elseif ($format === 'vrstcp') {
1831
-			    foreach($buffer as $all_data) {
1832
-				$line = json_decode('{'.$all_data.'}',true);
1831
+			    foreach ($buffer as $all_data) {
1832
+				$line = json_decode('{'.$all_data.'}', true);
1833 1833
 				$data = array();
1834 1834
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1835 1835
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1855,16 +1855,16 @@  discard block
 block discarded – undo
1855 1855
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1856 1856
 				unset($data);
1857 1857
 			    }
1858
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1858
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1859 1859
 			    $line = explode("\t", $buffer);
1860
-			    for($k = 0; $k < count($line); $k=$k+2) {
1860
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1861 1861
 				$key = $line[$k];
1862
-			        $lined[$key] = $line[$k+1];
1862
+			        $lined[$key] = $line[$k + 1];
1863 1863
 			    }
1864 1864
     			    if (count($lined) > 3) {
1865 1865
     				$data['hex'] = $lined['hexid'];
1866 1866
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1867
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1867
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1868 1868
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1869 1869
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1870 1870
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1883,23 +1883,23 @@  discard block
 block discarded – undo
1883 1883
     			    } else $error = true;
1884 1884
 			} elseif ($format === 'aprs' && $use_aprs) {
1885 1885
 			    if ($aprs_connect === 0) {
1886
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1886
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1887 1887
 				$aprs_connect = 1;
1888 1888
 			    }
1889 1889
 			    
1890
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1890
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1891 1891
 				$aprs_last_tx = time();
1892 1892
 				$data_aprs = "# Keep alive";
1893
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1893
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1894 1894
 			    }
1895 1895
 			    
1896 1896
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1897 1897
 			    //echo 'APRS data : '.$buffer."\n";
1898
-			    $buffer = str_replace('APRS <- ','',$buffer);
1899
-			    $buffer = str_replace('APRS -> ','',$buffer);
1898
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1899
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1900 1900
 			    //echo $buffer."\n";
1901 1901
 			    date_default_timezone_set('UTC');
1902
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1902
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1903 1903
 				$line = $APRS->parse($buffer);
1904 1904
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1905 1905
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1915 1915
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1916 1916
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1917
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1917
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1918 1918
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1919 1919
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1920 1920
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -2002,29 +2002,29 @@  discard block
 block discarded – undo
2002 2002
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2003 2003
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2004 2004
 					$Source->deleteOldLocationByType('gs');
2005
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2006
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2005
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
2006
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2007 2007
 					} else {
2008
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2008
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2009 2009
 					}
2010 2010
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2011 2011
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2012 2012
 					if ($globalDebug) echo '# Weather Station added'."\n";
2013 2013
 					$Source->deleteOldLocationByType('wx');
2014 2014
 					$weather_data = json_encode($line);
2015
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2016
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2015
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2016
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2017 2017
 					} else {
2018
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2018
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2019 2019
 					}
2020 2020
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2021 2021
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2022 2022
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2023 2023
 					$Source->deleteOldLocationByType('lightning');
2024
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2025
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2024
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2025
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2026 2026
 					} else {
2027
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2027
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2028 2028
 					}
2029 2029
 				    } elseif ($globalDebug) {
2030 2030
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 				    unset($data);
2034 2034
 				}
2035 2035
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2036
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2036
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2037 2037
 				}
2038 2038
 				/*
2039 2039
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -2042,7 +2042,7 @@  discard block
 block discarded – undo
2042 2042
 				*/
2043 2043
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2044 2044
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2045
-				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2045
+				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2046 2046
 					$Source->deleteOldLocationByType('lightning');
2047 2047
 					$Source->deleteOldLocationByType('wx');
2048 2048
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 				connect_all($sourceee);
2130 2130
 				$sourceee = array();
2131 2131
 				//connect_all($globalSources);
2132
-				$tt[$format]=0;
2132
+				$tt[$format] = 0;
2133 2133
 				break;
2134 2134
 			    } 
2135 2135
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2139,14 +2139,14 @@  discard block
 block discarded – undo
2139 2139
 	    } else {
2140 2140
 		$error = socket_strerror(socket_last_error());
2141 2141
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2142
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2142
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2143 2143
 			if (isset($globalDebug)) echo "Restarting...\n";
2144 2144
 			// Restart the script if possible
2145 2145
 			if (is_array($sockets)) {
2146 2146
 			    if ($globalDebug) echo "Shutdown all sockets...";
2147 2147
 			    
2148 2148
 			    foreach ($sockets as $sock) {
2149
-				@socket_shutdown($sock,2);
2149
+				@socket_shutdown($sock, 2);
2150 2150
 				@socket_close($sock);
2151 2151
 			    }
2152 2152
 			    
Please login to merge, or discard this patch.
Braces   +1273 added lines, -429 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$udp = false;
@@ -172,32 +219,44 @@  discard block
 block discarded – undo
172 219
         	//$formats[$id] = 'deltadbtxt';
173 220
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 221
         	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to deltadb source (".$host.")...\n";
224
+        	}
176 225
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177 226
         	//$formats[$id] = 'vatsimtxt';
178 227
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 228
         	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
229
+        	if ($globalDebug) {
230
+        		echo "Connect to vatsim source (".$host.")...\n";
231
+        	}
181 232
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182 233
         	//$formats[$id] = 'aircraftlistjson';
183 234
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 235
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
236
+        	if ($globalDebug) {
237
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
238
+        	}
186 239
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
187 240
         	//$formats[$id] = 'aircraftjson';
188 241
         	$globalSources[$id]['format'] = 'aircraftjson';
189 242
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
243
+        	if ($globalDebug) {
244
+        		echo "Connect to aircraft.json source (".$host.")...\n";
245
+        	}
191 246
     	    } else if (preg_match('/aircraft$/i',$host)) {
192 247
         	//$formats[$id] = 'planefinderclient';
193 248
         	$globalSources[$id]['format'] = 'planefinderclient';
194 249
         	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to planefinderclient source (".$host.")...\n";
252
+        	}
196 253
     	    } else if (preg_match('/opensky/i',$host)) {
197 254
         	//$formats[$id] = 'aircraftlistjson';
198 255
         	$globalSources[$id]['format'] = 'opensky';
199 256
         	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to opensky source (".$host.")...\n";
259
+        	}
201 260
     	    /*
202 261
     	    // Disabled for now, site change source format
203 262
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -214,7 +273,9 @@  discard block
 block discarded – undo
214 273
         	//$formats[$id] = 'planeupdatefaa';
215 274
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 275
         	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
276
+        	if ($globalDebug) {
277
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
278
+        	}
218 279
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219 280
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 281
         	    exit(0);
@@ -223,37 +284,53 @@  discard block
 block discarded – undo
223 284
         	//$formats[$id] = 'phpvmacars';
224 285
         	$globalSources[$id]['format'] = 'phpvmacars';
225 286
         	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
287
+        	if ($globalDebug) {
288
+        		echo "Connect to phpvmacars source (".$host.")...\n";
289
+        	}
227 290
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228 291
         	//$formats[$id] = 'phpvmacars';
229 292
         	$globalSources[$id]['format'] = 'vaos';
230 293
         	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
294
+        	if ($globalDebug) {
295
+        		echo "Connect to vaos source (".$host.")...\n";
296
+        	}
232 297
             } else if (preg_match('/VAM-json.php$/i',$host)) {
233 298
         	//$formats[$id] = 'phpvmacars';
234 299
         	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
300
+        	if ($globalDebug) {
301
+        		echo "Connect to Vam source (".$host.")...\n";
302
+        	}
236 303
             } else if (preg_match('/whazzup/i',$host)) {
237 304
         	//$formats[$id] = 'whazzup';
238 305
         	$globalSources[$id]['format'] = 'whazzup';
239 306
         	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
307
+        	if ($globalDebug) {
308
+        		echo "Connect to whazzup source (".$host.")...\n";
309
+        	}
241 310
             } else if (preg_match('/blitzortung/i',$host)) {
242 311
         	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
312
+        	if ($globalDebug) {
313
+        		echo "Connect to blitzortung source (".$host.")...\n";
314
+        	}
244 315
             } else if (preg_match('/airwhere/i',$host)) {
245 316
         	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
317
+        	if ($globalDebug) {
318
+        		echo "Connect to airwhere source (".$host.")...\n";
319
+        	}
247 320
             } else if (preg_match('/recentpireps/i',$host)) {
248 321
         	//$formats[$id] = 'pirepsjson';
249 322
         	$globalSources[$id]['format'] = 'pirepsjson';
250 323
         	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to pirepsjson source (".$host.")...\n";
326
+        	}
252 327
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253 328
         	//$formats[$id] = 'fr24json';
254 329
         	$globalSources[$id]['format'] = 'fr24json';
255 330
         	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
331
+        	if ($globalDebug) {
332
+        		echo "Connect to fr24 source (".$host.")...\n";
333
+        	}
257 334
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258 335
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 336
         	    exit(0);
@@ -262,7 +339,9 @@  discard block
 block discarded – undo
262 339
         	//$formats[$id] = 'fr24json';
263 340
         	$globalSources[$id]['format'] = 'myshiptracking';
264 341
         	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
342
+        	if ($globalDebug) {
343
+        		echo "Connect to myshiptracking source (".$host.")...\n";
344
+        	}
266 345
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267 346
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268 347
         	    exit(0);
@@ -271,18 +350,28 @@  discard block
 block discarded – undo
271 350
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 351
         	//$formats[$id] = 'tsv';
273 352
         	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
353
+        	if ($globalDebug) {
354
+        		echo "Connect to tsv source (".$host.")...\n";
355
+        	}
275 356
             }
276 357
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 358
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278 359
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279 360
     		    if ($idf !== false) {
280 361
     			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+        		if ($globalDebug) {
363
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+        		}
365
+    		    } elseif ($globalDebug) {
366
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
367
+    		    }
368
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
369
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
370
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') {
371
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
372
+    		} elseif ($globalDebug) {
373
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
374
+    		}
286 375
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287 376
 	    $hostport = explode(':',$host);
288 377
 	    if (isset($hostport[1])) {
@@ -323,20 +412,29 @@  discard block
 block discarded – undo
323 412
         		//$formats[$id] = 'beast';
324 413
         		$globalSources[$id]['format'] = 'beast';
325 414
 		    //} else $formats[$id] = 'sbs';
326
-		    } else $globalSources[$id]['format'] = 'sbs';
415
+		    } else {
416
+		    	$globalSources[$id]['format'] = 'sbs';
417
+		    }
327 418
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
328 419
 		}
329
-		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
-		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
420
+		if ($globalDebug && $udp) {
421
+			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
422
+		} elseif ($globalDebug) {
423
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
424
+		}
331 425
             } else {
332
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
426
+		if ($globalDebug) {
427
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
428
+		}
333 429
 		sleep(10);
334 430
 		connect_all($hosts);
335 431
     	    }
336 432
         }
337 433
     }
338 434
 }
339
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
435
+if (!isset($globalMinFetch)) {
436
+	$globalMinFetch = 15;
437
+}
340 438
 
341 439
 // Initialize all
342 440
 $status = array();
@@ -345,13 +443,19 @@  discard block
 block discarded – undo
345 443
 $formats = array();
346 444
 $last_exec = array();
347 445
 $time = time();
348
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
349
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350
-else $timeout = 20;
446
+if (isset($globalSourcesTimeout)) {
447
+	$timeout = $globalSourcesTimeOut;
448
+} else if (isset($globalSBS1TimeOut)) {
449
+	$timeout = $globalSBS1TimeOut;
450
+} else {
451
+	$timeout = 20;
452
+}
351 453
 $errno = '';
352 454
 $errstr='';
353 455
 
354
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
456
+if (!isset($globalDaemon)) {
457
+	$globalDaemon = TRUE;
458
+}
355 459
 /* Initiate connections to all the hosts simultaneously */
356 460
 //connect_all($hosts);
357 461
 //connect_all($globalSources);
@@ -380,7 +484,9 @@  discard block
 block discarded – undo
380 484
     if (isset($source['format']) && $source['format'] == 'aprs') {
381 485
 	$aprs_connect = 0;
382 486
 	$use_aprs = true;
383
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
487
+	if (isset($source['port']) && $source['port'] == '10152') {
488
+		$aprs_full = true;
489
+	}
384 490
 	break;
385 491
     }
386 492
 }
@@ -391,25 +497,46 @@  discard block
 block discarded – undo
391 497
 	$aprs_connect = 0;
392 498
 	$aprs_keep = 120;
393 499
 	$aprs_last_tx = time();
394
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
396
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
398
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400
-	if ($aprs_full) $aprs_filter = '';
401
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402
-	else $aprs_pass = '-1';
500
+	if (isset($globalAPRSversion)) {
501
+		$aprs_version = $globalAPRSversion;
502
+	} else {
503
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
504
+	}
505
+	if (isset($globalAPRSssid)) {
506
+		$aprs_ssid = $globalAPRSssid;
507
+	} else {
508
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
509
+	}
510
+	if (isset($globalAPRSfilter)) {
511
+		$aprs_filter = $globalAPRSfilter;
512
+	} else {
513
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
514
+	}
515
+	if ($aprs_full) {
516
+		$aprs_filter = '';
517
+	}
518
+	if (isset($globalAPRSpass)) {
519
+		$aprs_pass = $globalAPRSpass;
520
+	} else {
521
+		$aprs_pass = '-1';
522
+	}
403 523
 
404
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
405
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
406
-}
524
+	if ($aprs_filter != '') {
525
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
526
+	} else {
527
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
528
+	}
529
+	}
407 530
 
408 531
 // connected - lets do some work
409 532
 //if ($globalDebug) echo "Connected!\n";
410 533
 sleep(1);
411
-if ($globalDebug) echo "SCAN MODE \n\n";
412
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
534
+if ($globalDebug) {
535
+	echo "SCAN MODE \n\n";
536
+}
537
+if (!isset($globalCronEnd)) {
538
+	$globalCronEnd = 60;
539
+}
413 540
 $endtime = time()+$globalCronEnd;
414 541
 $i = 1;
415 542
 $tt = array();
@@ -423,22 +550,32 @@  discard block
 block discarded – undo
423 550
 
424 551
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
425 552
 while ($i > 0) {
426
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
553
+    if (function_exists('pcntl_fork')) {
554
+    	pcntl_signal_dispatch();
555
+    }
427 556
 
428
-    if (!$globalDaemon) $i = $endtime-time();
557
+    if (!$globalDaemon) {
558
+    	$i = $endtime-time();
559
+    }
429 560
     // Delete old ATC
430 561
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
562
+	if ($globalDebug) {
563
+		echo 'Delete old ATC...'."\n";
564
+	}
432 565
         $ATC->deleteOldATC();
433 566
     }
434 567
     
435 568
     if (count($last_exec) == count($globalSources)) {
436 569
 	$max = $globalMinFetch;
437 570
 	foreach ($last_exec as $last) {
438
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
571
+	    if ((time() - $last['last']) < $max) {
572
+	    	$max = time() - $last['last'];
573
+	    }
439 574
 	}
440 575
 	if ($max < $globalMinFetch) {
441
-	    if ($globalDebug) echo 'Sleeping...'."\n";
576
+	    if ($globalDebug) {
577
+	    	echo 'Sleeping...'."\n";
578
+	    }
442 579
 	    sleep($globalMinFetch-$max+2);
443 580
 	}
444 581
     }
@@ -448,7 +585,9 @@  discard block
 block discarded – undo
448 585
     foreach ($globalSources as $id => $value) {
449 586
 	date_default_timezone_set('UTC');
450 587
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
451
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
588
+	if (!isset($last_exec[$id]['last'])) {
589
+		$last_exec[$id]['last'] = 0;
590
+	}
452 591
 	if ($value['format'] === 'deltadbtxt' && 
453 592
 	    (
454 593
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -457,7 +596,9 @@  discard block
 block discarded – undo
457 596
 	) {
458 597
         //$buffer = $Common->getData($hosts[$id]);
459 598
         $buffer = $Common->getData($value['host']);
460
-        if ($buffer != '') $reset = 0;
599
+        if ($buffer != '') {
600
+        	$reset = 0;
601
+        }
461 602
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462 603
         $buffer = explode('\n', $buffer);
463 604
         foreach ($buffer as $line) {
@@ -466,20 +607,41 @@  discard block
 block discarded – undo
466 607
                 $data = array();
467 608
                 $data['hex'] = $line[1]; // hex
468 609
                 $data['ident'] = $line[2]; // ident
469
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
610
+                if (isset($line[3])) {
611
+                	$data['altitude'] = $line[3];
612
+                }
613
+                // altitude
614
+                if (isset($line[4])) {
615
+                	$data['speed'] = $line[4];
616
+                }
617
+                // speed
618
+                if (isset($line[5])) {
619
+                	$data['heading'] = $line[5];
620
+                }
621
+                // heading
622
+                if (isset($line[6])) {
623
+                	$data['latitude'] = $line[6];
624
+                }
625
+                // lat
626
+                if (isset($line[7])) {
627
+                	$data['longitude'] = $line[7];
628
+                }
629
+                // long
474 630
                 $data['verticalrate'] = ''; // vertical rate
475 631
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476 632
                 $data['emergency'] = ''; // emergency
477 633
                 $data['datetime'] = date('Y-m-d H:i:s');
478 634
                 $data['format_source'] = 'deltadbtxt';
479 635
                 $data['id_source'] = $id_source;
480
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
636
+                if (isset($value['name']) && $value['name'] != '') {
637
+                	$data['source_name'] = $value['name'];
638
+                }
639
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
640
+                	$data['noarchive'] = true;
641
+                }
642
+                if (isset($value['sourcestats'])) {
643
+                	$data['sourcestats'] = $value['sourcestats'];
644
+                }
483 645
                 $SI->add($data);
484 646
                 unset($data);
485 647
             }
@@ -514,11 +676,20 @@  discard block
 block discarded – undo
514 676
                     $data['format_source'] = 'radarcapejson';
515 677
                     $data['id_source'] = $id_source;
516 678
                     if (isset($value['name']) && $value['name'] != '') {
517
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
-                        else $data['source_name'] = $value['name'];
519
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
679
+                        if (isset($line['src']) && !$line['src'] == 'M') {
680
+                        	$data['source_name'] = $value['name'].'_MLAT';
681
+                        } else {
682
+                        	$data['source_name'] = $value['name'];
683
+                        }
684
+                    } elseif (isset($line['src']) && $line['src'] == 'M') {
685
+                    	$data['source_name'] = 'MLAT';
686
+                    }
687
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
688
+                    	$data['noarchive'] = true;
689
+                    }
690
+                    if (isset($value['sourcestats'])) {
691
+                    	$data['sourcestats'] = $value['sourcestats'];
692
+                    }
522 693
 
523 694
                     $SI->add($data);
524 695
                     unset($data);
@@ -534,7 +705,9 @@  discard block
 block discarded – undo
534 705
 	    date_default_timezone_set('CET');
535 706
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536 707
 	    date_default_timezone_set('UTC');
537
-	    if ($buffer != '') $reset = 0;
708
+	    if ($buffer != '') {
709
+	    	$reset = 0;
710
+	    }
538 711
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539 712
 	    $buffer = explode('\n',$buffer);
540 713
 	    foreach ($buffer as $line) {
@@ -543,18 +716,42 @@  discard block
 block discarded – undo
543 716
 		    $add = false;
544 717
 		    $ais_data = $AIS->parse_line(trim($line));
545 718
 		    $data = array();
546
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
719
+		    if (isset($ais_data['ident'])) {
720
+		    	$data['ident'] = $ais_data['ident'];
721
+		    }
722
+		    if (isset($ais_data['mmsi'])) {
723
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
724
+		    }
725
+		    if (isset($ais_data['speed'])) {
726
+		    	$data['speed'] = $ais_data['speed'];
727
+		    }
728
+		    if (isset($ais_data['heading'])) {
729
+		    	$data['heading'] = $ais_data['heading'];
730
+		    }
731
+		    if (isset($ais_data['latitude'])) {
732
+		    	$data['latitude'] = $ais_data['latitude'];
733
+		    }
734
+		    if (isset($ais_data['longitude'])) {
735
+		    	$data['longitude'] = $ais_data['longitude'];
736
+		    }
737
+		    if (isset($ais_data['status'])) {
738
+		    	$data['status'] = $ais_data['status'];
739
+		    }
740
+		    if (isset($ais_data['statusid'])) {
741
+		    	$data['status_id'] = $ais_data['statusid'];
742
+		    }
743
+		    if (isset($ais_data['type'])) {
744
+		    	$data['type'] = $ais_data['type'];
745
+		    }
746
+		    if (isset($ais_data['typeid'])) {
747
+		    	$data['type_id'] = $ais_data['typeid'];
748
+		    }
749
+		    if (isset($ais_data['imo'])) {
750
+		    	$data['imo'] = $ais_data['imo'];
751
+		    }
752
+		    if (isset($ais_data['callsign'])) {
753
+		    	$data['callsign'] = $ais_data['callsign'];
754
+		    }
558 755
 		    if (isset($ais_data['timestamp'])) {
559 756
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
560 757
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -568,8 +765,12 @@  discard block
 block discarded – undo
568 765
 		    $data['format_source'] = 'aisnmeatxt';
569 766
     		    $data['id_source'] = $id_source;
570 767
 		    //print_r($data);
571
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
768
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
769
+		    	$data['noarchive'] = true;
770
+		    }
771
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
772
+		    	$MI->add($data);
773
+		    }
573 774
 		    unset($data);
574 775
 		}
575 776
     	    }
@@ -592,20 +793,48 @@  discard block
 block discarded – undo
592 793
 			    if ($line != '') {
593 794
 				$ais_data = $AIS->parse_line(trim($line));
594 795
 				$data = array();
595
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
597
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
600
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
601
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
602
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
603
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
604
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
605
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
796
+				if (isset($ais_data['ident'])) {
797
+					$data['ident'] = $ais_data['ident'];
798
+				}
799
+				if (isset($ais_data['mmsi'])) {
800
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
801
+				}
802
+				if (isset($ais_data['speed'])) {
803
+					$data['speed'] = $ais_data['speed'];
804
+				}
805
+				if (isset($ais_data['heading'])) {
806
+					$data['heading'] = $ais_data['heading'];
807
+				}
808
+				if (isset($ais_data['latitude'])) {
809
+					$data['latitude'] = $ais_data['latitude'];
810
+				}
811
+				if (isset($ais_data['longitude'])) {
812
+					$data['longitude'] = $ais_data['longitude'];
813
+				}
814
+				if (isset($ais_data['status'])) {
815
+					$data['status'] = $ais_data['status'];
816
+				}
817
+				if (isset($ais_data['statusid'])) {
818
+					$data['status_id'] = $ais_data['statusid'];
819
+				}
820
+				if (isset($ais_data['type'])) {
821
+					$data['type'] = $ais_data['type'];
822
+				}
823
+				if (isset($ais_data['typeid'])) {
824
+					$data['type_id'] = $ais_data['typeid'];
825
+				}
826
+				if (isset($ais_data['imo'])) {
827
+					$data['imo'] = $ais_data['imo'];
828
+				}
829
+				if (isset($ais_data['callsign'])) {
830
+					$data['callsign'] = $ais_data['callsign'];
831
+				}
832
+				if (isset($ais_data['destination'])) {
833
+					$data['arrival_code'] = $ais_data['destination'];
834
+				}
835
+				if (isset($ais_data['eta_ts'])) {
836
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
837
+				}
609 838
 				if (isset($ais_data['timestamp'])) {
610 839
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
611 840
 				} else {
@@ -613,18 +842,27 @@  discard block
 block discarded – undo
613 842
 				}
614 843
 				$data['format_source'] = 'aisnmeahttp';
615 844
 				$data['id_source'] = $id_source;
616
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
617
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
845
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
846
+					$data['noarchive'] = true;
847
+				}
848
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
849
+					$MI->add($data);
850
+				}
618 851
 				unset($data);
619 852
 			    }
620 853
 			}
621 854
 		    }
622 855
 		} else {
623 856
 		    $format = $value['format'];
624
-		    if (isset($tt[$format])) $tt[$format]++;
625
-		    else $tt[$format] = 0;
857
+		    if (isset($tt[$format])) {
858
+		    	$tt[$format]++;
859
+		    } else {
860
+		    	$tt[$format] = 0;
861
+		    }
626 862
 		    if ($tt[$format] > 30) {
627
-			if ($globalDebug) echo 'Reconnect...'."\n";
863
+			if ($globalDebug) {
864
+				echo 'Reconnect...'."\n";
865
+			}
628 866
 			sleep(2);
629 867
 			//$sourceeen[] = $value;
630 868
 			//connect_all($sourceeen);
@@ -660,12 +898,18 @@  discard block
 block discarded – undo
660 898
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661 899
 			    //$data['type_id'] = $line['TYPE'];
662 900
 			    $data['imo'] = $line['IMO'];
663
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
901
+			    if ($line['DEST'] != '') {
902
+			    	$data['arrival_code'] = $line['DEST'];
903
+			    }
904
+			    if ($line['ARV'] != '') {
905
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
906
+			    }
665 907
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666 908
 			    $data['format_source'] = 'myshiptracking';
667 909
 			    $data['id_source'] = $id_source;
668
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
910
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
911
+			    	$data['noarchive'] = true;
912
+			    }
669 913
 			    $MI->add($data);
670 914
 			    unset($data);
671 915
 			}
@@ -690,7 +934,9 @@  discard block
 block discarded – undo
690 934
 			    $data['callsign'] = $line['callsign'];
691 935
 			    $data['mmsi'] = substr($line['mmsi'],-9);
692 936
 			    $data['speed'] = $line['sog'];
693
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
937
+			    if ($line['heading'] != '511') {
938
+			    	$data['heading'] = $line['heading'];
939
+			    }
694 940
 			    $data['latitude'] = $line['latitude'];
695 941
 			    $data['longitude'] = $line['longitude'];
696 942
 			    $data['type_id'] = $line['shiptype'];
@@ -698,7 +944,9 @@  discard block
 block discarded – undo
698 944
 			    $data['datetime'] = $line['time'];
699 945
 			    $data['format_source'] = 'boatbeaconapp';
700 946
 			    $data['id_source'] = $id_source;
701
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
947
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
948
+			    	$data['noarchive'] = true;
949
+			    }
702 950
 			    $MI->add($data);
703 951
 			    unset($data);
704 952
 			}
@@ -720,22 +968,44 @@  discard block
 block discarded – undo
720 968
 		    foreach ($all_data['features'] as $line) {
721 969
 			print_r($line);
722 970
 			$data = array();
723
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
726
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
971
+			if (isset($line['properties']['name'])) {
972
+				$data['ident'] = $line['properties']['name'];
973
+			}
974
+			if (isset($line['properties']['callsign'])) {
975
+				$data['callsign'] = $line['properties']['callsign'];
976
+			}
977
+			if (isset($line['properties']['mmsi'])) {
978
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
979
+			}
980
+			if (isset($line['properties']['imo'])) {
981
+				$data['imo'] = $line['properties']['imo'];
982
+			}
983
+			if (isset($line['properties']['speed'])) {
984
+				$data['speed'] = $line['properties']['speed'];
985
+			}
986
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
987
+				$data['heading'] = $line['properties']['heading'];
988
+			}
729 989
 			$data['latitude'] = $line['geometry']['coordinates'][1];
730 990
 			$data['longitude'] = $line['geometry']['coordinates'][0];
731
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
732
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
733
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
991
+			if (isset($line['properties']['vesselType'])) {
992
+				$data['type'] = $line['properties']['vesselType'];
993
+			}
994
+			if (isset($line['properties']['destination'])) {
995
+				$data['arrival_code'] = $line['properties']['destination'];
996
+			}
997
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
998
+				$data['arrival_date'] = $line['properties']['eta'];
999
+			}
734 1000
 			$data['format_source'] = 'boatnerd';
735 1001
 			$data['id_source'] = $id_source;
736 1002
 			$data['datetime'] = date('Y-m-d H:i:s');
737
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
1003
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1004
+				$data['noarchive'] = true;
1005
+			}
1006
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
1007
+				$MI->add($data);
1008
+			}
739 1009
 			unset($data);
740 1010
 		    }
741 1011
 		}
@@ -748,11 +1018,17 @@  discard block
 block discarded – undo
748 1018
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
749 1019
 	    )
750 1020
 	) {
751
-	    if ($globalDebug) echo 'download...';
1021
+	    if ($globalDebug) {
1022
+	    	echo 'download...';
1023
+	    }
752 1024
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
-	    if ($globalDebug) echo 'done !'."\n";
1025
+	    if ($globalDebug) {
1026
+	    	echo 'done !'."\n";
1027
+	    }
754 1028
 	    // FIXME: Need more work
755
-	    if ($buffer != '') $reset = 0;
1029
+	    if ($buffer != '') {
1030
+	    	$reset = 0;
1031
+	    }
756 1032
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757 1033
 	    $buffer = explode('\n',$buffer);
758 1034
 	    foreach ($buffer as $line) {
@@ -778,7 +1054,9 @@  discard block
 block discarded – undo
778 1054
 		    //$data['etaTime'] = substr($line,135,5);
779 1055
 		    $data['format_source'] = 'shipplotter';
780 1056
     		    $data['id_source'] = $id_source;
781
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1057
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1058
+		    	$data['noarchive'] = true;
1059
+		    }
782 1060
 		    //print_r($data);
783 1061
 		    //echo 'Add...'."\n";
784 1062
 		    $MI->add($data);
@@ -796,13 +1074,21 @@  discard block
 block discarded – undo
796 1074
 		exit(0);
797 1075
 	    }
798 1076
 	    $sailawayoption = array('key' => $globalSailaway['key']);
799
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
800
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1077
+	    if (isset($globalSailaway['usrnr'])) {
1078
+	    	$sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
1079
+	    }
1080
+	    if (isset($globalSailaway['ubtnr'])) {
1081
+	    	$sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1082
+	    }
801 1083
 
802 1084
 	    for ($i = 0; $i <= 1; $i++) {
803
-		if ($globalDebug) echo '! Download... ';
1085
+		if ($globalDebug) {
1086
+			echo '! Download... ';
1087
+		}
804 1088
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30);
805
-		if ($globalDebug) echo 'done'."\n";
1089
+		if ($globalDebug) {
1090
+			echo 'done'."\n";
1091
+		}
806 1092
 		if ($buffer != '') {
807 1093
 		    $all_data = json_decode($buffer,true);
808 1094
 		    if (isset($all_data['missions'])) {
@@ -817,8 +1103,11 @@  discard block
 block discarded – undo
817 1103
 					//$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname'])));
818 1104
 					$datar['creator'] = '';
819 1105
 					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])));
820
-					if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart']));
821
-					else $datar['startdate'] = '1970-01-01 00:00:00';
1106
+					if (isset($mission['misstart'])) {
1107
+						$datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart']));
1108
+					} else {
1109
+						$datar['startdate'] = '1970-01-01 00:00:00';
1110
+					}
822 1111
 					/*
823 1112
 					$markers = array();
824 1113
 					foreach ($race_data['mission']['course'] as $course) {
@@ -834,7 +1123,9 @@  discard block
 block discarded – undo
834 1123
 			}
835 1124
 		    }
836 1125
 		}
837
-		if ($globalDebug) echo '=== Wait... ===';
1126
+		if ($globalDebug) {
1127
+			echo '=== Wait... ===';
1128
+		}
838 1129
 		sleep(10*60);
839 1130
 	    }
840 1131
 	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
@@ -846,7 +1137,9 @@  discard block
 block discarded – undo
846 1137
 			$data = array();
847 1138
 			$data['id'] = $sail['ubtnr'];
848 1139
 			$data['datetime'] = date('Y-m-d H:i:s');
849
-			if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s');
1140
+			if ($sail['online'] == '1') {
1141
+				$data['last_update'] = date('Y-m-d H:i:s');
1142
+			}
850 1143
 			$data['latitude'] = $sail['ubtlat'];
851 1144
 			$data['longitude'] = $sail['ubtlon'];
852 1145
 			$data['type_id'] = 36;
@@ -855,16 +1148,24 @@  discard block
 block discarded – undo
855 1148
 			$data['captain_name'] = $sail['usrname'];
856 1149
 			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
857 1150
 			$boattype = $sail['ubtbtpnr'];
858
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
1151
+			if (isset($allboats[$boattype-1])) {
1152
+				$data['type'] = $allboats[$boattype-1];
1153
+			}
859 1154
 			$data['speed'] = round($sail['ubtspeed']*3.6,2);
860 1155
 			$data['format_source'] = 'sailaway';
861 1156
 			$data['id_source'] = $id_source;
862
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1157
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1158
+				$data['noarchive'] = true;
1159
+			}
863 1160
 			$MI->add($data);
864 1161
 			unset($data);
865 1162
 		    }
866
-		} elseif ($globalDebug) echo 'Error in JSON parsing';
867
-	    } elseif ($globalDebug) echo 'Empty result !'."\n";
1163
+		} elseif ($globalDebug) {
1164
+			echo 'Error in JSON parsing';
1165
+		}
1166
+	    } elseif ($globalDebug) {
1167
+	    	echo 'Empty result !'."\n";
1168
+	    }
868 1169
 
869 1170
     	    $last_exec[$id]['last'] = time();
870 1171
 	} elseif ($value['format'] === 'sailaway' && 
@@ -887,10 +1188,16 @@  discard block
 block discarded – undo
887 1188
 		echo 'Sailaway API key MUST be defined';
888 1189
 		exit(0);
889 1190
 	    }
890
-	    if ($globalDebug) echo '! Download... ';
1191
+	    if ($globalDebug) {
1192
+	    	echo '! Download... ';
1193
+	    }
891 1194
 	    $sailawayoption = array('key' => $globalSailaway['key']);
892
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
893
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1195
+	    if (isset($globalSailaway['usrnr'])) {
1196
+	    	$sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
1197
+	    }
1198
+	    if (isset($globalSailaway['ubtnr'])) {
1199
+	    	$sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
1200
+	    }
894 1201
 	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
895 1202
 	    if ($buffer != '') {
896 1203
 		$data = json_decode($buffer,true);
@@ -900,7 +1207,9 @@  discard block
 block discarded – undo
900 1207
 			$data = array();
901 1208
 			$data['id'] = $sail['ubtnr'];
902 1209
 			$data['datetime'] = date('Y-m-d H:i:s');
903
-			if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s');
1210
+			if ($sail['online'] == '1') {
1211
+				$data['last_update'] = date('Y-m-d H:i:s');
1212
+			}
904 1213
 			$data['latitude'] = $sail['ubtlat'];
905 1214
 			$data['longitude'] = $sail['ubtlon'];
906 1215
 			$data['type_id'] = 36;
@@ -909,16 +1218,24 @@  discard block
 block discarded – undo
909 1218
 			$data['captain_name'] = $sail['usrname'];
910 1219
 			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
911 1220
 			$boattype = $sail['ubtbtpnr'];
912
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
1221
+			if (isset($allboats[$boattype-1])) {
1222
+				$data['type'] = $allboats[$boattype-1];
1223
+			}
913 1224
 			$data['speed'] = round($sail['ubtspeed']*3.6,2);
914 1225
 			$data['format_source'] = 'sailaway';
915 1226
 			$data['id_source'] = $id_source;
916
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1227
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1228
+				$data['noarchive'] = true;
1229
+			}
917 1230
 			$MI->add($data);
918 1231
 			unset($data);
919 1232
 		    }
920
-		} elseif ($globalDebug) echo 'Error in JSON parsing';
921
-	    } elseif ($globalDebug) echo 'Empty result !'."\n";
1233
+		} elseif ($globalDebug) {
1234
+			echo 'Error in JSON parsing';
1235
+		}
1236
+	    } elseif ($globalDebug) {
1237
+	    	echo 'Empty result !'."\n";
1238
+	    }
922 1239
     	    $last_exec[$id]['last'] = time();
923 1240
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
924 1241
 	} elseif (
@@ -946,16 +1263,28 @@  discard block
 block discarded – undo
946 1263
     		    $line = explode(':', $line);
947 1264
     		    if (count($line) > 30 && $line[0] != 'callsign') {
948 1265
 			$data = array();
949
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
950
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1266
+			if (isset($line[37]) && $line[37] != '') {
1267
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1268
+			} else {
1269
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1270
+			}
951 1271
 			$data['pilot_id'] = $line[1];
952 1272
 			$data['pilot_name'] = $line[2];
953 1273
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
954 1274
 			$data['ident'] = $line[0]; // ident
955
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1275
+			if ($line[7] != '' && $line[7] != 0) {
1276
+				$data['altitude'] = $line[7];
1277
+			}
1278
+			// altitude
956 1279
 			$data['speed'] = $line[8]; // speed
957
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
958
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1280
+			if (isset($line[45])) {
1281
+				$data['heading'] = $line[45];
1282
+			}
1283
+			// heading
1284
+			elseif (isset($line[38])) {
1285
+				$data['heading'] = $line[38];
1286
+			}
1287
+			// heading
959 1288
 			$data['latitude'] = $line[5]; // lat
960 1289
 	        	$data['longitude'] = $line[6]; // long
961 1290
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -971,7 +1300,9 @@  discard block
 block discarded – undo
971 1300
 			$data['frequency'] = $line[4];
972 1301
 			$data['type'] = $line[18];
973 1302
 			$data['range'] = $line[19];
974
-			if (isset($line[35])) $data['info'] = $line[35];
1303
+			if (isset($line[35])) {
1304
+				$data['info'] = $line[35];
1305
+			}
975 1306
     			$data['id_source'] = $id_source;
976 1307
 	    		//$data['arrival_airport_time'] = ;
977 1308
 	    		if ($line[9] != '') {
@@ -985,27 +1316,47 @@  discard block
 block discarded – undo
985 1316
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
986 1317
 	    		*/
987 1318
 	    		$data['format_source'] = $value['format'];
988
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
989
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
990
-    			if ($line[3] === 'PILOT') $SI->add($data);
991
-			elseif ($line[3] === 'ATC') {
1319
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1320
+				$data['noarchive'] = true;
1321
+			}
1322
+			if (isset($value['name']) && $value['name'] != '') {
1323
+				$data['source_name'] = $value['name'];
1324
+			}
1325
+    			if ($line[3] === 'PILOT') {
1326
+    				$SI->add($data);
1327
+    			} elseif ($line[3] === 'ATC') {
992 1328
 				//print_r($data);
993 1329
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
994 1330
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
995 1331
 				$typec = substr($data['ident'],-3);
996
-				if ($typec === 'APP') $data['type'] = 'Approach';
997
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
998
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
999
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
1000
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1001
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
1002
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1003
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1004
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
1005
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1332
+				if ($typec === 'APP') {
1333
+					$data['type'] = 'Approach';
1334
+				} elseif ($typec === 'TWR') {
1335
+					$data['type'] = 'Tower';
1336
+				} elseif ($typec === 'OBS') {
1337
+					$data['type'] = 'Observer';
1338
+				} elseif ($typec === 'GND') {
1339
+					$data['type'] = 'Ground';
1340
+				} elseif ($typec === 'DEL') {
1341
+					$data['type'] = 'Delivery';
1342
+				} elseif ($typec === 'DEP') {
1343
+					$data['type'] = 'Departure';
1344
+				} elseif ($typec === 'FSS') {
1345
+					$data['type'] = 'Flight Service Station';
1346
+				} elseif ($typec === 'CTR') {
1347
+					$data['type'] = 'Control Radar or Centre';
1348
+				} elseif ($data['type'] === '') {
1349
+					$data['type'] = 'Observer';
1350
+				}
1351
+				if (!isset($data['source_name'])) {
1352
+					$data['source_name'] = '';
1353
+				}
1006 1354
 				if (isset($ATC)) {
1007
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1008
-					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']);
1355
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1356
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1357
+					} else {
1358
+						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']);
1359
+					}
1009 1360
 				}
1010 1361
 			}
1011 1362
     			unset($data);
@@ -1032,14 +1383,20 @@  discard block
 block discarded – undo
1032 1383
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1033 1384
 			$data['latitude'] = (float)$line['pktLatitude'];
1034 1385
 			$data['longitude'] = (float)$line['pktLongitude'];
1035
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1036
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1386
+			if ((float)$line['pktTrack'] != 0) {
1387
+				$data['heading'] = (float)$line['pktTrack'];
1388
+			}
1389
+			if ((int)$line['pktSpeed'] != 0) {
1390
+				$data['speed'] = (int)$line['pktSpeed'];
1391
+			}
1037 1392
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1038 1393
 			$data['altitude_relative'] = 'AMSL';
1039 1394
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1040 1395
 			$data['aircraft_icao'] = 'PARAGLIDER';
1041 1396
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1042
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1397
+			if (isset($pilot_data[4])) {
1398
+				$data['pilot_name'] = $pilot_data[4];
1399
+			}
1043 1400
 			$data['format_source'] = $value['format'];
1044 1401
 			$SI->add($data);
1045 1402
 			unset($data);
@@ -1087,25 +1444,59 @@  discard block
 block discarded – undo
1087 1444
 		    foreach ($all_data['acList'] as $line) {
1088 1445
 			$data = array();
1089 1446
 			$data['hex'] = $line['Icao']; // hex
1090
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1091
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1092
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1093
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1094
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1095
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1447
+			if (isset($line['Call'])) {
1448
+				$data['ident'] = $line['Call'];
1449
+			}
1450
+			// ident
1451
+			if (isset($line['Alt'])) {
1452
+				$data['altitude'] = $line['Alt'];
1453
+			}
1454
+			// altitude
1455
+			if (isset($line['Spd'])) {
1456
+				$data['speed'] = $line['Spd'];
1457
+			}
1458
+			// speed
1459
+			if (isset($line['Trak'])) {
1460
+				$data['heading'] = $line['Trak'];
1461
+			}
1462
+			// heading
1463
+			if (isset($line['Lat'])) {
1464
+				$data['latitude'] = $line['Lat'];
1465
+			}
1466
+			// lat
1467
+			if (isset($line['Long'])) {
1468
+				$data['longitude'] = $line['Long'];
1469
+			}
1470
+			// long
1096 1471
 			//$data['verticalrate'] = $line['']; // verticale rate
1097
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1472
+			if (isset($line['Sqk'])) {
1473
+				$data['squawk'] = $line['Sqk'];
1474
+			}
1475
+			// squawk
1098 1476
 			$data['emergency'] = ''; // emergency
1099
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1100
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1101
-			else $data['datetime'] = date('Y-m-d H:i:s');
1477
+			if (isset($line['Reg'])) {
1478
+				$data['registration'] = $line['Reg'];
1479
+			}
1480
+			if (isset($line['PosTime'])) {
1481
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1482
+			} else {
1483
+				$data['datetime'] = date('Y-m-d H:i:s');
1484
+			}
1102 1485
 			//$data['datetime'] = date('Y-m-d H:i:s');
1103
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1486
+			if (isset($line['Type'])) {
1487
+				$data['aircraft_icao'] = $line['Type'];
1488
+			}
1104 1489
 			$data['format_source'] = 'aircraftlistjson';
1105 1490
 			$data['id_source'] = $id_source;
1106
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1107
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1108
-			if (isset($data['latitude'])) $SI->add($data);
1491
+			if (isset($value['name']) && $value['name'] != '') {
1492
+				$data['source_name'] = $value['name'];
1493
+			}
1494
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1495
+				$data['noarchive'] = true;
1496
+			}
1497
+			if (isset($data['latitude'])) {
1498
+				$SI->add($data);
1499
+			}
1109 1500
 			unset($data);
1110 1501
 		    }
1111 1502
 		} elseif (is_array($all_data)) {
@@ -1122,17 +1513,26 @@  discard block
 block discarded – undo
1122 1513
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1123 1514
 			$data['squawk'] = $line['squawk']; // squawk
1124 1515
 			$data['emergency'] = ''; // emergency
1125
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1126
-			else $data['datetime'] = date('Y-m-d H:i:s');
1516
+			if (isset($line['PosTime'])) {
1517
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1518
+			} else {
1519
+				$data['datetime'] = date('Y-m-d H:i:s');
1520
+			}
1127 1521
 			$data['format_source'] = 'aircraftlistjson';
1128 1522
 			$data['id_source'] = $id_source;
1129
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1523
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1524
+				$data['noarchive'] = true;
1525
+			}
1526
+			if (isset($value['name']) && $value['name'] != '') {
1527
+				$data['source_name'] = $value['name'];
1528
+			}
1131 1529
 			$SI->add($data);
1132 1530
 			unset($data);
1133 1531
 		    }
1134 1532
 		}
1135
-	    } elseif ($globalDebug) echo 'No data'."\n";
1533
+	    } elseif ($globalDebug) {
1534
+	    	echo 'No data'."\n";
1535
+	    }
1136 1536
     	    //$last_exec['aircraftlistjson'] = time();
1137 1537
     	    $last_exec[$id]['last'] = time();
1138 1538
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1168,8 +1568,12 @@  discard block
 block discarded – undo
1168 1568
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1169 1569
 	    	    $data['format_source'] = 'planeupdatefaa';
1170 1570
     		    $data['id_source'] = $id_source;
1171
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1172
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1571
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1572
+		    	$data['noarchive'] = true;
1573
+		    }
1574
+		    if (isset($value['name']) && $value['name'] != '') {
1575
+		    	$data['source_name'] = $value['name'];
1576
+		    }
1173 1577
 		    $SI->add($data);
1174 1578
 		    unset($data);
1175 1579
 		}
@@ -1203,7 +1607,9 @@  discard block
 block discarded – undo
1203 1607
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1204 1608
 		    $data['format_source'] = 'opensky';
1205 1609
 		    $data['id_source'] = $id_source;
1206
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1610
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1611
+		    	$data['noarchive'] = true;
1612
+		    }
1207 1613
 		    $SI->add($data);
1208 1614
 		    unset($data);
1209 1615
 		}
@@ -1223,15 +1629,42 @@  discard block
 block discarded – undo
1223 1629
 		foreach ($all_data['aircraft'] as $key => $line) {
1224 1630
 		    $data = array();
1225 1631
 		    // add support for ground vehicule with ~ in front of hex
1226
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1227
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1228
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1229
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1230
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1231
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1232
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1233
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1234
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1632
+		    if (isset($line['hex'])) {
1633
+		    	$data['hex'] = $line['hex'];
1634
+		    }
1635
+		    // hex
1636
+		    if (isset($line['flight'])) {
1637
+		    	$data['ident'] = trim($line['flight']);
1638
+		    }
1639
+		    // ident
1640
+		    if (isset($line['altitude'])) {
1641
+		    	$data['altitude'] = $line['altitude'];
1642
+		    }
1643
+		    // altitude
1644
+		    if (isset($line['speed'])) {
1645
+		    	$data['speed'] = $line['speed'];
1646
+		    }
1647
+		    // speed
1648
+		    if (isset($line['track'])) {
1649
+		    	$data['heading'] = $line['track'];
1650
+		    }
1651
+		    // heading
1652
+		    if (isset($line['lat'])) {
1653
+		    	$data['latitude'] = $line['lat'];
1654
+		    }
1655
+		    // lat
1656
+		    if (isset($line['lon'])) {
1657
+		    	$data['longitude'] = $line['lon'];
1658
+		    }
1659
+		    // long
1660
+		    if (isset($line['vert_rate'])) {
1661
+		    	$data['verticalrate'] = $line['vert_rate'];
1662
+		    }
1663
+		    // verticale rate
1664
+		    if (isset($line['squawk'])) {
1665
+		    	$data['squawk'] = $line['squawk'];
1666
+		    }
1667
+		    // squawk
1235 1668
 		    //$data['emergency'] = ''; // emergency
1236 1669
 		    //$data['registration'] = $line[2];
1237 1670
 		    //$data['aircraft_icao'] = $line[0];
@@ -1239,10 +1672,17 @@  discard block
 block discarded – undo
1239 1672
 		    $data['format_source'] = 'aircraftjson';
1240 1673
 		    $data['id_source'] = $id_source;
1241 1674
 		    if (isset($value['name']) && $value['name'] != '') {
1242
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1243
-			    else $data['source_name'] = $value['name'];
1244
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1245
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1675
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1676
+			    	$data['source_name'] = $value['name'].'_MLAT';
1677
+			    } else {
1678
+			    	$data['source_name'] = $value['name'];
1679
+			    }
1680
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1681
+		    	$data['source_name'] = 'MLAT';
1682
+		    }
1683
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1684
+		    	$data['noarchive'] = true;
1685
+		    }
1246 1686
 		    $SI->add($data);
1247 1687
 		    unset($data);
1248 1688
 		}
@@ -1262,22 +1702,54 @@  discard block
 block discarded – undo
1262 1702
 		foreach ($all_data['aircraft'] as $key => $line) {
1263 1703
 		    $data = array();
1264 1704
 		    $data['hex'] = $key; // hex
1265
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1266
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1267
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1268
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1269
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1270
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1271
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1272
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1705
+		    if (isset($line['callsign'])) {
1706
+		    	$data['ident'] = trim($line['callsign']);
1707
+		    }
1708
+		    // ident
1709
+		    if (isset($line['altitude'])) {
1710
+		    	$data['altitude'] = $line['altitude'];
1711
+		    }
1712
+		    // altitude
1713
+		    if (isset($line['speed'])) {
1714
+		    	$data['speed'] = $line['speed'];
1715
+		    }
1716
+		    // speed
1717
+		    if (isset($line['heading'])) {
1718
+		    	$data['heading'] = $line['heading'];
1719
+		    }
1720
+		    // heading
1721
+		    if (isset($line['lat'])) {
1722
+		    	$data['latitude'] = $line['lat'];
1723
+		    }
1724
+		    // lat
1725
+		    if (isset($line['lon'])) {
1726
+		    	$data['longitude'] = $line['lon'];
1727
+		    }
1728
+		    // long
1729
+		    if (isset($line['vert_rate'])) {
1730
+		    	$data['verticalrate'] = $line['vert_rate'];
1731
+		    }
1732
+		    // verticale rate
1733
+		    if (isset($line['squawk'])) {
1734
+		    	$data['squawk'] = $line['squawk'];
1735
+		    }
1736
+		    // squawk
1273 1737
 		    //$data['emergency'] = ''; // emergency
1274
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1275
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1738
+		    if (isset($line['reg'])) {
1739
+		    	$data['registration'] = $line['reg'];
1740
+		    }
1741
+		    if (isset($line['type'])) {
1742
+		    	$data['aircraft_icao'] = $line['type'];
1743
+		    }
1276 1744
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1277 1745
 		    $data['format_source'] = 'planefinderclient';
1278 1746
 		    $data['id_source'] = $id_source;
1279
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1747
+		    if (isset($value['name']) && $value['name'] != '') {
1748
+		    	$data['source_name'] = $value['name'];
1749
+		    }
1750
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1751
+		    	$data['noarchive'] = true;
1752
+		    }
1281 1753
 		    $SI->add($data);
1282 1754
 		    unset($data);
1283 1755
 		}
@@ -1293,7 +1765,9 @@  discard block
 block discarded – undo
1293 1765
 	    //$buffer = $Common->getData($hosts[$id]);
1294 1766
 	    $buffer = $Common->getData($value['host']);
1295 1767
 	    $all_data = json_decode($buffer,true);
1296
-	    if (!empty($all_data)) $reset = 0;
1768
+	    if (!empty($all_data)) {
1769
+	    	$reset = 0;
1770
+	    }
1297 1771
 	    foreach ($all_data as $key => $line) {
1298 1772
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1299 1773
 		    $data = array();
@@ -1314,8 +1788,12 @@  discard block
 block discarded – undo
1314 1788
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1315 1789
 	    	    $data['format_source'] = 'fr24json';
1316 1790
     		    $data['id_source'] = $id_source;
1317
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1791
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1792
+		    	$data['noarchive'] = true;
1793
+		    }
1794
+		    if (isset($value['name']) && $value['name'] != '') {
1795
+		    	$data['source_name'] = $value['name'];
1796
+		    }
1319 1797
 		    $SI->add($data);
1320 1798
 		    unset($data);
1321 1799
 		}
@@ -1344,24 +1822,42 @@  discard block
 block discarded – undo
1344 1822
 		    if (isset($line['inf'])) {
1345 1823
 			$data = array();
1346 1824
 			$data['hex'] = $line['inf']['ia'];
1347
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1825
+			if (isset($line['inf']['cs'])) {
1826
+				$data['ident'] = $line['inf']['cs'];
1827
+			}
1828
+			//$line[13]
1348 1829
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1349
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1350
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1830
+	    		if (isset($line['inf']['gs'])) {
1831
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1832
+	    		}
1833
+	    		// speed
1834
+	    		if (isset($line['inf']['tr'])) {
1835
+	    			$data['heading'] = $line['inf']['tr'];
1836
+	    		}
1837
+	    		// heading
1351 1838
 	    		$data['latitude'] = $line['pt'][0]; // lat
1352 1839
 	    		$data['longitude'] = $line['pt'][1]; // long
1353 1840
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1354
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1841
+	    		if (isset($line['inf']['sq'])) {
1842
+	    			$data['squawk'] = $line['inf']['sq'];
1843
+	    		}
1844
+	    		// squawk
1355 1845
 	    		//$data['aircraft_icao'] = $line[8];
1356
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1846
+	    		if (isset($line['inf']['rc'])) {
1847
+	    			$data['registration'] = $line['inf']['rc'];
1848
+	    		}
1357 1849
 			//$data['departure_airport_iata'] = $line[11];
1358 1850
 			//$data['arrival_airport_iata'] = $line[12];
1359 1851
 	    		//$data['emergency'] = ''; // emergency
1360 1852
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1361 1853
 	    		$data['format_source'] = 'radarvirtueljson';
1362 1854
     			$data['id_source'] = $id_source;
1363
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1855
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1856
+				$data['noarchive'] = true;
1857
+			}
1858
+			if (isset($value['name']) && $value['name'] != '') {
1859
+				$data['source_name'] = $value['name'];
1860
+			}
1365 1861
 			$SI->add($data);
1366 1862
 			unset($data);
1367 1863
 		    }
@@ -1387,30 +1883,65 @@  discard block
 block discarded – undo
1387 1883
 		    $data['id'] = $line['id'];
1388 1884
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1389 1885
 		    $data['ident'] = $line['callsign']; // ident
1390
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1391
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1392
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1393
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1394
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1395
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1886
+		    if (isset($line['pilotid'])) {
1887
+		    	$data['pilot_id'] = $line['pilotid'];
1888
+		    }
1889
+		    // pilot id
1890
+		    if (isset($line['name'])) {
1891
+		    	$data['pilot_name'] = $line['name'];
1892
+		    }
1893
+		    // pilot name
1894
+		    if (isset($line['alt'])) {
1895
+		    	$data['altitude'] = $line['alt'];
1896
+		    }
1897
+		    // altitude
1898
+		    if (isset($line['gs'])) {
1899
+		    	$data['speed'] = $line['gs'];
1900
+		    }
1901
+		    // speed
1902
+		    if (isset($line['heading'])) {
1903
+		    	$data['heading'] = $line['heading'];
1904
+		    }
1905
+		    // heading
1906
+		    if (isset($line['route'])) {
1907
+		    	$data['waypoints'] = $line['route'];
1908
+		    }
1909
+		    // route
1396 1910
 		    $data['latitude'] = $line['lat']; // lat
1397 1911
 		    $data['longitude'] = $line['lon']; // long
1398 1912
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1399 1913
 		    //$data['squawk'] = $line['squawk']; // squawk
1400 1914
 		    //$data['emergency'] = ''; // emergency
1401
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1402
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1403
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1915
+		    if (isset($line['depicao'])) {
1916
+		    	$data['departure_airport_icao'] = $line['depicao'];
1917
+		    }
1918
+		    if (isset($line['deptime'])) {
1919
+		    	$data['departure_airport_time'] = $line['deptime'];
1920
+		    }
1921
+		    if (isset($line['arricao'])) {
1922
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1923
+		    }
1404 1924
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1405
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1406
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1407
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1408
-		    else $data['info'] = '';
1925
+		    if (isset($line['aircraft'])) {
1926
+		    	$data['aircraft_icao'] = $line['aircraft'];
1927
+		    }
1928
+		    if (isset($line['transponder'])) {
1929
+		    	$data['squawk'] = $line['transponder'];
1930
+		    }
1931
+		    if (isset($line['atis'])) {
1932
+		    	$data['info'] = $line['atis'];
1933
+		    } else {
1934
+		    	$data['info'] = '';
1935
+		    }
1409 1936
 		    $data['format_source'] = 'pireps';
1410 1937
     		    $data['id_source'] = $id_source;
1411 1938
 		    $data['datetime'] = date('Y-m-d H:i:s');
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1939
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1940
+		    	$data['noarchive'] = true;
1941
+		    }
1942
+		    if (isset($value['name']) && $value['name'] != '') {
1943
+		    	$data['source_name'] = $value['name'];
1944
+		    }
1414 1945
 		    if ($line['icon'] === 'plane') {
1415 1946
 			$SI->add($data);
1416 1947
 		    //    print_r($data);
@@ -1419,16 +1950,28 @@  discard block
 block discarded – undo
1419 1950
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1420 1951
 			$typec = substr($data['ident'],-3);
1421 1952
 			$data['type'] = '';
1422
-			if ($typec === 'APP') $data['type'] = 'Approach';
1423
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1424
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1425
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1426
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1427
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1428
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1429
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1430
-			else $data['type'] = 'Observer';
1431
-			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']);
1953
+			if ($typec === 'APP') {
1954
+				$data['type'] = 'Approach';
1955
+			} elseif ($typec === 'TWR') {
1956
+				$data['type'] = 'Tower';
1957
+			} elseif ($typec === 'OBS') {
1958
+				$data['type'] = 'Observer';
1959
+			} elseif ($typec === 'GND') {
1960
+				$data['type'] = 'Ground';
1961
+			} elseif ($typec === 'DEL') {
1962
+				$data['type'] = 'Delivery';
1963
+			} elseif ($typec === 'DEP') {
1964
+				$data['type'] = 'Departure';
1965
+			} elseif ($typec === 'FSS') {
1966
+				$data['type'] = 'Flight Service Station';
1967
+			} elseif ($typec === 'CTR') {
1968
+				$data['type'] = 'Control Radar or Centre';
1969
+			} else {
1970
+				$data['type'] = 'Observer';
1971
+			}
1972
+			if (isset($ATC)) {
1973
+				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']);
1974
+			}
1432 1975
 		    }
1433 1976
 		    unset($data);
1434 1977
 		}
@@ -1443,7 +1986,9 @@  discard block
 block discarded – undo
1443 1986
 	    )
1444 1987
 	) {
1445 1988
 	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1989
+	    if ($globalDebug) {
1990
+	    	echo 'Get Data...'."\n";
1991
+	    }
1447 1992
 	    $buffer = $Common->getData($value['host']);
1448 1993
 	    $all_data = json_decode($buffer,true);
1449 1994
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1451,11 +1996,18 @@  discard block
 block discarded – undo
1451 1996
 		foreach ($all_data as $line) {
1452 1997
 	    	    $data = array();
1453 1998
 	    	    //$data['id'] = $line['id']; // id not usable
1454
-	    	    if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
1455
-	    	    elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1999
+	    	    if (isset($line['pilotid']) && isset($line['registration'])) {
2000
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
2001
+	    	    } elseif (isset($line['pilotid'])) {
2002
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
2003
+	    	    }
1456 2004
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1458
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
2005
+	    	    if (isset($line['pilotname'])) {
2006
+	    	    	$data['pilot_name'] = $line['pilotname'];
2007
+	    	    }
2008
+	    	    if (isset($line['pilotid'])) {
2009
+	    	    	$data['pilot_id'] = $line['pilotid'];
2010
+	    	    }
1459 2011
 	    	    $data['ident'] = $line['flightnum']; // ident
1460 2012
 	    	    $data['altitude'] = $line['alt']; // altitude
1461 2013
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1471,7 +2023,9 @@  discard block
 block discarded – undo
1471 2023
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1472 2024
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1473 2025
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1474
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2026
+	    	    } else {
2027
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2028
+	    	    }
1475 2029
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1476 2030
 	    	    $data['departure_airport_time'] = $line['deptime'];
1477 2031
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1479,29 +2033,47 @@  discard block
 block discarded – undo
1479 2033
     		    if (isset($line['registration'])) {
1480 2034
     			$data['registration'] = trim($line['registration']);
1481 2035
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1482
-    		    } else $data['registration'] = $line['aircraft'];
1483
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1484
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2036
+    		    } else {
2037
+    		    	$data['registration'] = $line['aircraft'];
2038
+    		    }
2039
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2040
+		    	$data['noarchive'] = true;
2041
+		    }
2042
+		    if (isset($line['route'])) {
2043
+		    	$data['waypoints'] = $line['route'];
2044
+		    }
2045
+		    // route
1485 2046
 		    if (isset($line['aircraftname'])) {
1486 2047
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1487 2048
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1488 2049
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1489
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1490
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1491
-	    		else {
2050
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
2051
+	    			$data['aircraft_icao'] = $aircraft_data[0];
2052
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
2053
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2054
+	    		} else {
1492 2055
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1493
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1494
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2056
+	    		    if (isset($aircraft_data[1])) {
2057
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2058
+	    		    } else {
2059
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2060
+	    		    }
1495 2061
 	    		}
1496 2062
 	    	    }
1497
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2063
+    		    if (isset($line['route'])) {
2064
+    		    	$data['waypoints'] = $line['route'];
2065
+    		    }
1498 2066
     		    $data['id_source'] = $id_source;
1499 2067
 	    	    $data['format_source'] = 'phpvmacars';
1500
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2068
+		    if (isset($value['name']) && $value['name'] != '') {
2069
+		    	$data['source_name'] = $value['name'];
2070
+		    }
1501 2071
 		    $SI->add($data);
1502 2072
 		    unset($data);
1503 2073
 		}
1504
-		if ($globalDebug) echo 'No more data...'."\n";
2074
+		if ($globalDebug) {
2075
+			echo 'No more data...'."\n";
2076
+		}
1505 2077
 		unset($buffer);
1506 2078
 		unset($all_data);
1507 2079
 	    }
@@ -1514,7 +2086,9 @@  discard block
 block discarded – undo
1514 2086
 	    )
1515 2087
 	) {
1516 2088
 	    //$buffer = $Common->getData($hosts[$id]);
1517
-	    if ($globalDebug) echo 'Get Data...'."\n";
2089
+	    if ($globalDebug) {
2090
+	    	echo 'Get Data...'."\n";
2091
+	    }
1518 2092
 	    $buffer = $Common->getData($value['host']);
1519 2093
 	    $all_data = json_decode($buffer,true);
1520 2094
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1525,10 +2099,16 @@  discard block
 block discarded – undo
1525 2099
 	    	    //$data['id'] = $line['id']; // id not usable
1526 2100
 	    	    $data['id'] = $line['id'];
1527 2101
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1528
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1529
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2102
+	    	    if (isset($line['user']['username'])) {
2103
+	    	    	$data['pilot_name'] = $line['user']['username'];
2104
+	    	    }
2105
+	    	    if (isset($line['user_id'])) {
2106
+	    	    	$data['pilot_id'] = $line['user_id'];
2107
+	    	    }
1530 2108
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1531
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2109
+	    	    if (is_numeric($data['ident'])) {
2110
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2111
+	    	    }
1532 2112
 	    	    $data['altitude'] = $line['altitude']; // altitude
1533 2113
 	    	    $data['speed'] = $line['groundspeed']; // speed
1534 2114
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1541,7 +2121,9 @@  discard block
 block discarded – undo
1541 2121
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1542 2122
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1543 2123
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1544
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2124
+	    	    } else {
2125
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2126
+	    	    }
1545 2127
 	    	    
1546 2128
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1547 2129
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1549,17 +2131,26 @@  discard block
 block discarded – undo
1549 2131
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1550 2132
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1551 2133
 
1552
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1553
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2134
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2135
+		    	$data['noarchive'] = true;
2136
+		    }
2137
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2138
+		    	$data['waypoints'] = $line['bid']['route'];
2139
+		    }
2140
+		    // route
1554 2141
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1555 2142
 
1556 2143
     		    $data['id_source'] = $id_source;
1557 2144
 	    	    $data['format_source'] = 'vaos';
1558
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2145
+		    if (isset($value['name']) && $value['name'] != '') {
2146
+		    	$data['source_name'] = $value['name'];
2147
+		    }
1559 2148
 		    $SI->add($data);
1560 2149
 		    unset($data);
1561 2150
 		}
1562
-		if ($globalDebug) echo 'No more data...'."\n";
2151
+		if ($globalDebug) {
2152
+			echo 'No more data...'."\n";
2153
+		}
1563 2154
 		unset($buffer);
1564 2155
 		unset($all_data);
1565 2156
 	    }
@@ -1572,7 +2163,9 @@  discard block
 block discarded – undo
1572 2163
 	    )
1573 2164
 	) {
1574 2165
 	    //$buffer = $Common->getData($hosts[$id]);
1575
-	    if ($globalDebug) echo 'Get Data...'."\n";
2166
+	    if ($globalDebug) {
2167
+	    	echo 'Get Data...'."\n";
2168
+	    }
1576 2169
 	    $buffer = $Common->getData($value['host']);
1577 2170
 	    $all_data = json_decode($buffer,true);
1578 2171
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1601,16 +2194,25 @@  discard block
 block discarded – undo
1601 2194
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1602 2195
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1603 2196
     		    //$data['registration'] = $line['aircraft'];
1604
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2197
+		    if (isset($line['route'])) {
2198
+		    	$data['waypoints'] = $line['route'];
2199
+		    }
2200
+		    // route
1605 2201
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1606 2202
     		    $data['id_source'] = $id_source;
1607 2203
 	    	    $data['format_source'] = 'vam';
1608
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1609
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2204
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2205
+		    	$data['noarchive'] = true;
2206
+		    }
2207
+		    if (isset($value['name']) && $value['name'] != '') {
2208
+		    	$data['source_name'] = $value['name'];
2209
+		    }
1610 2210
 		    $SI->add($data);
1611 2211
 		    unset($data);
1612 2212
 		}
1613
-		if ($globalDebug) echo 'No more data...'."\n";
2213
+		if ($globalDebug) {
2214
+			echo 'No more data...'."\n";
2215
+		}
1614 2216
 		unset($buffer);
1615 2217
 		unset($all_data);
1616 2218
 	    }
@@ -1623,7 +2225,9 @@  discard block
 block discarded – undo
1623 2225
 	    )
1624 2226
 	) {
1625 2227
 	    //$buffer = $Common->getData($hosts[$id]);
1626
-	    if ($globalDebug) echo 'Get Data...'."\n";
2228
+	    if ($globalDebug) {
2229
+	    	echo 'Get Data...'."\n";
2230
+	    }
1627 2231
 	    $buffer = $Common->getData($value['host']);
1628 2232
 	    $all_data = json_decode($buffer,true);
1629 2233
 	    if ($buffer != '') {
@@ -1641,12 +2245,16 @@  discard block
 block discarded – undo
1641 2245
 			$data['id_source'] = $id_source;
1642 2246
 			$data['format_source'] = 'blitzortung';
1643 2247
 			$SI->add($data);
1644
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2248
+			if ($globalDebug) {
2249
+				echo '☈ Lightning added'."\n";
2250
+			}
1645 2251
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1646 2252
 			unset($data);
1647 2253
 		    }
1648 2254
 		}
1649
-		if ($globalDebug) echo 'No more data...'."\n";
2255
+		if ($globalDebug) {
2256
+			echo 'No more data...'."\n";
2257
+		}
1650 2258
 		unset($buffer);
1651 2259
 	    }
1652 2260
 	    $last_exec[$id]['last'] = time();
@@ -1675,10 +2283,15 @@  discard block
 block discarded – undo
1675 2283
                 }
1676 2284
             } else {
1677 2285
                 $format = $value['format'];
1678
-                if (isset($tt[$format])) $tt[$format]++;
1679
-                else $tt[$format] = 0;
2286
+                if (isset($tt[$format])) {
2287
+                	$tt[$format]++;
2288
+                } else {
2289
+                	$tt[$format] = 0;
2290
+                }
1680 2291
                 if ($tt[$format] > 30) {
1681
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2292
+                    if ($globalDebug) {
2293
+                    	echo 'Reconnect...'."\n";
2294
+                    }
1682 2295
                     sleep(2);
1683 2296
                     //$sourceeen[] = $value;
1684 2297
                     //connect_all($sourceeen);
@@ -1695,7 +2308,9 @@  discard block
 block discarded – undo
1695 2308
 	    $write = NULL;
1696 2309
 	    $e = NULL;
1697 2310
 	    $n = socket_select($read, $write, $e, $timeout);
1698
-	    if ($e != NULL) var_dump($e);
2311
+	    if ($e != NULL) {
2312
+	    	var_dump($e);
2313
+	    }
1699 2314
 	    if ($n > 0) {
1700 2315
 		$reset = 0;
1701 2316
 		foreach ($read as $nb => $r) {
@@ -1717,13 +2332,17 @@  discard block
 block discarded – undo
1717 2332
 		    if ($buffer !== FALSE) {
1718 2333
 			if ($format === 'vrstcp') {
1719 2334
 			    $buffer = explode('},{',$buffer);
1720
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2335
+			} else {
2336
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2337
+			}
1721 2338
 		    }
1722 2339
 		    // SBS format is CSV format
1723 2340
 		    if ($buffer !== FALSE && $buffer !== '') {
1724 2341
 			$tt[$format] = 0;
1725 2342
 			if ($format === 'acarssbs3') {
1726
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2343
+			    if ($globalDebug) {
2344
+			    	echo 'ACARS : '.$buffer."\n";
2345
+			    }
1727 2346
 			    $ACARS->add(trim($buffer));
1728 2347
 			    $ACARS->deleteLiveAcarsData();
1729 2348
 			} elseif ($format === 'raw') {
@@ -1733,9 +2352,15 @@  discard block
 block discarded – undo
1733 2352
 				//if (!empty($data)) print_r($data);
1734 2353
 				$data['datetime'] = date('Y-m-d H:i:s');
1735 2354
 				$data['format_source'] = 'raw';
1736
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1737
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1738
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2355
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2356
+					$data['source_name'] = $globalSources[$nb]['name'];
2357
+				}
2358
+				if (isset($globalSources[$nb]['sourcestats'])) {
2359
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2360
+				}
2361
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2362
+					$data['noarchive'] = true;
2363
+				}
1739 2364
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1740 2365
 				$SI->add($data);
1741 2366
 				unset($data);
@@ -1743,22 +2368,54 @@  discard block
 block discarded – undo
1743 2368
 			} elseif ($format === 'ais') {
1744 2369
 			    $ais_data = $AIS->parse_line(trim($buffer));
1745 2370
 			    $data = array();
1746
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1747
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1748
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1749
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1750
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1751
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1752
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1753
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1754
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1755
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1756
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1757
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1758
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1759
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1761
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2371
+			    if (isset($ais_data['ident'])) {
2372
+			    	$data['ident'] = $ais_data['ident'];
2373
+			    }
2374
+			    if (isset($ais_data['mmsi'])) {
2375
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2376
+			    }
2377
+			    if (isset($ais_data['speed'])) {
2378
+			    	$data['speed'] = $ais_data['speed'];
2379
+			    }
2380
+			    if (isset($ais_data['heading'])) {
2381
+			    	$data['heading'] = $ais_data['heading'];
2382
+			    }
2383
+			    if (isset($ais_data['latitude'])) {
2384
+			    	$data['latitude'] = $ais_data['latitude'];
2385
+			    }
2386
+			    if (isset($ais_data['longitude'])) {
2387
+			    	$data['longitude'] = $ais_data['longitude'];
2388
+			    }
2389
+			    if (isset($ais_data['status'])) {
2390
+			    	$data['status'] = $ais_data['status'];
2391
+			    }
2392
+			    if (isset($ais_data['statusid'])) {
2393
+			    	$data['status_id'] = $ais_data['statusid'];
2394
+			    }
2395
+			    if (isset($ais_data['type'])) {
2396
+			    	$data['type'] = $ais_data['type'];
2397
+			    }
2398
+			    if (isset($ais_data['imo'])) {
2399
+			    	$data['imo'] = $ais_data['imo'];
2400
+			    }
2401
+			    if (isset($ais_data['callsign'])) {
2402
+			    	$data['callsign'] = $ais_data['callsign'];
2403
+			    }
2404
+			    if (isset($ais_data['destination'])) {
2405
+			    	$data['arrival_code'] = $ais_data['destination'];
2406
+			    }
2407
+			    if (isset($ais_data['eta_ts'])) {
2408
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2409
+			    }
2410
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2411
+			    	$data['noarchive'] = true;
2412
+			    }
2413
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2414
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2415
+			    }
2416
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2417
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2418
+			    }
1762 2419
 
1763 2420
 			    if (isset($ais_data['timestamp'])) {
1764 2421
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1767,7 +2424,9 @@  discard block
 block discarded – undo
1767 2424
 			    }
1768 2425
 			    $data['format_source'] = 'aisnmea';
1769 2426
     			    $data['id_source'] = $id_source;
1770
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2427
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2428
+			    	$MI->add($data);
2429
+			    }
1771 2430
 			    unset($data);
1772 2431
                         } elseif ($format === 'flightgearsp') {
1773 2432
                     	    //echo $buffer."\n";
@@ -1785,17 +2444,25 @@  discard block
 block discarded – undo
1785 2444
 				$data['speed'] = round($line[5]*1.94384);
1786 2445
 				$data['datetime'] = date('Y-m-d H:i:s');
1787 2446
 				$data['format_source'] = 'flightgearsp';
1788
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1789
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2447
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2448
+					$data['noarchive'] = true;
2449
+				}
2450
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2451
+					$SI->add($data);
2452
+				}
1790 2453
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1791 2454
 			    }
1792 2455
                         } elseif ($format === 'acars') {
1793
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2456
+                    	    if ($globalDebug) {
2457
+                    	    	echo 'ACARS : '.$buffer."\n";
2458
+                    	    }
1794 2459
 			    $ACARS->add(trim($buffer));
1795 2460
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1796 2461
 			    $ACARS->deleteLiveAcarsData();
1797 2462
 			} elseif ($format === 'acarsjsonudp') {
1798
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2463
+			    if ($globalDebug) {
2464
+			    	echo 'ACARS : '.$buffer."\n";
2465
+			    }
1799 2466
                             $line = json_decode(trim($buffer), true);
1800 2467
                             if (!empty($line)) {
1801 2468
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
@@ -1820,8 +2487,12 @@  discard block
 block discarded – undo
1820 2487
 				    $aircraft_type = $line[10];
1821 2488
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1822 2489
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1823
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1824
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2490
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2491
+				    	$data['noarchive'] = true;
2492
+				    }
2493
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2494
+				    	$SI->add($data);
2495
+				    }
1825 2496
 				}
1826 2497
 			    }
1827 2498
 			} elseif ($format === 'beast') {
@@ -1831,28 +2502,62 @@  discard block
 block discarded – undo
1831 2502
 			    foreach($buffer as $all_data) {
1832 2503
 				$line = json_decode('{'.$all_data.'}',true);
1833 2504
 				$data = array();
1834
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1835
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1836
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1837
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1838
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1839
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1840
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2505
+				if (isset($line['Icao'])) {
2506
+					$data['hex'] = $line['Icao'];
2507
+				}
2508
+				// hex
2509
+				if (isset($line['Call'])) {
2510
+					$data['ident'] = $line['Call'];
2511
+				}
2512
+				// ident
2513
+				if (isset($line['Alt'])) {
2514
+					$data['altitude'] = $line['Alt'];
2515
+				}
2516
+				// altitude
2517
+				if (isset($line['Spd'])) {
2518
+					$data['speed'] = $line['Spd'];
2519
+				}
2520
+				// speed
2521
+				if (isset($line['Trak'])) {
2522
+					$data['heading'] = $line['Trak'];
2523
+				}
2524
+				// heading
2525
+				if (isset($line['Lat'])) {
2526
+					$data['latitude'] = $line['Lat'];
2527
+				}
2528
+				// lat
2529
+				if (isset($line['Long'])) {
2530
+					$data['longitude'] = $line['Long'];
2531
+				}
2532
+				// long
1841 2533
 				//$data['verticalrate'] = $line['']; // verticale rate
1842
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2534
+				if (isset($line['Sqk'])) {
2535
+					$data['squawk'] = $line['Sqk'];
2536
+				}
2537
+				// squawk
1843 2538
 				$data['emergency'] = ''; // emergency
1844
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2539
+				if (isset($line['Reg'])) {
2540
+					$data['registration'] = $line['Reg'];
2541
+				}
1845 2542
 				/*
1846 2543
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1847 2544
 				else $data['datetime'] = date('Y-m-d H:i:s');
1848 2545
 				*/
1849 2546
 				$data['datetime'] = date('Y-m-d H:i:s');
1850
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2547
+				if (isset($line['Type'])) {
2548
+					$data['aircraft_icao'] = $line['Type'];
2549
+				}
1851 2550
 		    		$data['format_source'] = 'vrstcp';
1852 2551
 				$data['id_source'] = $id_source;
1853
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1854
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1855
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2552
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2553
+					$data['noarchive'] = true;
2554
+				}
2555
+				if (isset($value['name']) && $value['name'] != '') {
2556
+					$data['source_name'] = $value['name'];
2557
+				}
2558
+				if (isset($data['latitude']) && isset($data['hex'])) {
2559
+					$SI->add($data);
2560
+				}
1856 2561
 				unset($data);
1857 2562
 			    }
1858 2563
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1865,22 +2570,46 @@  discard block
 block discarded – undo
1865 2570
     				$data['hex'] = $lined['hexid'];
1866 2571
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1867 2572
     				$data['datetime'] = date('Y-m-d H:i:s');;
1868
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1869
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1870
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1871
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1872
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1873
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1874
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2573
+    				if (isset($lined['ident'])) {
2574
+    					$data['ident'] = $lined['ident'];
2575
+    				}
2576
+    				if (isset($lined['lat'])) {
2577
+    					$data['latitude'] = $lined['lat'];
2578
+    				}
2579
+    				if (isset($lined['lon'])) {
2580
+    					$data['longitude'] = $lined['lon'];
2581
+    				}
2582
+    				if (isset($lined['speed'])) {
2583
+    					$data['speed'] = $lined['speed'];
2584
+    				}
2585
+    				if (isset($lined['squawk'])) {
2586
+    					$data['squawk'] = $lined['squawk'];
2587
+    				}
2588
+    				if (isset($lined['alt'])) {
2589
+    					$data['altitude'] = $lined['alt'];
2590
+    				}
2591
+    				if (isset($lined['heading'])) {
2592
+    					$data['heading'] = $lined['heading'];
2593
+    				}
1875 2594
     				$data['id_source'] = $id_source;
1876 2595
     				$data['format_source'] = 'tsv';
1877
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1878
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1879
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1880
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2596
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2597
+    					$data['source_name'] = $globalSources[$nb]['name'];
2598
+    				}
2599
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2600
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2601
+    				}
2602
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2603
+					$data['noarchive'] = true;
2604
+				}
2605
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2606
+    					$SI->add($data);
2607
+    				}
1881 2608
     				unset($lined);
1882 2609
     				unset($data);
1883
-    			    } else $error = true;
2610
+    			    } else {
2611
+    			    	$error = true;
2612
+    			    }
1884 2613
 			} elseif ($format === 'aprs' && $use_aprs) {
1885 2614
 			    if ($aprs_connect === 0) {
1886 2615
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1906,47 +2635,96 @@  discard block
 block discarded – undo
1906 2635
 				    $aprs_last_tx = time();
1907 2636
 				    $data = array();
1908 2637
 				    //print_r($line);
1909
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1910
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1911
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1912
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1913
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1914
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1915
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1916
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1917
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1918
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2638
+				    if (isset($line['address'])) {
2639
+				    	$data['hex'] = $line['address'];
2640
+				    }
2641
+				    if (isset($line['mmsi'])) {
2642
+				    	$data['mmsi'] = $line['mmsi'];
2643
+				    }
2644
+				    if (isset($line['imo'])) {
2645
+				    	$data['imo'] = $line['imo'];
2646
+				    }
2647
+				    if (isset($line['squawk'])) {
2648
+				    	$data['squawk'] = $line['squawk'];
2649
+				    }
2650
+				    if (isset($line['arrival_code'])) {
2651
+				    	$data['arrival_code'] = $line['arrival_code'];
2652
+				    }
2653
+				    if (isset($line['arrival_date'])) {
2654
+				    	$data['arrival_date'] = $line['arrival_date'];
2655
+				    }
2656
+				    if (isset($line['typeid'])) {
2657
+				    	$data['type_id'] = $line['typeid'];
2658
+				    }
2659
+				    if (isset($line['statusid'])) {
2660
+				    	$data['status_id'] = $line['statusid'];
2661
+				    }
2662
+				    if (isset($line['timestamp'])) {
2663
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2664
+				    } else {
2665
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2666
+				    }
1919 2667
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1920
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2668
+				    if (isset($line['ident'])) {
2669
+				    	$data['ident'] = $line['ident'];
2670
+				    }
1921 2671
 				    $data['latitude'] = $line['latitude'];
1922 2672
 				    $data['longitude'] = $line['longitude'];
1923 2673
 				    //$data['verticalrate'] = $line[16];
1924
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2674
+				    if (isset($line['speed'])) {
2675
+				    	$data['speed'] = $line['speed'];
2676
+				    }
1925 2677
 				    //else $data['speed'] = 0;
1926
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1927
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1928
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2678
+				    if (isset($line['altitude'])) {
2679
+				    	$data['altitude'] = $line['altitude'];
2680
+				    }
2681
+				    if (isset($line['comment'])) {
2682
+				    	$data['comment'] = $line['comment'];
2683
+				    }
2684
+				    if (isset($line['symbol'])) {
2685
+				    	$data['type'] = $line['symbol'];
2686
+				    }
1929 2687
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1930 2688
 				    
1931
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2689
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2690
+				    	$data['heading'] = $line['heading'];
2691
+				    }
1932 2692
 				    //else echo 'No heading...'."\n";
1933 2693
 				    //else $data['heading'] = 0;
1934
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2694
+				    if (isset($line['stealth'])) {
2695
+				    	$data['aircraft_type'] = $line['stealth'];
2696
+				    }
1935 2697
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1936
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1937
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1938
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1939
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2698
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2699
+				    	$data['noarchive'] = true;
2700
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2701
+				    	$data['noarchive'] = false;
2702
+				    }
2703
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2704
+				    	$data['noarchive'] = true;
2705
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2706
+				    	$data['noarchive'] = false;
2707
+				    }
1940 2708
     				    $data['id_source'] = $id_source;
1941
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1942
-				    else $data['format_source'] = 'aprs';
2709
+    				    if (isset($line['format_source'])) {
2710
+    				    	$data['format_source'] = $line['format_source'];
2711
+    				    } else {
2712
+				    	$data['format_source'] = 'aprs';
2713
+				    }
1943 2714
 				    $data['source_name'] = $line['source'];
1944
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1945
-				    else $data['source_type'] = 'flarm';
1946
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2715
+				    if (isset($line['source_type'])) {
2716
+				    	$data['source_type'] = $line['source_type'];
2717
+				    } else {
2718
+				    	$data['source_type'] = 'flarm';
2719
+				    }
2720
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2721
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2722
+    				    }
1947 2723
 				    $currentdate = date('Y-m-d H:i:s');
1948 2724
 				    $aprsdate = strtotime($data['datetime']);
1949
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2725
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2726
+				    	$data['altitude_relative'] = 'AMSL';
2727
+				    }
1950 2728
 				    // Accept data if time <= system time + 20s
1951 2729
 				    //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'])))) {
1952 2730
 				    if (
@@ -1958,7 +2736,9 @@  discard block
 block discarded – undo
1958 2736
 					$send = $SI->add($data);
1959 2737
 				    } elseif ($data['source_type'] === 'ais') {
1960 2738
 					$data['type'] = '';
1961
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2739
+					if (isset($globalMarine) && $globalMarine) {
2740
+						$send = $MI->add($data);
2741
+					}
1962 2742
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1963 2743
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1964 2744
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1966,8 +2746,12 @@  discard block
 block discarded – undo
1966 2746
 					    $line['symbol'] === 'Glider' || 
1967 2747
 					    $line['symbol'] === 'No. Plane' || 
1968 2748
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1969
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1970
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2749
+					    if ($line['symbol'] === 'Ballon') {
2750
+					    	$data['aircraft_icao'] = 'BALL';
2751
+					    }
2752
+					    if ($line['symbol'] === 'Glider') {
2753
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2754
+					    }
1971 2755
 					    $send = $SI->add($data);
1972 2756
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1973 2757
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1998,9 +2782,13 @@  discard block
 block discarded – undo
1998 2782
 				    //} 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') {
1999 2783
 				//    } 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') {
2000 2784
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
2001
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2785
+					if (isset($globalTracker) && $globalTracker) {
2786
+						$send = $TI->add($data);
2787
+					}
2002 2788
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2003
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2789
+					if (!isset($data['altitude'])) {
2790
+						$data['altitude'] = 0;
2791
+					}
2004 2792
 					$Source->deleteOldLocationByType('gs');
2005 2793
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2006 2794
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -2009,7 +2797,9 @@  discard block
 block discarded – undo
2009 2797
 					}
2010 2798
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2011 2799
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2012
-					if ($globalDebug) echo '# Weather Station added'."\n";
2800
+					if ($globalDebug) {
2801
+						echo '# Weather Station added'."\n";
2802
+					}
2013 2803
 					$Source->deleteOldLocationByType('wx');
2014 2804
 					$weather_data = json_encode($line);
2015 2805
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -2019,7 +2809,9 @@  discard block
 block discarded – undo
2019 2809
 					}
2020 2810
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2021 2811
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2022
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2812
+					if ($globalDebug) {
2813
+						echo '☈ Lightning added'."\n";
2814
+					}
2023 2815
 					$Source->deleteOldLocationByType('lightning');
2024 2816
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2025 2817
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -2031,8 +2823,7 @@  discard block
 block discarded – undo
2031 2823
 				    	print_r($line);
2032 2824
 				    }
2033 2825
 				    unset($data);
2034
-				}
2035
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2826
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2036 2827
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2037 2828
 				}
2038 2829
 				/*
@@ -2041,7 +2832,9 @@  discard block
 block discarded – undo
2041 2832
 				}
2042 2833
 				*/
2043 2834
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2044
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2835
+				elseif ($line === true && $globalDebug) {
2836
+					echo '!! Failed : '.$buffer."!!\n";
2837
+				}
2045 2838
 				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2046 2839
 					$Source->deleteOldLocationByType('lightning');
2047 2840
 					$Source->deleteOldLocationByType('wx');
@@ -2078,27 +2871,47 @@  discard block
 block discarded – undo
2078 2871
     				$data['ground'] = $line[21];
2079 2872
     				$data['emergency'] = $line[19];
2080 2873
     				$data['format_source'] = 'sbs';
2081
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2082
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2083
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2084
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2874
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2875
+					$data['source_name'] = $globalSources[$nb]['name'];
2876
+				} elseif ($line[0] == 'MLAT') {
2877
+					$data['source_name'] = 'MLAT';
2878
+				}
2879
+				if (isset($globalSources[$nb]['sourcestats'])) {
2880
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2881
+				}
2882
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2883
+					$data['noarchive'] = true;
2884
+				}
2085 2885
     				$data['id_source'] = $id_source;
2086
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2087
-    				else $error = true;
2886
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2887
+    					$send = $SI->add($data);
2888
+    				} else {
2889
+    					$error = true;
2890
+    				}
2088 2891
     				unset($data);
2089
-    			    } else $error = true;
2892
+    			    } else {
2893
+    			    	$error = true;
2894
+    			    }
2090 2895
 			    if ($error) {
2091 2896
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2092
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2897
+					if ($globalDebug) {
2898
+						echo "Not a message. Ignoring... \n";
2899
+					}
2093 2900
 				} else {
2094
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2901
+					if ($globalDebug) {
2902
+						echo "Wrong line format. Ignoring... \n";
2903
+					}
2095 2904
 					if ($globalDebug) {
2096 2905
 						echo $buffer;
2097 2906
 						//print_r($line);
2098 2907
 					}
2099 2908
 					//socket_close($r);
2100
-					if ($globalDebug) echo "Reconnect after an error...\n";
2101
-					if ($format === 'aprs') $aprs_connect = 0;
2909
+					if ($globalDebug) {
2910
+						echo "Reconnect after an error...\n";
2911
+					}
2912
+					if ($format === 'aprs') {
2913
+						$aprs_connect = 0;
2914
+					}
2102 2915
 					$sourceer[$nb] = $globalSources[$nb];
2103 2916
 					connect_all($sourceer);
2104 2917
 					$sourceer = array();
@@ -2106,10 +2919,14 @@  discard block
 block discarded – undo
2106 2919
 			    }
2107 2920
 			}
2108 2921
 			// Sleep for xxx microseconds
2109
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2922
+			if (isset($globalSBSSleep)) {
2923
+				usleep($globalSBSSleep);
2924
+			}
2110 2925
 		    } else {
2111 2926
 			if ($format === 'flightgearmp') {
2112
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2927
+			    	if ($globalDebug) {
2928
+			    		echo "Reconnect FlightGear MP...";
2929
+			    	}
2113 2930
 				//@socket_close($r);
2114 2931
 				sleep($globalMinFetch);
2115 2932
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2118,10 +2935,15 @@  discard block
 block discarded – undo
2118 2935
 				break;
2119 2936
 				
2120 2937
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2121
-			    if (isset($tt[$format])) $tt[$format]++;
2122
-			    else $tt[$format] = 0;
2938
+			    if (isset($tt[$format])) {
2939
+			    	$tt[$format]++;
2940
+			    } else {
2941
+			    	$tt[$format] = 0;
2942
+			    }
2123 2943
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2124
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2944
+				if ($globalDebug) {
2945
+					echo "ERROR : Reconnect ".$format."...";
2946
+				}
2125 2947
 				//@socket_close($r);
2126 2948
 				sleep(2);
2127 2949
 				$aprs_connect = 0;
@@ -2139,11 +2961,17 @@  discard block
 block discarded – undo
2139 2961
 	    } else {
2140 2962
 		$error = socket_strerror(socket_last_error());
2141 2963
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2142
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2143
-			if (isset($globalDebug)) echo "Restarting...\n";
2964
+			if ($globalDebug) {
2965
+				echo "ERROR : socket_select give this error ".$error . "\n";
2966
+			}
2967
+			if (isset($globalDebug)) {
2968
+				echo "Restarting...\n";
2969
+			}
2144 2970
 			// Restart the script if possible
2145 2971
 			if (is_array($sockets)) {
2146
-			    if ($globalDebug) echo "Shutdown all sockets...";
2972
+			    if ($globalDebug) {
2973
+			    	echo "Shutdown all sockets...";
2974
+			    }
2147 2975
 			    
2148 2976
 			    foreach ($sockets as $sock) {
2149 2977
 				@socket_shutdown($sock,2);
@@ -2151,23 +2979,39 @@  discard block
 block discarded – undo
2151 2979
 			    }
2152 2980
 			    
2153 2981
 			}
2154
-			if ($globalDebug) echo "Waiting...";
2982
+			if ($globalDebug) {
2983
+				echo "Waiting...";
2984
+			}
2155 2985
 			sleep(2);
2156 2986
 			$time = time();
2157 2987
 			//connect_all($hosts);
2158 2988
 			$aprs_connect = 0;
2159
-			if ($reset%5 === 0) sleep(20);
2160
-			if ($reset > 100) exit('Too many attempts...');
2161
-			if ($globalDebug) echo "Restart all connections...";
2989
+			if ($reset%5 === 0) {
2990
+				sleep(20);
2991
+			}
2992
+			if ($reset > 100) {
2993
+				exit('Too many attempts...');
2994
+			}
2995
+			if ($globalDebug) {
2996
+				echo "Restart all connections...";
2997
+			}
2162 2998
 			connect_all($globalSources);
2163 2999
 		}
2164 3000
 	    }
2165 3001
 	}
2166 3002
 	if ($globalDaemon === false) {
2167
-	    if ($globalDebug) echo 'Check all...'."\n";
2168
-	    if (isset($SI)) $SI->checkAll();
2169
-	    if (isset($TI)) $TI->checkAll();
2170
-	    if (isset($MI)) $MI->checkAll();
3003
+	    if ($globalDebug) {
3004
+	    	echo 'Check all...'."\n";
3005
+	    }
3006
+	    if (isset($SI)) {
3007
+	    	$SI->checkAll();
3008
+	    }
3009
+	    if (isset($TI)) {
3010
+	    	$TI->checkAll();
3011
+	    }
3012
+	    if (isset($MI)) {
3013
+	    	$MI->checkAll();
3014
+	    }
2171 3015
 	}
2172 3016
     }
2173 3017
 }
Please login to merge, or discard this patch.