Completed
Push — master ( 561404...142633 )
by Yannick
08:13
created
aircraft-data.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
14
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
18
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
21
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 	} else {
24 24
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 }
31 31
 if (isset($_GET['flightaware_id'])) {
32
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
32
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
33 33
 	if (isset($_GET['currenttime'])) {
34
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
34
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
35 35
 		$currenttime = round($currenttime/1000);
36
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
36
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
37 37
 		if (empty($spotter_array)) {
38 38
 			$from_archive = true;
39 39
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
40
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
40
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
41 41
 		}
42 42
 	} else {
43 43
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
57 57
 {
58 58
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
59
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
59
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
60 60
 	} else $image = $spotter_item['image_thumbnail'];
61 61
 
62 62
 }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
78 78
 	if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
79 79
 		if ($spotter_item['departure_airport_time'] > 2460) {
80
-			print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
80
+			print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
81 81
 		} else {
82 82
 			print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
83 83
 		}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
87 87
 	if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
88 88
 		if ($spotter_item['arrival_airport_time'] > 2460) {
89
-			print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
89
+			print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
90 90
 		} else {
91 91
 			print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
92 92
 		}
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 print '<div id ="altitude"><span>'._("Altitude").'</span>';
112 112
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
113 113
 	try {
114
-		$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
115
-	} catch(Exception $e) {
114
+		$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
115
+	} catch (Exception $e) {
116 116
 	}
117 117
 }
118 118
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
 if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
183 183
 if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
184
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
184
+if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>';
185 185
 if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
186 186
 print '</div>';
187 187
 ?>
Please login to merge, or discard this patch.
Braces   +51 added lines, -20 removed lines patch added patch discarded remove patch
@@ -57,7 +57,9 @@  discard block
 block discarded – undo
57 57
 {
58 58
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
59 59
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
60
-	} else $image = $spotter_item['image_thumbnail'];
60
+	} else {
61
+		$image = $spotter_item['image_thumbnail'];
62
+	}
61 63
 
62 64
 }
63 65
 /* else {
@@ -70,8 +72,12 @@  discard block
 block discarded – undo
70 72
 }
71 73
 print '<div class="right">';
72 74
 print '<div class="callsign-details">';
73
-if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
74
-if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
75
+if ($spotter_item['ident'] != 'Not Available') {
76
+	print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
77
+}
78
+if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') {
79
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
80
+}
75 81
 print '</div>';
76 82
 if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') {
77 83
 	print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
@@ -103,10 +109,16 @@  discard block
 block discarded – undo
103 109
 print '</div>';
104 110
 print '<div id="aircraft">';
105 111
 print '<span>'._("Aircraft").'</span>';
106
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
107
-if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
108
-elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
109
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
112
+if (isset($spotter_item['aircraft_wiki'])) {
113
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
114
+}
115
+if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
116
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
117
+} elseif (isset($spotter_item['aircraft_type'])) {
118
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
119
+} else {
120
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
121
+}
110 122
 print '</div>';
111 123
 print '<div id ="altitude"><span>'._("Altitude").'</span>';
112 124
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
@@ -117,12 +129,18 @@  discard block
 block discarded – undo
117 129
 }
118 130
 
119 131
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
120
-	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
121
-	else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
122
-} else {
123
-	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
124
-	else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
125
-}
132
+	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
133
+		print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
134
+	} else {
135
+		print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
136
+	}
137
+	} else {
138
+	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
139
+		print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
140
+	} else {
141
+		print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
142
+	}
143
+	}
126 144
 
127 145
 if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*30.48) {
128 146
 	print '<br>';
@@ -136,7 +154,9 @@  discard block
 block discarded – undo
136 154
 }
137 155
 
138 156
 print '</div>';
139
-if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
157
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
158
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
159
+}
140 160
 print '<div id="speed"><span>'._("Speed").'</span>';
141 161
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
142 162
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -150,8 +170,11 @@  discard block
 block discarded – undo
150 170
 print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
151 171
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
152 172
 	print '<div id="pilot"><span>'._("Pilot").'</span>';
153
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
154
-	else print $spotter_item['pilot_name'];
173
+	if (isset($spotter_item['pilot_id'])) {
174
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
175
+	} else {
176
+		print $spotter_item['pilot_name'];
177
+	}
155 178
 	print '</div>';
156 179
 }
157 180
 
@@ -179,10 +202,18 @@  discard block
 block discarded – undo
179 202
 print '</div>';
180 203
 print '</div>';
181 204
 
182
-if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
183
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
184
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
185
-if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
205
+if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
206
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
207
+}
208
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
209
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
210
+}
211
+if (isset($spotter_item['acars']['message'])) {
212
+	print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
213
+}
214
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
215
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
216
+}
186 217
 print '</div>';
187 218
 ?>
188 219
 </div>
189 220
\ No newline at end of file
Please login to merge, or discard this patch.
search-ajax.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $orderby = $Spotter->getOrderBy();
7 7
 
8
-$ask = filter_input(INPUT_GET,'ask',FILTER_SANITIZE_STRING);
8
+$ask = filter_input(INPUT_GET, 'ask', FILTER_SANITIZE_STRING);
9 9
 if ($ask == 'aircraftsdetected') {
10 10
 	require_once('require/class.SpotterLive.php');
11 11
 	$SpotterLive = new SpotterLive();
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 } elseif ($ask == 'manufacturer') {
25 25
 	$manufacturers = $Spotter->getAllManufacturers();
26 26
 	$all_manufacturers = array();
27
-	foreach($manufacturers as $manufacturer)
27
+	foreach ($manufacturers as $manufacturer)
28 28
 	{
29
-		$all_manufacturers[] = array('value' => $manufacturer['aircraft_manufacturer'], 'id' => strtolower(str_replace(' ','-',$manufacturer['aircraft_manufacturer'])));
29
+		$all_manufacturers[] = array('value' => $manufacturer['aircraft_manufacturer'], 'id' => strtolower(str_replace(' ', '-', $manufacturer['aircraft_manufacturer'])));
30 30
 	}
31 31
 	echo json_encode($all_manufacturers);
32 32
 } elseif ($ask == 'aircrafttypes') {
33 33
 	$aircraft_types = $Spotter->getAllAircraftTypes();
34 34
 	$all_aircraft_types = array();
35
-	foreach($aircraft_types as $aircraft_type)
35
+	foreach ($aircraft_types as $aircraft_type)
36 36
 	{
37 37
 		$all_aircraft_types[] = array('id' => $aircraft_type['aircraft_icao'], 'value' => $aircraft_type['aircraft_name'].' ('.$aircraft_type['aircraft_icao'].')');
38 38
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 } elseif ($ask == 'airlinenames') {
41 41
 	$airline_names = $Spotter->getAllAirlineNames();
42 42
 	$all_airline_names = array();
43
-	foreach($airline_names as $airline_name)
43
+	foreach ($airline_names as $airline_name)
44 44
 	{
45 45
 		$all_airline_names[] = array('id' => $airline_name['airline_icao'], 'value' => $airline_name['airline_name'].' ('.$airline_name['airline_icao'].')');
46 46
 	}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 } elseif ($ask == 'airlinecountries') {
49 49
 	$airline_countries = $Spotter->getAllAirlineCountries();
50 50
 	$all_airline_countries = array();
51
-	foreach($airline_countries as $airline_country)
51
+	foreach ($airline_countries as $airline_country)
52 52
 	{
53 53
 		$all_airline_countries[] = array('id' => $airline_country['airline_country'], 'value' => $airline_country['airline_country']);
54 54
 	}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	$airport_names = $Spotter->getAllAirportNames();
58 58
 	ksort($airport_names);
59 59
 	$all_airport_names = array();
60
-	foreach($airport_names as $airport_name)
60
+	foreach ($airport_names as $airport_name)
61 61
 	{
62 62
 		$all_airport_names[] = array('id' => $airport_name['airport_icao'], 'value' => $airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')');
63 63
 	}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 } elseif ($ask == 'airportcountries') {
66 66
 	$airport_countries = $Spotter->getAllAirportCountries();
67 67
 	$all_airport_countries = array();
68
-	foreach($airport_countries as $airport_country)
68
+	foreach ($airport_countries as $airport_country)
69 69
 	{
70 70
 		$all_airport_countries[] = array('id' => $airport_country['airport_country'], 'value' => $airport_country['airport_country']);
71 71
 	}
Please login to merge, or discard this patch.
require/class.GeoidHeight.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -91,6 +91,10 @@
 block discarded – undo
91 91
 		$this->rlatres = (($this->height - 1) / 180.0);
92 92
 	}
93 93
 
94
+	/**
95
+	 * @param integer $ix
96
+	 * @param integer $iy
97
+	 */
94 98
 	private function _rawval($ix,$iy) {
95 99
 		if (($iy < 0)) {
96 100
 			$iy = -$iy;
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * Translated to PHP of GeographicLib/src/Geoid.cpp
12 12
 * by Ycarus <[email protected]> in 2017
13 13
 */
14
-class GeoidHeight  {
14
+class GeoidHeight {
15 15
 	private $c0 = 240;
16 16
 	private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]];
17 17
 	private $c0n = 372;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	private $v10 = null;
35 35
 	private $v11 = null;
36 36
 
37
-	public function __construct($name='') {
37
+	public function __construct($name = '') {
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
43 43
 		}
44 44
 
45
-		$f = @fopen($name,"r");
45
+		$f = @fopen($name, "r");
46 46
 		if ($f === FALSE) {
47 47
 			throw new Exception("Can't open ".$name);
48 48
 		}
49
-		$line = fgets($f,4096);
49
+		$line = fgets($f, 4096);
50 50
 		if (trim($line) != 'P5') {
51 51
 			throw new Exception('No PGM header');
52 52
 		}
53 53
 		$headerlen = strlen($line);
54 54
 		while (true) {
55
-			$line = fgets($f,4096);
55
+			$line = fgets($f, 4096);
56 56
 			if ((strlen($line) == 0)) {
57 57
 				throw new Exception('EOF before end of file header');
58 58
 			}
59 59
 			$headerlen += strlen($line);
60
-			if (strpos($line,'# Offset ') !== FALSE) {
60
+			if (strpos($line, '# Offset ') !== FALSE) {
61 61
 				$this->offset = substr($line, 9);
62
-			} else if (strpos($line,'# Scale ') !== FALSE) {
62
+			} else if (strpos($line, '# Scale ') !== FALSE) {
63 63
 				$this->scale = substr($line, 8);
64
-			} else if ((strpos($line,'#') === FALSE)) {
65
-				list($this->width, $this->height) = preg_split('/\s+/',$line);
64
+			} else if ((strpos($line, '#') === FALSE)) {
65
+				list($this->width, $this->height) = preg_split('/\s+/', $line);
66 66
 				break;
67 67
 			}
68 68
 		}
69
-		$line = fgets($f,4096);
69
+		$line = fgets($f, 4096);
70 70
 		$headerlen += strlen($line);
71
-		$levels = (int)$line;
72
-		$this->width = (int)$this->width;
73
-		$this->height = (int)$this->height;
71
+		$levels = (int) $line;
72
+		$this->width = (int) $this->width;
73
+		$this->height = (int) $this->height;
74 74
 		if (($levels != 65535)) {
75 75
 			throw new Exception('PGM file must have 65535 gray levels ('.$levels.')');
76 76
 		}
@@ -85,42 +85,42 @@  discard block
 block discarded – undo
85 85
 		}
86 86
 
87 87
 		$fullsize = filesize($name);
88
-		if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) {
88
+		if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) {
89 89
 			throw new Exception('File has the wrong length');
90 90
 		}
91 91
 
92 92
 		$this->headerlen = $headerlen;
93
-		$this->raw= $f;
94
-		$this->rlonres = ($this->width / 360.0);
95
-		$this->rlatres = (($this->height - 1) / 180.0);
93
+		$this->raw = $f;
94
+		$this->rlonres = ($this->width/360.0);
95
+		$this->rlatres = (($this->height - 1)/180.0);
96 96
 	}
97 97
 
98
-	private function _rawval($ix,$iy) {
98
+	private function _rawval($ix, $iy) {
99 99
 		if (($iy < 0)) {
100 100
 			$iy = -$iy;
101
-			$ix += ($this->width / 2);
101
+			$ix += ($this->width/2);
102 102
 		} else if (($iy >= $this->height)) {
103
-			$iy = ((2 * ($this->height - 1)) - $iy);
104
-			$ix += ($this->width / 2);
103
+			$iy = ((2*($this->height - 1)) - $iy);
104
+			$ix += ($this->width/2);
105 105
 		}
106 106
 		if (($ix < 0)) {
107 107
 			$ix += $this->width;
108 108
 		} else if (($ix >= $this->width)) {
109 109
 			$ix -= $this->width;
110 110
 		}
111
-		$k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen;
112
-		fseek($this->raw,$k);
113
-		return unpack('n',fread($this->raw,2))[1];
111
+		$k = ((($iy*$this->width) + $ix)*2) + $this->headerlen;
112
+		fseek($this->raw, $k);
113
+		return unpack('n', fread($this->raw, 2))[1];
114 114
 	}
115 115
 
116
-	public function get($lat,$lon,$cubic=true) {
116
+	public function get($lat, $lon, $cubic = true) {
117 117
 		if (($lon < 0)) {
118 118
 			$lon += 360;
119 119
 		}
120
-		$fy = ((90 - $lat) * $this->rlatres);
121
-		$fx = ($lon * $this->rlonres);
122
-		$iy = (int)$fy;
123
-		$ix = (int)$fx;
120
+		$fy = ((90 - $lat)*$this->rlatres);
121
+		$fx = ($lon*$this->rlonres);
122
+		$iy = (int) $fy;
123
+		$ix = (int) $fx;
124 124
 		$fx -= $ix;
125 125
 		$fy -= $iy;
126 126
 		$t = array();
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 					$c3x = $this->c3;
148 148
 					$c0x = $this->c0;
149 149
 				}
150
-				for ($i = 0; $i < 10;++$i) {
150
+				for ($i = 0; $i < 10; ++$i) {
151 151
 					$t[$i] = 0;
152 152
 					for ($j = 0; $j < 12; ++$j) {
153 153
 						$t[$i] += $v[$j]*$c3x[$j][$i];
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 			$this->t = $t;
159 159
 		} else $t = $this->t;
160 160
 		if (!($cubic)) {
161
-			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
162
-			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
163
-			$h = (((1 - $fy) * $a) + ($fy * $b));
161
+			$a = (((1 - $fx)*$this->v00) + ($fx*$this->v01));
162
+			$b = (((1 - $fx)*$this->v10) + ($fx*$this->v11));
163
+			$h = (((1 - $fy)*$a) + ($fy*$b));
164 164
 		} else {
165
-			$h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9]))))));
165
+			$h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9]))))));
166 166
 		}
167
-		return ((float)$this->offset + ((float)$this->scale * (float)$h));
167
+		return ((float) $this->offset + ((float) $this->scale*(float) $h));
168 168
 	}
169 169
 }
170 170
 /*
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,8 +38,11 @@  discard block
 block discarded – undo
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
41
-			if (isset($globalGeoidSource) && $globalGeoidSource != '') $name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
42
-			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
41
+			if (isset($globalGeoidSource) && $globalGeoidSource != '') {
42
+				$name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
43
+			} else {
44
+				$name = dirname(__FILE__).'/../data/egm96-15.pgm';
45
+			}
43 46
 		}
44 47
 
45 48
 		$f = @fopen($name,"r");
@@ -156,7 +159,9 @@  discard block
 block discarded – undo
156 159
 				}
157 160
 			}
158 161
 			$this->t = $t;
159
-		} else $t = $this->t;
162
+		} else {
163
+			$t = $this->t;
164
+		}
160 165
 		if (!($cubic)) {
161 166
 			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
162 167
 			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
Please login to merge, or discard this patch.
install/index.php 3 patches
Spacing   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.create_db.php');
11 11
 require_once(dirname(__FILE__).'/class.update_schema.php');
12 12
 require_once(dirname(__FILE__).'/class.settings.php');
13
-$title="Install";
13
+$title = "Install";
14 14
 require(dirname(__FILE__).'/../require/settings.php');
15 15
 require(dirname(__FILE__).'/header.php');
16 16
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 if (!extension_loaded('curl')) {
70 70
 	$error[] = "Curl is not loaded.";
71 71
 }
72
-if(function_exists('apache_get_modules') ){
73
-	if(!in_array('mod_rewrite',apache_get_modules())) {
72
+if (function_exists('apache_get_modules')) {
73
+	if (!in_array('mod_rewrite', apache_get_modules())) {
74 74
 		$error[] = "mod_rewrite is not available.";
75 75
 	}
76 76
 /*
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
87 87
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
88 88
 	if (function_exists('get_headers')) {
89
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
90
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
89
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
90
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
91 91
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
92 92
 		}
93 93
 	}
@@ -452,13 +452,13 @@  discard block
 block discarded – undo
452 452
 ?>
453 453
 							<tr>
454 454
 								<?php
455
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
455
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
456 456
 								?>
457 457
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458 458
 								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
459 459
 								<?php
460 460
 								    } else {
461
-									$hostport = explode(':',$source['host']);
461
+									$hostport = explode(':', $source['host']);
462 462
 									if (isset($hostport[1])) {
463 463
 										$host = $hostport[0];
464 464
 										$port = $hostport[1];
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 									<select name="timezone[]" id="timezone">
504 504
 								<?php
505 505
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
506
-									foreach($timezonelist as $timezone){
506
+									foreach ($timezonelist as $timezone) {
507 507
 										if (isset($source['timezone']) && $source['timezone'] == $timezone) {
508 508
 											print '<option selected>'.$timezone.'</option>';
509 509
 										} elseif (!isset($source['timezone']) && $timezone == 'UTC') {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 									<select name="timezone[]" id="timezone">
554 554
 								<?php
555 555
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
556
-									foreach($timezonelist as $timezone){
556
+									foreach ($timezonelist as $timezone) {
557 557
 										if ($timezone == 'UTC') {
558 558
 											print '<option selected>'.$timezone.'</option>';
559 559
 										} else print '<option>'.$timezone.'</option>';
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 			<br />
866 866
 			<p>
867 867
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
868
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
868
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
869 869
 			</p>
870 870
 			<br />
871 871
 			<p>
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
 $error = '';
922 922
 
923 923
 if (isset($_POST['dbtype'])) {
924
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
925
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
926
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
927
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
928
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
929
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
930
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
931
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
924
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
925
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
926
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
927
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
928
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
929
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
930
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
931
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
932 932
 
933 933
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
934 934
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -948,49 +948,49 @@  discard block
 block discarded – undo
948 948
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
949 949
 	*/
950 950
 	
951
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
951
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
952 952
 
953
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
954
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
955
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
956
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
957
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
953
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
954
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
955
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
956
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
957
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
958 958
 
959
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
960
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
961
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
962
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
963
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
964
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
965
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
966
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
967
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
968
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
959
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
960
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
961
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
962
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
963
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
964
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
965
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
966
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
967
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
968
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
969 969
 	
970
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
971
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
972
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
973
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
974
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
975
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
970
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
971
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
972
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
973
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
974
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
975
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
976 976
 
977
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
978
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
977
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
978
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
979 979
 
980
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
981
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
982
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
980
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
981
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
982
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
983 983
 
984
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
984
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
985 985
 	if ($acars == 'acars') {
986
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
986
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
987 987
 	} else {
988
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
988
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
989 989
 	}
990 990
 
991
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
992
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
993
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
991
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
992
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
993
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
994 994
 	
995 995
 	$source_name = $_POST['source_name'];
996 996
 	$source_latitude = $_POST['source_latitude'];
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 	
1005 1005
 	$sources = array();
1006 1006
 	foreach ($source_name as $keys => $name) {
1007
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1008
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1007
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
1008
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
1009 1009
 	}
1010 1010
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1011 1011
 
@@ -1018,24 +1018,24 @@  discard block
 block discarded – undo
1018 1018
 	$sbsurl = $_POST['sbsurl'];
1019 1019
 	*/
1020 1020
 
1021
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1022
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1023
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1024
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1025
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1026
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1027
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1028
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1021
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1022
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1023
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1024
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1025
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1026
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1027
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1028
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1029 1029
 
1030
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1031
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1032
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1033
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1034
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1035
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1036
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1037
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1038
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1030
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1031
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1032
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1033
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1034
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1035
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1036
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1037
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1038
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1039 1039
 
1040 1040
 /*	
1041 1041
 	$globalSBS1Hosts = array();
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	}
1052 1052
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1053 1053
 */
1054
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1054
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1055 1055
 	$host = $_POST['host'];
1056 1056
 	$port = $_POST['port'];
1057 1057
 	$name = $_POST['name'];
@@ -1068,100 +1068,100 @@  discard block
 block discarded – undo
1068 1068
 		else $cov = 'FALSE';
1069 1069
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1070 1070
 		else $arch = 'FALSE';
1071
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]);
1071
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezone[$key]);
1072 1072
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1073 1073
 	}
1074
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1074
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1075 1075
 
1076 1076
 /*
1077 1077
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1078 1078
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1079 1079
 */
1080
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1081
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1082
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1080
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1081
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1082
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1083 1083
 
1084
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1085
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1084
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1085
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1086 1086
 
1087
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1088
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1087
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1088
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1089 1089
 
1090
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1091
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1092
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1093
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1090
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1091
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1092
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1093
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1094 1094
 
1095
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1096
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1097
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1095
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1096
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1097
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1098 1098
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1099
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1100
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1099
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1100
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1101 1101
 
1102
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1103
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1104
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1105
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1106
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1107
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1108
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1109
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1102
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1103
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1104
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1105
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1106
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1107
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1108
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1109
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1110 1110
 
1111
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1112
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1111
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1112
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1113 1113
 
1114
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1115
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1114
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1115
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1116 1116
 	
1117
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1117
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1118 1118
 	if ($archiveyear == "archiveyear") {
1119
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1119
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1120 1120
 	} else {
1121
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1121
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1122 1122
 	}
1123
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1124
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1125
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1126
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1123
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1124
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1125
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1126
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1127 1127
 
1128
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1129
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1130
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1131
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1128
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1129
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1130
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1131
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1132 1132
 
1133
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1134
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1135
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1133
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1134
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1135
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1136 1136
 
1137 1137
 	// Create in settings.php keys not yet configurable if not already here
1138 1138
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1139
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1139
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1140 1140
 
1141
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1141
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1142 1142
 	if ($resetyearstats == 'resetyearstats') {
1143
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1143
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1144 1144
 	} else {
1145
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1145
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1146 1146
 	}
1147 1147
 
1148
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1148
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1149 1149
 	if ($archive == 'archive') {
1150
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1150
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1151 1151
 	} else {
1152
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1152
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1153 1153
 	}
1154
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1154
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1155 1155
 	if ($daemon == 'daemon') {
1156
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1156
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1157 1157
 	} else {
1158
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1158
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1159 1159
 	}
1160
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1160
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1161 1161
 	if ($schedules == 'schedules') {
1162
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1162
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1163 1163
 	} else {
1164
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1164
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1165 1165
 	}
1166 1166
 
1167 1167
 /*
@@ -1172,227 +1172,227 @@  discard block
 block discarded – undo
1172 1172
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1173 1173
 	}
1174 1174
 */
1175
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1176
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1177
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1178
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1179
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1175
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1176
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1177
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1178
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1179
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1180 1180
 	$va = false;
1181 1181
 	if ($globalivao == 'ivao') {
1182
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1182
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1183 1183
 		$va = true;
1184
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1184
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1185 1185
 	if ($globalvatsim == 'vatsim') {
1186
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1186
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1187 1187
 		$va = true;
1188
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1188
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1189 1189
 	if ($globalphpvms == 'phpvms') {
1190
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1190
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1191 1191
 		$va = true;
1192
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1192
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1193 1193
 	if ($globalvam == 'vam') {
1194
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1194
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1195 1195
 		$va = true;
1196
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1196
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1197 1197
 	if ($va) {
1198
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1199
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1198
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1199
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1200 1200
 	if ($globalva == 'va' || $va) {
1201
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1202
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1201
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1202
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1203 1203
 	} else {
1204
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1205
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1206
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1204
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1205
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1206
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1207 1207
 	}
1208 1208
 	
1209 1209
 	
1210 1210
 
1211
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1211
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1212 1212
 	if ($notam == 'notam') {
1213
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1213
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1214 1214
 	} else {
1215
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1215
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1216 1216
 	}
1217
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1217
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1218 1218
 	if ($owner == 'owner') {
1219
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1219
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1220 1220
 	} else {
1221
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1221
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1222 1222
 	}
1223
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1223
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1224 1224
 	if ($map3d == 'map3d') {
1225
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1225
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1226 1226
 	} else {
1227
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1227
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1228 1228
 	}
1229
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1229
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1230 1230
 	if ($crash == 'crash') {
1231
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1231
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1232 1232
 	} else {
1233
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1233
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1234 1234
 	}
1235
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1235
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1236 1236
 	if ($mapsatellites == 'mapsatellites') {
1237
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1237
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1238 1238
 	} else {
1239
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1239
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1240 1240
 	}
1241
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1241
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1242 1242
 	if ($map3ddefault == 'map3ddefault') {
1243
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1243
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1244 1244
 	} else {
1245
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1245
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1246 1246
 	}
1247
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1247
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1248 1248
 	if ($translate == 'translate') {
1249
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1249
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1250 1250
 	} else {
1251
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1251
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1252 1252
 	}
1253
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1253
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1254 1254
 	if ($realairlines == 'realairlines') {
1255
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1255
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1256 1256
 	} else {
1257
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1257
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1258 1258
 	}
1259
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1259
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1260 1260
 	if ($estimation == 'estimation') {
1261
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1261
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1262 1262
 	} else {
1263
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1263
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1264 1264
 	}
1265
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1265
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1266 1266
 	if ($metar == 'metar') {
1267
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1267
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1268 1268
 	} else {
1269
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1269
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1270 1270
 	}
1271
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1271
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1272 1272
 	if ($metarcycle == 'metarcycle') {
1273
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1273
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1274 1274
 	} else {
1275
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1275
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1276 1276
 	}
1277
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1277
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1278 1278
 	if ($fork == 'fork') {
1279
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1279
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1280 1280
 	} else {
1281
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1281
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1282 1282
 	}
1283 1283
 
1284
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1284
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1285 1285
 	if ($colormap == 'colormap') {
1286
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1286
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1287 1287
 	} else {
1288
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1288
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1289 1289
 	}
1290 1290
 	
1291 1291
 	if (isset($_POST['aircrafticoncolor'])) {
1292
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1293
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1292
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1293
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1294 1294
 	}
1295 1295
 
1296
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1297
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1296
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1297
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1298 1298
 
1299
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1300
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1301
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1302
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1303
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1304
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1299
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1300
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1301
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1302
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1303
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1304
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1305 1305
 
1306
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1306
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1307 1307
 	if ($mappopup == 'mappopup') {
1308
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1308
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1309 1309
 	} else {
1310
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1310
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1311 1311
 	}
1312
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1312
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1313 1313
 	if ($airportpopup == 'airportpopup') {
1314
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1314
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1315 1315
 	} else {
1316
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1316
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1317 1317
 	}
1318
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1318
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1319 1319
 	if ($maphistory == 'maphistory') {
1320
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1320
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1321 1321
 	} else {
1322
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1322
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1323 1323
 	}
1324
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1324
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1325 1325
 	if ($maptooltip == 'maptooltip') {
1326
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1326
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1327 1327
 	} else {
1328
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1328
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1329 1329
 	}
1330
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1330
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1331 1331
 	if ($flightroute == 'flightroute') {
1332
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1332
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1333 1333
 	} else {
1334
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1334
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1335 1335
 	}
1336
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1336
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1337 1337
 	if ($flightremainingroute == 'flightremainingroute') {
1338
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1338
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1339 1339
 	} else {
1340
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1340
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1341 1341
 	}
1342
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1342
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1343 1343
 	if ($allflights == 'allflights') {
1344
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1344
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1345 1345
 	} else {
1346
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1346
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1347 1347
 	}
1348
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1348
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1349 1349
 	if ($bbox == 'bbox') {
1350
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1350
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1351 1351
 	} else {
1352
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1352
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1353 1353
 	}
1354
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1354
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1355 1355
 	if ($groundaltitude == 'groundaltitude') {
1356
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1356
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1357 1357
 	} else {
1358
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1358
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1359 1359
 	}
1360
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1360
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1361 1361
 	if ($waypoints == 'waypoints') {
1362
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1362
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1363 1363
 	} else {
1364
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1364
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1365 1365
 	}
1366
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1366
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1367 1367
 	if ($geoid == 'geoid') {
1368
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1368
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1369 1369
 	} else {
1370
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1370
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1371 1371
 	}
1372
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1373
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1372
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1373
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1374 1374
 
1375
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1375
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1376 1376
 	if ($noairlines == 'noairlines') {
1377
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1377
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1378 1378
 	} else {
1379
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1379
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1380 1380
 	}
1381 1381
 
1382
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1382
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1383 1383
 
1384 1384
 	// Set some defaults values...
1385 1385
 	if (!isset($globalAircraftImageSources)) {
1386
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1387
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1386
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1387
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1388 1388
 	}
1389 1389
 
1390 1390
 	if (!isset($globalSchedulesSources)) {
1391
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1392
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1391
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1392
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1393 1393
     	}
1394 1394
 
1395
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1395
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1396 1396
 
1397 1397
 	if ($error == '') settings::modify_settings($settings);
1398 1398
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +496 added lines, -133 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -409,11 +513,17 @@  discard block
 block discarded – undo
409 513
 			<div id="flightaware_data">
410 514
 				<p>
411 515
 					<label for="flightawareusername">FlightAware username</label>
412
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
516
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
517
+	print $globalFlightAwareUsername;
518
+}
519
+?>" />
413 520
 				</p>
414 521
 				<p>
415 522
 					<label for="flightawarepassword">FlightAware password/API key</label>
416
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
523
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
524
+	print $globalFlightAwarePassword;
525
+}
526
+?>" />
417 527
 				</p>
418 528
 			</div>
419 529
 -->
@@ -455,7 +565,10 @@  discard block
 block discarded – undo
455 565
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 566
 								?>
457 567
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458
-								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
568
+								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
569
+	print $source['port'];
570
+}
571
+?>" /></td>
459 572
 								<?php
460 573
 								    } else {
461 574
 									$hostport = explode(':',$source['host']);
@@ -474,31 +587,94 @@  discard block
 block discarded – undo
474 587
 								?>
475 588
 								<td>
476 589
 									<select name="format[]" id="format">
477
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
478
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
479
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
480
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
481
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
482
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
483
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
484
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
485
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
486
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
487
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
488
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
489
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
490
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
491
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
492
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
493
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
494
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
590
+										<option value="auto" <?php if (!isset($source['format'])) {
591
+	print 'selected';
592
+}
593
+?>>Auto</option>
594
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
595
+	print 'selected';
596
+}
597
+?>>SBS</option>
598
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
599
+	print 'selected';
600
+}
601
+?>>TSV</option>
602
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
603
+	print 'selected';
604
+}
605
+?>>Raw</option>
606
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
607
+	print 'selected';
608
+}
609
+?>>APRS</option>
610
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
611
+	print 'selected';
612
+}
613
+?>>Radarcape deltadb.txt</option>
614
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
615
+	print 'selected';
616
+}
617
+?>>Vatsim</option>
618
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
619
+	print 'selected';
620
+}
621
+?>>Virtual Radar Server AircraftList.json</option>
622
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
623
+	print 'selected';
624
+}
625
+?>>Virtual Radar Server TCP</option>
626
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
627
+	print 'selected';
628
+}
629
+?>>phpVMS</option>
630
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
631
+	print 'selected';
632
+}
633
+?>>Virtual Airlines Manager</option>
634
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
635
+	print 'selected';
636
+}
637
+?>>IVAO</option>
638
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
639
+	print 'selected';
640
+}
641
+?>>FlightGear Multiplayer</option>
642
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
643
+	print 'selected';
644
+}
645
+?>>FlightGear Singleplayer</option>
646
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
647
+	print 'selected';
648
+}
649
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
650
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
651
+	print 'selected';
652
+}
653
+?>>ACARS SBS-3 over TCP</option>
654
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
655
+	print 'selected';
656
+}
657
+?>>NMEA AIS over TCP</option>
658
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
659
+	print 'selected';
660
+}
661
+?>>AirWhere website</option>
495 662
 									</select>
496 663
 								</td>
497 664
 								<td>
498
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
665
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
666
+	print $source['name'];
667
+}
668
+?>" />
499 669
 								</td>
500
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
501
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
670
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
671
+	print 'checked';
672
+}
673
+?> /></td>
674
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
675
+	print 'checked';
676
+}
677
+?> /></td>
502 678
 								<td>
503 679
 									<select name="timezone[]" id="timezone">
504 680
 								<?php
@@ -508,7 +684,9 @@  discard block
 block discarded – undo
508 684
 											print '<option selected>'.$timezone.'</option>';
509 685
 										} elseif (!isset($source['timezone']) && $timezone == 'UTC') {
510 686
 											print '<option selected>'.$timezone.'</option>';
511
-										} else print '<option>'.$timezone.'</option>';
687
+										} else {
688
+											print '<option>'.$timezone.'</option>';
689
+										}
512 690
 									}
513 691
 								?>
514 692
 									</select>
@@ -556,7 +734,9 @@  discard block
 block discarded – undo
556 734
 									foreach($timezonelist as $timezone){
557 735
 										if ($timezone == 'UTC') {
558 736
 											print '<option selected>'.$timezone.'</option>';
559
-										} else print '<option>'.$timezone.'</option>';
737
+										} else {
738
+											print '<option>'.$timezone.'</option>';
739
+										}
560 740
 									}
561 741
 								?>
562 742
 									</select>
@@ -577,11 +757,17 @@  discard block
 block discarded – undo
577 757
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
578 758
 					<p>
579 759
 						<label for="acarshost">ACARS UDP host</label>
580
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
760
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
761
+	print $globalACARSHost;
762
+}
763
+?>" />
581 764
 					</p>
582 765
 					<p>
583 766
 						<label for="acarsport">ACARS UDP port</label>
584
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
767
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
768
+	print $globalACARSPort;
769
+}
770
+?>" />
585 771
 					</p>
586 772
 				</fieldset>
587 773
 			</div>
@@ -661,13 +847,19 @@  discard block
 block discarded – undo
661 847
 			<div id="schedules_options">
662 848
 				<p>
663 849
 					<label for="britishairways">British Airways API Key</label>
664
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
850
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
851
+	print $globalBritishAirwaysKey;
852
+}
853
+?>" />
665 854
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
666 855
 				</p>
667 856
 				<!--
668 857
 				<p>
669 858
 					<label for="transavia">Transavia Test API Consumer Key</label>
670
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
859
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
860
+	print $globalTransaviaKey;
861
+}
862
+?>" />
671 863
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
672 864
 				</p>
673 865
 				-->
@@ -676,10 +868,16 @@  discard block
 block discarded – undo
676 868
 						<b>Lufthansa API Key</b>
677 869
 						<p>
678 870
 							<label for="lufthansakey">Key</label>
679
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
871
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
872
+	print $globalLufthansaKey['key'];
873
+}
874
+?>" />
680 875
 						</p><p>
681 876
 							<label for="lufthansasecret">Secret</label>
682
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
877
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
878
+	print $globalLufthansaKey['secret'];
879
+}
880
+?>" />
683 881
 						</p>
684 882
 					</div>
685 883
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -699,7 +897,10 @@  discard block
 block discarded – undo
699 897
 			</p>
700 898
 			<p>
701 899
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
702
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
900
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
901
+	print $globalNOTAMSource;
902
+}
903
+?>" />
703 904
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
704 905
 			</p>
705 906
 			<br />
@@ -715,14 +916,20 @@  discard block
 block discarded – undo
715 916
 			<div id="metarsrc">
716 917
 				<p>
717 918
 					<label for="metarsource">URL of your METAR source</label>
718
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
919
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
920
+	print $globalMETARurl;
921
+}
922
+?>" />
719 923
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
720 924
 				</p>
721 925
 			</div>
722 926
 			<br />
723 927
 			<p>
724 928
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
725
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
929
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
930
+	print $globalBitlyAccessToken;
931
+}
932
+?>" />
726 933
 			</p>
727 934
 			<br />
728 935
 			<p>
@@ -738,11 +945,26 @@  discard block
 block discarded – undo
738 945
 			<p>
739 946
 				<label for="geoid_source">Geoid Source</label>
740 947
 				<select name="geoid_source" id="geoid_source">
741
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
742
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
743
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
744
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
745
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
948
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
949
+	print ' selected="selected"';
950
+}
951
+?>>EGM96 15' (2.1MB)</option>
952
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
953
+	print ' selected="selected"';
954
+}
955
+?>>EGM96 5' (19MB)</option>
956
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
957
+	print ' selected="selected"';
958
+}
959
+?>>EGM2008 5' (19MB)</option>
960
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
961
+	print ' selected="selected"';
962
+}
963
+?>>EGM2008 2.5' (75MB)</option>
964
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM2008 1' (470MB)</option>
746 968
 				</select>
747 969
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
748 970
 			</p>
@@ -759,7 +981,12 @@  discard block
 block discarded – undo
759 981
 			</p>
760 982
 			<p>
761 983
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
762
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
984
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
985
+	print $globalArchiveMonths;
986
+} else {
987
+	echo '0';
988
+}
989
+?>" />
763 990
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
764 991
 			</p>
765 992
 			<p>
@@ -769,12 +996,22 @@  discard block
 block discarded – undo
769 996
 			</p>
770 997
 			<p>
771 998
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
772
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
999
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1000
+	print $globalArchiveKeepMonths;
1001
+} else {
1002
+	echo '0';
1003
+}
1004
+?>" />
773 1005
 				<p class="help-block">0 to disable</p>
774 1006
 			</p>
775 1007
 			<p>
776 1008
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
777
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
1009
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1010
+	print $globalArchiveKeepTrackMonths;
1011
+} else {
1012
+	echo '0';
1013
+}
1014
+?>" />
778 1015
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
779 1016
 			</p>
780 1017
 			<br />
@@ -784,7 +1021,12 @@  discard block
 block discarded – undo
784 1021
 				<p class="help-block">Uncheck if the script is running as cron job</p>
785 1022
 				<div id="cronends"> 
786 1023
 					<label for="cronend">Run script for xx seconds</label>
787
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1024
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1025
+	print $globalCronEnd;
1026
+} else {
1027
+	print '0';
1028
+}
1029
+?>" />
788 1030
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
789 1031
 				</div>
790 1032
 			</p>
@@ -837,15 +1079,30 @@  discard block
 block discarded – undo
837 1079
 			<br />
838 1080
 			<p>
839 1081
 				<label for="refresh">Show flights detected since xxx seconds</label>
840
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1082
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1083
+	echo $globalLiveInterval;
1084
+} else {
1085
+	echo '200';
1086
+}
1087
+?>" />
841 1088
 			</p>
842 1089
 			<p>
843 1090
 				<label for="maprefresh">Live map refresh (in seconds)</label>
844
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1091
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1092
+	echo $globalMapRefresh;
1093
+} else {
1094
+	echo '30';
1095
+}
1096
+?>" />
845 1097
 			</p>
846 1098
 			<p>
847 1099
 				<label for="mapidle">Map idle timeout (in minutes)</label>
848
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1100
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1101
+	echo $globalMapIdleTimeout;
1102
+} else {
1103
+	echo '30';
1104
+}
1105
+?>" />
849 1106
 				<p class="help-block">0 to disable</p>
850 1107
 			</p>
851 1108
 			<p>
@@ -860,12 +1117,20 @@  discard block
 block discarded – undo
860 1117
 			<br />
861 1118
 			<p>
862 1119
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
863
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1120
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1121
+	echo $globalClosestMinDist;
1122
+} else {
1123
+	echo '50';
1124
+}
1125
+?>" />
864 1126
 			</p>
865 1127
 			<br />
866 1128
 			<p>
867 1129
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
868
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1130
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1131
+	echo $globalAircraftSize;
1132
+}
1133
+?>" />
869 1134
 			</p>
870 1135
 			<br />
871 1136
 			<p>
@@ -878,7 +1143,12 @@  discard block
 block discarded – undo
878 1143
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
879 1144
 			?>
880 1145
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
881
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1146
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1147
+	echo $globalAircraftIconColor;
1148
+} else {
1149
+	echo '1a3151';
1150
+}
1151
+?>" />
882 1152
 			<?php
883 1153
 				if (!is_writable('../cache')) {
884 1154
 			?>
@@ -896,14 +1166,27 @@  discard block
 block discarded – undo
896 1166
 			<p>
897 1167
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
898 1168
 				<div class="range">
899
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
900
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1169
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1170
+	echo $globalAirportZoom;
1171
+} else {
1172
+	echo '7';
1173
+}
1174
+?>" />
1175
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1176
+	echo $globalAirportZoom;
1177
+} else {
1178
+	echo '7';
1179
+}
1180
+?></output>
901 1181
 				</div>
902 1182
 			</p>
903 1183
 			<br />
904 1184
 			<p>
905 1185
 				<label for="customcss">Custom CSS web path</label>
906
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1186
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1187
+	echo $globalCustomCSS;
1188
+}
1189
+?>" />
907 1190
 			</p>
908 1191
 		</fieldset>
909 1192
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -930,8 +1213,12 @@  discard block
 block discarded – undo
930 1213
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
931 1214
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
932 1215
 
933
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
934
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1216
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1217
+		$error .= 'Mysql driver for PDO must be loaded';
1218
+	}
1219
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1220
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1221
+	}
935 1222
 	
936 1223
 	$_SESSION['database_root'] = $dbroot;
937 1224
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -999,15 +1286,23 @@  discard block
 block discarded – undo
999 1286
 	$source_city = $_POST['source_city'];
1000 1287
 	$source_country = $_POST['source_country'];
1001 1288
 	$source_ref = $_POST['source_ref'];
1002
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1003
-	else $source_id = array();
1289
+	if (isset($source_id)) {
1290
+		$source_id = $_POST['source_id'];
1291
+	} else {
1292
+		$source_id = array();
1293
+	}
1004 1294
 	
1005 1295
 	$sources = array();
1006 1296
 	foreach ($source_name as $keys => $name) {
1007
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1008
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1297
+	    if (isset($source_id[$keys])) {
1298
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1299
+	    } else {
1300
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1301
+	    }
1302
+	}
1303
+	if (count($sources) > 0) {
1304
+		$_SESSION['sources'] = $sources;
1009 1305
 	}
1010
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1011 1306
 
1012 1307
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1013 1308
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1028,14 +1323,23 @@  discard block
 block discarded – undo
1028 1323
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1029 1324
 
1030 1325
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1031
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1032
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1326
+	if ($globalaircraft == 'aircraft') {
1327
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1328
+	} else {
1329
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1330
+	}
1033 1331
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1034
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1035
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1332
+	if ($globaltracker == 'tracker') {
1333
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1334
+	} else {
1335
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1336
+	}
1036 1337
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1037
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1038
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1338
+	if ($globalmarine == 'marine') {
1339
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1340
+	} else {
1341
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1342
+	}
1039 1343
 
1040 1344
 /*	
1041 1345
 	$globalSBS1Hosts = array();
@@ -1057,19 +1361,35 @@  discard block
 block discarded – undo
1057 1361
 	$name = $_POST['name'];
1058 1362
 	$format = $_POST['format'];
1059 1363
 	$timezone = $_POST['timezone'];
1060
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1061
-	else $sourcestats = array();
1062
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1063
-	else $noarchive = array();
1364
+	if (isset($_POST['sourcestats'])) {
1365
+		$sourcestats = $_POST['sourcestats'];
1366
+	} else {
1367
+		$sourcestats = array();
1368
+	}
1369
+	if (isset($_POST['noarchive'])) {
1370
+		$noarchive = $_POST['noarchive'];
1371
+	} else {
1372
+		$noarchive = array();
1373
+	}
1064 1374
 	$gSources = array();
1065 1375
 	$forcepilots = false;
1066 1376
 	foreach ($host as $key => $h) {
1067
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1068
-		else $cov = 'FALSE';
1069
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1070
-		else $arch = 'FALSE';
1071
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]);
1072
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1377
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1378
+			$cov = 'TRUE';
1379
+		} else {
1380
+			$cov = 'FALSE';
1381
+		}
1382
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1383
+			$arch = 'TRUE';
1384
+		} else {
1385
+			$arch = 'FALSE';
1386
+		}
1387
+		if ($h != '') {
1388
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]);
1389
+		}
1390
+		if ($format[$key] == 'airwhere') {
1391
+			$forcepilots = true;
1392
+		}
1073 1393
 	}
1074 1394
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1075 1395
 
@@ -1097,7 +1417,9 @@  discard block
 block discarded – undo
1097 1417
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1098 1418
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1099 1419
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1100
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1420
+	} else {
1421
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1422
+	}
1101 1423
 
1102 1424
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1103 1425
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1136,7 +1458,9 @@  discard block
 block discarded – undo
1136 1458
 
1137 1459
 	// Create in settings.php keys not yet configurable if not already here
1138 1460
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1139
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1461
+	if (!isset($globalDebug)) {
1462
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1463
+	}
1140 1464
 
1141 1465
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1142 1466
 	if ($resetyearstats == 'resetyearstats') {
@@ -1173,37 +1497,56 @@  discard block
 block discarded – undo
1173 1497
 	}
1174 1498
 */
1175 1499
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1176
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1177
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1178
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1179
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1500
+	if ($globalsbs == 'sbs') {
1501
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1502
+	} else {
1503
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1504
+	}
1505
+	if ($globalaprs == 'aprs') {
1506
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1507
+	} else {
1508
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1509
+	}
1180 1510
 	$va = false;
1181 1511
 	if ($globalivao == 'ivao') {
1182 1512
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1183 1513
 		$va = true;
1184
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1514
+	} else {
1515
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1516
+	}
1185 1517
 	if ($globalvatsim == 'vatsim') {
1186 1518
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1187 1519
 		$va = true;
1188
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1520
+	} else {
1521
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1522
+	}
1189 1523
 	if ($globalphpvms == 'phpvms') {
1190 1524
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1191 1525
 		$va = true;
1192
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1526
+	} else {
1527
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1528
+	}
1193 1529
 	if ($globalvam == 'vam') {
1194 1530
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1195 1531
 		$va = true;
1196
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1532
+	} else {
1533
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1534
+	}
1197 1535
 	if ($va) {
1198 1536
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1199
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1537
+	} else {
1538
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1539
+	}
1200 1540
 	if ($globalva == 'va' || $va) {
1201 1541
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1202 1542
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1203 1543
 	} else {
1204 1544
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1205
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1206
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1545
+		if ($forcepilots) {
1546
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1547
+		} else {
1548
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1549
+		}
1207 1550
 	}
1208 1551
 	
1209 1552
 	
@@ -1379,7 +1722,9 @@  discard block
 block discarded – undo
1379 1722
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1380 1723
 	}
1381 1724
 
1382
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1725
+	if (!isset($globalTransaction)) {
1726
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1727
+	}
1383 1728
 
1384 1729
 	// Set some defaults values...
1385 1730
 	if (!isset($globalAircraftImageSources)) {
@@ -1394,15 +1739,23 @@  discard block
 block discarded – undo
1394 1739
 
1395 1740
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1396 1741
 
1397
-	if ($error == '') settings::modify_settings($settings);
1398
-	if ($error == '') settings::comment_settings($settings_comment);
1742
+	if ($error == '') {
1743
+		settings::modify_settings($settings);
1744
+	}
1745
+	if ($error == '') {
1746
+		settings::comment_settings($settings_comment);
1747
+	}
1399 1748
 	if ($error != '') {
1400 1749
 		print '<div class="info column">'.$error.'</div>';
1401 1750
 		require('../footer.php');
1402 1751
 		exit;
1403 1752
 	} else {
1404
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1405
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1753
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1754
+			$_SESSION['waypoints'] = 1;
1755
+		}
1756
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1757
+			$_SESSION['owner'] = 1;
1758
+		}
1406 1759
 		if (isset($_POST['createdb'])) {
1407 1760
 			$_SESSION['install'] = 'database_create';
1408 1761
 		} else {
@@ -1443,10 +1796,18 @@  discard block
 block discarded – undo
1443 1796
 	$popw = false;
1444 1797
 	foreach ($_SESSION['done'] as $done) {
1445 1798
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1446
-	    if ($done == 'Create database') $pop = true;
1447
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1448
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1449
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1799
+	    if ($done == 'Create database') {
1800
+	    	$pop = true;
1801
+	    }
1802
+	    if ($_SESSION['install'] == 'database_create') {
1803
+	    	$pop = true;
1804
+	    }
1805
+	    if ($_SESSION['install'] == 'database_import') {
1806
+	    	$popi = true;
1807
+	    }
1808
+	    if ($_SESSION['install'] == 'waypoints') {
1809
+	    	$popw = true;
1810
+	    }
1450 1811
 	}
1451 1812
 	if ($pop) {
1452 1813
 	    sleep(5);
@@ -1457,7 +1818,9 @@  discard block
 block discarded – undo
1457 1818
 	} else if ($popw) {
1458 1819
 	    sleep(5);
1459 1820
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1460
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1821
+	} else {
1822
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1823
+	}
1461 1824
 	print '</div></ul>';
1462 1825
 	print '<div id="error"></div>';
1463 1826
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 				</tr>
318 318
 				<!--
319 319
 		<?php
320
-		    require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
-		    $Connection = new Connection();
320
+			require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
+			$Connection = new Connection();
322 322
 		?>
323 323
 				-->
324 324
 		<?php
325
-		    if ($Connection->db != NULL) {
325
+			if ($Connection->db != NULL) {
326 326
 			if ($Connection->tableExists('source_location')) {
327
-			    require_once(dirname(__FILE__).'/../require/class.Source.php');
328
-			    $Source = new Source();
329
-			    //$alllocations = $Source->getAllLocationInfo();
330
-			    $alllocations = $Source->getLocationInfobyType('');
331
-			    foreach ($alllocations as $location) {
327
+				require_once(dirname(__FILE__).'/../require/class.Source.php');
328
+				$Source = new Source();
329
+				//$alllocations = $Source->getAllLocationInfo();
330
+				$alllocations = $Source->getLocationInfobyType('');
331
+				foreach ($alllocations as $location) {
332 332
 		?>
333 333
 				<tr>
334 334
 	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 				</tr>
343 343
 		
344 344
 		<?php
345
-			    }
345
+				}
346
+			}
346 347
 			}
347
-		    }
348 348
 		?>
349 349
 
350 350
 				<tr>
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 ?>
453 453
 							<tr>
454 454
 								<?php
455
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
455
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 456
 								?>
457 457
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458 458
 								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
459 459
 								<?php
460
-								    } else {
460
+									} else {
461 461
 									$hostport = explode(':',$source['host']);
462 462
 									if (isset($hostport[1])) {
463 463
 										$host = $hostport[0];
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
471 471
 								<td><input type="number" name="port[]" id="port" class="col-xs-2" value="<?php print $port; ?>" /></td>
472 472
 								<?php
473
-								    }
473
+									}
474 474
 								?>
475 475
 								<td>
476 476
 									<select name="format[]" id="format">
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 			<br />
877 877
 			<p>
878 878
 			<?php 
879
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
879
+				if (extension_loaded('gd') && function_exists('gd_info')) {
880 880
 			?>
881 881
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
882 882
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
887 887
 			<?php
888 888
 				}
889
-			    } else {
889
+				} else {
890 890
 			?>
891 891
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
892 892
 			<?php
893
-			    }
893
+				}
894 894
 			?>
895 895
 			</p>
896 896
 			<br />
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 	</p>
915 915
 <?php
916 916
 	require('../footer.php');
917
-        exit;
917
+		exit;
918 918
 }
919 919
 	
920 920
 $settings = array();
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
 	
1006 1006
 	$sources = array();
1007 1007
 	foreach ($source_name as $keys => $name) {
1008
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1009
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1008
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1009
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1010 1010
 	}
1011 1011
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1012 1012
 
@@ -1384,14 +1384,14 @@  discard block
 block discarded – undo
1384 1384
 
1385 1385
 	// Set some defaults values...
1386 1386
 	if (!isset($globalAircraftImageSources)) {
1387
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1388
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1387
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1388
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1389 1389
 	}
1390 1390
 
1391 1391
 	if (!isset($globalSchedulesSources)) {
1392
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1393
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1394
-    	}
1392
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1393
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1394
+		}
1395 1395
 
1396 1396
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1397 1397
 
@@ -1443,21 +1443,21 @@  discard block
 block discarded – undo
1443 1443
 	$popi = false;
1444 1444
 	$popw = false;
1445 1445
 	foreach ($_SESSION['done'] as $done) {
1446
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1447
-	    if ($done == 'Create database') $pop = true;
1448
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1449
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1450
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1446
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1447
+		if ($done == 'Create database') $pop = true;
1448
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1449
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1450
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1451 1451
 	}
1452 1452
 	if ($pop) {
1453
-	    sleep(5);
1454
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1453
+		sleep(5);
1454
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1455 1455
 	} else if ($popi) {
1456
-	    sleep(5);
1457
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1456
+		sleep(5);
1457
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1458 1458
 	} else if ($popw) {
1459
-	    sleep(5);
1460
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1459
+		sleep(5);
1460
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1461 1461
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1462 1462
 	print '</div></ul>';
1463 1463
 	print '<div id="error"></div>';
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 	unset($_COOKIE['install']);
1521 1521
 	print '<div class="info column"><ul>';
1522 1522
 	foreach ($_SESSION['done'] as $done) {
1523
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1523
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1524 1524
 	}
1525 1525
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1526 1526
 	print '</ul></div>';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +904 added lines, -904 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,42 +25,42 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->latest() === false) {
28
-    echo "You MUST update to latest schema. Run install/index.php";
29
-    exit();
28
+	echo "You MUST update to latest schema. Run install/index.php";
29
+	exit();
30 30
 }
31 31
 if (PHP_SAPI != 'cli') {
32
-    echo "This script MUST be called from console, not a web browser.";
32
+	echo "This script MUST be called from console, not a web browser.";
33 33
 //    exit();
34 34
 }
35 35
 
36 36
 // This is to be compatible with old version of settings.php
37 37
 if (!isset($globalSources)) {
38
-    if (isset($globalSBS1Hosts)) {
39
-        //$hosts = $globalSBS1Hosts;
40
-        foreach ($globalSBS1Hosts as $host) {
41
-	    $globalSources[] = array('host' => $host);
42
-    	}
43
-    } else {
44
-        if (!isset($globalSBS1Host)) {
45
-	    echo '$globalSources MUST be defined !';
46
-	    die;
38
+	if (isset($globalSBS1Hosts)) {
39
+		//$hosts = $globalSBS1Hosts;
40
+		foreach ($globalSBS1Hosts as $host) {
41
+		$globalSources[] = array('host' => $host);
42
+		}
43
+	} else {
44
+		if (!isset($globalSBS1Host)) {
45
+		echo '$globalSources MUST be defined !';
46
+		die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49 49
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
50
-    }
50
+	}
51 51
 }
52 52
 
53 53
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57
-    $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
57
+	$globalSources = array();
58
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
+	else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
66 66
 	$globalServerAPRS = TRUE;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 if (isset($options['idsource'])) $id_source = $options['idsource'];
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
78
+	if ($globalDebug) echo "Using Server Mode\n";
79
+	$SI=new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 } else $SI=new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88
-    $AIS = new AIS();
89
-    $MI = new MarineImport($Connection->db);
88
+	$AIS = new AIS();
89
+	$MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92 92
 $SBS=new SBS();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
101
-        global $sockets;
102
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
-        die("Bye!\n");
104
-    });
105
-    pcntl_signal_dispatch();
100
+	pcntl_signal(SIGINT,  function() {
101
+		global $sockets;
102
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
+		die("Bye!\n");
104
+	});
105
+	pcntl_signal_dispatch();
106 106
 }
107 107
 
108 108
 // let's try and connect
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
 $reset = 0;
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    /*
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			/*
145 145
     	    // Disabled for now, site change source format
146 146
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
147 147
         	//$formats[$id] = 'radarvirtueljson';
@@ -153,118 +153,118 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
-        	//$formats[$id] = 'planeupdatefaa';
158
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
159
-        	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
-        	    exit(0);
164
-        	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'phpvmacars';
168
-        	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
171
-        	//$formats[$id] = 'phpvmacars';
172
-        	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
175
-        	//$formats[$id] = 'whazzup';
176
-        	$globalSources[$id]['format'] = 'whazzup';
177
-        	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
180
-        	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
183
-        	//$formats[$id] = 'pirepsjson';
184
-        	$globalSources[$id]['format'] = 'pirepsjson';
185
-        	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
-        	//$formats[$id] = 'fr24json';
189
-        	$globalSources[$id]['format'] = 'fr24json';
190
-        	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
-        	    exit(0);
195
-        	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
197
-        	//$formats[$id] = 'fr24json';
198
-        	$globalSources[$id]['format'] = 'myshiptracking';
199
-        	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
-        	    exit(0);
204
-        	}
205
-            //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
-        	//$formats[$id] = 'tsv';
208
-        	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
-            }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
-    		    if ($idf !== false) {
215
-    			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
-    		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
222
-	    if (isset($hostport[1])) {
156
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
+			//$formats[$id] = 'planeupdatefaa';
158
+			$globalSources[$id]['format'] = 'planeupdatefaa';
159
+			//$last_exec['planeupdatefaa'] = 0;
160
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
+				exit(0);
164
+			}
165
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'phpvmacars';
168
+			//$last_exec['phpvmacars'] = 0;
169
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
171
+			//$formats[$id] = 'phpvmacars';
172
+			$globalSources[$id]['format'] = 'vam';
173
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
+			} else if (preg_match('/whazzup/i',$host)) {
175
+			//$formats[$id] = 'whazzup';
176
+			$globalSources[$id]['format'] = 'whazzup';
177
+			//$last_exec['whazzup'] = 0;
178
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
+			} else if (preg_match('/airwhere/i',$host)) {
180
+			$globalSources[$id]['format'] = 'airwhere';
181
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
+			} else if (preg_match('/recentpireps/i',$host)) {
183
+			//$formats[$id] = 'pirepsjson';
184
+			$globalSources[$id]['format'] = 'pirepsjson';
185
+			//$last_exec['pirepsjson'] = 0;
186
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
+			//$formats[$id] = 'fr24json';
189
+			$globalSources[$id]['format'] = 'fr24json';
190
+			//$last_exec['fr24json'] = 0;
191
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
+				exit(0);
195
+			}
196
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
197
+			//$formats[$id] = 'fr24json';
198
+			$globalSources[$id]['format'] = 'myshiptracking';
199
+			//$last_exec['fr24json'] = 0;
200
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
+				exit(0);
204
+			}
205
+			//} else if (preg_match('/10001/',$host)) {
206
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
+			//$formats[$id] = 'tsv';
208
+			$globalSources[$id]['format'] = 'tsv';
209
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
+			}
211
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
+				if ($idf !== false) {
215
+				$httpfeeds[$id] = $idf;
216
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
+				}
218
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
+		$hostport = explode(':',$host);
222
+		if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
225
-	    } else {
225
+		} else {
226 226
 		$port = $globalSources[$id]['port'];
227 227
 		$hostn = $globalSources[$id]['host'];
228
-	    }
229
-	    $Common = new Common();
230
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
-    	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
-	    }
235
-	    if ($s) {
236
-    	        $sockets[$id] = $s;
237
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
228
+		}
229
+		$Common = new Common();
230
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
+			} else {
233
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
+		}
235
+		if ($s) {
236
+				$sockets[$id] = $s;
237
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245
-    		    } elseif ($port == '10001') {
246
-        		//$formats[$id] = 'tsv';
247
-        		$globalSources[$id]['format'] = 'tsv';
248
-		    } elseif ($port == '30002') {
249
-        		//$formats[$id] = 'raw';
250
-        		$globalSources[$id]['format'] = 'raw';
251
-		    } elseif ($port == '5001') {
252
-        		//$formats[$id] = 'raw';
253
-        		$globalSources[$id]['format'] = 'flightgearmp';
254
-		    } elseif ($port == '30005') {
245
+				} elseif ($port == '10001') {
246
+				//$formats[$id] = 'tsv';
247
+				$globalSources[$id]['format'] = 'tsv';
248
+			} elseif ($port == '30002') {
249
+				//$formats[$id] = 'raw';
250
+				$globalSources[$id]['format'] = 'raw';
251
+			} elseif ($port == '5001') {
252
+				//$formats[$id] = 'raw';
253
+				$globalSources[$id]['format'] = 'flightgearmp';
254
+			} elseif ($port == '30005') {
255 255
 			// Not yet supported
256
-        		//$formats[$id] = 'beast';
257
-        		$globalSources[$id]['format'] = 'beast';
258
-		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
260
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256
+				//$formats[$id] = 'beast';
257
+				$globalSources[$id]['format'] = 'beast';
258
+			//} else $formats[$id] = 'sbs';
259
+			} else $globalSources[$id]['format'] = 'sbs';
260
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 261
 		}
262 262
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
263
-            } else {
263
+			} else {
264 264
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
265
-    	    }
266
-        }
267
-    }
265
+			}
266
+		}
267
+	}
268 268
 }
269 269
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
270 270
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
291 291
 } else {
292
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
292
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
294 294
 
295 295
 // APRS Configuration
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
 	die;
299 299
 }
300 300
 foreach ($globalSources as $key => $source) {
301
-    if (!isset($source['format'])) {
302
-        $globalSources[$key]['format'] = 'auto';
303
-    }
301
+	if (!isset($source['format'])) {
302
+		$globalSources[$key]['format'] = 'auto';
303
+	}
304 304
 }
305 305
 connect_all($globalSources);
306 306
 foreach ($globalSources as $key => $source) {
307
-    if (isset($source['format']) && $source['format'] == 'aprs') {
307
+	if (isset($source['format']) && $source['format'] == 'aprs') {
308 308
 	$aprs_connect = 0;
309 309
 	$use_aprs = true;
310 310
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
311 311
 	break;
312
-    }
312
+	}
313 313
 }
314 314
 
315 315
 if ($use_aprs) {
@@ -350,115 +350,115 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
354
-    // Delete old ATC
355
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
353
+	if (!$globalDaemon) $i = $endtime-time();
354
+	// Delete old ATC
355
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
357
-        $ATC->deleteOldATC();
358
-    }
357
+		$ATC->deleteOldATC();
358
+	}
359 359
     
360
-    if (count($last_exec) == count($globalSources)) {
360
+	if (count($last_exec) == count($globalSources)) {
361 361
 	$max = $globalMinFetch;
362 362
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
363
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
366
+		if ($globalDebug) echo 'Sleeping...'."\n";
367
+		sleep($globalMinFetch-$max+2);
368
+	}
368 369
 	}
369
-    }
370 370
 
371 371
     
372
-    //foreach ($formats as $id => $value) {
373
-    foreach ($globalSources as $id => $value) {
372
+	//foreach ($formats as $id => $value) {
373
+	foreach ($globalSources as $id => $value) {
374 374
 	date_default_timezone_set('UTC');
375 375
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
376 376
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377
-	    //$buffer = $Common->getData($hosts[$id]);
378
-	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
382
-	    foreach ($buffer as $line) {
383
-    		if ($line != '' && count($line) > 7) {
384
-    		    $line = explode(',', $line);
385
-	            $data = array();
386
-	            $data['hex'] = $line[1]; // hex
387
-	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
-	            $data['verticalrate'] = ''; // vertical rate
394
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
-	            $data['emergency'] = ''; // emergency
396
-		    $data['datetime'] = date('Y-m-d H:i:s');
397
-		    $data['format_source'] = 'deltadbtxt';
398
-    		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
-    		    $SI->add($data);
403
-		    unset($data);
404
-    		}
405
-    	    }
406
-    	    $last_exec[$id]['last'] = time();
377
+		//$buffer = $Common->getData($hosts[$id]);
378
+		$buffer = $Common->getData($value['host']);
379
+		if ($buffer != '') $reset = 0;
380
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
+		$buffer = explode('\n',$buffer);
382
+		foreach ($buffer as $line) {
383
+			if ($line != '' && count($line) > 7) {
384
+				$line = explode(',', $line);
385
+				$data = array();
386
+				$data['hex'] = $line[1]; // hex
387
+				$data['ident'] = $line[2]; // ident
388
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
+				$data['verticalrate'] = ''; // vertical rate
394
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
+				$data['emergency'] = ''; // emergency
396
+			$data['datetime'] = date('Y-m-d H:i:s');
397
+			$data['format_source'] = 'deltadbtxt';
398
+				$data['id_source'] = $id_source;
399
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
+				$SI->add($data);
403
+			unset($data);
404
+			}
405
+			}
406
+			$last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408
-	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
-	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
414
-	    foreach ($buffer as $line) {
408
+		date_default_timezone_set('CET');
409
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
+		date_default_timezone_set('UTC');
411
+		if ($buffer != '') $reset = 0;
412
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
+		$buffer = explode('\n',$buffer);
414
+		foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416
-		    //echo "'".$line."'\n";
417
-		    $add = false;
418
-		    $ais_data = $AIS->parse_line(trim($line));
419
-		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
-		    if (isset($ais_data['timestamp'])) {
416
+			//echo "'".$line."'\n";
417
+			$add = false;
418
+			$ais_data = $AIS->parse_line(trim($line));
419
+			$data = array();
420
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
+			if (isset($ais_data['timestamp'])) {
431 431
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
-			    $add = true;
433
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
+				$add = true;
435 435
 			}
436
-		    } else {
436
+			} else {
437 437
 			$data['datetime'] = date('Y-m-d H:i:s');
438 438
 			$add = true;
439
-		    }
440
-		    $data['format_source'] = 'aisnmeatxt';
441
-    		    $data['id_source'] = $id_source;
442
-		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
-		    unset($data);
439
+			}
440
+			$data['format_source'] = 'aisnmeatxt';
441
+				$data['id_source'] = $id_source;
442
+			//print_r($data);
443
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
+			unset($data);
446 446
 		}
447
-    	    }
448
-    	    $last_exec[$id]['last'] = time();
447
+			}
448
+			$last_exec[$id]['last'] = time();
449 449
 	} elseif ($value['format'] == 'aisnmeahttp') {
450
-	    $arr = $httpfeeds;
451
-	    $w = $e = null;
450
+		$arr = $httpfeeds;
451
+		$w = $e = null;
452 452
 	    
453
-	    if (isset($arr[$id])) {
453
+		if (isset($arr[$id])) {
454 454
 		$nn = stream_select($arr,$w,$e,$timeout);
455 455
 		if ($nn > 0) {
456
-		    foreach ($httpfeeds as $feed) {
456
+			foreach ($httpfeeds as $feed) {
457 457
 			$buffer = stream_get_line($feed,2000,"\n");
458 458
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459 459
 			$buffer = explode('\n',$buffer);
460 460
 			foreach ($buffer as $line) {
461
-			    if ($line != '') {
461
+				if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
463 463
 				$data = array();
464 464
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -476,96 +476,96 @@  discard block
 block discarded – undo
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477 477
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 480
 				} else {
481
-				    $data['datetime'] = date('Y-m-d H:i:s');
481
+					$data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
483 483
 				$data['format_source'] = 'aisnmeahttp';
484 484
 				$data['id_source'] = $id_source;
485 485
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486 486
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
487 487
 				unset($data);
488
-			    }
488
+				}
489
+			}
489 490
 			}
490
-		    }
491 491
 		} else {
492
-		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
495
-		    if ($tt[$format] > 30) {
492
+			$format = $value['format'];
493
+			if (isset($tt[$format])) $tt[$format]++;
494
+			else $tt[$format] = 0;
495
+			if ($tt[$format] > 30) {
496 496
 			if ($globalDebug) echo 'Reconnect...'."\n";
497 497
 			sleep(2);
498 498
 			$sourceeen[] = $value;
499 499
 			connect_all($sourceeen);
500 500
 			$sourceeen = array();
501
-		    }
501
+			}
502
+		}
502 503
 		}
503
-	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
506
-	    if ($buffer != '') {
505
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
506
+		if ($buffer != '') {
507 507
 		//echo $buffer;
508 508
 		$all_data = json_decode($buffer,true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511
-		    foreach ($all_data[0]['DATA'] as $line) {
511
+			foreach ($all_data[0]['DATA'] as $line) {
512 512
 			if ($line != '') {
513
-			    $data = array();
514
-			    $data['ident'] = $line['NAME'];
515
-			    $data['mmsi'] = $line['MMSI'];
516
-			    $data['speed'] = $line['SOG'];
517
-			    $data['heading'] = $line['COG'];
518
-			    $data['latitude'] = $line['LAT'];
519
-			    $data['longitude'] = $line['LNG'];
520
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
-			    $data['imo'] = $line['IMO'];
522
-			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
-			    $data['format_source'] = 'myshiptracking';
525
-			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
-			    $MI->add($data);
528
-			    unset($data);
513
+				$data = array();
514
+				$data['ident'] = $line['NAME'];
515
+				$data['mmsi'] = $line['MMSI'];
516
+				$data['speed'] = $line['SOG'];
517
+				$data['heading'] = $line['COG'];
518
+				$data['latitude'] = $line['LAT'];
519
+				$data['longitude'] = $line['LNG'];
520
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
+				$data['imo'] = $line['IMO'];
522
+				//$data['arrival_code'] = $ais_data['destination'];
523
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
+				$data['format_source'] = 'myshiptracking';
525
+				$data['id_source'] = $id_source;
526
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
+				$MI->add($data);
528
+				unset($data);
529
+			}
529 530
 			}
530
-		    }
531 531
 		}
532
-	    }
533
-	    $last_exec[$id]['last'] = time();
532
+		}
533
+		$last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
-	    if ($buffer != '') {
535
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
+		if ($buffer != '') {
537 537
 		$all_data = json_decode($buffer,true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539
-		    foreach ($all_data as $line) {
539
+			foreach ($all_data as $line) {
540 540
 			if ($line != '') {
541
-			    $data = array();
542
-			    $data['ident'] = $line['shipname'];
543
-			    $data['callsign'] = $line['callsign'];
544
-			    $data['mmsi'] = $line['mmsi'];
545
-			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
-			    $data['latitude'] = $line['latitude'];
548
-			    $data['longitude'] = $line['longitude'];
549
-			    $data['type_id'] = $line['shiptype'];
550
-			    $data['arrival_code'] = $line['destination'];
551
-			    $data['datetime'] = $line['time'];
552
-			    $data['format_source'] = 'boatbeaconapp';
553
-			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
-			    $MI->add($data);
556
-			    unset($data);
541
+				$data = array();
542
+				$data['ident'] = $line['shipname'];
543
+				$data['callsign'] = $line['callsign'];
544
+				$data['mmsi'] = $line['mmsi'];
545
+				$data['speed'] = $line['sog'];
546
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
+				$data['latitude'] = $line['latitude'];
548
+				$data['longitude'] = $line['longitude'];
549
+				$data['type_id'] = $line['shiptype'];
550
+				$data['arrival_code'] = $line['destination'];
551
+				$data['datetime'] = $line['time'];
552
+				$data['format_source'] = 'boatbeaconapp';
553
+				$data['id_source'] = $id_source;
554
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
+				$MI->add($data);
556
+				unset($data);
557
+			}
557 558
 			}
558
-		    }
559 559
 		}
560 560
 		
561
-	    }
562
-    	    $last_exec[$id]['last'] = time();
561
+		}
562
+			$last_exec[$id]['last'] = time();
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564
-	    $buffer = $Common->getData($value['host']);
565
-	    if ($buffer != '') {
564
+		$buffer = $Common->getData($value['host']);
565
+		if ($buffer != '') {
566 566
 		$all_data = json_decode($buffer,true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568
-		    foreach ($all_data['features'] as $line) {
568
+			foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
570 570
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571 571
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -584,59 +584,59 @@  discard block
 block discarded – undo
584 584
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585 585
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
586 586
 			unset($data);
587
-		    }
587
+			}
588 588
 		}
589 589
 		
590
-	    }
591
-    	    $last_exec[$id]['last'] = time();
590
+		}
591
+			$last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593
-	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
-	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
599
-	    foreach ($buffer as $line) {
593
+		echo 'download...';
594
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
+		echo 'done !'."\n";
596
+		if ($buffer != '') $reset = 0;
597
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
+		$buffer = explode('\n',$buffer);
599
+		foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601
-		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
-		    //$data['status'] = substr($line,21,2);
605
-		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
609
-		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
611
-		    //$data['draft'] = substr($line,67,4);
612
-		    //$data['length'] = substr($line,72,3);
613
-		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
-		    //$data['callsign'] = trim(substr($line,100,7);
616
-		    //$data['dest'] = substr($line,108,20);
617
-		    //$data['etaDate'] = substr($line,129,5);
618
-		    //$data['etaTime'] = substr($line,135,5);
619
-		    $data['format_source'] = 'shipplotter';
620
-    		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
-		    //print_r($data);
623
-		    echo 'Add...'."\n";
624
-		    $MI->add($data);
625
-		    unset($data);
601
+			$data = array();
602
+			$data['mmsi'] = (int)substr($line,0,9);
603
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
+			//$data['status'] = substr($line,21,2);
605
+			//$data['type'] = substr($line,24,3);
606
+			$data['latitude'] = substr($line,29,9);
607
+			$data['longitude'] = substr($line,41,9);
608
+			$data['speed'] = round(substr($line,51,5));
609
+			//$data['course'] = substr($line,57,5);
610
+			$data['heading'] = round(substr($line,63,3));
611
+			//$data['draft'] = substr($line,67,4);
612
+			//$data['length'] = substr($line,72,3);
613
+			//$data['beam'] = substr($line,76,2);
614
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
+			//$data['callsign'] = trim(substr($line,100,7);
616
+			//$data['dest'] = substr($line,108,20);
617
+			//$data['etaDate'] = substr($line,129,5);
618
+			//$data['etaTime'] = substr($line,135,5);
619
+			$data['format_source'] = 'shipplotter';
620
+				$data['id_source'] = $id_source;
621
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
+			//print_r($data);
623
+			echo 'Add...'."\n";
624
+			$MI->add($data);
625
+			unset($data);
626 626
 		}
627
-    	    }
628
-    	    $last_exec[$id]['last'] = time();
627
+			}
628
+			$last_exec[$id]['last'] = time();
629 629
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
635
-	    $reset = 0;
636
-	    foreach ($buffer as $line) {
637
-    		if ($line != '') {
638
-    		    $line = explode(':', $line);
639
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host']);
633
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
+		$buffer = explode('\n',$buffer);
635
+		$reset = 0;
636
+		foreach ($buffer as $line) {
637
+			if ($line != '') {
638
+				$line = explode(':', $line);
639
+				if (count($line) > 30 && $line[0] != 'callsign') {
640 640
 			$data = array();
641 641
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -649,37 +649,37 @@  discard block
 block discarded – undo
649 649
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650 650
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
651 651
 			$data['latitude'] = $line[5]; // lat
652
-	        	$data['longitude'] = $line[6]; // long
653
-	        	$data['verticalrate'] = ''; // vertical rate
654
-	        	$data['squawk'] = ''; // squawk
655
-	        	$data['emergency'] = ''; // emergency
656
-	        	$data['waypoints'] = $line[30];
652
+				$data['longitude'] = $line[6]; // long
653
+				$data['verticalrate'] = ''; // vertical rate
654
+				$data['squawk'] = ''; // squawk
655
+				$data['emergency'] = ''; // emergency
656
+				$data['waypoints'] = $line[30];
657 657
 			$data['datetime'] = date('Y-m-d H:i:s');
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660
-		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
-		        $data['arrival_airport_icao'] = $line[13];
660
+				$data['departure_airport_icao'] = $line[11];
661
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
+				$data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
665 665
 			$data['range'] = $line[19];
666 666
 			if (isset($line[35])) $data['info'] = $line[35];
667
-    			$data['id_source'] = $id_source;
668
-	    		//$data['arrival_airport_time'] = ;
669
-	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
671
-	    		    if (isset($aircraft_data[1])) {
672
-	    			$data['aircraft_icao'] = $aircraft_data[1];
673
-	    		    }
674
-        		}
675
-	    		/*
667
+				$data['id_source'] = $id_source;
668
+				//$data['arrival_airport_time'] = ;
669
+				if ($line[9] != '') {
670
+					$aircraft_data = explode('/',$line[9]);
671
+					if (isset($aircraft_data[1])) {
672
+					$data['aircraft_icao'] = $aircraft_data[1];
673
+					}
674
+				}
675
+				/*
676 676
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
677 677
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 678
 	    		*/
679
-	    		$data['format_source'] = $value['format'];
679
+				$data['format_source'] = $value['format'];
680 680
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681 681
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
682
+				if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685 685
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -700,16 +700,16 @@  discard block
 block discarded – undo
700 700
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
701 701
 				}
702 702
 			}
703
-    			unset($data);
704
-    		    }
705
-    		}
706
-    	    }
707
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
-    	    $last_exec[$id]['last'] = time();
710
-    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
-	    if ($buffer != '') {
703
+				unset($data);
704
+				}
705
+			}
706
+			}
707
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
+			$last_exec[$id]['last'] = time();
710
+		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
+		if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714 714
 		foreach($all_data->children() as $childdata) {
715 715
 			$data = array();
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 			$SI->add($data);
732 732
 			unset($data);
733 733
 		}
734
-	    }
735
-	    $Source->deleteOldLocationByType('gs');
736
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
737
-	    if ($buffer != '') {
734
+		}
735
+		$Source->deleteOldLocationByType('gs');
736
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
737
+		if ($buffer != '') {
738 738
 		$all_data = simplexml_load_string($buffer);
739 739
 		foreach($all_data->children() as $childdata) {
740 740
 			$data = array();
@@ -752,249 +752,249 @@  discard block
 block discarded – undo
752 752
 			}
753 753
 			unset($data);
754 754
 		}
755
-	    }
756
-	    $last_exec[$id]['last'] = time();
755
+		}
756
+		$last_exec[$id]['last'] = time();
757 757
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
758
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
759
-	    if ($buffer != '') {
760
-	    $all_data = json_decode($buffer,true);
761
-	    if (isset($all_data['acList'])) {
758
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
759
+		if ($buffer != '') {
760
+		$all_data = json_decode($buffer,true);
761
+		if (isset($all_data['acList'])) {
762 762
 		$reset = 0;
763 763
 		foreach ($all_data['acList'] as $line) {
764
-		    $data = array();
765
-		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
772
-		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
774
-		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
764
+			$data = array();
765
+			$data['hex'] = $line['Icao']; // hex
766
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
772
+			//$data['verticalrate'] = $line['']; // verticale rate
773
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
774
+			$data['emergency'] = ''; // emergency
775
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
776 776
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
777
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
+			else $data['datetime'] = date('Y-m-d H:i:s');
779 779
 		    
780
-		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
782
-	    	    $data['format_source'] = 'aircraftlistjson';
783
-		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
787
-		    unset($data);
780
+			//$data['datetime'] = date('Y-m-d H:i:s');
781
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
782
+				$data['format_source'] = 'aircraftlistjson';
783
+			$data['id_source'] = $id_source;
784
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
+			if (isset($data['latitude'])) $SI->add($data);
787
+			unset($data);
788 788
 		}
789
-	    } elseif (is_array($all_data)) {
789
+		} elseif (is_array($all_data)) {
790 790
 		$reset = 0;
791 791
 		foreach ($all_data as $line) {
792
-		    $data = array();
793
-		    $data['hex'] = $line['hex']; // hex
794
-		    $data['ident'] = $line['flight']; // ident
795
-		    $data['altitude'] = $line['altitude']; // altitude
796
-		    $data['speed'] = $line['speed']; // speed
797
-		    $data['heading'] = $line['track']; // heading
798
-		    $data['latitude'] = $line['lat']; // lat
799
-		    $data['longitude'] = $line['lon']; // long
800
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
801
-		    $data['squawk'] = $line['squawk']; // squawk
802
-		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
805
-	    	    $data['format_source'] = 'aircraftlistjson';
806
-    		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
809
-		    $SI->add($data);
810
-		    unset($data);
792
+			$data = array();
793
+			$data['hex'] = $line['hex']; // hex
794
+			$data['ident'] = $line['flight']; // ident
795
+			$data['altitude'] = $line['altitude']; // altitude
796
+			$data['speed'] = $line['speed']; // speed
797
+			$data['heading'] = $line['track']; // heading
798
+			$data['latitude'] = $line['lat']; // lat
799
+			$data['longitude'] = $line['lon']; // long
800
+			$data['verticalrate'] = $line['vrt']; // verticale rate
801
+			$data['squawk'] = $line['squawk']; // squawk
802
+			$data['emergency'] = ''; // emergency
803
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
+			else $data['datetime'] = date('Y-m-d H:i:s');
805
+				$data['format_source'] = 'aircraftlistjson';
806
+				$data['id_source'] = $id_source;
807
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
809
+			$SI->add($data);
810
+			unset($data);
811
+		}
811 812
 		}
812
-	    }
813
-	    }
814
-    	    //$last_exec['aircraftlistjson'] = time();
815
-    	    $last_exec[$id]['last'] = time();
816
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818
-	    $buffer = $Common->getData($value['host']);
819
-	    $all_data = json_decode($buffer,true);
820
-	    if (isset($all_data['planes'])) {
813
+		}
814
+			//$last_exec['aircraftlistjson'] = time();
815
+			$last_exec[$id]['last'] = time();
816
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818
+		$buffer = $Common->getData($value['host']);
819
+		$all_data = json_decode($buffer,true);
820
+		if (isset($all_data['planes'])) {
821 821
 		$reset = 0;
822 822
 		foreach ($all_data['planes'] as $key => $line) {
823
-		    $data = array();
824
-		    $data['hex'] = $key; // hex
825
-		    $data['ident'] = $line[3]; // ident
826
-		    $data['altitude'] = $line[6]; // altitude
827
-		    $data['speed'] = $line[8]; // speed
828
-		    $data['heading'] = $line[7]; // heading
829
-		    $data['latitude'] = $line[4]; // lat
830
-		    $data['longitude'] = $line[5]; // long
831
-		    //$data['verticalrate'] = $line[]; // verticale rate
832
-		    $data['squawk'] = $line[10]; // squawk
833
-		    $data['emergency'] = ''; // emergency
834
-		    $data['registration'] = $line[2];
835
-		    $data['aircraft_icao'] = $line[0];
836
-		    $deparr = explode('-',$line[1]);
837
-		    if (count($deparr) == 2) {
823
+			$data = array();
824
+			$data['hex'] = $key; // hex
825
+			$data['ident'] = $line[3]; // ident
826
+			$data['altitude'] = $line[6]; // altitude
827
+			$data['speed'] = $line[8]; // speed
828
+			$data['heading'] = $line[7]; // heading
829
+			$data['latitude'] = $line[4]; // lat
830
+			$data['longitude'] = $line[5]; // long
831
+			//$data['verticalrate'] = $line[]; // verticale rate
832
+			$data['squawk'] = $line[10]; // squawk
833
+			$data['emergency'] = ''; // emergency
834
+			$data['registration'] = $line[2];
835
+			$data['aircraft_icao'] = $line[0];
836
+			$deparr = explode('-',$line[1]);
837
+			if (count($deparr) == 2) {
838 838
 			$data['departure_airport_icao'] = $deparr[0];
839 839
 			$data['arrival_airport_icao'] = $deparr[1];
840
-		    }
841
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842
-	    	    $data['format_source'] = 'planeupdatefaa';
843
-    		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
846
-		    $SI->add($data);
847
-		    unset($data);
840
+			}
841
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842
+				$data['format_source'] = 'planeupdatefaa';
843
+				$data['id_source'] = $id_source;
844
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
846
+			$SI->add($data);
847
+			unset($data);
848 848
 		}
849
-	    }
850
-    	    //$last_exec['planeupdatefaa'] = time();
851
-    	    $last_exec[$id]['last'] = time();
852
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853
-	    $buffer = $Common->getData($value['host']);
854
-	    $all_data = json_decode($buffer,true);
855
-	    if (isset($all_data['states'])) {
849
+		}
850
+			//$last_exec['planeupdatefaa'] = time();
851
+			$last_exec[$id]['last'] = time();
852
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853
+		$buffer = $Common->getData($value['host']);
854
+		$all_data = json_decode($buffer,true);
855
+		if (isset($all_data['states'])) {
856 856
 		$reset = 0;
857 857
 		foreach ($all_data['states'] as $key => $line) {
858
-		    $data = array();
859
-		    $data['hex'] = $line[0]; // hex
860
-		    $data['ident'] = trim($line[1]); // ident
861
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
862
-		    $data['speed'] = round($line[9]*1.94384); // speed
863
-		    $data['heading'] = round($line[10]); // heading
864
-		    $data['latitude'] = $line[6]; // lat
865
-		    $data['longitude'] = $line[5]; // long
866
-		    $data['verticalrate'] = $line[11]; // verticale rate
867
-		    //$data['squawk'] = $line[10]; // squawk
868
-		    //$data['emergency'] = ''; // emergency
869
-		    //$data['registration'] = $line[2];
870
-		    //$data['aircraft_icao'] = $line[0];
871
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872
-	    	    $data['format_source'] = 'opensky';
873
-    		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
-		    $SI->add($data);
876
-		    unset($data);
858
+			$data = array();
859
+			$data['hex'] = $line[0]; // hex
860
+			$data['ident'] = trim($line[1]); // ident
861
+			$data['altitude'] = round($line[7]*3.28084); // altitude
862
+			$data['speed'] = round($line[9]*1.94384); // speed
863
+			$data['heading'] = round($line[10]); // heading
864
+			$data['latitude'] = $line[6]; // lat
865
+			$data['longitude'] = $line[5]; // long
866
+			$data['verticalrate'] = $line[11]; // verticale rate
867
+			//$data['squawk'] = $line[10]; // squawk
868
+			//$data['emergency'] = ''; // emergency
869
+			//$data['registration'] = $line[2];
870
+			//$data['aircraft_icao'] = $line[0];
871
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872
+				$data['format_source'] = 'opensky';
873
+				$data['id_source'] = $id_source;
874
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
+			$SI->add($data);
876
+			unset($data);
877
+		}
877 878
 		}
878
-	    }
879
-    	    //$last_exec['planeupdatefaa'] = time();
880
-    	    $last_exec[$id]['last'] = time();
881
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
882
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883
-	    //$buffer = $Common->getData($hosts[$id]);
884
-	    $buffer = $Common->getData($value['host']);
885
-	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
887
-	    foreach ($all_data as $key => $line) {
879
+			//$last_exec['planeupdatefaa'] = time();
880
+			$last_exec[$id]['last'] = time();
881
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
882
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883
+		//$buffer = $Common->getData($hosts[$id]);
884
+		$buffer = $Common->getData($value['host']);
885
+		$all_data = json_decode($buffer,true);
886
+		if (!empty($all_data)) $reset = 0;
887
+		foreach ($all_data as $key => $line) {
888 888
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889
-		    $data = array();
890
-		    $data['hex'] = $line[0];
891
-		    $data['ident'] = $line[16]; //$line[13]
892
-	    	    $data['altitude'] = $line[4]; // altitude
893
-	    	    $data['speed'] = $line[5]; // speed
894
-	    	    $data['heading'] = $line[3]; // heading
895
-	    	    $data['latitude'] = $line[1]; // lat
896
-	    	    $data['longitude'] = $line[2]; // long
897
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
898
-	    	    $data['squawk'] = $line[6]; // squawk
899
-	    	    $data['aircraft_icao'] = $line[8];
900
-	    	    $data['registration'] = $line[9];
901
-		    $data['departure_airport_iata'] = $line[11];
902
-		    $data['arrival_airport_iata'] = $line[12];
903
-	    	    $data['emergency'] = ''; // emergency
904
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905
-	    	    $data['format_source'] = 'fr24json';
906
-    		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
-		    $SI->add($data);
910
-		    unset($data);
889
+			$data = array();
890
+			$data['hex'] = $line[0];
891
+			$data['ident'] = $line[16]; //$line[13]
892
+				$data['altitude'] = $line[4]; // altitude
893
+				$data['speed'] = $line[5]; // speed
894
+				$data['heading'] = $line[3]; // heading
895
+				$data['latitude'] = $line[1]; // lat
896
+				$data['longitude'] = $line[2]; // long
897
+				$data['verticalrate'] = $line[15]; // verticale rate
898
+				$data['squawk'] = $line[6]; // squawk
899
+				$data['aircraft_icao'] = $line[8];
900
+				$data['registration'] = $line[9];
901
+			$data['departure_airport_iata'] = $line[11];
902
+			$data['arrival_airport_iata'] = $line[12];
903
+				$data['emergency'] = ''; // emergency
904
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905
+				$data['format_source'] = 'fr24json';
906
+				$data['id_source'] = $id_source;
907
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
+			$SI->add($data);
910
+			unset($data);
911 911
 		}
912
-	    }
913
-    	    //$last_exec['fr24json'] = time();
914
-    	    $last_exec[$id]['last'] = time();
915
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
919
-	    //echo $buffer;
920
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
921
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
-	    $all_data = json_decode($buffer,true);
923
-	    if (json_last_error() != JSON_ERROR_NONE) {
912
+		}
913
+			//$last_exec['fr24json'] = time();
914
+			$last_exec[$id]['last'] = time();
915
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
919
+		//echo $buffer;
920
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
921
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
+		$all_data = json_decode($buffer,true);
923
+		if (json_last_error() != JSON_ERROR_NONE) {
924 924
 		die(json_last_error_msg());
925
-	    }
926
-	    if (isset($all_data['mrkrs'])) {
925
+		}
926
+		if (isset($all_data['mrkrs'])) {
927 927
 		$reset = 0;
928 928
 		foreach ($all_data['mrkrs'] as $key => $line) {
929
-		    if (isset($line['inf'])) {
929
+			if (isset($line['inf'])) {
930 930
 			$data = array();
931 931
 			$data['hex'] = $line['inf']['ia'];
932 932
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
933
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
936
-	    		$data['latitude'] = $line['pt'][0]; // lat
937
-	    		$data['longitude'] = $line['pt'][1]; // long
938
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
940
-	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
933
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
936
+				$data['latitude'] = $line['pt'][0]; // lat
937
+				$data['longitude'] = $line['pt'][1]; // long
938
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
940
+				//$data['aircraft_icao'] = $line[8];
941
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
942 942
 			//$data['departure_airport_iata'] = $line[11];
943 943
 			//$data['arrival_airport_iata'] = $line[12];
944
-	    		//$data['emergency'] = ''; // emergency
944
+				//$data['emergency'] = ''; // emergency
945 945
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946
-	    		$data['format_source'] = 'radarvirtueljson';
947
-    			$data['id_source'] = $id_source;
946
+				$data['format_source'] = 'radarvirtueljson';
947
+				$data['id_source'] = $id_source;
948 948
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949 949
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
950 950
 			$SI->add($data);
951 951
 			unset($data);
952
-		    }
952
+			}
953
+		}
953 954
 		}
954
-	    }
955
-    	    //$last_exec['radarvirtueljson'] = time();
956
-    	    $last_exec[$id]['last'] = time();
957
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
958
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
-	    //$buffer = $Common->getData($hosts[$id]);
960
-	    $buffer = $Common->getData($value['host'].'?'.time());
961
-	    $all_data = json_decode(utf8_encode($buffer),true);
955
+			//$last_exec['radarvirtueljson'] = time();
956
+			$last_exec[$id]['last'] = time();
957
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
958
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
+		//$buffer = $Common->getData($hosts[$id]);
960
+		$buffer = $Common->getData($value['host'].'?'.time());
961
+		$all_data = json_decode(utf8_encode($buffer),true);
962 962
 	    
963
-	    if (isset($all_data['pireps'])) {
963
+		if (isset($all_data['pireps'])) {
964 964
 		$reset = 0;
965
-	        foreach ($all_data['pireps'] as $line) {
966
-		    $data = array();
967
-		    $data['id'] = $line['id'];
968
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969
-		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
-		    $data['latitude'] = $line['lat']; // lat
977
-		    $data['longitude'] = $line['lon']; // long
978
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979
-		    //$data['squawk'] = $line['squawk']; // squawk
980
-		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
984
-		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
989
-		    $data['format_source'] = 'pireps';
990
-    		    $data['id_source'] = $id_source;
991
-		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
-		    if ($line['icon'] == 'plane') {
965
+			foreach ($all_data['pireps'] as $line) {
966
+			$data = array();
967
+			$data['id'] = $line['id'];
968
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969
+			$data['ident'] = $line['callsign']; // ident
970
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
+			$data['latitude'] = $line['lat']; // lat
977
+			$data['longitude'] = $line['lon']; // long
978
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
979
+			//$data['squawk'] = $line['squawk']; // squawk
980
+			//$data['emergency'] = ''; // emergency
981
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
984
+			//$data['arrival_airport_time'] = $line['arrtime'];
985
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
988
+			else $data['info'] = '';
989
+			$data['format_source'] = 'pireps';
990
+				$data['id_source'] = $id_source;
991
+			$data['datetime'] = date('Y-m-d H:i:s');
992
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
+			if ($line['icon'] == 'plane') {
995 995
 			$SI->add($data);
996
-		    //    print_r($data);
997
-    		    } elseif ($line['icon'] == 'ct') {
996
+			//    print_r($data);
997
+				} elseif ($line['icon'] == 'ct') {
998 998
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999 999
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1000
 			$typec = substr($data['ident'],-3);
@@ -1009,203 +1009,203 @@  discard block
 block discarded – undo
1009 1009
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010 1010
 			else $data['type'] = 'Observer';
1011 1011
 			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']);
1012
-		    }
1013
-		    unset($data);
1012
+			}
1013
+			unset($data);
1014
+		}
1014 1015
 		}
1015
-	    }
1016
-    	    //$last_exec['pirepsjson'] = time();
1017
-    	    $last_exec[$id]['last'] = time();
1018
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020
-	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1022
-	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1024
-	    if ($buffer != '' && is_array($all_data)) {
1016
+			//$last_exec['pirepsjson'] = time();
1017
+			$last_exec[$id]['last'] = time();
1018
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020
+		//$buffer = $Common->getData($hosts[$id]);
1021
+		if ($globalDebug) echo 'Get Data...'."\n";
1022
+		$buffer = $Common->getData($value['host']);
1023
+		$all_data = json_decode($buffer,true);
1024
+		if ($buffer != '' && is_array($all_data)) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data as $line) {
1027
-	    	    $data = array();
1028
-	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033
-	    	    $data['ident'] = $line['flightnum']; // ident
1034
-	    	    $data['altitude'] = $line['alt']; // altitude
1035
-	    	    $data['speed'] = $line['gs']; // speed
1036
-	    	    $data['heading'] = $line['heading']; // heading
1037
-	    	    $data['latitude'] = $line['lat']; // lat
1038
-	    	    $data['longitude'] = $line['lng']; // long
1039
-	    	    $data['verticalrate'] = ''; // verticale rate
1040
-	    	    $data['squawk'] = ''; // squawk
1041
-	    	    $data['emergency'] = ''; // emergency
1042
-	    	    //$data['datetime'] = $line['lastupdate'];
1043
-	    	    //$data['last_update'] = $line['lastupdate'];
1044
-	    	    if (isset($value['timezone'])) {
1045
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1049
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1050
-	    	    $data['departure_airport_time'] = $line['deptime'];
1051
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1053
-    		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056
-		    if (isset($line['aircraftname'])) {
1027
+				$data = array();
1028
+				//$data['id'] = $line['id']; // id not usable
1029
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033
+				$data['ident'] = $line['flightnum']; // ident
1034
+				$data['altitude'] = $line['alt']; // altitude
1035
+				$data['speed'] = $line['gs']; // speed
1036
+				$data['heading'] = $line['heading']; // heading
1037
+				$data['latitude'] = $line['lat']; // lat
1038
+				$data['longitude'] = $line['lng']; // long
1039
+				$data['verticalrate'] = ''; // verticale rate
1040
+				$data['squawk'] = ''; // squawk
1041
+				$data['emergency'] = ''; // emergency
1042
+				//$data['datetime'] = $line['lastupdate'];
1043
+				//$data['last_update'] = $line['lastupdate'];
1044
+				if (isset($value['timezone'])) {
1045
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1047
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1049
+				$data['departure_airport_icao'] = $line['depicao'];
1050
+				$data['departure_airport_time'] = $line['deptime'];
1051
+				$data['arrival_airport_icao'] = $line['arricao'];
1052
+				$data['arrival_airport_time'] = $line['arrtime'];
1053
+				$data['registration'] = $line['aircraft'];
1054
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056
+			if (isset($line['aircraftname'])) {
1057 1057
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1058
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1063
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
-	    		}
1067
-	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1069
-    		    $data['id_source'] = $id_source;
1070
-	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1072
-		    $SI->add($data);
1073
-		    unset($data);
1059
+				$aircraft_data = explode('-',$line['aircraftname']);
1060
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
+				else {
1063
+					$aircraft_data = explode(' ',$line['aircraftname']);
1064
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
+				}
1067
+				}
1068
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1069
+				$data['id_source'] = $id_source;
1070
+				$data['format_source'] = 'phpvmacars';
1071
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1072
+			$SI->add($data);
1073
+			unset($data);
1074 1074
 		}
1075 1075
 		if ($globalDebug) echo 'No more data...'."\n";
1076 1076
 		unset($buffer);
1077 1077
 		unset($all_data);
1078
-	    }
1079
-    	    //$last_exec['phpvmacars'] = time();
1080
-    	    $last_exec[$id]['last'] = time();
1081
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082
-	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1084
-	    $buffer = $Common->getData($value['host']);
1085
-	    $all_data = json_decode($buffer,true);
1086
-	    if ($buffer != '' && is_array($all_data)) {
1078
+		}
1079
+			//$last_exec['phpvmacars'] = time();
1080
+			$last_exec[$id]['last'] = time();
1081
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082
+		//$buffer = $Common->getData($hosts[$id]);
1083
+		if ($globalDebug) echo 'Get Data...'."\n";
1084
+		$buffer = $Common->getData($value['host']);
1085
+		$all_data = json_decode($buffer,true);
1086
+		if ($buffer != '' && is_array($all_data)) {
1087 1087
 		$reset = 0;
1088 1088
 		foreach ($all_data as $line) {
1089
-	    	    $data = array();
1090
-	    	    //$data['id'] = $line['id']; // id not usable
1091
-	    	    $data['id'] = trim($line['flight_id']);
1092
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1093
-	    	    $data['pilot_name'] = $line['pilot_name'];
1094
-	    	    $data['pilot_id'] = $line['pilot_id'];
1095
-	    	    $data['ident'] = trim($line['callsign']); // ident
1096
-	    	    $data['altitude'] = $line['altitude']; // altitude
1097
-	    	    $data['speed'] = $line['gs']; // speed
1098
-	    	    $data['heading'] = $line['heading']; // heading
1099
-	    	    $data['latitude'] = $line['latitude']; // lat
1100
-	    	    $data['longitude'] = $line['longitude']; // long
1101
-	    	    $data['verticalrate'] = ''; // verticale rate
1102
-	    	    $data['squawk'] = ''; // squawk
1103
-	    	    $data['emergency'] = ''; // emergency
1104
-	    	    //$data['datetime'] = $line['lastupdate'];
1105
-	    	    $data['last_update'] = $line['last_update'];
1106
-		    $data['datetime'] = date('Y-m-d H:i:s');
1107
-	    	    $data['departure_airport_icao'] = $line['departure'];
1108
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1109
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111
-    		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1113
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1114
-    		    $data['id_source'] = $id_source;
1115
-	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1118
-		    $SI->add($data);
1119
-		    unset($data);
1089
+				$data = array();
1090
+				//$data['id'] = $line['id']; // id not usable
1091
+				$data['id'] = trim($line['flight_id']);
1092
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1093
+				$data['pilot_name'] = $line['pilot_name'];
1094
+				$data['pilot_id'] = $line['pilot_id'];
1095
+				$data['ident'] = trim($line['callsign']); // ident
1096
+				$data['altitude'] = $line['altitude']; // altitude
1097
+				$data['speed'] = $line['gs']; // speed
1098
+				$data['heading'] = $line['heading']; // heading
1099
+				$data['latitude'] = $line['latitude']; // lat
1100
+				$data['longitude'] = $line['longitude']; // long
1101
+				$data['verticalrate'] = ''; // verticale rate
1102
+				$data['squawk'] = ''; // squawk
1103
+				$data['emergency'] = ''; // emergency
1104
+				//$data['datetime'] = $line['lastupdate'];
1105
+				$data['last_update'] = $line['last_update'];
1106
+			$data['datetime'] = date('Y-m-d H:i:s');
1107
+				$data['departure_airport_icao'] = $line['departure'];
1108
+				//$data['departure_airport_time'] = $line['departure_time'];
1109
+				$data['arrival_airport_icao'] = $line['arrival'];
1110
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1111
+				//$data['registration'] = $line['aircraft'];
1112
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1113
+				$data['aircraft_icao'] = $line['plane_type'];
1114
+				$data['id_source'] = $id_source;
1115
+				$data['format_source'] = 'vam';
1116
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1118
+			$SI->add($data);
1119
+			unset($data);
1120 1120
 		}
1121 1121
 		if ($globalDebug) echo 'No more data...'."\n";
1122 1122
 		unset($buffer);
1123 1123
 		unset($all_data);
1124
-	    }
1125
-    	    //$last_exec['phpvmacars'] = time();
1126
-    	    $last_exec[$id]['last'] = time();
1124
+		}
1125
+			//$last_exec['phpvmacars'] = time();
1126
+			$last_exec[$id]['last'] = time();
1127 1127
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1128
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1130
-    	    //$last_exec[$id]['last'] = time();
1129
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1130
+			//$last_exec[$id]['last'] = time();
1131 1131
 
1132
-	    //$read = array( $sockets[$id] );
1133
-	    $read = $sockets;
1134
-	    $write = NULL;
1135
-	    $e = NULL;
1136
-	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1138
-	    if ($n > 0) {
1132
+		//$read = array( $sockets[$id] );
1133
+		$read = $sockets;
1134
+		$write = NULL;
1135
+		$e = NULL;
1136
+		$n = socket_select($read, $write, $e, $timeout);
1137
+		if ($e != NULL) var_dump($e);
1138
+		if ($n > 0) {
1139 1139
 		$reset = 0;
1140 1140
 		foreach ($read as $nb => $r) {
1141
-		    //$value = $formats[$nb];
1142
-		    $format = $globalSources[$nb]['format'];
1143
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1141
+			//$value = $formats[$nb];
1142
+			$format = $globalSources[$nb]['format'];
1143
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144 1144
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1145
-		    } elseif ($format == 'vrstcp') {
1145
+			} elseif ($format == 'vrstcp') {
1146 1146
 			$buffer = @socket_read($r, 6000);
1147
-		    } else {
1147
+			} else {
1148 1148
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1149
-		    }
1150
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151
-		    //echo $buffer."\n";
1152
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1153
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1154
-		    $error = false;
1155
-		    //$SI::del();
1156
-		    if ($format == 'vrstcp') {
1149
+			}
1150
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151
+			//echo $buffer."\n";
1152
+			// lets play nice and handle signals such as ctrl-c/kill properly
1153
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1154
+			$error = false;
1155
+			//$SI::del();
1156
+			if ($format == 'vrstcp') {
1157 1157
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1159
-		    // SBS format is CSV format
1160
-		    if ($buffer !== FALSE && $buffer != '') {
1158
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1159
+			// SBS format is CSV format
1160
+			if ($buffer !== FALSE && $buffer != '') {
1161 1161
 			$tt[$format] = 0;
1162 1162
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1164
-			    $ACARS->add(trim($buffer));
1165
-			    $ACARS->deleteLiveAcarsData();
1163
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1164
+				$ACARS->add(trim($buffer));
1165
+				$ACARS->deleteLiveAcarsData();
1166 1166
 			} elseif ($format == 'raw') {
1167
-			    // AVR format
1168
-			    $data = $SBS->parse($buffer);
1169
-			    if (is_array($data)) {
1167
+				// AVR format
1168
+				$data = $SBS->parse($buffer);
1169
+				if (is_array($data)) {
1170 1170
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1171
 				$data['format_source'] = 'raw';
1172 1172
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173 1173
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174 1174
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175 1175
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1176
-			    }
1176
+				}
1177 1177
 			} elseif ($format == 'ais') {
1178
-			    $ais_data = $AIS->parse_line(trim($buffer));
1179
-			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1178
+				$ais_data = $AIS->parse_line(trim($buffer));
1179
+				$data = array();
1180
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196 1196
 
1197
-			    if (isset($ais_data['timestamp'])) {
1197
+				if (isset($ais_data['timestamp'])) {
1198 1198
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1199
-			    } else {
1199
+				} else {
1200 1200
 				$data['datetime'] = date('Y-m-d H:i:s');
1201
-			    }
1202
-			    $data['format_source'] = 'aisnmea';
1203
-    			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1205
-			    unset($data);
1206
-                        } elseif ($format == 'flightgearsp') {
1207
-                    	    //echo $buffer."\n";
1208
-                    	    if (strlen($buffer) > 5) {
1201
+				}
1202
+				$data['format_source'] = 'aisnmea';
1203
+					$data['id_source'] = $id_source;
1204
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1205
+				unset($data);
1206
+						} elseif ($format == 'flightgearsp') {
1207
+							//echo $buffer."\n";
1208
+							if (strlen($buffer) > 5) {
1209 1209
 				$line = explode(',',$buffer);
1210 1210
 				$data = array();
1211 1211
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1222,38 +1222,38 @@  discard block
 block discarded – undo
1222 1222
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223 1223
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1224 1224
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225
-			    }
1226
-                        } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228
-			    $ACARS->add(trim($buffer));
1229
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230
-			    $ACARS->deleteLiveAcarsData();
1225
+				}
1226
+						} elseif ($format == 'acars') {
1227
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228
+				$ACARS->add(trim($buffer));
1229
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230
+				$ACARS->deleteLiveAcarsData();
1231 1231
 			} elseif ($format == 'flightgearmp') {
1232
-			    if (substr($buffer,0,1) != '#') {
1232
+				if (substr($buffer,0,1) != '#') {
1233 1233
 				$data = array();
1234 1234
 				//echo $buffer."\n";
1235 1235
 				$line = explode(' ',$buffer);
1236 1236
 				if (count($line) == 11) {
1237
-				    $userserver = explode('@',$line[0]);
1238
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1239
-				    $data['ident'] = $userserver[0];
1240
-				    $data['registration'] = $userserver[0];
1241
-				    $data['latitude'] = $line[4];
1242
-				    $data['longitude'] = $line[5];
1243
-				    $data['altitude'] = $line[6];
1244
-				    $data['datetime'] = date('Y-m-d H:i:s');
1245
-				    $aircraft_type = $line[10];
1246
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1237
+					$userserver = explode('@',$line[0]);
1238
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1239
+					$data['ident'] = $userserver[0];
1240
+					$data['registration'] = $userserver[0];
1241
+					$data['latitude'] = $line[4];
1242
+					$data['longitude'] = $line[5];
1243
+					$data['altitude'] = $line[6];
1244
+					$data['datetime'] = date('Y-m-d H:i:s');
1245
+					$aircraft_type = $line[10];
1246
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1247
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1250
+				}
1250 1251
 				}
1251
-			    }
1252 1252
 			} elseif ($format == 'beast') {
1253
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254
-			    die;
1253
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254
+				die;
1255 1255
 			} elseif ($format == 'vrstcp') {
1256
-			    foreach($buffer as $all_data) {
1256
+				foreach($buffer as $all_data) {
1257 1257
 				$line = json_decode('{'.$all_data.'}',true);
1258 1258
 				$data = array();
1259 1259
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1273,116 +1273,116 @@  discard block
 block discarded – undo
1273 1273
 				*/
1274 1274
 				$data['datetime'] = date('Y-m-d H:i:s');
1275 1275
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1276
-		    		$data['format_source'] = 'vrstcp';
1276
+					$data['format_source'] = 'vrstcp';
1277 1277
 				$data['id_source'] = $id_source;
1278 1278
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279 1279
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280 1280
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1281 1281
 				unset($data);
1282
-			    }
1282
+				}
1283 1283
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1284
-			    $line = explode("\t", $buffer);
1285
-			    for($k = 0; $k < count($line); $k=$k+2) {
1284
+				$line = explode("\t", $buffer);
1285
+				for($k = 0; $k < count($line); $k=$k+2) {
1286 1286
 				$key = $line[$k];
1287
-			        $lined[$key] = $line[$k+1];
1288
-			    }
1289
-    			    if (count($lined) > 3) {
1290
-    				$data['hex'] = $lined['hexid'];
1291
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1300
-    				$data['id_source'] = $id_source;
1301
-    				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1287
+					$lined[$key] = $line[$k+1];
1288
+				}
1289
+					if (count($lined) > 3) {
1290
+					$data['hex'] = $lined['hexid'];
1291
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
+					$data['datetime'] = date('Y-m-d H:i:s');;
1293
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1300
+					$data['id_source'] = $id_source;
1301
+					$data['format_source'] = 'tsv';
1302
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304 1304
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1306
-    				unset($lined);
1307
-    				unset($data);
1308
-    			    } else $error = true;
1305
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1306
+					unset($lined);
1307
+					unset($data);
1308
+					} else $error = true;
1309 1309
 			} elseif ($format == 'aprs' && $use_aprs) {
1310
-			    if ($aprs_connect == 0) {
1310
+				if ($aprs_connect == 0) {
1311 1311
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1312 1312
 				$aprs_connect = 1;
1313
-			    }
1313
+				}
1314 1314
 			    
1315
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1315
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1316 1316
 				$aprs_last_tx = time();
1317 1317
 				$data_aprs = "# Keep alive";
1318 1318
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1319
-			    }
1319
+				}
1320 1320
 			    
1321
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322
-			    //echo 'APRS data : '.$buffer."\n";
1323
-			    $buffer = str_replace('APRS <- ','',$buffer);
1324
-			    $buffer = str_replace('APRS -> ','',$buffer);
1325
-			    //echo $buffer."\n";
1326
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1321
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322
+				//echo 'APRS data : '.$buffer."\n";
1323
+				$buffer = str_replace('APRS <- ','',$buffer);
1324
+				$buffer = str_replace('APRS -> ','',$buffer);
1325
+				//echo $buffer."\n";
1326
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1327 1327
 				$line = $APRS->parse($buffer);
1328 1328
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1329 1329
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1330
-				    $aprs_last_tx = time();
1331
-				    $data = array();
1332
-				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1343
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1345
-				    $data['latitude'] = $line['latitude'];
1346
-				    $data['longitude'] = $line['longitude'];
1347
-				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1349
-				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1354
-				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1356
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1361
-    				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1364
-				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
-				    $currentdate = date('Y-m-d H:i:s');
1369
-				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1371
-				    // Accept data if time <= system time + 20s
1372
-				    //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'])))) {
1373
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1330
+					$aprs_last_tx = time();
1331
+					$data = array();
1332
+					//print_r($line);
1333
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1334
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
+					else $data['datetime'] = date('Y-m-d H:i:s');
1343
+					//$data['datetime'] = date('Y-m-d H:i:s');
1344
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1345
+					$data['latitude'] = $line['latitude'];
1346
+					$data['longitude'] = $line['longitude'];
1347
+					//$data['verticalrate'] = $line[16];
1348
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1349
+					//else $data['speed'] = 0;
1350
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1354
+					//else $data['heading'] = 0;
1355
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1356
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1361
+						$data['id_source'] = $id_source;
1362
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
+					else $data['format_source'] = 'aprs';
1364
+					$data['source_name'] = $line['source'];
1365
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
+					else $data['source_type'] = 'flarm';
1367
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
+					$currentdate = date('Y-m-d H:i:s');
1369
+					$aprsdate = strtotime($data['datetime']);
1370
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1371
+					// Accept data if time <= system time + 20s
1372
+					//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'])))) {
1373
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1374
 					$send = $SI->add($data);
1375
-				    } elseif ($data['source_type'] == 'ais') {
1375
+					} elseif ($data['source_type'] == 'ais') {
1376 1376
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1377
-				    } elseif (isset($line['stealth'])) {
1377
+					} elseif (isset($line['stealth'])) {
1378 1378
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379 1379
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1380
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381
-				    //} 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') {
1382
-				    } 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') {
1380
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381
+					//} 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') {
1382
+					} 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') {
1383 1383
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1384 1384
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1385
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1385
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1386 1386
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1387 1387
 					$Source->deleteOldLocationByType('gs');
1388 1388
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
@@ -1390,11 +1390,11 @@  discard block
 block discarded – undo
1390 1390
 					} else {
1391 1391
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1392 1392
 					}
1393
-				    } else {
1394
-				    	echo '/!\ Not added: '.$buffer."\n";
1395
-				    	print_r($line);
1396
-				    }
1397
-				    unset($data);
1393
+					} else {
1394
+						echo '/!\ Not added: '.$buffer."\n";
1395
+						print_r($line);
1396
+					}
1397
+					unset($data);
1398 1398
 				} 
1399 1399
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1400 1400
 					echo '!! Weather Station not yet supported'."\n";
@@ -1410,12 +1410,12 @@  discard block
 block discarded – undo
1410 1410
 				*/
1411 1411
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1412 1412
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1413
-			    }
1413
+				}
1414 1414
 			} else {
1415
-			    $line = explode(',', $buffer);
1416
-    			    if (count($line) > 20) {
1417
-    			    	$data['hex'] = $line[4];
1418
-    				/*
1415
+				$line = explode(',', $buffer);
1416
+					if (count($line) > 20) {
1417
+						$data['hex'] = $line[4];
1418
+					/*
1419 1419
     				$data['datetime'] = $line[6].' '.$line[7];
1420 1420
     					date_default_timezone_set($globalTimezone);
1421 1421
     					$datetime = new DateTime($data['datetime']);
@@ -1423,30 +1423,30 @@  discard block
 block discarded – undo
1423 1423
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1424 1424
     					date_default_timezone_set('UTC');
1425 1425
     				*/
1426
-    				// Force datetime to current UTC datetime
1427
-    				date_default_timezone_set('UTC');
1428
-    				$data['datetime'] = date('Y-m-d H:i:s');
1429
-    				$data['ident'] = trim($line[10]);
1430
-    				$data['latitude'] = $line[14];
1431
-    				$data['longitude'] = $line[15];
1432
-    				$data['verticalrate'] = $line[16];
1433
-    				$data['emergency'] = $line[20];
1434
-    				$data['speed'] = $line[12];
1435
-    				$data['squawk'] = $line[17];
1436
-    				$data['altitude'] = $line[11];
1437
-    				$data['heading'] = $line[13];
1438
-    				$data['ground'] = $line[21];
1439
-    				$data['emergency'] = $line[19];
1440
-    				$data['format_source'] = 'sbs';
1426
+					// Force datetime to current UTC datetime
1427
+					date_default_timezone_set('UTC');
1428
+					$data['datetime'] = date('Y-m-d H:i:s');
1429
+					$data['ident'] = trim($line[10]);
1430
+					$data['latitude'] = $line[14];
1431
+					$data['longitude'] = $line[15];
1432
+					$data['verticalrate'] = $line[16];
1433
+					$data['emergency'] = $line[20];
1434
+					$data['speed'] = $line[12];
1435
+					$data['squawk'] = $line[17];
1436
+					$data['altitude'] = $line[11];
1437
+					$data['heading'] = $line[13];
1438
+					$data['ground'] = $line[21];
1439
+					$data['emergency'] = $line[19];
1440
+					$data['format_source'] = 'sbs';
1441 1441
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1442
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1443 1443
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1444
-    				$data['id_source'] = $id_source;
1445
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
-    				else $error = true;
1447
-    				unset($data);
1448
-    			    } else $error = true;
1449
-			    if ($error) {
1444
+					$data['id_source'] = $id_source;
1445
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
+					else $error = true;
1447
+					unset($data);
1448
+					} else $error = true;
1449
+				if ($error) {
1450 1450
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1451 1451
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1452 1452
 				} else {
@@ -1462,13 +1462,13 @@  discard block
 block discarded – undo
1462 1462
 					connect_all($sourceer);
1463 1463
 					$sourceer = array();
1464 1464
 				}
1465
-			    }
1465
+				}
1466 1466
 			}
1467 1467
 			// Sleep for xxx microseconds
1468 1468
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1469
-		    } else {
1469
+			} else {
1470 1470
 			if ($format == 'flightgearmp') {
1471
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1471
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1472 1472
 				//@socket_close($r);
1473 1473
 				sleep($globalMinFetch);
1474 1474
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1477,9 +1477,9 @@  discard block
 block discarded – undo
1477 1477
 				break;
1478 1478
 				
1479 1479
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1480
-			    if (isset($tt[$format])) $tt[$format]++;
1481
-			    else $tt[$format] = 0;
1482
-			    if ($tt[$format] > 30) {
1480
+				if (isset($tt[$format])) $tt[$format]++;
1481
+				else $tt[$format] = 0;
1482
+				if ($tt[$format] > 30) {
1483 1483
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1484 1484
 				//@socket_close($r);
1485 1485
 				sleep(2);
@@ -1490,23 +1490,23 @@  discard block
 block discarded – undo
1490 1490
 				//connect_all($globalSources);
1491 1491
 				$tt[$format]=0;
1492 1492
 				break;
1493
-			    }
1493
+				}
1494
+			}
1494 1495
 			}
1495
-		    }
1496 1496
 		}
1497
-	    } else {
1497
+		} else {
1498 1498
 		$error = socket_strerror(socket_last_error());
1499 1499
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1500 1500
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1501 1501
 			if (isset($globalDebug)) echo "Restarting...\n";
1502 1502
 			// Restart the script if possible
1503 1503
 			if (is_array($sockets)) {
1504
-			    if ($globalDebug) echo "Shutdown all sockets...";
1504
+				if ($globalDebug) echo "Shutdown all sockets...";
1505 1505
 			    
1506
-			    foreach ($sockets as $sock) {
1506
+				foreach ($sockets as $sock) {
1507 1507
 				@socket_shutdown($sock,2);
1508 1508
 				@socket_close($sock);
1509
-			    }
1509
+				}
1510 1510
 			    
1511 1511
 			}
1512 1512
 			if ($globalDebug) echo "Waiting...";
@@ -1521,13 +1521,13 @@  discard block
 block discarded – undo
1521 1521
 			if ($globalDebug) echo "Restart all connections...";
1522 1522
 			connect_all($globalSources);
1523 1523
 		}
1524
-	    }
1524
+		}
1525 1525
 	}
1526 1526
 	if ($globalDaemon === false) {
1527
-	    if ($globalDebug) echo 'Check all...'."\n";
1528
-	    $SI->checkAll();
1527
+		if ($globalDebug) echo 'Check all...'."\n";
1528
+		$SI->checkAll();
1529
+	}
1529 1530
 	}
1530
-    }
1531 1531
 }
1532 1532
 
1533 1533
 ?>
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	    die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
50 50
     }
51 51
 }
52 52
 
53
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57 57
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
59 59
     else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78 78
     if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
79
+    $SI = new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
83 83
     $SI->connect();
84 84
 */
85
-} else $SI=new SpotterImport($Connection->db);
85
+} else $SI = new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88 88
     $AIS = new AIS();
89 89
     $MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92
-$SBS=new SBS();
93
-$ACARS=new ACARS($Connection->db);
94
-$Source=new Source($Connection->db);
95
-$Common=new Common();
92
+$SBS = new SBS();
93
+$ACARS = new ACARS($Connection->db);
94
+$Source = new Source($Connection->db);
95
+$Common = new Common();
96 96
 date_default_timezone_set('UTC');
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
100
+    pcntl_signal(SIGINT, function() {
101 101
         global $sockets;
102 102
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103 103
         die("Bye!\n");
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
116
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
156
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
157 157
         	//$formats[$id] = 'planeupdatefaa';
158 158
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 159
         	//$last_exec['planeupdatefaa'] = 0;
@@ -162,29 +162,29 @@  discard block
 block discarded – undo
162 162
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 163
         	    exit(0);
164 164
         	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
165
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'phpvmacars';
168 168
         	//$last_exec['phpvmacars'] = 0;
169 169
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
170
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
171 171
         	//$formats[$id] = 'phpvmacars';
172 172
         	$globalSources[$id]['format'] = 'vam';
173 173
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
174
+            } else if (preg_match('/whazzup/i', $host)) {
175 175
         	//$formats[$id] = 'whazzup';
176 176
         	$globalSources[$id]['format'] = 'whazzup';
177 177
         	//$last_exec['whazzup'] = 0;
178 178
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
179
+            } else if (preg_match('/airwhere/i', $host)) {
180 180
         	$globalSources[$id]['format'] = 'airwhere';
181 181
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
182
+            } else if (preg_match('/recentpireps/i', $host)) {
183 183
         	//$formats[$id] = 'pirepsjson';
184 184
         	$globalSources[$id]['format'] = 'pirepsjson';
185 185
         	//$last_exec['pirepsjson'] = 0;
186 186
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
187
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
188 188
         	//$formats[$id] = 'fr24json';
189 189
         	$globalSources[$id]['format'] = 'fr24json';
190 190
         	//$last_exec['fr24json'] = 0;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 194
         	    exit(0);
195 195
         	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
196
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
197 197
         	//$formats[$id] = 'fr24json';
198 198
         	$globalSources[$id]['format'] = 'myshiptracking';
199 199
         	//$last_exec['fr24json'] = 0;
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
         	    exit(0);
204 204
         	}
205 205
             //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
206
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 207
         	//$formats[$id] = 'tsv';
208 208
         	$globalSources[$id]['format'] = 'tsv';
209 209
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210 210
             }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
211
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
212 212
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
213
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
214 214
     		    if ($idf !== false) {
215 215
     			$httpfeeds[$id] = $idf;
216 216
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217 217
     		    }
218 218
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219 219
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
220
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
221
+	    $hostport = explode(':', $host);
222 222
 	    if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 	    }
229 229
 	    $Common = new Common();
230 230
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
231
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
232 232
     	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
233
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
234 234
 	    }
235 235
 	    if ($s) {
236 236
     	        $sockets[$id] = $s;
237 237
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
238
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245 245
     		    } elseif ($port == '10001') {
246 246
         		//$formats[$id] = 'tsv';
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280 280
 else $timeout = 20;
281 281
 $errno = '';
282
-$errstr='';
282
+$errstr = '';
283 283
 
284 284
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 /* Initiate connections to all the hosts simultaneously */
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
291 291
 } else {
292 292
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 
315 315
 if ($use_aprs) {
316 316
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
317
-	$APRS=new APRS();
317
+	$APRS = new APRS();
318 318
 	$aprs_connect = 0;
319 319
 	$aprs_keep = 120;
320 320
 	$aprs_last_tx = time();
321 321
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
322
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
323 323
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
324
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
325 325
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
326
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327 327
 	if ($aprs_full) $aprs_filter = '';
328 328
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329 329
 	else $aprs_pass = '-1';
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
 sleep(1);
338 338
 if ($globalDebug) echo "SCAN MODE \n\n";
339 339
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
340
-$endtime = time()+$globalCronEnd;
340
+$endtime = time() + $globalCronEnd;
341 341
 $i = 1;
342 342
 $tt = array();
343 343
 // Delete all ATC
344 344
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
345
-	$ATC=new ATC($Connection->db);
345
+	$ATC = new ATC($Connection->db);
346 346
 }
347 347
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	$ATC->deleteAll();
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
353
+    if (!$globalDaemon) $i = $endtime - time();
354 354
     // Delete old ATC
355 355
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366 366
 	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
367
+	    sleep($globalMinFetch - $max + 2);
368 368
 	}
369 369
     }
370 370
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	    //$buffer = $Common->getData($hosts[$id]);
378 378
 	    $buffer = $Common->getData($value['host']);
379 379
 	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
380
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
381
+	    $buffer = explode('\n', $buffer);
382 382
 	    foreach ($buffer as $line) {
383 383
     		if ($line != '' && count($line) > 7) {
384 384
     		    $line = explode(',', $line);
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
     	    $last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408 408
 	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
409
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
410 410
 	    date_default_timezone_set('UTC');
411 411
 	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
412
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
413
+	    $buffer = explode('\n', $buffer);
414 414
 	    foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416 416
 		    //echo "'".$line."'\n";
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429 429
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430 430
 		    if (isset($ais_data['timestamp'])) {
431
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
431
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433 433
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434 434
 			    $add = true;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 	    $w = $e = null;
452 452
 	    
453 453
 	    if (isset($arr[$id])) {
454
-		$nn = stream_select($arr,$w,$e,$timeout);
454
+		$nn = stream_select($arr, $w, $e, $timeout);
455 455
 		if ($nn > 0) {
456 456
 		    foreach ($httpfeeds as $feed) {
457
-			$buffer = stream_get_line($feed,2000,"\n");
458
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459
-			$buffer = explode('\n',$buffer);
457
+			$buffer = stream_get_line($feed, 2000, "\n");
458
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
459
+			$buffer = explode('\n', $buffer);
460 460
 			foreach ($buffer as $line) {
461 461
 			    if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475 475
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
477
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
480 480
 				} else {
481 481
 				    $data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
505
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
506 506
 	    if ($buffer != '') {
507 507
 		//echo $buffer;
508
-		$all_data = json_decode($buffer,true);
508
+		$all_data = json_decode($buffer, true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511 511
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521 521
 			    $data['imo'] = $line['IMO'];
522 522
 			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
523
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
524 524
 			    $data['format_source'] = 'myshiptracking';
525 525
 			    $data['id_source'] = $id_source;
526 526
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	    }
533 533
 	    $last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
536 536
 	    if ($buffer != '') {
537
-		$all_data = json_decode($buffer,true);
537
+		$all_data = json_decode($buffer, true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539 539
 		    foreach ($all_data as $line) {
540 540
 			if ($line != '') {
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564 564
 	    $buffer = $Common->getData($value['host']);
565 565
 	    if ($buffer != '') {
566
-		$all_data = json_decode($buffer,true);
566
+		$all_data = json_decode($buffer, true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568 568
 		    foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
@@ -591,27 +591,27 @@  discard block
 block discarded – undo
591 591
     	    $last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593 593
 	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
594
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
595 595
 	    echo 'done !'."\n";
596 596
 	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
597
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
598
+	    $buffer = explode('\n', $buffer);
599 599
 	    foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601 601
 		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
602
+		    $data['mmsi'] = (int) substr($line, 0, 9);
603
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
604 604
 		    //$data['status'] = substr($line,21,2);
605 605
 		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
606
+		    $data['latitude'] = substr($line, 29, 9);
607
+		    $data['longitude'] = substr($line, 41, 9);
608
+		    $data['speed'] = round(substr($line, 51, 5));
609 609
 		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
610
+		    $data['heading'] = round(substr($line, 63, 3));
611 611
 		    //$data['draft'] = substr($line,67,4);
612 612
 		    //$data['length'] = substr($line,72,3);
613 613
 		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
614
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
615 615
 		    //$data['callsign'] = trim(substr($line,100,7);
616 616
 		    //$data['dest'] = substr($line,108,20);
617 617
 		    //$data['etaDate'] = substr($line,129,5);
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631 631
 	    //$buffer = $Common->getData($hosts[$id]);
632 632
 	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
633
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
634
+	    $buffer = explode('\n', $buffer);
635 635
 	    $reset = 0;
636 636
 	    foreach ($buffer as $line) {
637 637
     		if ($line != '') {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
643 643
 			$data['pilot_id'] = $line[1];
644 644
 			$data['pilot_name'] = $line[2];
645
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
645
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
646 646
 			$data['ident'] = $line[0]; // ident
647 647
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
648 648
 			$data['speed'] = $line[8]; // speed
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660 660
 		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
661
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
662 662
 		        $data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     			$data['id_source'] = $id_source;
668 668
 	    		//$data['arrival_airport_time'] = ;
669 669
 	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
670
+	    		    $aircraft_data = explode('/', $line[9]);
671 671
 	    		    if (isset($aircraft_data[1])) {
672 672
 	    			$data['aircraft_icao'] = $aircraft_data[1];
673 673
 	    		    }
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
     			if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687
-				$typec = substr($data['ident'],-3);
685
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
686
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
687
+				$typec = substr($data['ident'], -3);
688 688
 				if ($typec == 'APP') $data['type'] = 'Approach';
689 689
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690 690
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
697 697
 				if (!isset($data['source_name'])) $data['source_name'] = '';
698 698
 				if (isset($ATC)) {
699
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
700
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
699
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
700
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
701 701
 				}
702 702
 			}
703 703
     			unset($data);
@@ -708,24 +708,24 @@  discard block
 block discarded – undo
708 708
     	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709 709
     	    $last_exec[$id]['last'] = time();
710 710
     	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
711
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
712 712
 	    if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714
-		foreach($all_data->children() as $childdata) {
714
+		foreach ($all_data->children() as $childdata) {
715 715
 			$data = array();
716 716
 			$line = $childdata;
717 717
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
718
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
719
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720
-			$data['latitude'] = (float)$line['pktLatitude'];
721
-			$data['longitude'] = (float)$line['pktLongitude'];
722
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
723
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
724
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
718
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
719
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
720
+			$data['latitude'] = (float) $line['pktLatitude'];
721
+			$data['longitude'] = (float) $line['pktLongitude'];
722
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
723
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
724
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
725 725
 			$data['altitude_relative'] = 'AMSL';
726
-			$data['pilot_id'] = (int)$line['pktPilotID'];
726
+			$data['pilot_id'] = (int) $line['pktPilotID'];
727 727
 			$data['aircraft_icao'] = 'PARAGLIDER';
728
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
728
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729 729
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
730 730
 			$data['format_source'] = $value['format'];
731 731
 			$SI->add($data);
@@ -733,31 +733,31 @@  discard block
 block discarded – undo
733 733
 		}
734 734
 	    }
735 735
 	    $Source->deleteOldLocationByType('gs');
736
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
736
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
737 737
 	    if ($buffer != '') {
738 738
 		$all_data = simplexml_load_string($buffer);
739
-		foreach($all_data->children() as $childdata) {
739
+		foreach ($all_data->children() as $childdata) {
740 740
 			$data = array();
741 741
 			$line = $childdata;
742
-			$data['id'] = (int)$line['gsID'];
743
-			$data['latitude'] = (float)$line['gsLatitude'];
744
-			$data['longitude'] = (float)$line['gsLongitude'];
745
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
742
+			$data['id'] = (int) $line['gsID'];
743
+			$data['latitude'] = (float) $line['gsLatitude'];
744
+			$data['longitude'] = (float) $line['gsLongitude'];
745
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
746 746
 			$data['altitude_relative'] = 'AMSL';
747
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
747
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
748 748
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
749
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
749
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
750 750
 			} else {
751
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
751
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
752 752
 			}
753 753
 			unset($data);
754 754
 		}
755 755
 	    }
756 756
 	    $last_exec[$id]['last'] = time();
757 757
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
758
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
758
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
759 759
 	    if ($buffer != '') {
760
-	    $all_data = json_decode($buffer,true);
760
+	    $all_data = json_decode($buffer, true);
761 761
 	    if (isset($all_data['acList'])) {
762 762
 		$reset = 0;
763 763
 		foreach ($all_data['acList'] as $line) {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		    $data['emergency'] = ''; // emergency
775 775
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
776 776
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
777
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
778 778
 		    else $data['datetime'] = date('Y-m-d H:i:s');
779 779
 		    
780 780
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 801
 		    $data['squawk'] = $line['squawk']; // squawk
802 802
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
803
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
804 804
 		    else $data['datetime'] = date('Y-m-d H:i:s');
805 805
 	    	    $data['format_source'] = 'aircraftlistjson';
806 806
     		    $data['id_source'] = $id_source;
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817 817
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818 818
 	    $buffer = $Common->getData($value['host']);
819
-	    $all_data = json_decode($buffer,true);
819
+	    $all_data = json_decode($buffer, true);
820 820
 	    if (isset($all_data['planes'])) {
821 821
 		$reset = 0;
822 822
 		foreach ($all_data['planes'] as $key => $line) {
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
 		    $data['emergency'] = ''; // emergency
834 834
 		    $data['registration'] = $line[2];
835 835
 		    $data['aircraft_icao'] = $line[0];
836
-		    $deparr = explode('-',$line[1]);
836
+		    $deparr = explode('-', $line[1]);
837 837
 		    if (count($deparr) == 2) {
838 838
 			$data['departure_airport_icao'] = $deparr[0];
839 839
 			$data['arrival_airport_icao'] = $deparr[1];
840 840
 		    }
841
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
841
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
842 842
 	    	    $data['format_source'] = 'planeupdatefaa';
843 843
     		    $data['id_source'] = $id_source;
844 844
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     	    $last_exec[$id]['last'] = time();
852 852
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853 853
 	    $buffer = $Common->getData($value['host']);
854
-	    $all_data = json_decode($buffer,true);
854
+	    $all_data = json_decode($buffer, true);
855 855
 	    if (isset($all_data['states'])) {
856 856
 		$reset = 0;
857 857
 		foreach ($all_data['states'] as $key => $line) {
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 		    //$data['emergency'] = ''; // emergency
869 869
 		    //$data['registration'] = $line[2];
870 870
 		    //$data['aircraft_icao'] = $line[0];
871
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
871
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
872 872
 	    	    $data['format_source'] = 'opensky';
873 873
     		    $data['id_source'] = $id_source;
874 874
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883 883
 	    //$buffer = $Common->getData($hosts[$id]);
884 884
 	    $buffer = $Common->getData($value['host']);
885
-	    $all_data = json_decode($buffer,true);
885
+	    $all_data = json_decode($buffer, true);
886 886
 	    if (!empty($all_data)) $reset = 0;
887 887
 	    foreach ($all_data as $key => $line) {
888 888
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -915,11 +915,11 @@  discard block
 block discarded – undo
915 915
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916 916
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917 917
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
918
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
919 919
 	    //echo $buffer;
920
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
921
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
-	    $all_data = json_decode($buffer,true);
920
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
921
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
922
+	    $all_data = json_decode($buffer, true);
923 923
 	    if (json_last_error() != JSON_ERROR_NONE) {
924 924
 		die(json_last_error_msg());
925 925
 	    }
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			//$data['departure_airport_iata'] = $line[11];
943 943
 			//$data['arrival_airport_iata'] = $line[12];
944 944
 	    		//$data['emergency'] = ''; // emergency
945
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
945
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
946 946
 	    		$data['format_source'] = 'radarvirtueljson';
947 947
     			$data['id_source'] = $id_source;
948 948
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -958,14 +958,14 @@  discard block
 block discarded – undo
958 958
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959 959
 	    //$buffer = $Common->getData($hosts[$id]);
960 960
 	    $buffer = $Common->getData($value['host'].'?'.time());
961
-	    $all_data = json_decode(utf8_encode($buffer),true);
961
+	    $all_data = json_decode(utf8_encode($buffer), true);
962 962
 	    
963 963
 	    if (isset($all_data['pireps'])) {
964 964
 		$reset = 0;
965 965
 	        foreach ($all_data['pireps'] as $line) {
966 966
 		    $data = array();
967 967
 		    $data['id'] = $line['id'];
968
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
968
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
969 969
 		    $data['ident'] = $line['callsign']; // ident
970 970
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971 971
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -995,9 +995,9 @@  discard block
 block discarded – undo
995 995
 			$SI->add($data);
996 996
 		    //    print_r($data);
997 997
     		    } elseif ($line['icon'] == 'ct') {
998
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000
-			$typec = substr($data['ident'],-3);
998
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
999
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1000
+			$typec = substr($data['ident'], -3);
1001 1001
 			$data['type'] = '';
1002 1002
 			if ($typec == 'APP') $data['type'] = 'Approach';
1003 1003
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009 1009
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010 1010
 			else $data['type'] = 'Observer';
1011
-			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']);
1011
+			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']);
1012 1012
 		    }
1013 1013
 		    unset($data);
1014 1014
 		}
@@ -1020,14 +1020,14 @@  discard block
 block discarded – undo
1020 1020
 	    //$buffer = $Common->getData($hosts[$id]);
1021 1021
 	    if ($globalDebug) echo 'Get Data...'."\n";
1022 1022
 	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1023
+	    $all_data = json_decode($buffer, true);
1024 1024
 	    if ($buffer != '' && is_array($all_data)) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data as $line) {
1027 1027
 	    	    $data = array();
1028 1028
 	    	    //$data['id'] = $line['id']; // id not usable
1029 1029
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1030
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1031 1031
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032 1032
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033 1033
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 	    	    //$data['datetime'] = $line['lastupdate'];
1043 1043
 	    	    //$data['last_update'] = $line['lastupdate'];
1044 1044
 	    	    if (isset($value['timezone'])) {
1045
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1045
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1046 1046
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1047
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048 1048
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1055,14 +1055,14 @@  discard block
 block discarded – undo
1055 1055
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056 1056
 		    if (isset($line['aircraftname'])) {
1057 1057
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1058
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1059
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1060 1060
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061 1061
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062 1062
 	    		else {
1063
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1063
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1064
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1065
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1066 1066
 	    		}
1067 1067
 	    	    }
1068 1068
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1082,14 +1082,14 @@  discard block
 block discarded – undo
1082 1082
 	    //$buffer = $Common->getData($hosts[$id]);
1083 1083
 	    if ($globalDebug) echo 'Get Data...'."\n";
1084 1084
 	    $buffer = $Common->getData($value['host']);
1085
-	    $all_data = json_decode($buffer,true);
1085
+	    $all_data = json_decode($buffer, true);
1086 1086
 	    if ($buffer != '' && is_array($all_data)) {
1087 1087
 		$reset = 0;
1088 1088
 		foreach ($all_data as $line) {
1089 1089
 	    	    $data = array();
1090 1090
 	    	    //$data['id'] = $line['id']; // id not usable
1091 1091
 	    	    $data['id'] = trim($line['flight_id']);
1092
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1092
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1093 1093
 	    	    $data['pilot_name'] = $line['pilot_name'];
1094 1094
 	    	    $data['pilot_id'] = $line['pilot_id'];
1095 1095
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
 		    //$value = $formats[$nb];
1142 1142
 		    $format = $globalSources[$nb]['format'];
1143 1143
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1144
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1145 1145
 		    } elseif ($format == 'vrstcp') {
1146 1146
 			$buffer = @socket_read($r, 6000);
1147 1147
 		    } else {
1148
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1148
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1149 1149
 		    }
1150 1150
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151 1151
 		    //echo $buffer."\n";
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 		    $error = false;
1155 1155
 		    //$SI::del();
1156 1156
 		    if ($format == 'vrstcp') {
1157
-			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1157
+			$buffer = explode('},{', $buffer);
1158
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1159 1159
 		    // SBS format is CSV format
1160 1160
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1161
 			$tt[$format] = 0;
@@ -1189,13 +1189,13 @@  discard block
 block discarded – undo
1189 1189
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190 1190
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191 1191
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1192
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1193 1193
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194 1194
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195 1195
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196 1196
 
1197 1197
 			    if (isset($ais_data['timestamp'])) {
1198
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1198
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1199 1199
 			    } else {
1200 1200
 				$data['datetime'] = date('Y-m-d H:i:s');
1201 1201
 			    }
@@ -1206,10 +1206,10 @@  discard block
 block discarded – undo
1206 1206
                         } elseif ($format == 'flightgearsp') {
1207 1207
                     	    //echo $buffer."\n";
1208 1208
                     	    if (strlen($buffer) > 5) {
1209
-				$line = explode(',',$buffer);
1209
+				$line = explode(',', $buffer);
1210 1210
 				$data = array();
1211 1211
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1212
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1212
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1213 1213
 				$data['ident'] = $line[6];
1214 1214
 				$data['aircraft_name'] = $line[7];
1215 1215
 				$data['longitude'] = $line[1];
@@ -1226,16 +1226,16 @@  discard block
 block discarded – undo
1226 1226
                         } elseif ($format == 'acars') {
1227 1227
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228 1228
 			    $ACARS->add(trim($buffer));
1229
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1229
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1230 1230
 			    $ACARS->deleteLiveAcarsData();
1231 1231
 			} elseif ($format == 'flightgearmp') {
1232
-			    if (substr($buffer,0,1) != '#') {
1232
+			    if (substr($buffer, 0, 1) != '#') {
1233 1233
 				$data = array();
1234 1234
 				//echo $buffer."\n";
1235
-				$line = explode(' ',$buffer);
1235
+				$line = explode(' ', $buffer);
1236 1236
 				if (count($line) == 11) {
1237
-				    $userserver = explode('@',$line[0]);
1238
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1237
+				    $userserver = explode('@', $line[0]);
1238
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1239 1239
 				    $data['ident'] = $userserver[0];
1240 1240
 				    $data['registration'] = $userserver[0];
1241 1241
 				    $data['latitude'] = $line[4];
@@ -1243,8 +1243,8 @@  discard block
 block discarded – undo
1243 1243
 				    $data['altitude'] = $line[6];
1244 1244
 				    $data['datetime'] = date('Y-m-d H:i:s');
1245 1245
 				    $aircraft_type = $line[10];
1246
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1246
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1247
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1248 1248
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249 1249
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1250 1250
 				}
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254 1254
 			    die;
1255 1255
 			} elseif ($format == 'vrstcp') {
1256
-			    foreach($buffer as $all_data) {
1257
-				$line = json_decode('{'.$all_data.'}',true);
1256
+			    foreach ($buffer as $all_data) {
1257
+				$line = json_decode('{'.$all_data.'}', true);
1258 1258
 				$data = array();
1259 1259
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260 1260
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1280,16 +1280,16 @@  discard block
 block discarded – undo
1280 1280
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1281 1281
 				unset($data);
1282 1282
 			    }
1283
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1283
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1284 1284
 			    $line = explode("\t", $buffer);
1285
-			    for($k = 0; $k < count($line); $k=$k+2) {
1285
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1286 1286
 				$key = $line[$k];
1287
-			        $lined[$key] = $line[$k+1];
1287
+			        $lined[$key] = $line[$k + 1];
1288 1288
 			    }
1289 1289
     			    if (count($lined) > 3) {
1290 1290
     				$data['hex'] = $lined['hexid'];
1291 1291
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1292
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1293 1293
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294 1294
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295 1295
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1308,22 +1308,22 @@  discard block
 block discarded – undo
1308 1308
     			    } else $error = true;
1309 1309
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1310
 			    if ($aprs_connect == 0) {
1311
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1311
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1312 1312
 				$aprs_connect = 1;
1313 1313
 			    }
1314 1314
 			    
1315
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1315
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1316 1316
 				$aprs_last_tx = time();
1317 1317
 				$data_aprs = "# Keep alive";
1318
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1318
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1319 1319
 			    }
1320 1320
 			    
1321 1321
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322 1322
 			    //echo 'APRS data : '.$buffer."\n";
1323
-			    $buffer = str_replace('APRS <- ','',$buffer);
1324
-			    $buffer = str_replace('APRS -> ','',$buffer);
1323
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1324
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1325 1325
 			    //echo $buffer."\n";
1326
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1326
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1327 1327
 				$line = $APRS->parse($buffer);
1328 1328
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1329 1329
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339 1339
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340 1340
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1341
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1342 1342
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1343 1343
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344 1344
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1386,9 +1386,9 @@  discard block
 block discarded – undo
1386 1386
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1387 1387
 					$Source->deleteOldLocationByType('gs');
1388 1388
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1389
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1389
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1390 1390
 					} else {
1391
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1391
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1392 1392
 					}
1393 1393
 				    } else {
1394 1394
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 				}
1402 1402
 				 
1403 1403
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1404
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1404
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1405 1405
 				}
1406 1406
 				/*
1407 1407
 				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')) {
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
 				connect_all($sourceee);
1489 1489
 				$sourceee = array();
1490 1490
 				//connect_all($globalSources);
1491
-				$tt[$format]=0;
1491
+				$tt[$format] = 0;
1492 1492
 				break;
1493 1493
 			    }
1494 1494
 			}
@@ -1497,14 +1497,14 @@  discard block
 block discarded – undo
1497 1497
 	    } else {
1498 1498
 		$error = socket_strerror(socket_last_error());
1499 1499
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1500
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1500
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1501 1501
 			if (isset($globalDebug)) echo "Restarting...\n";
1502 1502
 			// Restart the script if possible
1503 1503
 			if (is_array($sockets)) {
1504 1504
 			    if ($globalDebug) echo "Shutdown all sockets...";
1505 1505
 			    
1506 1506
 			    foreach ($sockets as $sock) {
1507
-				@socket_shutdown($sock,2);
1507
+				@socket_shutdown($sock, 2);
1508 1508
 				@socket_close($sock);
1509 1509
 			    }
1510 1510
 			    
Please login to merge, or discard this patch.
Braces   +993 added lines, -342 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,29 +211,41 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/airwhere/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to airwhere source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/recentpireps/i',$host)) {
183 236
         	//$formats[$id] = 'pirepsjson';
184 237
         	$globalSources[$id]['format'] = 'pirepsjson';
185 238
         	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to pirepsjson source (".$host.")...\n";
241
+        	}
187 242
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188 243
         	//$formats[$id] = 'fr24json';
189 244
         	$globalSources[$id]['format'] = 'fr24json';
190 245
         	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
246
+        	if ($globalDebug) {
247
+        		echo "Connect to fr24 source (".$host.")...\n";
248
+        	}
192 249
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193 250
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 251
         	    exit(0);
@@ -197,7 +254,9 @@  discard block
 block discarded – undo
197 254
         	//$formats[$id] = 'fr24json';
198 255
         	$globalSources[$id]['format'] = 'myshiptracking';
199 256
         	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to myshiptracking source (".$host.")...\n";
259
+        	}
201 260
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202 261
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203 262
         	    exit(0);
@@ -206,17 +265,24 @@  discard block
 block discarded – undo
206 265
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 266
         	//$formats[$id] = 'tsv';
208 267
         	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to tsv source (".$host.")...\n";
270
+        	}
210 271
             }
211 272
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212 273
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213 274
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214 275
     		    if ($idf !== false) {
215 276
     			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+        		if ($globalDebug) {
278
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
279
+        		}
280
+    		    } elseif ($globalDebug) {
281
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
217 282
     		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
283
+    		} elseif ($globalDebug) {
284
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+    		}
220 286
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221 287
 	    $hostport = explode(':',$host);
222 288
 	    if (isset($hostport[1])) {
@@ -256,17 +322,25 @@  discard block
 block discarded – undo
256 322
         		//$formats[$id] = 'beast';
257 323
         		$globalSources[$id]['format'] = 'beast';
258 324
 		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
325
+		    } else {
326
+		    	$globalSources[$id]['format'] = 'sbs';
327
+		    }
260 328
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 329
 		}
262
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
+		if ($globalDebug) {
331
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
332
+		}
263 333
             } else {
264
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
334
+		if ($globalDebug) {
335
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
336
+		}
265 337
     	    }
266 338
         }
267 339
     }
268 340
 }
269
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
341
+if (!isset($globalMinFetch)) {
342
+	$globalMinFetch = 15;
343
+}
270 344
 
271 345
 // Initialize all
272 346
 $status = array();
@@ -275,13 +349,19 @@  discard block
 block discarded – undo
275 349
 $formats = array();
276 350
 $last_exec = array();
277 351
 $time = time();
278
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
279
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280
-else $timeout = 20;
352
+if (isset($globalSourcesTimeout)) {
353
+	$timeout = $globalSourcesTimeOut;
354
+} else if (isset($globalSBS1TimeOut)) {
355
+	$timeout = $globalSBS1TimeOut;
356
+} else {
357
+	$timeout = 20;
358
+}
281 359
 $errno = '';
282 360
 $errstr='';
283 361
 
284
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
362
+if (!isset($globalDaemon)) {
363
+	$globalDaemon = TRUE;
364
+}
285 365
 /* Initiate connections to all the hosts simultaneously */
286 366
 //connect_all($hosts);
287 367
 //connect_all($globalSources);
@@ -307,7 +387,9 @@  discard block
 block discarded – undo
307 387
     if (isset($source['format']) && $source['format'] == 'aprs') {
308 388
 	$aprs_connect = 0;
309 389
 	$use_aprs = true;
310
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
390
+	if (isset($source['port']) && $source['port'] == '10152') {
391
+		$aprs_full = true;
392
+	}
311 393
 	break;
312 394
     }
313 395
 }
@@ -318,25 +400,48 @@  discard block
 block discarded – undo
318 400
 	$aprs_connect = 0;
319 401
 	$aprs_keep = 120;
320 402
 	$aprs_last_tx = time();
321
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
323
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
325
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327
-	if ($aprs_full) $aprs_filter = '';
328
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329
-	else $aprs_pass = '-1';
403
+	if (isset($globalAPRSversion)) {
404
+		$aprs_version = $globalAPRSversion;
405
+	} else {
406
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
407
+	}
408
+	if (isset($globalAPRSssid)) {
409
+		$aprs_ssid = $globalAPRSssid;
410
+	} else {
411
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
412
+	}
413
+	if (isset($globalAPRSfilter)) {
414
+		$aprs_filter = $globalAPRSfilter;
415
+	} else {
416
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
417
+	}
418
+	if ($aprs_full) {
419
+		$aprs_filter = '';
420
+	}
421
+	if (isset($globalAPRSpass)) {
422
+		$aprs_pass = $globalAPRSpass;
423
+	} else {
424
+		$aprs_pass = '-1';
425
+	}
330 426
 
331
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
332
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
333
-}
427
+	if ($aprs_filter != '') {
428
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
429
+	} else {
430
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
431
+	}
432
+	}
334 433
 
335 434
 // connected - lets do some work
336
-if ($globalDebug) echo "Connected!\n";
435
+if ($globalDebug) {
436
+	echo "Connected!\n";
437
+}
337 438
 sleep(1);
338
-if ($globalDebug) echo "SCAN MODE \n\n";
339
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
439
+if ($globalDebug) {
440
+	echo "SCAN MODE \n\n";
441
+}
442
+if (!isset($globalCronEnd)) {
443
+	$globalCronEnd = 60;
444
+}
340 445
 $endtime = time()+$globalCronEnd;
341 446
 $i = 1;
342 447
 $tt = array();
@@ -350,20 +455,28 @@  discard block
 block discarded – undo
350 455
 
351 456
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 457
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
458
+    if (!$globalDaemon) {
459
+    	$i = $endtime-time();
460
+    }
354 461
     // Delete old ATC
355 462
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
463
+	if ($globalDebug) {
464
+		echo 'Delete old ATC...'."\n";
465
+	}
357 466
         $ATC->deleteOldATC();
358 467
     }
359 468
     
360 469
     if (count($last_exec) == count($globalSources)) {
361 470
 	$max = $globalMinFetch;
362 471
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
472
+	    if ((time() - $last['last']) < $max) {
473
+	    	$max = time() - $last['last'];
474
+	    }
364 475
 	}
365 476
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
477
+	    if ($globalDebug) {
478
+	    	echo 'Sleeping...'."\n";
479
+	    }
367 480
 	    sleep($globalMinFetch-$max+2);
368 481
 	}
369 482
     }
@@ -372,11 +485,15 @@  discard block
 block discarded – undo
372 485
     //foreach ($formats as $id => $value) {
373 486
     foreach ($globalSources as $id => $value) {
374 487
 	date_default_timezone_set('UTC');
375
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
488
+	if (!isset($last_exec[$id]['last'])) {
489
+		$last_exec[$id]['last'] = 0;
490
+	}
376 491
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377 492
 	    //$buffer = $Common->getData($hosts[$id]);
378 493
 	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
494
+	    if ($buffer != '') {
495
+	    	$reset = 0;
496
+	    }
380 497
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381 498
 	    $buffer = explode('\n',$buffer);
382 499
 	    foreach ($buffer as $line) {
@@ -385,20 +502,41 @@  discard block
 block discarded – undo
385 502
 	            $data = array();
386 503
 	            $data['hex'] = $line[1]; // hex
387 504
 	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
505
+	            if (isset($line[3])) {
506
+	            	$data['altitude'] = $line[3];
507
+	            }
508
+	            // altitude
509
+	            if (isset($line[4])) {
510
+	            	$data['speed'] = $line[4];
511
+	            }
512
+	            // speed
513
+	            if (isset($line[5])) {
514
+	            	$data['heading'] = $line[5];
515
+	            }
516
+	            // heading
517
+	            if (isset($line[6])) {
518
+	            	$data['latitude'] = $line[6];
519
+	            }
520
+	            // lat
521
+	            if (isset($line[7])) {
522
+	            	$data['longitude'] = $line[7];
523
+	            }
524
+	            // long
393 525
 	            $data['verticalrate'] = ''; // vertical rate
394 526
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395 527
 	            $data['emergency'] = ''; // emergency
396 528
 		    $data['datetime'] = date('Y-m-d H:i:s');
397 529
 		    $data['format_source'] = 'deltadbtxt';
398 530
     		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
531
+		    if (isset($value['name']) && $value['name'] != '') {
532
+		    	$data['source_name'] = $value['name'];
533
+		    }
534
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
535
+		    	$data['noarchive'] = true;
536
+		    }
537
+		    if (isset($value['sourcestats'])) {
538
+		    	$data['sourcestats'] = $value['sourcestats'];
539
+		    }
402 540
     		    $SI->add($data);
403 541
 		    unset($data);
404 542
     		}
@@ -408,7 +546,9 @@  discard block
 block discarded – undo
408 546
 	    date_default_timezone_set('CET');
409 547
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410 548
 	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
549
+	    if ($buffer != '') {
550
+	    	$reset = 0;
551
+	    }
412 552
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413 553
 	    $buffer = explode('\n',$buffer);
414 554
 	    foreach ($buffer as $line) {
@@ -417,16 +557,36 @@  discard block
 block discarded – undo
417 557
 		    $add = false;
418 558
 		    $ais_data = $AIS->parse_line(trim($line));
419 559
 		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
560
+		    if (isset($ais_data['ident'])) {
561
+		    	$data['ident'] = $ais_data['ident'];
562
+		    }
563
+		    if (isset($ais_data['mmsi'])) {
564
+		    	$data['mmsi'] = $ais_data['mmsi'];
565
+		    }
566
+		    if (isset($ais_data['speed'])) {
567
+		    	$data['speed'] = $ais_data['speed'];
568
+		    }
569
+		    if (isset($ais_data['heading'])) {
570
+		    	$data['heading'] = $ais_data['heading'];
571
+		    }
572
+		    if (isset($ais_data['latitude'])) {
573
+		    	$data['latitude'] = $ais_data['latitude'];
574
+		    }
575
+		    if (isset($ais_data['longitude'])) {
576
+		    	$data['longitude'] = $ais_data['longitude'];
577
+		    }
578
+		    if (isset($ais_data['status'])) {
579
+		    	$data['status'] = $ais_data['status'];
580
+		    }
581
+		    if (isset($ais_data['type'])) {
582
+		    	$data['type'] = $ais_data['type'];
583
+		    }
584
+		    if (isset($ais_data['imo'])) {
585
+		    	$data['imo'] = $ais_data['imo'];
586
+		    }
587
+		    if (isset($ais_data['callsign'])) {
588
+		    	$data['callsign'] = $ais_data['callsign'];
589
+		    }
430 590
 		    if (isset($ais_data['timestamp'])) {
431 591
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 592
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -440,8 +600,12 @@  discard block
 block discarded – undo
440 600
 		    $data['format_source'] = 'aisnmeatxt';
441 601
     		    $data['id_source'] = $id_source;
442 602
 		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
603
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
604
+		    	$data['noarchive'] = true;
605
+		    }
606
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
607
+		    	$MI->add($data);
608
+		    }
445 609
 		    unset($data);
446 610
 		}
447 611
     	    }
@@ -461,20 +625,48 @@  discard block
 block discarded – undo
461 625
 			    if ($line != '') {
462 626
 				$ais_data = $AIS->parse_line(trim($line));
463 627
 				$data = array();
464
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
465
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
466
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
467
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
468
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
469
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
470
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
471
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
472
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
473
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
474
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
476
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
628
+				if (isset($ais_data['ident'])) {
629
+					$data['ident'] = $ais_data['ident'];
630
+				}
631
+				if (isset($ais_data['mmsi'])) {
632
+					$data['mmsi'] = $ais_data['mmsi'];
633
+				}
634
+				if (isset($ais_data['speed'])) {
635
+					$data['speed'] = $ais_data['speed'];
636
+				}
637
+				if (isset($ais_data['heading'])) {
638
+					$data['heading'] = $ais_data['heading'];
639
+				}
640
+				if (isset($ais_data['latitude'])) {
641
+					$data['latitude'] = $ais_data['latitude'];
642
+				}
643
+				if (isset($ais_data['longitude'])) {
644
+					$data['longitude'] = $ais_data['longitude'];
645
+				}
646
+				if (isset($ais_data['status'])) {
647
+					$data['status'] = $ais_data['status'];
648
+				}
649
+				if (isset($ais_data['statusid'])) {
650
+					$data['status_id'] = $ais_data['statusid'];
651
+				}
652
+				if (isset($ais_data['type'])) {
653
+					$data['type'] = $ais_data['type'];
654
+				}
655
+				if (isset($ais_data['typeid'])) {
656
+					$data['type_id'] = $ais_data['typeid'];
657
+				}
658
+				if (isset($ais_data['imo'])) {
659
+					$data['imo'] = $ais_data['imo'];
660
+				}
661
+				if (isset($ais_data['callsign'])) {
662
+					$data['callsign'] = $ais_data['callsign'];
663
+				}
664
+				if (isset($ais_data['destination'])) {
665
+					$data['arrival_code'] = $ais_data['destination'];
666
+				}
667
+				if (isset($ais_data['eta_ts'])) {
668
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
669
+				}
478 670
 				if (isset($ais_data['timestamp'])) {
479 671
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 672
 				} else {
@@ -482,18 +674,27 @@  discard block
 block discarded – undo
482 674
 				}
483 675
 				$data['format_source'] = 'aisnmeahttp';
484 676
 				$data['id_source'] = $id_source;
485
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
677
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
678
+					$data['noarchive'] = true;
679
+				}
680
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
681
+					$MI->add($data);
682
+				}
487 683
 				unset($data);
488 684
 			    }
489 685
 			}
490 686
 		    }
491 687
 		} else {
492 688
 		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
689
+		    if (isset($tt[$format])) {
690
+		    	$tt[$format]++;
691
+		    } else {
692
+		    	$tt[$format] = 0;
693
+		    }
495 694
 		    if ($tt[$format] > 30) {
496
-			if ($globalDebug) echo 'Reconnect...'."\n";
695
+			if ($globalDebug) {
696
+				echo 'Reconnect...'."\n";
697
+			}
497 698
 			sleep(2);
498 699
 			$sourceeen[] = $value;
499 700
 			connect_all($sourceeen);
@@ -523,7 +724,9 @@  discard block
 block discarded – undo
523 724
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524 725
 			    $data['format_source'] = 'myshiptracking';
525 726
 			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
728
+			    	$data['noarchive'] = true;
729
+			    }
527 730
 			    $MI->add($data);
528 731
 			    unset($data);
529 732
 			}
@@ -543,7 +746,9 @@  discard block
 block discarded – undo
543 746
 			    $data['callsign'] = $line['callsign'];
544 747
 			    $data['mmsi'] = $line['mmsi'];
545 748
 			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
749
+			    if ($line['heading'] != '511') {
750
+			    	$data['heading'] = $line['heading'];
751
+			    }
547 752
 			    $data['latitude'] = $line['latitude'];
548 753
 			    $data['longitude'] = $line['longitude'];
549 754
 			    $data['type_id'] = $line['shiptype'];
@@ -551,7 +756,9 @@  discard block
 block discarded – undo
551 756
 			    $data['datetime'] = $line['time'];
552 757
 			    $data['format_source'] = 'boatbeaconapp';
553 758
 			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
759
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
760
+			    	$data['noarchive'] = true;
761
+			    }
555 762
 			    $MI->add($data);
556 763
 			    unset($data);
557 764
 			}
@@ -567,22 +774,44 @@  discard block
 block discarded – undo
567 774
 		if (isset($all_data['features'][0]['id'])) {
568 775
 		    foreach ($all_data['features'] as $line) {
569 776
 			$data = array();
570
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
572
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
573
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
574
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
575
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
777
+			if (isset($line['properties']['name'])) {
778
+				$data['ident'] = $line['properties']['name'];
779
+			}
780
+			if (isset($line['properties']['callsign'])) {
781
+				$data['callsign'] = $line['properties']['callsign'];
782
+			}
783
+			if (isset($line['properties']['mmsi'])) {
784
+				$data['mmsi'] = $line['properties']['mmsi'];
785
+			}
786
+			if (isset($line['properties']['imo'])) {
787
+				$data['mmsi'] = $line['properties']['imo'];
788
+			}
789
+			if (isset($line['properties']['speed'])) {
790
+				$data['speed'] = $line['properties']['speed'];
791
+			}
792
+			if (isset($line['properties']['heading'])) {
793
+				$data['heading'] = $line['properties']['heading'];
794
+			}
576 795
 			$data['latitude'] = $line['geometry']['coordinates'][1];
577 796
 			$data['longitude'] = $line['geometry']['coordinates'][0];
578
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
579
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
580
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
797
+			if (isset($line['properties']['vesselType'])) {
798
+				$data['type'] = $line['properties']['vesselType'];
799
+			}
800
+			if (isset($line['properties']['destination'])) {
801
+				$data['arrival_code'] = $line['properties']['destination'];
802
+			}
803
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
804
+				$data['arrival_date'] = $line['properties']['eta'];
805
+			}
581 806
 			$data['format_source'] = 'boatnerd';
582 807
 			$data['id_source'] = $id_source;
583 808
 			$data['datetime'] = date('Y-m-d H:i:s');
584
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
809
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
810
+				$data['noarchive'] = true;
811
+			}
812
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
813
+				$MI->add($data);
814
+			}
586 815
 			unset($data);
587 816
 		    }
588 817
 		}
@@ -593,7 +822,9 @@  discard block
 block discarded – undo
593 822
 	    echo 'download...';
594 823
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595 824
 	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
825
+	    if ($buffer != '') {
826
+	    	$reset = 0;
827
+	    }
597 828
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598 829
 	    $buffer = explode('\n',$buffer);
599 830
 	    foreach ($buffer as $line) {
@@ -618,7 +849,9 @@  discard block
 block discarded – undo
618 849
 		    //$data['etaTime'] = substr($line,135,5);
619 850
 		    $data['format_source'] = 'shipplotter';
620 851
     		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
852
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
853
+		    	$data['noarchive'] = true;
854
+		    }
622 855
 		    //print_r($data);
623 856
 		    echo 'Add...'."\n";
624 857
 		    $MI->add($data);
@@ -638,16 +871,28 @@  discard block
 block discarded – undo
638 871
     		    $line = explode(':', $line);
639 872
     		    if (count($line) > 30 && $line[0] != 'callsign') {
640 873
 			$data = array();
641
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
874
+			if (isset($line[37]) && $line[37] != '') {
875
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
876
+			} else {
877
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
878
+			}
643 879
 			$data['pilot_id'] = $line[1];
644 880
 			$data['pilot_name'] = $line[2];
645 881
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
646 882
 			$data['ident'] = $line[0]; // ident
647
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
883
+			if ($line[7] != '' && $line[7] != 0) {
884
+				$data['altitude'] = $line[7];
885
+			}
886
+			// altitude
648 887
 			$data['speed'] = $line[8]; // speed
649
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
888
+			if (isset($line[45])) {
889
+				$data['heading'] = $line[45];
890
+			}
891
+			// heading
892
+			elseif (isset($line[38])) {
893
+				$data['heading'] = $line[38];
894
+			}
895
+			// heading
651 896
 			$data['latitude'] = $line[5]; // lat
652 897
 	        	$data['longitude'] = $line[6]; // long
653 898
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -663,7 +908,9 @@  discard block
 block discarded – undo
663 908
 			$data['frequency'] = $line[4];
664 909
 			$data['type'] = $line[18];
665 910
 			$data['range'] = $line[19];
666
-			if (isset($line[35])) $data['info'] = $line[35];
911
+			if (isset($line[35])) {
912
+				$data['info'] = $line[35];
913
+			}
667 914
     			$data['id_source'] = $id_source;
668 915
 	    		//$data['arrival_airport_time'] = ;
669 916
 	    		if ($line[9] != '') {
@@ -677,27 +924,47 @@  discard block
 block discarded – undo
677 924
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 925
 	    		*/
679 926
 	    		$data['format_source'] = $value['format'];
680
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
683
-			elseif ($line[3] == 'ATC') {
927
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
928
+				$data['noarchive'] = true;
929
+			}
930
+			if (isset($value['name']) && $value['name'] != '') {
931
+				$data['source_name'] = $value['name'];
932
+			}
933
+    			if ($line[3] == 'PILOT') {
934
+    				$SI->add($data);
935
+    			} elseif ($line[3] == 'ATC') {
684 936
 				//print_r($data);
685 937
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686 938
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687 939
 				$typec = substr($data['ident'],-3);
688
-				if ($typec == 'APP') $data['type'] = 'Approach';
689
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
691
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
692
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
693
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
694
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
695
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
697
-				if (!isset($data['source_name'])) $data['source_name'] = '';
940
+				if ($typec == 'APP') {
941
+					$data['type'] = 'Approach';
942
+				} elseif ($typec == 'TWR') {
943
+					$data['type'] = 'Tower';
944
+				} elseif ($typec == 'OBS') {
945
+					$data['type'] = 'Observer';
946
+				} elseif ($typec == 'GND') {
947
+					$data['type'] = 'Ground';
948
+				} elseif ($typec == 'DEL') {
949
+					$data['type'] = 'Delivery';
950
+				} elseif ($typec == 'DEP') {
951
+					$data['type'] = 'Departure';
952
+				} elseif ($typec == 'FSS') {
953
+					$data['type'] = 'Flight Service Station';
954
+				} elseif ($typec == 'CTR') {
955
+					$data['type'] = 'Control Radar or Centre';
956
+				} elseif ($data['type'] == '') {
957
+					$data['type'] = 'Observer';
958
+				}
959
+				if (!isset($data['source_name'])) {
960
+					$data['source_name'] = '';
961
+				}
698 962
 				if (isset($ATC)) {
699
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
700
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
963
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
964
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
965
+					} else {
966
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
967
+					}
701 968
 				}
702 969
 			}
703 970
     			unset($data);
@@ -719,14 +986,20 @@  discard block
 block discarded – undo
719 986
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720 987
 			$data['latitude'] = (float)$line['pktLatitude'];
721 988
 			$data['longitude'] = (float)$line['pktLongitude'];
722
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
723
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
989
+			if ((float)$line['pktTrack'] != 0) {
990
+				$data['heading'] = (float)$line['pktTrack'];
991
+			}
992
+			if ((int)$line['pktSpeed'] != 0) {
993
+				$data['speed'] = (int)$line['pktSpeed'];
994
+			}
724 995
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
725 996
 			$data['altitude_relative'] = 'AMSL';
726 997
 			$data['pilot_id'] = (int)$line['pktPilotID'];
727 998
 			$data['aircraft_icao'] = 'PARAGLIDER';
728 999
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1000
+			if (isset($pilot_data[4])) {
1001
+				$data['pilot_name'] = $pilot_data[4];
1002
+			}
730 1003
 			$data['format_source'] = $value['format'];
731 1004
 			$SI->add($data);
732 1005
 			unset($data);
@@ -763,27 +1036,61 @@  discard block
 block discarded – undo
763 1036
 		foreach ($all_data['acList'] as $line) {
764 1037
 		    $data = array();
765 1038
 		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1039
+		    if (isset($line['Call'])) {
1040
+		    	$data['ident'] = $line['Call'];
1041
+		    }
1042
+		    // ident
1043
+		    if (isset($line['Alt'])) {
1044
+		    	$data['altitude'] = $line['Alt'];
1045
+		    }
1046
+		    // altitude
1047
+		    if (isset($line['Spd'])) {
1048
+		    	$data['speed'] = $line['Spd'];
1049
+		    }
1050
+		    // speed
1051
+		    if (isset($line['Trak'])) {
1052
+		    	$data['heading'] = $line['Trak'];
1053
+		    }
1054
+		    // heading
1055
+		    if (isset($line['Lat'])) {
1056
+		    	$data['latitude'] = $line['Lat'];
1057
+		    }
1058
+		    // lat
1059
+		    if (isset($line['Long'])) {
1060
+		    	$data['longitude'] = $line['Long'];
1061
+		    }
1062
+		    // long
772 1063
 		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1064
+		    if (isset($line['Sqk'])) {
1065
+		    	$data['squawk'] = $line['Sqk'];
1066
+		    }
1067
+		    // squawk
774 1068
 		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1069
+		    if (isset($line['Reg'])) {
1070
+		    	$data['registration'] = $line['Reg'];
1071
+		    }
776 1072
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1073
+		    if (isset($line['PosTime'])) {
1074
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1075
+		    } else {
1076
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1077
+		    }
779 1078
 		    
780 1079
 		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1080
+		    if (isset($line['Type'])) {
1081
+		    	$data['aircraft_icao'] = $line['Type'];
1082
+		    }
782 1083
 	    	    $data['format_source'] = 'aircraftlistjson';
783 1084
 		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
1085
+		    if (isset($value['name']) && $value['name'] != '') {
1086
+		    	$data['source_name'] = $value['name'];
1087
+		    }
1088
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1089
+		    	$data['noarchive'] = true;
1090
+		    }
1091
+		    if (isset($data['latitude'])) {
1092
+		    	$SI->add($data);
1093
+		    }
787 1094
 		    unset($data);
788 1095
 		}
789 1096
 	    } elseif (is_array($all_data)) {
@@ -800,12 +1107,19 @@  discard block
 block discarded – undo
800 1107
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 1108
 		    $data['squawk'] = $line['squawk']; // squawk
802 1109
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1110
+		    if (isset($line['PosTime'])) {
1111
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1112
+		    } else {
1113
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1114
+		    }
805 1115
 	    	    $data['format_source'] = 'aircraftlistjson';
806 1116
     		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1117
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1118
+		    	$data['noarchive'] = true;
1119
+		    }
1120
+		    if (isset($value['name']) && $value['name'] != '') {
1121
+		    	$data['source_name'] = $value['name'];
1122
+		    }
809 1123
 		    $SI->add($data);
810 1124
 		    unset($data);
811 1125
 		}
@@ -841,8 +1155,12 @@  discard block
 block discarded – undo
841 1155
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842 1156
 	    	    $data['format_source'] = 'planeupdatefaa';
843 1157
     		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1158
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1159
+		    	$data['noarchive'] = true;
1160
+		    }
1161
+		    if (isset($value['name']) && $value['name'] != '') {
1162
+		    	$data['source_name'] = $value['name'];
1163
+		    }
846 1164
 		    $SI->add($data);
847 1165
 		    unset($data);
848 1166
 		}
@@ -871,7 +1189,9 @@  discard block
 block discarded – undo
871 1189
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872 1190
 	    	    $data['format_source'] = 'opensky';
873 1191
     		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1193
+		    	$data['noarchive'] = true;
1194
+		    }
875 1195
 		    $SI->add($data);
876 1196
 		    unset($data);
877 1197
 		}
@@ -883,7 +1203,9 @@  discard block
 block discarded – undo
883 1203
 	    //$buffer = $Common->getData($hosts[$id]);
884 1204
 	    $buffer = $Common->getData($value['host']);
885 1205
 	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
1206
+	    if (!empty($all_data)) {
1207
+	    	$reset = 0;
1208
+	    }
887 1209
 	    foreach ($all_data as $key => $line) {
888 1210
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889 1211
 		    $data = array();
@@ -904,8 +1226,12 @@  discard block
 block discarded – undo
904 1226
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905 1227
 	    	    $data['format_source'] = 'fr24json';
906 1228
     		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1229
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1230
+		    	$data['noarchive'] = true;
1231
+		    }
1232
+		    if (isset($value['name']) && $value['name'] != '') {
1233
+		    	$data['source_name'] = $value['name'];
1234
+		    }
909 1235
 		    $SI->add($data);
910 1236
 		    unset($data);
911 1237
 		}
@@ -929,24 +1255,42 @@  discard block
 block discarded – undo
929 1255
 		    if (isset($line['inf'])) {
930 1256
 			$data = array();
931 1257
 			$data['hex'] = $line['inf']['ia'];
932
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1258
+			if (isset($line['inf']['cs'])) {
1259
+				$data['ident'] = $line['inf']['cs'];
1260
+			}
1261
+			//$line[13]
933 1262
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1263
+	    		if (isset($line['inf']['gs'])) {
1264
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1265
+	    		}
1266
+	    		// speed
1267
+	    		if (isset($line['inf']['tr'])) {
1268
+	    			$data['heading'] = $line['inf']['tr'];
1269
+	    		}
1270
+	    		// heading
936 1271
 	    		$data['latitude'] = $line['pt'][0]; // lat
937 1272
 	    		$data['longitude'] = $line['pt'][1]; // long
938 1273
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1274
+	    		if (isset($line['inf']['sq'])) {
1275
+	    			$data['squawk'] = $line['inf']['sq'];
1276
+	    		}
1277
+	    		// squawk
940 1278
 	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1279
+	    		if (isset($line['inf']['rc'])) {
1280
+	    			$data['registration'] = $line['inf']['rc'];
1281
+	    		}
942 1282
 			//$data['departure_airport_iata'] = $line[11];
943 1283
 			//$data['arrival_airport_iata'] = $line[12];
944 1284
 	    		//$data['emergency'] = ''; // emergency
945 1285
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946 1286
 	    		$data['format_source'] = 'radarvirtueljson';
947 1287
     			$data['id_source'] = $id_source;
948
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1289
+				$data['noarchive'] = true;
1290
+			}
1291
+			if (isset($value['name']) && $value['name'] != '') {
1292
+				$data['source_name'] = $value['name'];
1293
+			}
950 1294
 			$SI->add($data);
951 1295
 			unset($data);
952 1296
 		    }
@@ -967,30 +1311,65 @@  discard block
 block discarded – undo
967 1311
 		    $data['id'] = $line['id'];
968 1312
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969 1313
 		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1314
+		    if (isset($line['pilotid'])) {
1315
+		    	$data['pilot_id'] = $line['pilotid'];
1316
+		    }
1317
+		    // pilot id
1318
+		    if (isset($line['name'])) {
1319
+		    	$data['pilot_name'] = $line['name'];
1320
+		    }
1321
+		    // pilot name
1322
+		    if (isset($line['alt'])) {
1323
+		    	$data['altitude'] = $line['alt'];
1324
+		    }
1325
+		    // altitude
1326
+		    if (isset($line['gs'])) {
1327
+		    	$data['speed'] = $line['gs'];
1328
+		    }
1329
+		    // speed
1330
+		    if (isset($line['heading'])) {
1331
+		    	$data['heading'] = $line['heading'];
1332
+		    }
1333
+		    // heading
1334
+		    if (isset($line['route'])) {
1335
+		    	$data['waypoints'] = $line['route'];
1336
+		    }
1337
+		    // route
976 1338
 		    $data['latitude'] = $line['lat']; // lat
977 1339
 		    $data['longitude'] = $line['lon']; // long
978 1340
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979 1341
 		    //$data['squawk'] = $line['squawk']; // squawk
980 1342
 		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1343
+		    if (isset($line['depicao'])) {
1344
+		    	$data['departure_airport_icao'] = $line['depicao'];
1345
+		    }
1346
+		    if (isset($line['deptime'])) {
1347
+		    	$data['departure_airport_time'] = $line['deptime'];
1348
+		    }
1349
+		    if (isset($line['arricao'])) {
1350
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1351
+		    }
984 1352
 		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
1353
+		    if (isset($line['aircraft'])) {
1354
+		    	$data['aircraft_icao'] = $line['aircraft'];
1355
+		    }
1356
+		    if (isset($line['transponder'])) {
1357
+		    	$data['squawk'] = $line['transponder'];
1358
+		    }
1359
+		    if (isset($line['atis'])) {
1360
+		    	$data['info'] = $line['atis'];
1361
+		    } else {
1362
+		    	$data['info'] = '';
1363
+		    }
989 1364
 		    $data['format_source'] = 'pireps';
990 1365
     		    $data['id_source'] = $id_source;
991 1366
 		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1367
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1368
+		    	$data['noarchive'] = true;
1369
+		    }
1370
+		    if (isset($value['name']) && $value['name'] != '') {
1371
+		    	$data['source_name'] = $value['name'];
1372
+		    }
994 1373
 		    if ($line['icon'] == 'plane') {
995 1374
 			$SI->add($data);
996 1375
 		    //    print_r($data);
@@ -999,16 +1378,28 @@  discard block
 block discarded – undo
999 1378
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1379
 			$typec = substr($data['ident'],-3);
1001 1380
 			$data['type'] = '';
1002
-			if ($typec == 'APP') $data['type'] = 'Approach';
1003
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1004
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1005
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1006
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1007
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1008
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010
-			else $data['type'] = 'Observer';
1011
-			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']);
1381
+			if ($typec == 'APP') {
1382
+				$data['type'] = 'Approach';
1383
+			} elseif ($typec == 'TWR') {
1384
+				$data['type'] = 'Tower';
1385
+			} elseif ($typec == 'OBS') {
1386
+				$data['type'] = 'Observer';
1387
+			} elseif ($typec == 'GND') {
1388
+				$data['type'] = 'Ground';
1389
+			} elseif ($typec == 'DEL') {
1390
+				$data['type'] = 'Delivery';
1391
+			} elseif ($typec == 'DEP') {
1392
+				$data['type'] = 'Departure';
1393
+			} elseif ($typec == 'FSS') {
1394
+				$data['type'] = 'Flight Service Station';
1395
+			} elseif ($typec == 'CTR') {
1396
+				$data['type'] = 'Control Radar or Centre';
1397
+			} else {
1398
+				$data['type'] = 'Observer';
1399
+			}
1400
+			if (isset($ATC)) {
1401
+				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']);
1402
+			}
1012 1403
 		    }
1013 1404
 		    unset($data);
1014 1405
 		}
@@ -1018,7 +1409,9 @@  discard block
 block discarded – undo
1018 1409
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019 1410
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020 1411
 	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1412
+	    if ($globalDebug) {
1413
+	    	echo 'Get Data...'."\n";
1414
+	    }
1022 1415
 	    $buffer = $Common->getData($value['host']);
1023 1416
 	    $all_data = json_decode($buffer,true);
1024 1417
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1026,10 +1419,16 @@  discard block
 block discarded – undo
1026 1419
 		foreach ($all_data as $line) {
1027 1420
 	    	    $data = array();
1028 1421
 	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1422
+	    	    if (isset($line['pilotid'])) {
1423
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1424
+	    	    }
1030 1425
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1426
+	    	    if (isset($line['pilotname'])) {
1427
+	    	    	$data['pilot_name'] = $line['pilotname'];
1428
+	    	    }
1429
+	    	    if (isset($line['pilotid'])) {
1430
+	    	    	$data['pilot_id'] = $line['pilotid'];
1431
+	    	    }
1033 1432
 	    	    $data['ident'] = $line['flightnum']; // ident
1034 1433
 	    	    $data['altitude'] = $line['alt']; // altitude
1035 1434
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1045,34 +1444,52 @@  discard block
 block discarded – undo
1045 1444
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046 1445
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1446
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1447
+	    	    } else {
1448
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1449
+	    	    }
1049 1450
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1050 1451
 	    	    $data['departure_airport_time'] = $line['deptime'];
1051 1452
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052 1453
     		    $data['arrival_airport_time'] = $line['arrtime'];
1053 1454
     		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1455
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1456
+		    	$data['noarchive'] = true;
1457
+		    }
1458
+		    if (isset($line['route'])) {
1459
+		    	$data['waypoints'] = $line['route'];
1460
+		    }
1461
+		    // route
1056 1462
 		    if (isset($line['aircraftname'])) {
1057 1463
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1464
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059 1465
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1466
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1467
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1468
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1469
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1470
+	    		} else {
1063 1471
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1472
+	    		    if (isset($aircraft_data[1])) {
1473
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1474
+	    		    } else {
1475
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1476
+	    		    }
1066 1477
 	    		}
1067 1478
 	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1479
+    		    if (isset($line['route'])) {
1480
+    		    	$data['waypoints'] = $line['route'];
1481
+    		    }
1069 1482
     		    $data['id_source'] = $id_source;
1070 1483
 	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1484
+		    if (isset($value['name']) && $value['name'] != '') {
1485
+		    	$data['source_name'] = $value['name'];
1486
+		    }
1072 1487
 		    $SI->add($data);
1073 1488
 		    unset($data);
1074 1489
 		}
1075
-		if ($globalDebug) echo 'No more data...'."\n";
1490
+		if ($globalDebug) {
1491
+			echo 'No more data...'."\n";
1492
+		}
1076 1493
 		unset($buffer);
1077 1494
 		unset($all_data);
1078 1495
 	    }
@@ -1080,7 +1497,9 @@  discard block
 block discarded – undo
1080 1497
     	    $last_exec[$id]['last'] = time();
1081 1498
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082 1499
 	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1500
+	    if ($globalDebug) {
1501
+	    	echo 'Get Data...'."\n";
1502
+	    }
1084 1503
 	    $buffer = $Common->getData($value['host']);
1085 1504
 	    $all_data = json_decode($buffer,true);
1086 1505
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1109,16 +1528,25 @@  discard block
 block discarded – undo
1109 1528
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110 1529
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111 1530
     		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1531
+		    if (isset($line['route'])) {
1532
+		    	$data['waypoints'] = $line['route'];
1533
+		    }
1534
+		    // route
1113 1535
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1114 1536
     		    $data['id_source'] = $id_source;
1115 1537
 	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1538
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1539
+		    	$data['noarchive'] = true;
1540
+		    }
1541
+		    if (isset($value['name']) && $value['name'] != '') {
1542
+		    	$data['source_name'] = $value['name'];
1543
+		    }
1118 1544
 		    $SI->add($data);
1119 1545
 		    unset($data);
1120 1546
 		}
1121
-		if ($globalDebug) echo 'No more data...'."\n";
1547
+		if ($globalDebug) {
1548
+			echo 'No more data...'."\n";
1549
+		}
1122 1550
 		unset($buffer);
1123 1551
 		unset($all_data);
1124 1552
 	    }
@@ -1126,7 +1554,9 @@  discard block
 block discarded – undo
1126 1554
     	    $last_exec[$id]['last'] = time();
1127 1555
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1556
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1557
+	    if (function_exists('pcntl_fork')) {
1558
+	    	pcntl_signal_dispatch();
1559
+	    }
1130 1560
     	    //$last_exec[$id]['last'] = time();
1131 1561
 
1132 1562
 	    //$read = array( $sockets[$id] );
@@ -1134,7 +1564,9 @@  discard block
 block discarded – undo
1134 1564
 	    $write = NULL;
1135 1565
 	    $e = NULL;
1136 1566
 	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1567
+	    if ($e != NULL) {
1568
+	    	var_dump($e);
1569
+	    }
1138 1570
 	    if ($n > 0) {
1139 1571
 		$reset = 0;
1140 1572
 		foreach ($read as $nb => $r) {
@@ -1155,12 +1587,16 @@  discard block
 block discarded – undo
1155 1587
 		    //$SI::del();
1156 1588
 		    if ($format == 'vrstcp') {
1157 1589
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1590
+		    } else {
1591
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1592
+		    }
1159 1593
 		    // SBS format is CSV format
1160 1594
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1595
 			$tt[$format] = 0;
1162 1596
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1597
+			    if ($globalDebug) {
1598
+			    	echo 'ACARS : '.$buffer."\n";
1599
+			    }
1164 1600
 			    $ACARS->add(trim($buffer));
1165 1601
 			    $ACARS->deleteLiveAcarsData();
1166 1602
 			} elseif ($format == 'raw') {
@@ -1169,30 +1605,70 @@  discard block
 block discarded – undo
1169 1605
 			    if (is_array($data)) {
1170 1606
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1607
 				$data['format_source'] = 'raw';
1172
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1608
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1609
+					$data['source_name'] = $globalSources[$nb]['name'];
1610
+				}
1611
+				if (isset($globalSources[$nb]['sourcestats'])) {
1612
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1613
+				}
1614
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1615
+					$data['noarchive'] = true;
1616
+				}
1617
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1618
+					$SI->add($data);
1619
+				}
1176 1620
 			    }
1177 1621
 			} elseif ($format == 'ais') {
1178 1622
 			    $ais_data = $AIS->parse_line(trim($buffer));
1179 1623
 			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+			    if (isset($ais_data['ident'])) {
1625
+			    	$data['ident'] = $ais_data['ident'];
1626
+			    }
1627
+			    if (isset($ais_data['mmsi'])) {
1628
+			    	$data['mmsi'] = $ais_data['mmsi'];
1629
+			    }
1630
+			    if (isset($ais_data['speed'])) {
1631
+			    	$data['speed'] = $ais_data['speed'];
1632
+			    }
1633
+			    if (isset($ais_data['heading'])) {
1634
+			    	$data['heading'] = $ais_data['heading'];
1635
+			    }
1636
+			    if (isset($ais_data['latitude'])) {
1637
+			    	$data['latitude'] = $ais_data['latitude'];
1638
+			    }
1639
+			    if (isset($ais_data['longitude'])) {
1640
+			    	$data['longitude'] = $ais_data['longitude'];
1641
+			    }
1642
+			    if (isset($ais_data['status'])) {
1643
+			    	$data['status'] = $ais_data['status'];
1644
+			    }
1645
+			    if (isset($ais_data['statusid'])) {
1646
+			    	$data['status_id'] = $ais_data['statusid'];
1647
+			    }
1648
+			    if (isset($ais_data['type'])) {
1649
+			    	$data['type'] = $ais_data['type'];
1650
+			    }
1651
+			    if (isset($ais_data['imo'])) {
1652
+			    	$data['imo'] = $ais_data['imo'];
1653
+			    }
1654
+			    if (isset($ais_data['callsign'])) {
1655
+			    	$data['callsign'] = $ais_data['callsign'];
1656
+			    }
1657
+			    if (isset($ais_data['destination'])) {
1658
+			    	$data['arrival_code'] = $ais_data['destination'];
1659
+			    }
1660
+			    if (isset($ais_data['eta_ts'])) {
1661
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1662
+			    }
1663
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1664
+			    	$data['noarchive'] = true;
1665
+			    }
1666
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1667
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1668
+			    }
1669
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1670
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1671
+			    }
1196 1672
 
1197 1673
 			    if (isset($ais_data['timestamp'])) {
1198 1674
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1201,7 +1677,9 @@  discard block
 block discarded – undo
1201 1677
 			    }
1202 1678
 			    $data['format_source'] = 'aisnmea';
1203 1679
     			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1680
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1681
+			    	$MI->add($data);
1682
+			    }
1205 1683
 			    unset($data);
1206 1684
                         } elseif ($format == 'flightgearsp') {
1207 1685
                     	    //echo $buffer."\n";
@@ -1219,12 +1697,18 @@  discard block
 block discarded – undo
1219 1697
 				$data['speed'] = round($line[5]*1.94384);
1220 1698
 				$data['datetime'] = date('Y-m-d H:i:s');
1221 1699
 				$data['format_source'] = 'flightgearsp';
1222
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1700
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1701
+					$data['noarchive'] = true;
1702
+				}
1703
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1704
+					$SI->add($data);
1705
+				}
1224 1706
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225 1707
 			    }
1226 1708
                         } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1709
+                    	    if ($globalDebug) {
1710
+                    	    	echo 'ACARS : '.$buffer."\n";
1711
+                    	    }
1228 1712
 			    $ACARS->add(trim($buffer));
1229 1713
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230 1714
 			    $ACARS->deleteLiveAcarsData();
@@ -1245,8 +1729,12 @@  discard block
 block discarded – undo
1245 1729
 				    $aircraft_type = $line[10];
1246 1730
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247 1731
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1732
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1733
+				    	$data['noarchive'] = true;
1734
+				    }
1735
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1736
+				    	$SI->add($data);
1737
+				    }
1250 1738
 				}
1251 1739
 			    }
1252 1740
 			} elseif ($format == 'beast') {
@@ -1256,28 +1744,62 @@  discard block
 block discarded – undo
1256 1744
 			    foreach($buffer as $all_data) {
1257 1745
 				$line = json_decode('{'.$all_data.'}',true);
1258 1746
 				$data = array();
1259
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1261
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1262
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1263
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1264
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1265
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1747
+				if (isset($line['Icao'])) {
1748
+					$data['hex'] = $line['Icao'];
1749
+				}
1750
+				// hex
1751
+				if (isset($line['Call'])) {
1752
+					$data['ident'] = $line['Call'];
1753
+				}
1754
+				// ident
1755
+				if (isset($line['Alt'])) {
1756
+					$data['altitude'] = $line['Alt'];
1757
+				}
1758
+				// altitude
1759
+				if (isset($line['Spd'])) {
1760
+					$data['speed'] = $line['Spd'];
1761
+				}
1762
+				// speed
1763
+				if (isset($line['Trak'])) {
1764
+					$data['heading'] = $line['Trak'];
1765
+				}
1766
+				// heading
1767
+				if (isset($line['Lat'])) {
1768
+					$data['latitude'] = $line['Lat'];
1769
+				}
1770
+				// lat
1771
+				if (isset($line['Long'])) {
1772
+					$data['longitude'] = $line['Long'];
1773
+				}
1774
+				// long
1266 1775
 				//$data['verticalrate'] = $line['']; // verticale rate
1267
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1776
+				if (isset($line['Sqk'])) {
1777
+					$data['squawk'] = $line['Sqk'];
1778
+				}
1779
+				// squawk
1268 1780
 				$data['emergency'] = ''; // emergency
1269
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1781
+				if (isset($line['Reg'])) {
1782
+					$data['registration'] = $line['Reg'];
1783
+				}
1270 1784
 				/*
1271 1785
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1272 1786
 				else $data['datetime'] = date('Y-m-d H:i:s');
1273 1787
 				*/
1274 1788
 				$data['datetime'] = date('Y-m-d H:i:s');
1275
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1789
+				if (isset($line['Type'])) {
1790
+					$data['aircraft_icao'] = $line['Type'];
1791
+				}
1276 1792
 		    		$data['format_source'] = 'vrstcp';
1277 1793
 				$data['id_source'] = $id_source;
1278
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1794
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1795
+					$data['noarchive'] = true;
1796
+				}
1797
+				if (isset($value['name']) && $value['name'] != '') {
1798
+					$data['source_name'] = $value['name'];
1799
+				}
1800
+				if (isset($data['latitude']) && isset($data['hex'])) {
1801
+					$SI->add($data);
1802
+				}
1281 1803
 				unset($data);
1282 1804
 			    }
1283 1805
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1290,22 +1812,46 @@  discard block
 block discarded – undo
1290 1812
     				$data['hex'] = $lined['hexid'];
1291 1813
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292 1814
     				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1815
+    				if (isset($lined['ident'])) {
1816
+    					$data['ident'] = $lined['ident'];
1817
+    				}
1818
+    				if (isset($lined['lat'])) {
1819
+    					$data['latitude'] = $lined['lat'];
1820
+    				}
1821
+    				if (isset($lined['lon'])) {
1822
+    					$data['longitude'] = $lined['lon'];
1823
+    				}
1824
+    				if (isset($lined['speed'])) {
1825
+    					$data['speed'] = $lined['speed'];
1826
+    				}
1827
+    				if (isset($lined['squawk'])) {
1828
+    					$data['squawk'] = $lined['squawk'];
1829
+    				}
1830
+    				if (isset($lined['alt'])) {
1831
+    					$data['altitude'] = $lined['alt'];
1832
+    				}
1833
+    				if (isset($lined['heading'])) {
1834
+    					$data['heading'] = $lined['heading'];
1835
+    				}
1300 1836
     				$data['id_source'] = $id_source;
1301 1837
     				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1838
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1839
+    					$data['source_name'] = $globalSources[$nb]['name'];
1840
+    				}
1841
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1842
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1843
+    				}
1844
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1845
+					$data['noarchive'] = true;
1846
+				}
1847
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1848
+    					$SI->add($data);
1849
+    				}
1306 1850
     				unset($lined);
1307 1851
     				unset($data);
1308
-    			    } else $error = true;
1852
+    			    } else {
1853
+    			    	$error = true;
1854
+    			    }
1309 1855
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1856
 			    if ($aprs_connect == 0) {
1311 1857
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1330,60 +1876,118 @@  discard block
 block discarded – undo
1330 1876
 				    $aprs_last_tx = time();
1331 1877
 				    $data = array();
1332 1878
 				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1879
+				    if (isset($line['address'])) {
1880
+				    	$data['hex'] = $line['address'];
1881
+				    }
1882
+				    if (isset($line['mmsi'])) {
1883
+				    	$data['mmsi'] = $line['mmsi'];
1884
+				    }
1885
+				    if (isset($line['imo'])) {
1886
+				    	$data['imo'] = $line['imo'];
1887
+				    }
1888
+				    if (isset($line['squawk'])) {
1889
+				    	$data['squawk'] = $line['squawk'];
1890
+				    }
1891
+				    if (isset($line['arrival_code'])) {
1892
+				    	$data['arrical_code'] = $line['arrival_code'];
1893
+				    }
1894
+				    if (isset($line['arrival_date'])) {
1895
+				    	$data['arrical_date'] = $line['arrival_date'];
1896
+				    }
1897
+				    if (isset($line['type_id'])) {
1898
+				    	$data['type_id'] = $line['typeid'];
1899
+				    }
1900
+				    if (isset($line['status_id'])) {
1901
+				    	$data['status_id'] = $line['statusid'];
1902
+				    }
1903
+				    if (isset($line['timestamp'])) {
1904
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1905
+				    } else {
1906
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1907
+				    }
1343 1908
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1909
+				    if (isset($line['ident'])) {
1910
+				    	$data['ident'] = $line['ident'];
1911
+				    }
1345 1912
 				    $data['latitude'] = $line['latitude'];
1346 1913
 				    $data['longitude'] = $line['longitude'];
1347 1914
 				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1915
+				    if (isset($line['speed'])) {
1916
+				    	$data['speed'] = $line['speed'];
1917
+				    }
1349 1918
 				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1919
+				    if (isset($line['altitude'])) {
1920
+				    	$data['altitude'] = $line['altitude'];
1921
+				    }
1922
+				    if (isset($line['comment'])) {
1923
+				    	$data['comment'] = $line['comment'];
1924
+				    }
1925
+				    if (isset($line['symbol'])) {
1926
+				    	$data['type'] = $line['symbol'];
1927
+				    }
1928
+				    if (isset($line['heading'])) {
1929
+				    	$data['heading'] = $line['heading'];
1930
+				    }
1354 1931
 				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1932
+				    if (isset($line['stealth'])) {
1933
+				    	$data['aircraft_type'] = $line['stealth'];
1934
+				    }
1356 1935
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1936
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1937
+				    	$data['noarchive'] = true;
1938
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1939
+				    	$data['noarchive'] = false;
1940
+				    }
1941
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1942
+				    	$data['noarchive'] = true;
1943
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1944
+				    	$data['noarchive'] = false;
1945
+				    }
1361 1946
     				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1947
+    				    if (isset($line['format_source'])) {
1948
+    				    	$data['format_source'] = $line['format_source'];
1949
+    				    } else {
1950
+				    	$data['format_source'] = 'aprs';
1951
+				    }
1364 1952
 				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1953
+				    if (isset($line['source_type'])) {
1954
+				    	$data['source_type'] = $line['source_type'];
1955
+				    } else {
1956
+				    	$data['source_type'] = 'flarm';
1957
+				    }
1958
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1959
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1960
+    				    }
1368 1961
 				    $currentdate = date('Y-m-d H:i:s');
1369 1962
 				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1963
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
1964
+				    	$data['altitude_relative'] = 'AMSL';
1965
+				    }
1371 1966
 				    // Accept data if time <= system time + 20s
1372 1967
 				    //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'])))) {
1373 1968
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1969
 					$send = $SI->add($data);
1375 1970
 				    } elseif ($data['source_type'] == 'ais') {
1376
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1971
+					if (isset($globalMarine) && $globalMarine) {
1972
+						$send = $MI->add($data);
1973
+					}
1377 1974
 				    } elseif (isset($line['stealth'])) {
1378
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1975
+					if ($line['stealth'] != 0) {
1976
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1977
+					} else {
1978
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1979
+					}
1380 1980
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381 1981
 				    //} 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') {
1382 1982
 				    } 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') {
1383 1983
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1384
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1984
+					if (isset($globalTracker) && $globalTracker) {
1985
+						$send = $TI->add($data);
1986
+					}
1385 1987
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1386
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
1988
+					if (!isset($data['altitude'])) {
1989
+						$data['altitude'] = 0;
1990
+					}
1387 1991
 					$Source->deleteOldLocationByType('gs');
1388 1992
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1389 1993
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1395,12 +1999,9 @@  discard block
 block discarded – undo
1395 1999
 				    	print_r($line);
1396 2000
 				    }
1397 2001
 				    unset($data);
1398
-				} 
1399
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
2002
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1400 2003
 					echo '!! Weather Station not yet supported'."\n";
1401
-				}
1402
-				 
1403
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2004
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1404 2005
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1405 2006
 				}
1406 2007
 				/*
@@ -1409,7 +2010,9 @@  discard block
 block discarded – undo
1409 2010
 				}
1410 2011
 				*/
1411 2012
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1412
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2013
+				elseif ($line == true && $globalDebug) {
2014
+					echo '!! Failed : '.$buffer."!!\n";
2015
+				}
1413 2016
 			    }
1414 2017
 			} else {
1415 2018
 			    $line = explode(',', $buffer);
@@ -1438,26 +2041,45 @@  discard block
 block discarded – undo
1438 2041
     				$data['ground'] = $line[21];
1439 2042
     				$data['emergency'] = $line[19];
1440 2043
     				$data['format_source'] = 'sbs';
1441
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1442
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1443
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2044
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2045
+					$data['source_name'] = $globalSources[$nb]['name'];
2046
+				}
2047
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2048
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2049
+    				}
2050
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2051
+					$data['noarchive'] = true;
2052
+				}
1444 2053
     				$data['id_source'] = $id_source;
1445
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
-    				else $error = true;
2054
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2055
+    					$send = $SI->add($data);
2056
+    				} else {
2057
+    					$error = true;
2058
+    				}
1447 2059
     				unset($data);
1448
-    			    } else $error = true;
2060
+    			    } else {
2061
+    			    	$error = true;
2062
+    			    }
1449 2063
 			    if ($error) {
1450 2064
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1451
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2065
+					if ($globalDebug) {
2066
+						echo "Not a message. Ignoring... \n";
2067
+					}
1452 2068
 				} else {
1453
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2069
+					if ($globalDebug) {
2070
+						echo "Wrong line format. Ignoring... \n";
2071
+					}
1454 2072
 					if ($globalDebug) {
1455 2073
 						echo $buffer;
1456 2074
 						//print_r($line);
1457 2075
 					}
1458 2076
 					//socket_close($r);
1459
-					if ($globalDebug) echo "Reconnect after an error...\n";
1460
-					if ($format == 'aprs') $aprs_connect = 0;
2077
+					if ($globalDebug) {
2078
+						echo "Reconnect after an error...\n";
2079
+					}
2080
+					if ($format == 'aprs') {
2081
+						$aprs_connect = 0;
2082
+					}
1461 2083
 					$sourceer[$nb] = $globalSources[$nb];
1462 2084
 					connect_all($sourceer);
1463 2085
 					$sourceer = array();
@@ -1465,10 +2087,14 @@  discard block
 block discarded – undo
1465 2087
 			    }
1466 2088
 			}
1467 2089
 			// Sleep for xxx microseconds
1468
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2090
+			if (isset($globalSBSSleep)) {
2091
+				usleep($globalSBSSleep);
2092
+			}
1469 2093
 		    } else {
1470 2094
 			if ($format == 'flightgearmp') {
1471
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2095
+			    	if ($globalDebug) {
2096
+			    		echo "Reconnect FlightGear MP...";
2097
+			    	}
1472 2098
 				//@socket_close($r);
1473 2099
 				sleep($globalMinFetch);
1474 2100
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1477,10 +2103,15 @@  discard block
 block discarded – undo
1477 2103
 				break;
1478 2104
 				
1479 2105
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1480
-			    if (isset($tt[$format])) $tt[$format]++;
1481
-			    else $tt[$format] = 0;
2106
+			    if (isset($tt[$format])) {
2107
+			    	$tt[$format]++;
2108
+			    } else {
2109
+			    	$tt[$format] = 0;
2110
+			    }
1482 2111
 			    if ($tt[$format] > 30) {
1483
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2112
+				if ($globalDebug) {
2113
+					echo "ERROR : Reconnect ".$format."...";
2114
+				}
1484 2115
 				//@socket_close($r);
1485 2116
 				sleep(2);
1486 2117
 				$aprs_connect = 0;
@@ -1497,11 +2128,17 @@  discard block
 block discarded – undo
1497 2128
 	    } else {
1498 2129
 		$error = socket_strerror(socket_last_error());
1499 2130
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1500
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1501
-			if (isset($globalDebug)) echo "Restarting...\n";
2131
+			if ($globalDebug) {
2132
+				echo "ERROR : socket_select give this error ".$error . "\n";
2133
+			}
2134
+			if (isset($globalDebug)) {
2135
+				echo "Restarting...\n";
2136
+			}
1502 2137
 			// Restart the script if possible
1503 2138
 			if (is_array($sockets)) {
1504
-			    if ($globalDebug) echo "Shutdown all sockets...";
2139
+			    if ($globalDebug) {
2140
+			    	echo "Shutdown all sockets...";
2141
+			    }
1505 2142
 			    
1506 2143
 			    foreach ($sockets as $sock) {
1507 2144
 				@socket_shutdown($sock,2);
@@ -1509,22 +2146,36 @@  discard block
 block discarded – undo
1509 2146
 			    }
1510 2147
 			    
1511 2148
 			}
1512
-			if ($globalDebug) echo "Waiting...";
2149
+			if ($globalDebug) {
2150
+				echo "Waiting...";
2151
+			}
1513 2152
 			sleep(2);
1514 2153
 			$time = time();
1515 2154
 			//connect_all($hosts);
1516 2155
 			$aprs_connect = 0;
1517
-			if ($reset%5 == 0) sleep(20);
1518
-			if ($reset%10 == 0) sleep(100);
1519
-			if ($reset%20 == 0) sleep(200);
1520
-			if ($reset > 100) exit('Too many attempts...');
1521
-			if ($globalDebug) echo "Restart all connections...";
2156
+			if ($reset%5 == 0) {
2157
+				sleep(20);
2158
+			}
2159
+			if ($reset%10 == 0) {
2160
+				sleep(100);
2161
+			}
2162
+			if ($reset%20 == 0) {
2163
+				sleep(200);
2164
+			}
2165
+			if ($reset > 100) {
2166
+				exit('Too many attempts...');
2167
+			}
2168
+			if ($globalDebug) {
2169
+				echo "Restart all connections...";
2170
+			}
1522 2171
 			connect_all($globalSources);
1523 2172
 		}
1524 2173
 	    }
1525 2174
 	}
1526 2175
 	if ($globalDaemon === false) {
1527
-	    if ($globalDebug) echo 'Check all...'."\n";
2176
+	    if ($globalDebug) {
2177
+	    	echo 'Check all...'."\n";
2178
+	    }
1528 2179
 	    $SI->checkAll();
1529 2180
 	}
1530 2181
     }
Please login to merge, or discard this patch.
require/class.TrackerImport.php 3 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
94
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
95
+		$globalCoordMinChange = '0.02';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source();
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +642 added lines, -642 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
289
-			$sth->execute();
290
-    		    } catch(PDOException $e) {
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289
+			$sth->execute();
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
431
-			$sth->execute();
432
-    		    } catch(PDOException $e) {
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 			} catch(PDOException $e) {
1724 1724
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1725 1725
 			}
1726
-                }
1726
+				}
1727 1727
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1728 1728
 		try {
1729 1729
 			$sth = $Connection->db->prepare($query);
@@ -2129,205 +2129,205 @@  discard block
 block discarded – undo
2129 2129
 
2130 2130
 
2131 2131
 
2132
-    	public static function check_version($update = false) {
2133
-    	    global $globalDBname;
2134
-    	    $version = 0;
2135
-    	    $Connection = new Connection();
2136
-    	    if ($Connection->tableExists('aircraft')) {
2137
-    		if (!$Connection->tableExists('config')) {
2138
-    		    $version = '1';
2139
-    		    if ($update) return self::update_from_1();
2140
-    		    else return $version;
2132
+		public static function check_version($update = false) {
2133
+			global $globalDBname;
2134
+			$version = 0;
2135
+			$Connection = new Connection();
2136
+			if ($Connection->tableExists('aircraft')) {
2137
+			if (!$Connection->tableExists('config')) {
2138
+				$version = '1';
2139
+				if ($update) return self::update_from_1();
2140
+				else return $version;
2141 2141
 		} else {
2142
-    		    $Connection = new Connection();
2143
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2144
-		    try {
2145
-            		$sth = $Connection->db->prepare($query);
2146
-		        $sth->execute();
2147
-		    } catch(PDOException $e) {
2142
+				$Connection = new Connection();
2143
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2144
+			try {
2145
+					$sth = $Connection->db->prepare($query);
2146
+				$sth->execute();
2147
+			} catch(PDOException $e) {
2148 2148
 			return "error : ".$e->getMessage()."\n";
2149
-    		    }
2150
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
2151
-    		    if ($update) {
2152
-    			if ($result['value'] == '2') {
2153
-    			    $error = self::update_from_2();
2154
-    			    if ($error != '') return $error;
2155
-    			    else return self::check_version(true);
2156
-    			} elseif ($result['value'] == '3') {
2157
-    			    $error = self::update_from_3();
2158
-    			    if ($error != '') return $error;
2159
-    			    else return self::check_version(true);
2160
-    			} elseif ($result['value'] == '4') {
2161
-    			    $error = self::update_from_4();
2162
-    			    if ($error != '') return $error;
2163
-    			    else return self::check_version(true);
2164
-    			} elseif ($result['value'] == '5') {
2165
-    			    $error = self::update_from_5();
2166
-    			    if ($error != '') return $error;
2167
-    			    else return self::check_version(true);
2168
-    			} elseif ($result['value'] == '6') {
2169
-    			    $error = self::update_from_6();
2170
-    			    if ($error != '') return $error;
2171
-    			    else return self::check_version(true);
2172
-    			} elseif ($result['value'] == '7') {
2173
-    			    $error = self::update_from_7();
2174
-    			    if ($error != '') return $error;
2175
-    			    else return self::check_version(true);
2176
-    			} elseif ($result['value'] == '8') {
2177
-    			    $error = self::update_from_8();
2178
-    			    if ($error != '') return $error;
2179
-    			    else return self::check_version(true);
2180
-    			} elseif ($result['value'] == '9') {
2181
-    			    $error = self::update_from_9();
2182
-    			    if ($error != '') return $error;
2183
-    			    else return self::check_version(true);
2184
-    			} elseif ($result['value'] == '10') {
2185
-    			    $error = self::update_from_10();
2186
-    			    if ($error != '') return $error;
2187
-    			    else return self::check_version(true);
2188
-    			} elseif ($result['value'] == '11') {
2189
-    			    $error = self::update_from_11();
2190
-    			    if ($error != '') return $error;
2191
-    			    else return self::check_version(true);
2192
-    			} elseif ($result['value'] == '12') {
2193
-    			    $error = self::update_from_12();
2194
-    			    if ($error != '') return $error;
2195
-    			    else return self::check_version(true);
2196
-    			} elseif ($result['value'] == '13') {
2197
-    			    $error = self::update_from_13();
2198
-    			    if ($error != '') return $error;
2199
-    			    else return self::check_version(true);
2200
-    			} elseif ($result['value'] == '14') {
2201
-    			    $error = self::update_from_14();
2202
-    			    if ($error != '') return $error;
2203
-    			    else return self::check_version(true);
2204
-    			} elseif ($result['value'] == '15') {
2205
-    			    $error = self::update_from_15();
2206
-    			    if ($error != '') return $error;
2207
-    			    else return self::check_version(true);
2208
-    			} elseif ($result['value'] == '16') {
2209
-    			    $error = self::update_from_16();
2210
-    			    if ($error != '') return $error;
2211
-    			    else return self::check_version(true);
2212
-    			} elseif ($result['value'] == '17') {
2213
-    			    $error = self::update_from_17();
2214
-    			    if ($error != '') return $error;
2215
-    			    else return self::check_version(true);
2216
-    			} elseif ($result['value'] == '18') {
2217
-    			    $error = self::update_from_18();
2218
-    			    if ($error != '') return $error;
2219
-    			    else return self::check_version(true);
2220
-    			} elseif ($result['value'] == '19') {
2221
-    			    $error = self::update_from_19();
2222
-    			    if ($error != '') return $error;
2223
-    			    else return self::check_version(true);
2224
-    			} elseif ($result['value'] == '20') {
2225
-    			    $error = self::update_from_20();
2226
-    			    if ($error != '') return $error;
2227
-    			    else return self::check_version(true);
2228
-    			} elseif ($result['value'] == '21') {
2229
-    			    $error = self::update_from_21();
2230
-    			    if ($error != '') return $error;
2231
-    			    else return self::check_version(true);
2232
-    			} elseif ($result['value'] == '22') {
2233
-    			    $error = self::update_from_22();
2234
-    			    if ($error != '') return $error;
2235
-    			    else return self::check_version(true);
2236
-    			} elseif ($result['value'] == '23') {
2237
-    			    $error = self::update_from_23();
2238
-    			    if ($error != '') return $error;
2239
-    			    else return self::check_version(true);
2240
-    			} elseif ($result['value'] == '24') {
2241
-    			    $error = self::update_from_24();
2242
-    			    if ($error != '') return $error;
2243
-    			    else return self::check_version(true);
2244
-    			} elseif ($result['value'] == '25') {
2245
-    			    $error = self::update_from_25();
2246
-    			    if ($error != '') return $error;
2247
-    			    else return self::check_version(true);
2248
-    			} elseif ($result['value'] == '26') {
2249
-    			    $error = self::update_from_26();
2250
-    			    if ($error != '') return $error;
2251
-    			    else return self::check_version(true);
2252
-    			} elseif ($result['value'] == '27') {
2253
-    			    $error = self::update_from_27();
2254
-    			    if ($error != '') return $error;
2255
-    			    else return self::check_version(true);
2256
-    			} elseif ($result['value'] == '28') {
2257
-    			    $error = self::update_from_28();
2258
-    			    if ($error != '') return $error;
2259
-    			    else return self::check_version(true);
2260
-    			} elseif ($result['value'] == '29') {
2261
-    			    $error = self::update_from_29();
2262
-    			    if ($error != '') return $error;
2263
-    			    else return self::check_version(true);
2264
-    			} elseif ($result['value'] == '30') {
2265
-    			    $error = self::update_from_30();
2266
-    			    if ($error != '') return $error;
2267
-    			    else return self::check_version(true);
2268
-    			} elseif ($result['value'] == '31') {
2269
-    			    $error = self::update_from_31();
2270
-    			    if ($error != '') return $error;
2271
-    			    else return self::check_version(true);
2272
-    			} elseif ($result['value'] == '32') {
2273
-    			    $error = self::update_from_32();
2274
-    			    if ($error != '') return $error;
2275
-    			    else return self::check_version(true);
2276
-    			} elseif ($result['value'] == '33') {
2277
-    			    $error = self::update_from_33();
2278
-    			    if ($error != '') return $error;
2279
-    			    else return self::check_version(true);
2280
-    			} elseif ($result['value'] == '34') {
2281
-    			    $error = self::update_from_34();
2282
-    			    if ($error != '') return $error;
2283
-    			    else return self::check_version(true);
2284
-    			} elseif ($result['value'] == '35') {
2285
-    			    $error = self::update_from_35();
2286
-    			    if ($error != '') return $error;
2287
-    			    else return self::check_version(true);
2288
-    			} elseif ($result['value'] == '36') {
2289
-    			    $error = self::update_from_36();
2290
-    			    if ($error != '') return $error;
2291
-    			    else return self::check_version(true);
2292
-    			} elseif ($result['value'] == '37') {
2293
-    			    $error = self::update_from_37();
2294
-    			    if ($error != '') return $error;
2295
-    			    else return self::check_version(true);
2296
-    			} elseif ($result['value'] == '38') {
2297
-    			    $error = self::update_from_38();
2298
-    			    if ($error != '') return $error;
2299
-    			    else return self::check_version(true);
2300
-    			} elseif ($result['value'] == '39') {
2301
-    			    $error = self::update_from_39();
2302
-    			    if ($error != '') return $error;
2303
-    			    else return self::check_version(true);
2304
-    			} elseif ($result['value'] == '40') {
2305
-    			    $error = self::update_from_40();
2306
-    			    if ($error != '') return $error;
2307
-    			    else return self::check_version(true);
2308
-    			} elseif ($result['value'] == '41') {
2309
-    			    $error = self::update_from_41();
2310
-    			    if ($error != '') return $error;
2311
-    			    else return self::check_version(true);
2312
-    			} elseif ($result['value'] == '42') {
2313
-    			    $error = self::update_from_42();
2314
-    			    if ($error != '') return $error;
2315
-    			    else return self::check_version(true);
2316
-    			} elseif ($result['value'] == '43') {
2317
-    			    $error = self::update_from_43();
2318
-    			    if ($error != '') return $error;
2319
-    			    else return self::check_version(true);
2320
-    			} elseif ($result['value'] == '44') {
2321
-    			    $error = self::update_from_44();
2322
-    			    if ($error != '') return $error;
2323
-    			    else return self::check_version(true);
2324
-    			} else return '';
2325
-    		    }
2326
-    		    else return $result['value'];
2149
+				}
2150
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
2151
+				if ($update) {
2152
+				if ($result['value'] == '2') {
2153
+					$error = self::update_from_2();
2154
+					if ($error != '') return $error;
2155
+					else return self::check_version(true);
2156
+				} elseif ($result['value'] == '3') {
2157
+					$error = self::update_from_3();
2158
+					if ($error != '') return $error;
2159
+					else return self::check_version(true);
2160
+				} elseif ($result['value'] == '4') {
2161
+					$error = self::update_from_4();
2162
+					if ($error != '') return $error;
2163
+					else return self::check_version(true);
2164
+				} elseif ($result['value'] == '5') {
2165
+					$error = self::update_from_5();
2166
+					if ($error != '') return $error;
2167
+					else return self::check_version(true);
2168
+				} elseif ($result['value'] == '6') {
2169
+					$error = self::update_from_6();
2170
+					if ($error != '') return $error;
2171
+					else return self::check_version(true);
2172
+				} elseif ($result['value'] == '7') {
2173
+					$error = self::update_from_7();
2174
+					if ($error != '') return $error;
2175
+					else return self::check_version(true);
2176
+				} elseif ($result['value'] == '8') {
2177
+					$error = self::update_from_8();
2178
+					if ($error != '') return $error;
2179
+					else return self::check_version(true);
2180
+				} elseif ($result['value'] == '9') {
2181
+					$error = self::update_from_9();
2182
+					if ($error != '') return $error;
2183
+					else return self::check_version(true);
2184
+				} elseif ($result['value'] == '10') {
2185
+					$error = self::update_from_10();
2186
+					if ($error != '') return $error;
2187
+					else return self::check_version(true);
2188
+				} elseif ($result['value'] == '11') {
2189
+					$error = self::update_from_11();
2190
+					if ($error != '') return $error;
2191
+					else return self::check_version(true);
2192
+				} elseif ($result['value'] == '12') {
2193
+					$error = self::update_from_12();
2194
+					if ($error != '') return $error;
2195
+					else return self::check_version(true);
2196
+				} elseif ($result['value'] == '13') {
2197
+					$error = self::update_from_13();
2198
+					if ($error != '') return $error;
2199
+					else return self::check_version(true);
2200
+				} elseif ($result['value'] == '14') {
2201
+					$error = self::update_from_14();
2202
+					if ($error != '') return $error;
2203
+					else return self::check_version(true);
2204
+				} elseif ($result['value'] == '15') {
2205
+					$error = self::update_from_15();
2206
+					if ($error != '') return $error;
2207
+					else return self::check_version(true);
2208
+				} elseif ($result['value'] == '16') {
2209
+					$error = self::update_from_16();
2210
+					if ($error != '') return $error;
2211
+					else return self::check_version(true);
2212
+				} elseif ($result['value'] == '17') {
2213
+					$error = self::update_from_17();
2214
+					if ($error != '') return $error;
2215
+					else return self::check_version(true);
2216
+				} elseif ($result['value'] == '18') {
2217
+					$error = self::update_from_18();
2218
+					if ($error != '') return $error;
2219
+					else return self::check_version(true);
2220
+				} elseif ($result['value'] == '19') {
2221
+					$error = self::update_from_19();
2222
+					if ($error != '') return $error;
2223
+					else return self::check_version(true);
2224
+				} elseif ($result['value'] == '20') {
2225
+					$error = self::update_from_20();
2226
+					if ($error != '') return $error;
2227
+					else return self::check_version(true);
2228
+				} elseif ($result['value'] == '21') {
2229
+					$error = self::update_from_21();
2230
+					if ($error != '') return $error;
2231
+					else return self::check_version(true);
2232
+				} elseif ($result['value'] == '22') {
2233
+					$error = self::update_from_22();
2234
+					if ($error != '') return $error;
2235
+					else return self::check_version(true);
2236
+				} elseif ($result['value'] == '23') {
2237
+					$error = self::update_from_23();
2238
+					if ($error != '') return $error;
2239
+					else return self::check_version(true);
2240
+				} elseif ($result['value'] == '24') {
2241
+					$error = self::update_from_24();
2242
+					if ($error != '') return $error;
2243
+					else return self::check_version(true);
2244
+				} elseif ($result['value'] == '25') {
2245
+					$error = self::update_from_25();
2246
+					if ($error != '') return $error;
2247
+					else return self::check_version(true);
2248
+				} elseif ($result['value'] == '26') {
2249
+					$error = self::update_from_26();
2250
+					if ($error != '') return $error;
2251
+					else return self::check_version(true);
2252
+				} elseif ($result['value'] == '27') {
2253
+					$error = self::update_from_27();
2254
+					if ($error != '') return $error;
2255
+					else return self::check_version(true);
2256
+				} elseif ($result['value'] == '28') {
2257
+					$error = self::update_from_28();
2258
+					if ($error != '') return $error;
2259
+					else return self::check_version(true);
2260
+				} elseif ($result['value'] == '29') {
2261
+					$error = self::update_from_29();
2262
+					if ($error != '') return $error;
2263
+					else return self::check_version(true);
2264
+				} elseif ($result['value'] == '30') {
2265
+					$error = self::update_from_30();
2266
+					if ($error != '') return $error;
2267
+					else return self::check_version(true);
2268
+				} elseif ($result['value'] == '31') {
2269
+					$error = self::update_from_31();
2270
+					if ($error != '') return $error;
2271
+					else return self::check_version(true);
2272
+				} elseif ($result['value'] == '32') {
2273
+					$error = self::update_from_32();
2274
+					if ($error != '') return $error;
2275
+					else return self::check_version(true);
2276
+				} elseif ($result['value'] == '33') {
2277
+					$error = self::update_from_33();
2278
+					if ($error != '') return $error;
2279
+					else return self::check_version(true);
2280
+				} elseif ($result['value'] == '34') {
2281
+					$error = self::update_from_34();
2282
+					if ($error != '') return $error;
2283
+					else return self::check_version(true);
2284
+				} elseif ($result['value'] == '35') {
2285
+					$error = self::update_from_35();
2286
+					if ($error != '') return $error;
2287
+					else return self::check_version(true);
2288
+				} elseif ($result['value'] == '36') {
2289
+					$error = self::update_from_36();
2290
+					if ($error != '') return $error;
2291
+					else return self::check_version(true);
2292
+				} elseif ($result['value'] == '37') {
2293
+					$error = self::update_from_37();
2294
+					if ($error != '') return $error;
2295
+					else return self::check_version(true);
2296
+				} elseif ($result['value'] == '38') {
2297
+					$error = self::update_from_38();
2298
+					if ($error != '') return $error;
2299
+					else return self::check_version(true);
2300
+				} elseif ($result['value'] == '39') {
2301
+					$error = self::update_from_39();
2302
+					if ($error != '') return $error;
2303
+					else return self::check_version(true);
2304
+				} elseif ($result['value'] == '40') {
2305
+					$error = self::update_from_40();
2306
+					if ($error != '') return $error;
2307
+					else return self::check_version(true);
2308
+				} elseif ($result['value'] == '41') {
2309
+					$error = self::update_from_41();
2310
+					if ($error != '') return $error;
2311
+					else return self::check_version(true);
2312
+				} elseif ($result['value'] == '42') {
2313
+					$error = self::update_from_42();
2314
+					if ($error != '') return $error;
2315
+					else return self::check_version(true);
2316
+				} elseif ($result['value'] == '43') {
2317
+					$error = self::update_from_43();
2318
+					if ($error != '') return $error;
2319
+					else return self::check_version(true);
2320
+				} elseif ($result['value'] == '44') {
2321
+					$error = self::update_from_44();
2322
+					if ($error != '') return $error;
2323
+					else return self::check_version(true);
2324
+				} else return '';
2325
+				}
2326
+				else return $result['value'];
2327 2327
 		}
2328 2328
 		
2329
-	    } else return $version;
2330
-    	}
2329
+		} else return $version;
2330
+		}
2331 2331
     	
2332 2332
 }
2333 2333
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,19 +1388,19 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1400 1400
 				try {
1401 1401
 					$sth = $Connection->db->prepare($query);
1402 1402
 					$sth->execute();
1403
-				} catch(PDOException $e) {
1403
+				} catch (PDOException $e) {
1404 1404
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1405 1405
 				}
1406 1406
 				
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 				try {
1409 1409
 					$sth = $Connection->db->prepare($query);
1410 1410
 					$sth->execute();
1411
-				} catch(PDOException $e) {
1411
+				} catch (PDOException $e) {
1412 1412
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 				try {
1460 1460
 					$sth = $Connection->db->prepare($query);
1461 1461
 					$sth->execute();
1462
-				} catch(PDOException $e) {
1462
+				} catch (PDOException $e) {
1463 1463
 					return "error (fix date) : ".$e->getMessage()."\n";
1464 1464
 				}
1465 1465
 			}
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 		try {
1545 1545
 			$sth = $Connection->db->prepare($query);
1546 1546
 			$sth->execute();
1547
-		} catch(PDOException $e) {
1547
+		} catch (PDOException $e) {
1548 1548
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1549 1549
 		}
1550 1550
 		return $error;
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
 		global $globalDBdriver;
1554 1554
 		$Connection = new Connection();
1555 1555
 		$error = '';
1556
-		if (!$Connection->indexExists('accidents','type')) {
1556
+		if (!$Connection->indexExists('accidents', 'type')) {
1557 1557
 			// Add index key
1558 1558
 			$query = "create index type on accidents (type,date)";
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
 				$sth->execute();
1562
-			} catch(PDOException $e) {
1562
+			} catch (PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565 1565
                 }
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
1569 1569
 			$sth->execute();
1570
-		} catch(PDOException $e) {
1570
+		} catch (PDOException $e) {
1571 1571
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1572 1572
 		}
1573 1573
 		return $error;
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
 		global $globalDBdriver;
1578 1578
 		$Connection = new Connection();
1579 1579
 		$error = '';
1580
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1580
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1581 1581
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1582 1582
 			try {
1583 1583
 				$sth = $Connection->db->prepare($query);
1584 1584
 				$sth->execute();
1585
-			} catch(PDOException $e) {
1585
+			} catch (PDOException $e) {
1586 1586
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1587 1587
 			}
1588 1588
 		}
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		try {
1649 1649
 			$sth = $Connection->db->prepare($query);
1650 1650
 			$sth->execute();
1651
-		} catch(PDOException $e) {
1651
+		} catch (PDOException $e) {
1652 1652
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1653 1653
 		}
1654 1654
 		return $error;
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 			try {
1701 1701
 				$sth = $Connection->db->prepare($query);
1702 1702
 				$sth->execute();
1703
-			} catch(PDOException $e) {
1703
+			} catch (PDOException $e) {
1704 1704
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1705 1705
 			}
1706 1706
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1709,18 +1709,18 @@  discard block
 block discarded – undo
1709 1709
 				try {
1710 1710
 					$sth = $Connection->db->prepare($query);
1711 1711
 					$sth->execute();
1712
-				} catch(PDOException $e) {
1712
+				} catch (PDOException $e) {
1713 1713
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1714 1714
 				}
1715 1715
 			}
1716 1716
 		}
1717
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1717
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1718 1718
 			// Add index key
1719 1719
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1720 1720
 			try {
1721 1721
 				$sth = $Connection->db->prepare($query);
1722 1722
 				$sth->execute();
1723
-			} catch(PDOException $e) {
1723
+			} catch (PDOException $e) {
1724 1724
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1725 1725
 			}
1726 1726
                 }
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 		try {
1729 1729
 			$sth = $Connection->db->prepare($query);
1730 1730
 			$sth->execute();
1731
-		} catch(PDOException $e) {
1731
+		} catch (PDOException $e) {
1732 1732
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1733 1733
 		}
1734 1734
 		return $error;
@@ -1739,148 +1739,148 @@  discard block
 block discarded – undo
1739 1739
 		$Connection = new Connection();
1740 1740
 		$error = '';
1741 1741
 		if ($globalDBdriver == 'mysql') {
1742
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1742
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1743 1743
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1744 1744
 				try {
1745 1745
 					$sth = $Connection->db->prepare($query);
1746 1746
 					$sth->execute();
1747
-				} catch(PDOException $e) {
1747
+				} catch (PDOException $e) {
1748 1748
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1749 1749
 				}
1750 1750
 			}
1751
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1751
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1752 1752
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1753 1753
 				try {
1754 1754
 					$sth = $Connection->db->prepare($query);
1755 1755
 					$sth->execute();
1756
-				} catch(PDOException $e) {
1756
+				} catch (PDOException $e) {
1757 1757
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1758 1758
 				}
1759 1759
 			}
1760
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1760
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1761 1761
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1762 1762
 				try {
1763 1763
 					$sth = $Connection->db->prepare($query);
1764 1764
 					$sth->execute();
1765
-				} catch(PDOException $e) {
1765
+				} catch (PDOException $e) {
1766 1766
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1767 1767
 				}
1768 1768
 			}
1769
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1769
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1770 1770
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1771 1771
 				try {
1772 1772
 					$sth = $Connection->db->prepare($query);
1773 1773
 					$sth->execute();
1774
-				} catch(PDOException $e) {
1774
+				} catch (PDOException $e) {
1775 1775
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1776 1776
 				}
1777 1777
 			}
1778
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1778
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1779 1779
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1780 1780
 				try {
1781 1781
 					$sth = $Connection->db->prepare($query);
1782 1782
 					$sth->execute();
1783
-				} catch(PDOException $e) {
1783
+				} catch (PDOException $e) {
1784 1784
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1785 1785
 				}
1786 1786
 			}
1787
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1787
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1788 1788
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1789 1789
 				try {
1790 1790
 					$sth = $Connection->db->prepare($query);
1791 1791
 					$sth->execute();
1792
-				} catch(PDOException $e) {
1792
+				} catch (PDOException $e) {
1793 1793
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1794 1794
 				}
1795 1795
 			}
1796
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1796
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1797 1797
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1798 1798
 				try {
1799 1799
 					$sth = $Connection->db->prepare($query);
1800 1800
 					$sth->execute();
1801
-				} catch(PDOException $e) {
1801
+				} catch (PDOException $e) {
1802 1802
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1803 1803
 				}
1804 1804
 			}
1805
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1805
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1806 1806
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1807 1807
 				try {
1808 1808
 					$sth = $Connection->db->prepare($query);
1809 1809
 					$sth->execute();
1810
-				} catch(PDOException $e) {
1810
+				} catch (PDOException $e) {
1811 1811
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1812 1812
 				}
1813 1813
 			}
1814 1814
 		} else {
1815
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1815
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1816 1816
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1817 1817
 				try {
1818 1818
 					$sth = $Connection->db->prepare($query);
1819 1819
 					$sth->execute();
1820
-				} catch(PDOException $e) {
1820
+				} catch (PDOException $e) {
1821 1821
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1822 1822
 				}
1823 1823
 			}
1824
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1824
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1825 1825
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1826 1826
 				try {
1827 1827
 					$sth = $Connection->db->prepare($query);
1828 1828
 					$sth->execute();
1829
-				} catch(PDOException $e) {
1829
+				} catch (PDOException $e) {
1830 1830
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1831 1831
 				}
1832 1832
 			}
1833
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1833
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1834 1834
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1835 1835
 				try {
1836 1836
 					$sth = $Connection->db->prepare($query);
1837 1837
 					$sth->execute();
1838
-				} catch(PDOException $e) {
1838
+				} catch (PDOException $e) {
1839 1839
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1840 1840
 				}
1841 1841
 			}
1842
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1842
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1843 1843
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1844 1844
 				try {
1845 1845
 					$sth = $Connection->db->prepare($query);
1846 1846
 					$sth->execute();
1847
-				} catch(PDOException $e) {
1847
+				} catch (PDOException $e) {
1848 1848
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1849 1849
 				}
1850 1850
 			}
1851
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1851
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1852 1852
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1853 1853
 				try {
1854 1854
 					$sth = $Connection->db->prepare($query);
1855 1855
 					$sth->execute();
1856
-				} catch(PDOException $e) {
1856
+				} catch (PDOException $e) {
1857 1857
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1858 1858
 				}
1859 1859
 			}
1860
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1860
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1861 1861
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1862 1862
 				try {
1863 1863
 					$sth = $Connection->db->prepare($query);
1864 1864
 					$sth->execute();
1865
-				} catch(PDOException $e) {
1865
+				} catch (PDOException $e) {
1866 1866
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1867 1867
 				}
1868 1868
 			}
1869
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1869
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1870 1870
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1871 1871
 				try {
1872 1872
 					$sth = $Connection->db->prepare($query);
1873 1873
 					$sth->execute();
1874
-				} catch(PDOException $e) {
1874
+				} catch (PDOException $e) {
1875 1875
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1876 1876
 				}
1877 1877
 			}
1878
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1878
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1879 1879
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1880 1880
 				try {
1881 1881
 					$sth = $Connection->db->prepare($query);
1882 1882
 					$sth->execute();
1883
-				} catch(PDOException $e) {
1883
+				} catch (PDOException $e) {
1884 1884
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1885 1885
 				}
1886 1886
 			}
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
 		try {
1890 1890
 			$sth = $Connection->db->prepare($query);
1891 1891
 			$sth->execute();
1892
-		} catch(PDOException $e) {
1892
+		} catch (PDOException $e) {
1893 1893
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1894 1894
 		}
1895 1895
 		return $error;
@@ -1904,14 +1904,14 @@  discard block
 block discarded – undo
1904 1904
 			try {
1905 1905
 				$sth = $Connection->db->prepare($query);
1906 1906
 				$sth->execute();
1907
-			} catch(PDOException $e) {
1907
+			} catch (PDOException $e) {
1908 1908
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1909 1909
 			}
1910 1910
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1911 1911
 			try {
1912 1912
 				$sth = $Connection->db->prepare($query);
1913 1913
 				$sth->execute();
1914
-			} catch(PDOException $e) {
1914
+			} catch (PDOException $e) {
1915 1915
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1916 1916
 			}
1917 1917
 		} else {
@@ -1919,14 +1919,14 @@  discard block
 block discarded – undo
1919 1919
 			try {
1920 1920
 				$sth = $Connection->db->prepare($query);
1921 1921
 				$sth->execute();
1922
-			} catch(PDOException $e) {
1922
+			} catch (PDOException $e) {
1923 1923
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1924 1924
 			}
1925 1925
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1926 1926
 			try {
1927 1927
 				$sth = $Connection->db->prepare($query);
1928 1928
 				$sth->execute();
1929
-			} catch(PDOException $e) {
1929
+			} catch (PDOException $e) {
1930 1930
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1931 1931
 			}
1932 1932
 		}
@@ -1934,7 +1934,7 @@  discard block
 block discarded – undo
1934 1934
 		try {
1935 1935
 			$sth = $Connection->db->prepare($query);
1936 1936
 			$sth->execute();
1937
-		} catch(PDOException $e) {
1937
+		} catch (PDOException $e) {
1938 1938
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1939 1939
 		}
1940 1940
 		return $error;
@@ -1944,32 +1944,32 @@  discard block
 block discarded – undo
1944 1944
 		global $globalDBdriver;
1945 1945
 		$Connection = new Connection();
1946 1946
 		$error = '';
1947
-		if (!$Connection->checkColumnName('source_location','last_seen')) {
1947
+		if (!$Connection->checkColumnName('source_location', 'last_seen')) {
1948 1948
 			$query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL";
1949 1949
 			try {
1950 1950
 				$sth = $Connection->db->prepare($query);
1951 1951
 				$sth->execute();
1952
-			} catch(PDOException $e) {
1952
+			} catch (PDOException $e) {
1953 1953
 				return "error (add column last_seen in source_location) : ".$e->getMessage()."\n";
1954 1954
 			}
1955 1955
 		}
1956 1956
 		if ($globalDBdriver == 'mysql') {
1957
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1957
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1958 1958
 				$query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL";
1959 1959
 				try {
1960 1960
 					$sth = $Connection->db->prepare($query);
1961 1961
 					$sth->execute();
1962
-				} catch(PDOException $e) {
1962
+				} catch (PDOException $e) {
1963 1963
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1964 1964
 				}
1965 1965
 			}
1966 1966
 		} else {
1967
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1967
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1968 1968
 				$query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL";
1969 1969
 				try {
1970 1970
 					$sth = $Connection->db->prepare($query);
1971 1971
 					$sth->execute();
1972
-				} catch(PDOException $e) {
1972
+				} catch (PDOException $e) {
1973 1973
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1974 1974
 				}
1975 1975
 			}
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 		try {
1979 1979
 			$sth = $Connection->db->prepare($query);
1980 1980
 			$sth->execute();
1981
-		} catch(PDOException $e) {
1981
+		} catch (PDOException $e) {
1982 1982
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1983 1983
 		}
1984 1984
 		return $error;
@@ -1988,12 +1988,12 @@  discard block
 block discarded – undo
1988 1988
 		global $globalDBdriver;
1989 1989
 		$Connection = new Connection();
1990 1990
 		$error = '';
1991
-		if (!$Connection->checkColumnName('source_location','description')) {
1991
+		if (!$Connection->checkColumnName('source_location', 'description')) {
1992 1992
 			$query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL";
1993 1993
 			try {
1994 1994
 				$sth = $Connection->db->prepare($query);
1995 1995
 				$sth->execute();
1996
-			} catch(PDOException $e) {
1996
+			} catch (PDOException $e) {
1997 1997
 				return "error (add column description in source_location) : ".$e->getMessage()."\n";
1998 1998
 			}
1999 1999
 		}
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 		try {
2002 2002
 			$sth = $Connection->db->prepare($query);
2003 2003
 			$sth->execute();
2004
-		} catch(PDOException $e) {
2004
+		} catch (PDOException $e) {
2005 2005
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2006 2006
 		}
2007 2007
 		return $error;
@@ -2011,39 +2011,39 @@  discard block
 block discarded – undo
2011 2011
 		global $globalDBdriver;
2012 2012
 		$Connection = new Connection();
2013 2013
 		$error = '';
2014
-		if (!$Connection->checkColumnName('spotter_live','real_altitude')) {
2014
+		if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) {
2015 2015
 			$query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL";
2016 2016
 			try {
2017 2017
 				$sth = $Connection->db->prepare($query);
2018 2018
 				$sth->execute();
2019
-			} catch(PDOException $e) {
2019
+			} catch (PDOException $e) {
2020 2020
 				return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n";
2021 2021
 			}
2022 2022
 		}
2023
-		if (!$Connection->checkColumnName('spotter_output','real_altitude')) {
2023
+		if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) {
2024 2024
 			$query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL";
2025 2025
 			try {
2026 2026
 				$sth = $Connection->db->prepare($query);
2027 2027
 				$sth->execute();
2028
-			} catch(PDOException $e) {
2028
+			} catch (PDOException $e) {
2029 2029
 				return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n";
2030 2030
 			}
2031 2031
 		}
2032
-		if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) {
2032
+		if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) {
2033 2033
 			$query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL";
2034 2034
 			try {
2035 2035
 				$sth = $Connection->db->prepare($query);
2036 2036
 				$sth->execute();
2037
-			} catch(PDOException $e) {
2037
+			} catch (PDOException $e) {
2038 2038
 				return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n";
2039 2039
 			}
2040 2040
 		}
2041
-		if (!$Connection->checkColumnName('spotter_archive','real_altitude')) {
2041
+		if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) {
2042 2042
 			$query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL";
2043 2043
 			try {
2044 2044
 				$sth = $Connection->db->prepare($query);
2045 2045
 				$sth->execute();
2046
-			} catch(PDOException $e) {
2046
+			} catch (PDOException $e) {
2047 2047
 				return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n";
2048 2048
 			}
2049 2049
 		}
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 		try {
2052 2052
 			$sth = $Connection->db->prepare($query);
2053 2053
 			$sth->execute();
2054
-		} catch(PDOException $e) {
2054
+		} catch (PDOException $e) {
2055 2055
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2056 2056
 		}
2057 2057
 		return $error;
@@ -2073,14 +2073,14 @@  discard block
 block discarded – undo
2073 2073
 		try {
2074 2074
 			$sth = $Connection->db->prepare($query);
2075 2075
 			$sth->execute();
2076
-		} catch(PDOException $e) {
2076
+		} catch (PDOException $e) {
2077 2077
 			return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n";
2078 2078
 		}
2079 2079
 		$query = "UPDATE config SET value = '44' WHERE name = 'schema_version'";
2080 2080
 		try {
2081 2081
 			$sth = $Connection->db->prepare($query);
2082 2082
 			$sth->execute();
2083
-		} catch(PDOException $e) {
2083
+		} catch (PDOException $e) {
2084 2084
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2085 2085
 		}
2086 2086
 		return $error;
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 		try {
2122 2122
 			$sth = $Connection->db->prepare($query);
2123 2123
 			$sth->execute();
2124
-		} catch(PDOException $e) {
2124
+		} catch (PDOException $e) {
2125 2125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2126 2126
 		}
2127 2127
 		return $error;
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		    try {
2145 2145
             		$sth = $Connection->db->prepare($query);
2146 2146
 		        $sth->execute();
2147
-		    } catch(PDOException $e) {
2147
+		    } catch (PDOException $e) {
2148 2148
 			return "error : ".$e->getMessage()."\n";
2149 2149
     		    }
2150 2150
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +414 added lines, -153 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1661,39 +1751,61 @@  discard block
 block discarded – undo
1661 1751
 		if ($globalDBdriver == 'mysql') {
1662 1752
 			if (!$Connection->tableExists('marine_image')) {
1663 1753
 				$error .= create_db::import_file('../db/marine_image.sql');
1664
-				if ($error != '') return $error;
1754
+				if ($error != '') {
1755
+					return $error;
1756
+				}
1665 1757
 			}
1666 1758
 			if (!$Connection->tableExists('marine_archive')) {
1667 1759
 				$error .= create_db::import_file('../db/marine_archive.sql');
1668
-				if ($error != '') return $error;
1760
+				if ($error != '') {
1761
+					return $error;
1762
+				}
1669 1763
 			}
1670 1764
 			if (!$Connection->tableExists('marine_archive_output')) {
1671 1765
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1672
-				if ($error != '') return $error;
1766
+				if ($error != '') {
1767
+					return $error;
1768
+				}
1673 1769
 			}
1674 1770
 			if (!$Connection->tableExists('tracker_archive')) {
1675 1771
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1676
-				if ($error != '') return $error;
1772
+				if ($error != '') {
1773
+					return $error;
1774
+				}
1677 1775
 			}
1678 1776
 			if (!$Connection->tableExists('tracker_archive_output')) {
1679 1777
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1680
-				if ($error != '') return $error;
1778
+				if ($error != '') {
1779
+					return $error;
1780
+				}
1681 1781
 			}
1682 1782
 			if (!$Connection->tableExists('marine_archive_output')) {
1683 1783
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1684
-				if ($error != '') return $error;
1784
+				if ($error != '') {
1785
+					return $error;
1786
+				}
1685 1787
 			}
1686 1788
 		} else {
1687 1789
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1688
-			if ($error != '') return $error;
1790
+			if ($error != '') {
1791
+				return $error;
1792
+			}
1689 1793
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1690
-			if ($error != '') return $error;
1794
+			if ($error != '') {
1795
+				return $error;
1796
+			}
1691 1797
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1692
-			if ($error != '') return $error;
1798
+			if ($error != '') {
1799
+				return $error;
1800
+			}
1693 1801
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1694
-			if ($error != '') return $error;
1802
+			if ($error != '') {
1803
+				return $error;
1804
+			}
1695 1805
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1696
-			if ($error != '') return $error;
1806
+			if ($error != '') {
1807
+				return $error;
1808
+			}
1697 1809
 		}
1698 1810
 		if ($globalDBdriver == 'mysql') {
1699 1811
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2064,7 +2176,9 @@  discard block
 block discarded – undo
2064 2176
 		if ($globalDBdriver == 'mysql') {
2065 2177
 			if (!$Connection->tableExists('tracker_archive_output')) {
2066 2178
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2067
-				if ($error != '') return $error;
2179
+				if ($error != '') {
2180
+					return $error;
2181
+				}
2068 2182
 			}
2069 2183
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2070 2184
 		} else {
@@ -2092,14 +2206,22 @@  discard block
 block discarded – undo
2092 2206
 		$error = '';
2093 2207
 		if ($globalDBdriver == 'mysql') {
2094 2208
 			$error .= create_db::import_file('../db/airport.sql');
2095
-			if ($error != '') return $error;
2209
+			if ($error != '') {
2210
+				return $error;
2211
+			}
2096 2212
 			$error .= create_db::import_file('../db/airlines.sql');
2097
-			if ($error != '') return $error;
2213
+			if ($error != '') {
2214
+				return $error;
2215
+			}
2098 2216
 		} else {
2099 2217
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2100
-			if ($error != '') return $error;
2218
+			if ($error != '') {
2219
+				return $error;
2220
+			}
2101 2221
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2102
-			if ($error != '') return $error;
2222
+			if ($error != '') {
2223
+				return $error;
2224
+			}
2103 2225
 		}
2104 2226
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2105 2227
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2116,7 +2238,9 @@  discard block
 block discarded – undo
2116 2238
 				$error .= update_db::update_vatsim();
2117 2239
 			}
2118 2240
 		}
2119
-		if ($error != '') return $error;
2241
+		if ($error != '') {
2242
+			return $error;
2243
+		}
2120 2244
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2121 2245
 		try {
2122 2246
 			$sth = $Connection->db->prepare($query);
@@ -2136,8 +2260,11 @@  discard block
 block discarded – undo
2136 2260
     	    if ($Connection->tableExists('aircraft')) {
2137 2261
     		if (!$Connection->tableExists('config')) {
2138 2262
     		    $version = '1';
2139
-    		    if ($update) return self::update_from_1();
2140
-    		    else return $version;
2263
+    		    if ($update) {
2264
+    		    	return self::update_from_1();
2265
+    		    } else {
2266
+    		    	return $version;
2267
+    		    }
2141 2268
 		} else {
2142 2269
     		    $Connection = new Connection();
2143 2270
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -2151,182 +2278,316 @@  discard block
 block discarded – undo
2151 2278
     		    if ($update) {
2152 2279
     			if ($result['value'] == '2') {
2153 2280
     			    $error = self::update_from_2();
2154
-    			    if ($error != '') return $error;
2155
-    			    else return self::check_version(true);
2281
+    			    if ($error != '') {
2282
+    			    	return $error;
2283
+    			    } else {
2284
+    			    	return self::check_version(true);
2285
+    			    }
2156 2286
     			} elseif ($result['value'] == '3') {
2157 2287
     			    $error = self::update_from_3();
2158
-    			    if ($error != '') return $error;
2159
-    			    else return self::check_version(true);
2288
+    			    if ($error != '') {
2289
+    			    	return $error;
2290
+    			    } else {
2291
+    			    	return self::check_version(true);
2292
+    			    }
2160 2293
     			} elseif ($result['value'] == '4') {
2161 2294
     			    $error = self::update_from_4();
2162
-    			    if ($error != '') return $error;
2163
-    			    else return self::check_version(true);
2295
+    			    if ($error != '') {
2296
+    			    	return $error;
2297
+    			    } else {
2298
+    			    	return self::check_version(true);
2299
+    			    }
2164 2300
     			} elseif ($result['value'] == '5') {
2165 2301
     			    $error = self::update_from_5();
2166
-    			    if ($error != '') return $error;
2167
-    			    else return self::check_version(true);
2302
+    			    if ($error != '') {
2303
+    			    	return $error;
2304
+    			    } else {
2305
+    			    	return self::check_version(true);
2306
+    			    }
2168 2307
     			} elseif ($result['value'] == '6') {
2169 2308
     			    $error = self::update_from_6();
2170
-    			    if ($error != '') return $error;
2171
-    			    else return self::check_version(true);
2309
+    			    if ($error != '') {
2310
+    			    	return $error;
2311
+    			    } else {
2312
+    			    	return self::check_version(true);
2313
+    			    }
2172 2314
     			} elseif ($result['value'] == '7') {
2173 2315
     			    $error = self::update_from_7();
2174
-    			    if ($error != '') return $error;
2175
-    			    else return self::check_version(true);
2316
+    			    if ($error != '') {
2317
+    			    	return $error;
2318
+    			    } else {
2319
+    			    	return self::check_version(true);
2320
+    			    }
2176 2321
     			} elseif ($result['value'] == '8') {
2177 2322
     			    $error = self::update_from_8();
2178
-    			    if ($error != '') return $error;
2179
-    			    else return self::check_version(true);
2323
+    			    if ($error != '') {
2324
+    			    	return $error;
2325
+    			    } else {
2326
+    			    	return self::check_version(true);
2327
+    			    }
2180 2328
     			} elseif ($result['value'] == '9') {
2181 2329
     			    $error = self::update_from_9();
2182
-    			    if ($error != '') return $error;
2183
-    			    else return self::check_version(true);
2330
+    			    if ($error != '') {
2331
+    			    	return $error;
2332
+    			    } else {
2333
+    			    	return self::check_version(true);
2334
+    			    }
2184 2335
     			} elseif ($result['value'] == '10') {
2185 2336
     			    $error = self::update_from_10();
2186
-    			    if ($error != '') return $error;
2187
-    			    else return self::check_version(true);
2337
+    			    if ($error != '') {
2338
+    			    	return $error;
2339
+    			    } else {
2340
+    			    	return self::check_version(true);
2341
+    			    }
2188 2342
     			} elseif ($result['value'] == '11') {
2189 2343
     			    $error = self::update_from_11();
2190
-    			    if ($error != '') return $error;
2191
-    			    else return self::check_version(true);
2344
+    			    if ($error != '') {
2345
+    			    	return $error;
2346
+    			    } else {
2347
+    			    	return self::check_version(true);
2348
+    			    }
2192 2349
     			} elseif ($result['value'] == '12') {
2193 2350
     			    $error = self::update_from_12();
2194
-    			    if ($error != '') return $error;
2195
-    			    else return self::check_version(true);
2351
+    			    if ($error != '') {
2352
+    			    	return $error;
2353
+    			    } else {
2354
+    			    	return self::check_version(true);
2355
+    			    }
2196 2356
     			} elseif ($result['value'] == '13') {
2197 2357
     			    $error = self::update_from_13();
2198
-    			    if ($error != '') return $error;
2199
-    			    else return self::check_version(true);
2358
+    			    if ($error != '') {
2359
+    			    	return $error;
2360
+    			    } else {
2361
+    			    	return self::check_version(true);
2362
+    			    }
2200 2363
     			} elseif ($result['value'] == '14') {
2201 2364
     			    $error = self::update_from_14();
2202
-    			    if ($error != '') return $error;
2203
-    			    else return self::check_version(true);
2365
+    			    if ($error != '') {
2366
+    			    	return $error;
2367
+    			    } else {
2368
+    			    	return self::check_version(true);
2369
+    			    }
2204 2370
     			} elseif ($result['value'] == '15') {
2205 2371
     			    $error = self::update_from_15();
2206
-    			    if ($error != '') return $error;
2207
-    			    else return self::check_version(true);
2372
+    			    if ($error != '') {
2373
+    			    	return $error;
2374
+    			    } else {
2375
+    			    	return self::check_version(true);
2376
+    			    }
2208 2377
     			} elseif ($result['value'] == '16') {
2209 2378
     			    $error = self::update_from_16();
2210
-    			    if ($error != '') return $error;
2211
-    			    else return self::check_version(true);
2379
+    			    if ($error != '') {
2380
+    			    	return $error;
2381
+    			    } else {
2382
+    			    	return self::check_version(true);
2383
+    			    }
2212 2384
     			} elseif ($result['value'] == '17') {
2213 2385
     			    $error = self::update_from_17();
2214
-    			    if ($error != '') return $error;
2215
-    			    else return self::check_version(true);
2386
+    			    if ($error != '') {
2387
+    			    	return $error;
2388
+    			    } else {
2389
+    			    	return self::check_version(true);
2390
+    			    }
2216 2391
     			} elseif ($result['value'] == '18') {
2217 2392
     			    $error = self::update_from_18();
2218
-    			    if ($error != '') return $error;
2219
-    			    else return self::check_version(true);
2393
+    			    if ($error != '') {
2394
+    			    	return $error;
2395
+    			    } else {
2396
+    			    	return self::check_version(true);
2397
+    			    }
2220 2398
     			} elseif ($result['value'] == '19') {
2221 2399
     			    $error = self::update_from_19();
2222
-    			    if ($error != '') return $error;
2223
-    			    else return self::check_version(true);
2400
+    			    if ($error != '') {
2401
+    			    	return $error;
2402
+    			    } else {
2403
+    			    	return self::check_version(true);
2404
+    			    }
2224 2405
     			} elseif ($result['value'] == '20') {
2225 2406
     			    $error = self::update_from_20();
2226
-    			    if ($error != '') return $error;
2227
-    			    else return self::check_version(true);
2407
+    			    if ($error != '') {
2408
+    			    	return $error;
2409
+    			    } else {
2410
+    			    	return self::check_version(true);
2411
+    			    }
2228 2412
     			} elseif ($result['value'] == '21') {
2229 2413
     			    $error = self::update_from_21();
2230
-    			    if ($error != '') return $error;
2231
-    			    else return self::check_version(true);
2414
+    			    if ($error != '') {
2415
+    			    	return $error;
2416
+    			    } else {
2417
+    			    	return self::check_version(true);
2418
+    			    }
2232 2419
     			} elseif ($result['value'] == '22') {
2233 2420
     			    $error = self::update_from_22();
2234
-    			    if ($error != '') return $error;
2235
-    			    else return self::check_version(true);
2421
+    			    if ($error != '') {
2422
+    			    	return $error;
2423
+    			    } else {
2424
+    			    	return self::check_version(true);
2425
+    			    }
2236 2426
     			} elseif ($result['value'] == '23') {
2237 2427
     			    $error = self::update_from_23();
2238
-    			    if ($error != '') return $error;
2239
-    			    else return self::check_version(true);
2428
+    			    if ($error != '') {
2429
+    			    	return $error;
2430
+    			    } else {
2431
+    			    	return self::check_version(true);
2432
+    			    }
2240 2433
     			} elseif ($result['value'] == '24') {
2241 2434
     			    $error = self::update_from_24();
2242
-    			    if ($error != '') return $error;
2243
-    			    else return self::check_version(true);
2435
+    			    if ($error != '') {
2436
+    			    	return $error;
2437
+    			    } else {
2438
+    			    	return self::check_version(true);
2439
+    			    }
2244 2440
     			} elseif ($result['value'] == '25') {
2245 2441
     			    $error = self::update_from_25();
2246
-    			    if ($error != '') return $error;
2247
-    			    else return self::check_version(true);
2442
+    			    if ($error != '') {
2443
+    			    	return $error;
2444
+    			    } else {
2445
+    			    	return self::check_version(true);
2446
+    			    }
2248 2447
     			} elseif ($result['value'] == '26') {
2249 2448
     			    $error = self::update_from_26();
2250
-    			    if ($error != '') return $error;
2251
-    			    else return self::check_version(true);
2449
+    			    if ($error != '') {
2450
+    			    	return $error;
2451
+    			    } else {
2452
+    			    	return self::check_version(true);
2453
+    			    }
2252 2454
     			} elseif ($result['value'] == '27') {
2253 2455
     			    $error = self::update_from_27();
2254
-    			    if ($error != '') return $error;
2255
-    			    else return self::check_version(true);
2456
+    			    if ($error != '') {
2457
+    			    	return $error;
2458
+    			    } else {
2459
+    			    	return self::check_version(true);
2460
+    			    }
2256 2461
     			} elseif ($result['value'] == '28') {
2257 2462
     			    $error = self::update_from_28();
2258
-    			    if ($error != '') return $error;
2259
-    			    else return self::check_version(true);
2463
+    			    if ($error != '') {
2464
+    			    	return $error;
2465
+    			    } else {
2466
+    			    	return self::check_version(true);
2467
+    			    }
2260 2468
     			} elseif ($result['value'] == '29') {
2261 2469
     			    $error = self::update_from_29();
2262
-    			    if ($error != '') return $error;
2263
-    			    else return self::check_version(true);
2470
+    			    if ($error != '') {
2471
+    			    	return $error;
2472
+    			    } else {
2473
+    			    	return self::check_version(true);
2474
+    			    }
2264 2475
     			} elseif ($result['value'] == '30') {
2265 2476
     			    $error = self::update_from_30();
2266
-    			    if ($error != '') return $error;
2267
-    			    else return self::check_version(true);
2477
+    			    if ($error != '') {
2478
+    			    	return $error;
2479
+    			    } else {
2480
+    			    	return self::check_version(true);
2481
+    			    }
2268 2482
     			} elseif ($result['value'] == '31') {
2269 2483
     			    $error = self::update_from_31();
2270
-    			    if ($error != '') return $error;
2271
-    			    else return self::check_version(true);
2484
+    			    if ($error != '') {
2485
+    			    	return $error;
2486
+    			    } else {
2487
+    			    	return self::check_version(true);
2488
+    			    }
2272 2489
     			} elseif ($result['value'] == '32') {
2273 2490
     			    $error = self::update_from_32();
2274
-    			    if ($error != '') return $error;
2275
-    			    else return self::check_version(true);
2491
+    			    if ($error != '') {
2492
+    			    	return $error;
2493
+    			    } else {
2494
+    			    	return self::check_version(true);
2495
+    			    }
2276 2496
     			} elseif ($result['value'] == '33') {
2277 2497
     			    $error = self::update_from_33();
2278
-    			    if ($error != '') return $error;
2279
-    			    else return self::check_version(true);
2498
+    			    if ($error != '') {
2499
+    			    	return $error;
2500
+    			    } else {
2501
+    			    	return self::check_version(true);
2502
+    			    }
2280 2503
     			} elseif ($result['value'] == '34') {
2281 2504
     			    $error = self::update_from_34();
2282
-    			    if ($error != '') return $error;
2283
-    			    else return self::check_version(true);
2505
+    			    if ($error != '') {
2506
+    			    	return $error;
2507
+    			    } else {
2508
+    			    	return self::check_version(true);
2509
+    			    }
2284 2510
     			} elseif ($result['value'] == '35') {
2285 2511
     			    $error = self::update_from_35();
2286
-    			    if ($error != '') return $error;
2287
-    			    else return self::check_version(true);
2512
+    			    if ($error != '') {
2513
+    			    	return $error;
2514
+    			    } else {
2515
+    			    	return self::check_version(true);
2516
+    			    }
2288 2517
     			} elseif ($result['value'] == '36') {
2289 2518
     			    $error = self::update_from_36();
2290
-    			    if ($error != '') return $error;
2291
-    			    else return self::check_version(true);
2519
+    			    if ($error != '') {
2520
+    			    	return $error;
2521
+    			    } else {
2522
+    			    	return self::check_version(true);
2523
+    			    }
2292 2524
     			} elseif ($result['value'] == '37') {
2293 2525
     			    $error = self::update_from_37();
2294
-    			    if ($error != '') return $error;
2295
-    			    else return self::check_version(true);
2526
+    			    if ($error != '') {
2527
+    			    	return $error;
2528
+    			    } else {
2529
+    			    	return self::check_version(true);
2530
+    			    }
2296 2531
     			} elseif ($result['value'] == '38') {
2297 2532
     			    $error = self::update_from_38();
2298
-    			    if ($error != '') return $error;
2299
-    			    else return self::check_version(true);
2533
+    			    if ($error != '') {
2534
+    			    	return $error;
2535
+    			    } else {
2536
+    			    	return self::check_version(true);
2537
+    			    }
2300 2538
     			} elseif ($result['value'] == '39') {
2301 2539
     			    $error = self::update_from_39();
2302
-    			    if ($error != '') return $error;
2303
-    			    else return self::check_version(true);
2540
+    			    if ($error != '') {
2541
+    			    	return $error;
2542
+    			    } else {
2543
+    			    	return self::check_version(true);
2544
+    			    }
2304 2545
     			} elseif ($result['value'] == '40') {
2305 2546
     			    $error = self::update_from_40();
2306
-    			    if ($error != '') return $error;
2307
-    			    else return self::check_version(true);
2547
+    			    if ($error != '') {
2548
+    			    	return $error;
2549
+    			    } else {
2550
+    			    	return self::check_version(true);
2551
+    			    }
2308 2552
     			} elseif ($result['value'] == '41') {
2309 2553
     			    $error = self::update_from_41();
2310
-    			    if ($error != '') return $error;
2311
-    			    else return self::check_version(true);
2554
+    			    if ($error != '') {
2555
+    			    	return $error;
2556
+    			    } else {
2557
+    			    	return self::check_version(true);
2558
+    			    }
2312 2559
     			} elseif ($result['value'] == '42') {
2313 2560
     			    $error = self::update_from_42();
2314
-    			    if ($error != '') return $error;
2315
-    			    else return self::check_version(true);
2561
+    			    if ($error != '') {
2562
+    			    	return $error;
2563
+    			    } else {
2564
+    			    	return self::check_version(true);
2565
+    			    }
2316 2566
     			} elseif ($result['value'] == '43') {
2317 2567
     			    $error = self::update_from_43();
2318
-    			    if ($error != '') return $error;
2319
-    			    else return self::check_version(true);
2568
+    			    if ($error != '') {
2569
+    			    	return $error;
2570
+    			    } else {
2571
+    			    	return self::check_version(true);
2572
+    			    }
2320 2573
     			} elseif ($result['value'] == '44') {
2321 2574
     			    $error = self::update_from_44();
2322
-    			    if ($error != '') return $error;
2323
-    			    else return self::check_version(true);
2324
-    			} else return '';
2575
+    			    if ($error != '') {
2576
+    			    	return $error;
2577
+    			    } else {
2578
+    			    	return self::check_version(true);
2579
+    			    }
2580
+    			} else {
2581
+    				return '';
2582
+    			}
2583
+    		    } else {
2584
+    		    	return $result['value'];
2325 2585
     		    }
2326
-    		    else return $result['value'];
2327 2586
 		}
2328 2587
 		
2329
-	    } else return $version;
2588
+	    } else {
2589
+	    	return $version;
2590
+	    }
2330 2591
     	}
2331 2592
     	
2332 2593
 }
Please login to merge, or discard this patch.
require/settings.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $globalLongitudeMin = '1.0'; //the minimum longitude (east)
43 43
 
44 44
 $globalCenterLatitude = '46.38'; //the latitude center of your coverage area
45
-$globalCenterLongitude = '5.29';//the longitude center of your coverage area
45
+$globalCenterLongitude = '5.29'; //the longitude center of your coverage area
46 46
 
47 47
 $globalLiveZoom = '9'; //default zoom on Live Map
48 48
 $globalAirportZoom = '7'; //default zoom to begin to display airports icons
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 $globalACARS = FALSE;
152 152
 $globalACARSHost = '0.0.0.0'; // Local IP to listen
153 153
 $globalACARSPort = '9999';
154
-$globalACARSArchive = array('10','80','81','82','3F'); // labels of messages to archive
154
+$globalACARSArchive = array('10', '80', '81', '82', '3F'); // labels of messages to archive
155 155
 $globalACARSArchiveKeepMonths = '0';
156 156
 
157 157
 //APRS configuration (for glidernet)
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 //Check by aircraft ICAO if image is not found by registration
249 249
 $globalAircraftImageCheckICAO = TRUE;
250 250
 //Sources for Aircraft image
251
-$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters','customsources');
251
+$globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters', 'customsources');
252 252
 // Custom source configuration {registration} will be replaced by aircraft registration (exif get copyright from exif data for each pic)
253 253
 // example of config : $globalAircraftImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{registration}.jpg','original' => 'http://myurl/original/{registration}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true);
254 254
 // ************************
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 //Retrieve Image from externals sources
258 258
 $globalMarineImageFetch = TRUE;
259 259
 //Sources for Marine image
260
-$globalMarineImageSources = array('wikimedia','flickr','deviantart','bing','customsources');
260
+$globalMarineImageSources = array('wikimedia', 'flickr', 'deviantart', 'bing', 'customsources');
261 261
 // Custom source configuration {mmsi} will be replaced by vessel mmsi, {name} by it's name (exif get copyright from exif data for each pic)
262 262
 // example of config : $globalMarineImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{name}.jpg','original' => 'http://myurl/original/{name}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true);
263 263
 // ************************
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 //Retrieve schedules from externals sources (set to FALSE for IVAO or if $globalFork = FALSE)
266 266
 $globalSchedulesFetch = TRUE;
267 267
 //Sources for airline schedule if not official airline site
268
-$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
268
+$globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
269 269
 
270 270
 //Retrieve translation from external sources (set to FALSE for IVAO)
271 271
 $globalTranslationFetch = TRUE;
Please login to merge, or discard this patch.